#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <iostream>

// ---------------------------------
// BEGIN OF USER AREA

// Debug level, possible values: 0 - 5, 5 is highest
// Highest level will cause EXTREMELY detailed output (the whole array will be printed)
__constant__ const int DEBUG_LEVEL = 4;

// Array size for initialization, used only in inputArray functiont
__constant__ const int G_ARRAY_SIZE = 8192;

// Number of threads inside of block
__constant__ const int BLOCK_SIZE = 8;

int inputArray(int ** _arr) {
	int arr_size = G_ARRAY_SIZE;
	*_arr = new int[arr_size];

	for (int i = 0; i < arr_size; i++) {
		(*_arr)[i] = rand() % arr_size;
	}

	if (DEBUG_LEVEL >= 5) {
		std::wcout << "Array: ";
		for (int i = 0; i < arr_size; i++) {
			std::wcout << (*_arr)[i] << ", ";
		}
		std::wcout << std::endl;
	}


	return arr_size;
}

void outputArray(int * _arr, int arr_size) {
	if (DEBUG_LEVEL >= 5) {
		std::wcout << "Array: ";
		for (int i = 0; i < arr_size; i++) {
			std::wcout << _arr[i] << ", ";
		}
		std::wcout << std::endl;
	}
	
	bool sorted = true;
	for (int i = 1; i < arr_size; i++) {
		if (_arr[i] < _arr[i - 1]) {
			sorted = false;
			break;
		}
	}

	if (DEBUG_LEVEL >= 1) std::wcout << "Array sorting check, sorted: " << std::boolalpha << sorted << std::endl;
}

// END OF USER AREA
// ---------------------------------

// Number of blocks
__constant__ const int GRID_SIZE = G_ARRAY_SIZE / 2 / BLOCK_SIZE;

void pause() {
	std::wcout << "Press enter to continue . . . " << std::endl;
	std::cin.ignore();
}

bool inline cudaErrorOccured(cudaError_t _cudaStatus) {
	if (_cudaStatus != cudaSuccess) {
		std::wcout << std::endl << std::endl
			<< "------------------------------"
			<< "CUDA error: " << _cudaStatus << std::endl;
		if (DEBUG_LEVEL >= 1) std::wcout << cudaGetErrorString(_cudaStatus) << std::endl;
		std::wcout 
			<< "------------------------------"
			<< std::endl << std::endl;

		return true;
	}
	return false;
}

__device__ bool D_SORTED = false;

__device__ inline void swap(int * arr, int i, int j) {
	int tmp = arr[i];
	arr[i] = arr[j];
	arr[j] = tmp;
}

__global__ void kernel(int * arr, int parity) {
	//get own index
	int idx = blockIdx.x * blockDim.x + threadIdx.x;

	//array for swapping
	__shared__ int shared_arr[BLOCK_SIZE * 2];

	//copying forth	
	int last_deduction = 0;
	if (threadIdx.x == 0) {
		if (parity == 1 && blockIdx.x == GRID_SIZE - 1) last_deduction = 1;

		for (int i = 0; i < blockDim.x * 2 - last_deduction; i++) {
			shared_arr[i] = arr[2 * idx + i + parity];
		}
	}
	
	__syncthreads();

	// Last kernel shouldn't work in this case
	if (parity == 1 && idx == BLOCK_SIZE * GRID_SIZE - 1) return;

	//swapping
	if (shared_arr[threadIdx.x * 2] > shared_arr[threadIdx.x * 2 + 1]) {
		swap(shared_arr, threadIdx.x * 2, threadIdx.x * 2 + 1);
		D_SORTED = false;
	}

	__syncthreads();


	//copying back
	if (threadIdx.x == 0) {
		for (int i = 0; i < blockDim.x * 2 - last_deduction; i++) {
			arr[2 * idx + i + parity] = shared_arr[i];
		}
	}
}

void oddevensort(int * arr, int arr_size) {
	bool sorted = false;
	cudaError_t cudaStatus = cudaSuccess;
	int counter = 0;

	while (!sorted) {
		sorted = true;
		
		cudaStatus = cudaMemcpyToSymbol(D_SORTED, &sorted, sizeof(bool));
		if (cudaErrorOccured(cudaStatus)) return;

		kernel<<<GRID_SIZE, BLOCK_SIZE>>>(arr, 0);
		kernel<<<GRID_SIZE, BLOCK_SIZE>>>(arr, 1);

		cudaStatus = cudaMemcpyFromSymbol(&sorted, D_SORTED, sizeof(bool));
		if (cudaErrorOccured(cudaStatus)) return;
		counter++;
	}

	if (DEBUG_LEVEL >= 1) std::cout << "Sorting finished, iterations: " << counter << std::endl;
}

int main()
{
	cudaError_t cudaStatus = cudaSuccess;

	int arr_size = 0;
	int * arr = 0;
	int * d_arr = 0; //GPU copy of array

	//0.    CUDA device'
	if (DEBUG_LEVEL >= 1)
	{
		std::wcout << "CUDA realization of odd-even sorting algorithm" << std::endl;
		std::wcout << "Author: Roman Beltyukov" << std::endl << std::endl;

		std::wcout << "CUDA information" << std::endl;
		int deviceCount = 0;
		cudaStatus = cudaGetDeviceCount(&deviceCount);
		if (cudaErrorOccured(cudaStatus)) return 1;
		std::wcout << "Available CUDA device count: " << deviceCount << std::endl << std::endl;

		cudaDeviceProp devProps;
		for (int i = 0; i < deviceCount; i++) {
			cudaStatus = cudaGetDeviceProperties(&devProps, i);
			if (cudaErrorOccured(cudaStatus)) return 1;

			std::wcout
				<< "Device #" << i << ", CUDA version: " << devProps.major << "." << devProps.minor
				<< ", integrated: " << std::boolalpha << devProps.integrated << std::endl
				<< "Name: " << devProps.name << std::endl
				<< "Clockrate: " << (double)devProps.clockRate / 1024 << "MHz" << std::endl
				<< "Total global memory: " << (double)devProps.totalGlobalMem / 1024 / 1024 / 1024 << "GB" << std::endl
				<< "Shared memory per block: " << (double)devProps.sharedMemPerBlock / 1024 << "KB" << std::endl
				<< "Warp size: " << devProps.warpSize << std::endl
				<< "Max threads per block: " << devProps.maxThreadsPerBlock << std::endl
				<< "Max threads dimension: [" 
					<< devProps.maxThreadsDim[0] << ", " 
					<< devProps.maxThreadsDim[1] << ", " 
					<< devProps.maxThreadsDim[2] << "]" << std::endl
				<< "Max grid size: [" 
					<< devProps.maxGridSize[0] << ", " 
					<< devProps.maxGridSize[1] << ", " 
					<< devProps.maxGridSize[0] << "]" << std::endl
				<< std::endl;
		}
		std::wcout << std::endl;
	}

	//1.  
	arr_size = inputArray(&arr);
	if (DEBUG_LEVEL >= 1) std::wcout << "Array generated, size: " << arr_size << ", last element: " << arr[arr_size - 1] << std::endl;

	//2.        
	cudaStatus = cudaMalloc((void **)&D_SORTED, sizeof(bool));
	if (cudaErrorOccured(cudaStatus)) return 1;

	cudaStatus = cudaMalloc((void **)&d_arr, arr_size * sizeof(int));
	if (cudaErrorOccured(cudaStatus)) return 1;

	cudaStatus = cudaMemcpy(d_arr, arr, arr_size * sizeof(int), cudaMemcpyHostToDevice);
	if (cudaErrorOccured(cudaStatus)) return 1;

	if (DEBUG_LEVEL >= 1) std::wcout << "Memory allocation and copying host->device finished" << std::endl;

	//3. 
	oddevensort(d_arr, arr_size);

	cudaStatus = cudaGetLastError();
	if (cudaErrorOccured(cudaStatus)) return 1;

	cudaStatus = cudaDeviceSynchronize();
	if (cudaErrorOccured(cudaStatus)) return 1;


	//4.   
	cudaStatus = cudaMemcpy(arr, d_arr, arr_size * sizeof(int), cudaMemcpyDeviceToHost);
	if (cudaErrorOccured(cudaStatus)) return 1;

	cudaStatus = cudaFree(d_arr);
	if (cudaErrorOccured(cudaStatus)) return 1;

	cudaStatus = cudaDeviceReset();;
	if (cudaErrorOccured(cudaStatus)) return 1;

	if (DEBUG_LEVEL >= 1) std::wcout << "Copying device->host and memory releasing finished" << std::endl;

	//5.  
	outputArray(arr, arr_size);
	delete[] arr;
	if (DEBUG_LEVEL >= 1) std::wcout << "Array output finished" << std::endl;
	
	if (DEBUG_LEVEL >= 1) {
		std::wcout << "Program finished" << std::endl;
	}

	if (DEBUG_LEVEL >= 2) pause();
    return 0;
}


	.file	"tmpxft_002b2f82_00000000-6_kernel.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.section	.text._ZSt9boolalphaRSt8ios_base,"axG",@progbits,_ZSt9boolalphaRSt8ios_base,comdat
	.weak	_ZSt9boolalphaRSt8ios_base
	.type	_ZSt9boolalphaRSt8ios_base, @function
_ZSt9boolalphaRSt8ios_base:
.LFB3265:
	.cfi_startproc
	endbr64
	orl	$1, 24(%rdi)
	movq	%rdi, %rax
	ret
	.cfi_endproc
.LFE3265:
	.size	_ZSt9boolalphaRSt8ios_base, .-_ZSt9boolalphaRSt8ios_base
	.text
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3644:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3644:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z10inputArrayPPi
	.type	_Z10inputArrayPPi, @function
_Z10inputArrayPPi:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$8192, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	movl	$32768, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	call	_Znam@PLT
	movq	%rax, 0(%rbp)
.L4:
	call	rand@PLT
	movq	0(%rbp), %rcx
	cltd
	idivl	%r12d
	movl	%edx, (%rcx,%rbx)
	addq	$4, %rbx
	cmpq	$32768, %rbx
	jne	.L4
	popq	%rbx
	.cfi_def_cfa_offset 24
	movl	$8192, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z10inputArrayPPi, .-_Z10inputArrayPPi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Array sorting check, sorted: "
	.text
	.globl	_Z11outputArrayPii
	.type	_Z11outputArrayPii, @function
_Z11outputArrayPii:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	$1, %eax
.L9:
	cmpl	%eax, %esi
	jle	.L14
	movl	(%rdi,%rax,4), %edx
	incq	%rax
	cmpl	-8(%rdi,%rax,4), %edx
	jge	.L9
	xorl	%ebx, %ebx
	jmp	.L10
.L14:
	movb	$1, %bl
.L10:
	leaq	.LC0(%rip), %rsi
	leaq	_ZSt5wcout(%rip), %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	leaq	_ZSt9boolalphaRSt8ios_base(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRSt8ios_baseS4_E@PLT
	movzbl	%bl, %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIbEERS2_T_@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 8
	movq	%rax, %rdi
	jmp	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	.cfi_endproc
.LFE3636:
	.size	_Z11outputArrayPii, .-_Z11outputArrayPii
	.section	.rodata.str1.1
.LC1:
	.string	"Press enter to continue . . . "
	.text
	.globl	_Z5pausev
	.type	_Z5pausev, @function
_Z5pausev:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	.LC1(%rip), %rsi
	leaq	_ZSt5wcout(%rip), %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	_ZSt3cin(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	_ZNSi6ignoreEv@PLT
	.cfi_endproc
.LFE3637:
	.size	_Z5pausev, .-_Z5pausev
	.section	.rodata._Z16cudaErrorOccured9cudaError.str1.1,"aMS",@progbits,1
.LC2:
	.string	"------------------------------"
.LC3:
	.string	"CUDA error: "
	.section	.text._Z16cudaErrorOccured9cudaError,"axG",@progbits,_Z16cudaErrorOccured9cudaError,comdat
	.weak	_Z16cudaErrorOccured9cudaError
	.type	_Z16cudaErrorOccured9cudaError, @function
_Z16cudaErrorOccured9cudaError:
.LFB3638:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L21
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	.LC2(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	_ZSt5wcout(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edi, %ebx
	movq	%rbp, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	movl	%ebx, %edi
	call	cudaGetErrorString@PLT
	movq	%rbp, %rdi
	movq	%rax, %rsi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	movb	$1, %al
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L21:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE3638:
	.size	_Z16cudaErrorOccured9cudaError, .-_Z16cudaErrorOccured9cudaError
	.text
	.globl	_Z26__device_stub__Z6kernelPiiPii
	.type	_Z26__device_stub__Z6kernelPiiPii, @function
_Z26__device_stub__Z6kernelPiiPii:
.LFB3666:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L26
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z6kernelPii(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L26:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3666:
	.size	_Z26__device_stub__Z6kernelPiiPii, .-_Z26__device_stub__Z6kernelPiiPii
	.globl	_Z6kernelPii
	.type	_Z6kernelPii, @function
_Z6kernelPii:
.LFB3667:
	.cfi_startproc
	endbr64
	jmp	_Z26__device_stub__Z6kernelPiiPii
	.cfi_endproc
.LFE3667:
	.size	_Z6kernelPii, .-_Z6kernelPii
	.section	.rodata.str1.1
.LC4:
	.string	"Sorting finished, iterations: "
	.text
	.globl	_Z11oddevensortPii
	.type	_Z11oddevensortPii, @function
_Z11oddevensortPii:
.LFB3640:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	_ZL8D_SORTED(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rdi, %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movb	$0, 15(%rsp)
.L32:
	cmpb	$0, 15(%rsp)
	jne	.L40
	leaq	15(%rsp), %r13
	xorl	%ecx, %ecx
	movq	%r12, %rdi
	movl	$1, %r8d
	movl	$1, %edx
	movq	%r13, %rsi
	movb	$1, 15(%rsp)
	call	cudaMemcpyToSymbol@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L31
	movl	$536870913, %edx
	movl	$8388609, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$3, %rdx
	salq	$9, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%rdx, 28(%rsp)
	movl	$1, 36(%rsp)
	movq	%rdi, 16(%rsp)
	movl	$1, 24(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L34
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	_Z26__device_stub__Z6kernelPiiPii
.L34:
	movl	$536870913, %edx
	movl	$8388609, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$3, %rdx
	salq	$9, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%rdx, 28(%rsp)
	movl	$1, 36(%rsp)
	movq	%rdi, 16(%rsp)
	movl	$1, 24(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L35
	movl	$1, %esi
	movq	%rbx, %rdi
	call	_Z26__device_stub__Z6kernelPiiPii
.L35:
	xorl	%ecx, %ecx
	movq	%r13, %rdi
	movl	$2, %r8d
	movl	$1, %edx
	movq	%r12, %rsi
	call	cudaMemcpyFromSymbol@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L31
	incl	%ebp
	jmp	.L32
.L40:
	leaq	.LC4(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebp, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
.L31:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3640:
	.size	_Z11oddevensortPii, .-_Z11oddevensortPii
	.section	.rodata.str1.1
.LC5:
	.string	"CUDA realization of odd-even sorting algorithm"
.LC6:
	.string	"Author: Roman Beltyukov"
.LC7:
	.string	"CUDA information"
.LC8:
	.string	"Available CUDA device count: "
.LC9:
	.string	"Device #"
.LC10:
	.string	", CUDA version: "
.LC11:
	.string	"."
.LC12:
	.string	", integrated: "
.LC13:
	.string	"Name: "
.LC14:
	.string	"Clockrate: "
.LC16:
	.string	"MHz"
.LC17:
	.string	"Total global memory: "
.LC18:
	.string	"GB"
.LC19:
	.string	"Shared memory per block: "
.LC20:
	.string	"KB"
.LC21:
	.string	"Warp size: "
.LC22:
	.string	"Max threads per block: "
.LC23:
	.string	"Max threads dimension: ["
.LC24:
	.string	", "
.LC25:
	.string	"]"
.LC26:
	.string	"Max grid size: ["
.LC27:
	.string	"Array generated, size: "
.LC28:
	.string	", last element: "
.LC29:
	.string	"Memory allocation and copying host->device finished"
.LC30:
	.string	"Copying device->host and memory releasing finished"
.LC31:
	.string	"Array output finished"
.LC32:
	.string	"Program finished"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3641:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC5(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	_ZSt5wcout(%rip), %rbx
	movq	%rbx, %rdi
	subq	$1072, %rsp
	.cfi_def_cfa_offset 1120
	movq	%fs:40, %rax
	movq	%rax, 1064(%rsp)
	xorl	%eax, %eax
	xorl	%eax, %eax
	movq	%rax, 16(%rsp)
	movq	%rax, 24(%rsp)
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC7(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	xorl	%edx, %edx
	leaq	12(%rsp), %rdi
	movl	%edx, 12(%rsp)
	call	cudaGetDeviceCount@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L51
	leaq	.LC8(%rip), %rsi
	movq	%rbx, %rdi
	xorl	%ebp, %ebp
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	12(%rsp), %esi
	leaq	.LC9(%rip), %r12
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
.L43:
	cmpl	%ebp, 12(%rsp)
	jle	.L59
	leaq	32(%rsp), %r13
	movl	%ebp, %esi
	movq	%r13, %rdi
	call	cudaGetDeviceProperties_v2@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L51
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	%ebp, %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	leaq	.LC10(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	392(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	leaq	.LC11(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	396(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	leaq	.LC12(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	leaq	_ZSt9boolalphaRSt8ios_base(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRSt8ios_baseS4_E@PLT
	movl	428(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC13(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC14(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	cvtsi2sdl	380(%rsp), %xmm0
	mulsd	.LC15(%rip), %xmm0
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIdEERS2_T_@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC17(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	320(%rsp), %rdx
	movq	%rax, %rdi
	testq	%rdx, %rdx
	js	.L44
	cvtsi2sdq	%rdx, %xmm0
	jmp	.L45
.L44:
	movq	%rdx, %rax
	andl	$1, %edx
	shrq	%rax
	orq	%rdx, %rax
	cvtsi2sdq	%rax, %xmm0
	addsd	%xmm0, %xmm0
.L45:
	mulsd	.LC15(%rip), %xmm0
	mulsd	.LC15(%rip), %xmm0
	mulsd	.LC15(%rip), %xmm0
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIdEERS2_T_@PLT
	leaq	.LC18(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC19(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	328(%rsp), %rdx
	movq	%rax, %rdi
	testq	%rdx, %rdx
	js	.L46
	cvtsi2sdq	%rdx, %xmm0
	jmp	.L47
.L46:
	movq	%rdx, %rax
	andl	$1, %edx
	shrq	%rax
	orq	%rdx, %rax
	cvtsi2sdq	%rax, %xmm0
	addsd	%xmm0, %xmm0
.L47:
	leaq	.LC24(%rip), %r13
	mulsd	.LC15(%rip), %xmm0
	leaq	.LC25(%rip), %r14
	incl	%ebp
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIdEERS2_T_@PLT
	leaq	.LC20(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC21(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	340(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC22(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	352(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC23(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	356(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	360(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	364(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	%r14, %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC26(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	368(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	372(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	368(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	%r14, %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	jmp	.L43
.L59:
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	16(%rsp), %rdi
	call	_Z10inputArrayPPi
	leaq	.LC27(%rip), %rsi
	movq	%rbx, %rdi
	movslq	%eax, %r13
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movl	%r13d, %esi
	movq	%r13, %r12
	salq	$2, %r13
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	leaq	.LC28(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	16(%rsp), %rbp
	movq	%rax, %rdi
	movl	-4(%rbp,%r13), %esi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	_ZL8D_SORTED(%rip), %rdi
	movl	$1, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	je	.L49
.L51:
	movl	$1, %eax
	jmp	.L41
.L49:
	leaq	24(%rsp), %rdi
	movq	%r13, %rsi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L51
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%r13, %rdx
	movq	%rbp, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L51
	leaq	.LC29(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	movq	24(%rsp), %rdi
	movl	%r12d, %esi
	call	_Z11oddevensortPii
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L51
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L51
	movq	24(%rsp), %rsi
	movq	%rbp, %rdi
	movl	$2, %ecx
	movq	%r13, %rdx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L51
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L51
	call	cudaDeviceReset@PLT
	movl	%eax, %edi
	call	_Z16cudaErrorOccured9cudaError
	testb	%al, %al
	jne	.L51
	leaq	.LC30(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	movl	%r12d, %esi
	movq	%rbp, %rdi
	call	_Z11outputArrayPii
	testq	%rbp, %rbp
	je	.L53
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
.L53:
	leaq	.LC31(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	leaq	.LC32(%rip), %rsi
	movq	%rbx, %rdi
	call	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc@PLT
	movq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@PLT
	call	_Z5pausev
	xorl	%eax, %eax
.L41:
	movq	1064(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L54
	call	__stack_chk_fail@PLT
.L54:
	addq	$1072, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3641:
	.size	main, .-main
	.section	.rodata.str1.1
.LC33:
	.string	"_Z6kernelPii"
.LC34:
	.string	"DEBUG_LEVEL"
.LC35:
	.string	"G_ARRAY_SIZE"
.LC36:
	.string	"BLOCK_SIZE"
.LC37:
	.string	"GRID_SIZE"
.LC38:
	.string	"D_SORTED"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3669:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC33(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z6kernelPii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC34(%rip), %rdx
	movl	$4, %r9d
	leaq	_ZL11DEBUG_LEVEL(%rip), %rsi
	pushq	$1
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC35(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$4, %r9d
	leaq	_ZL12G_ARRAY_SIZE(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC36(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$4, %r9d
	leaq	_ZL10BLOCK_SIZE(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%rdi
	.cfi_def_cfa_offset 24
	popq	%r8
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	.LC37(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$4, %r9d
	leaq	_ZL9GRID_SIZE(%rip), %rsi
	call	__cudaRegisterVar@PLT
	popq	%r9
	.cfi_def_cfa_offset 24
	popq	%r10
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC38(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movl	$1, %r9d
	movq	%rdx, %rcx
	leaq	_ZL8D_SORTED(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%r11
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3669:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.local	_ZL8D_SORTED
	.comm	_ZL8D_SORTED,1,1
	.section	.rodata
	.align 4
	.type	_ZL9GRID_SIZE, @object
	.size	_ZL9GRID_SIZE, 4
_ZL9GRID_SIZE:
	.long	512
	.align 4
	.type	_ZL10BLOCK_SIZE, @object
	.size	_ZL10BLOCK_SIZE, 4
_ZL10BLOCK_SIZE:
	.long	8
	.align 4
	.type	_ZL12G_ARRAY_SIZE, @object
	.size	_ZL12G_ARRAY_SIZE, 4
_ZL12G_ARRAY_SIZE:
	.long	8192
	.align 4
	.type	_ZL11DEBUG_LEVEL, @object
	.size	_ZL11DEBUG_LEVEL, 4
_ZL11DEBUG_LEVEL:
	.long	4
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC15:
	.long	0
	.long	1062207488
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include "hip/hip_runtime.h"

#include <stdio.h>
#include <iostream>

// ---------------------------------
// BEGIN OF USER AREA

// Debug level, possible values: 0 - 5, 5 is highest
// Highest level will cause EXTREMELY detailed output (the whole array will be printed)
__constant__ const int DEBUG_LEVEL = 4;

// Array size for initialization, used only in inputArray functiont
__constant__ const int G_ARRAY_SIZE = 8192;

// Number of threads inside of block
__constant__ const int BLOCK_SIZE = 8;

int inputArray(int ** _arr) {
	int arr_size = G_ARRAY_SIZE;
	*_arr = new int[arr_size];

	for (int i = 0; i < arr_size; i++) {
		(*_arr)[i] = rand() % arr_size;
	}

	if (DEBUG_LEVEL >= 5) {
		std::wcout << "Array: ";
		for (int i = 0; i < arr_size; i++) {
			std::wcout << (*_arr)[i] << ", ";
		}
		std::wcout << std::endl;
	}


	return arr_size;
}

void outputArray(int * _arr, int arr_size) {
	if (DEBUG_LEVEL >= 5) {
		std::wcout << "Array: ";
		for (int i = 0; i < arr_size; i++) {
			std::wcout << _arr[i] << ", ";
		}
		std::wcout << std::endl;
	}
	
	bool sorted = true;
	for (int i = 1; i < arr_size; i++) {
		if (_arr[i] < _arr[i - 1]) {
			sorted = false;
			break;
		}
	}

	if (DEBUG_LEVEL >= 1) std::wcout << "Array sorting check, sorted: " << std::boolalpha << sorted << std::endl;
}

// END OF USER AREA
// ---------------------------------

// Number of blocks
__constant__ const int GRID_SIZE = G_ARRAY_SIZE / 2 / BLOCK_SIZE;

void pause() {
	std::wcout << "Press enter to continue . . . " << std::endl;
	std::cin.ignore();
}

bool inline cudaErrorOccured(hipError_t _cudaStatus) {
	if (_cudaStatus != hipSuccess) {
		std::wcout << std::endl << std::endl
			<< "------------------------------"
			<< "CUDA error: " << _cudaStatus << std::endl;
		if (DEBUG_LEVEL >= 1) std::wcout << hipGetErrorString(_cudaStatus) << std::endl;
		std::wcout 
			<< "------------------------------"
			<< std::endl << std::endl;

		return true;
	}
	return false;
}

__device__ bool D_SORTED = false;

__device__ inline void swap(int * arr, int i, int j) {
	int tmp = arr[i];
	arr[i] = arr[j];
	arr[j] = tmp;
}

__global__ void kernel(int * arr, int parity) {
	//get own index
	int idx = blockIdx.x * blockDim.x + threadIdx.x;

	//array for swapping
	__shared__ int shared_arr[BLOCK_SIZE * 2];

	//copying forth	
	int last_deduction = 0;
	if (threadIdx.x == 0) {
		if (parity == 1 && blockIdx.x == GRID_SIZE - 1) last_deduction = 1;

		for (int i = 0; i < blockDim.x * 2 - last_deduction; i++) {
			shared_arr[i] = arr[2 * idx + i + parity];
		}
	}
	
	__syncthreads();

	// Last kernel shouldn't work in this case
	if (parity == 1 && idx == BLOCK_SIZE * GRID_SIZE - 1) return;

	//swapping
	if (shared_arr[threadIdx.x * 2] > shared_arr[threadIdx.x * 2 + 1]) {
		swap(shared_arr, threadIdx.x * 2, threadIdx.x * 2 + 1);
		D_SORTED = false;
	}

	__syncthreads();


	//copying back
	if (threadIdx.x == 0) {
		for (int i = 0; i < blockDim.x * 2 - last_deduction; i++) {
			arr[2 * idx + i + parity] = shared_arr[i];
		}
	}
}

void oddevensort(int * arr, int arr_size) {
	bool sorted = false;
	hipError_t cudaStatus = hipSuccess;
	int counter = 0;

	while (!sorted) {
		sorted = true;
		
		cudaStatus = hipMemcpyToSymbol(HIP_SYMBOL(D_SORTED), &sorted, sizeof(bool));
		if (cudaErrorOccured(cudaStatus)) return;

		kernel<<<GRID_SIZE, BLOCK_SIZE>>>(arr, 0);
		kernel<<<GRID_SIZE, BLOCK_SIZE>>>(arr, 1);

		cudaStatus = hipMemcpyFromSymbol(&sorted, HIP_SYMBOL(D_SORTED), sizeof(bool));
		if (cudaErrorOccured(cudaStatus)) return;
		counter++;
	}

	if (DEBUG_LEVEL >= 1) std::cout << "Sorting finished, iterations: " << counter << std::endl;
}

int main()
{
	hipError_t cudaStatus = hipSuccess;

	int arr_size = 0;
	int * arr = 0;
	int * d_arr = 0; //GPU copy of array

	//0.    CUDA device'
	if (DEBUG_LEVEL >= 1)
	{
		std::wcout << "CUDA realization of odd-even sorting algorithm" << std::endl;
		std::wcout << "Author: Roman Beltyukov" << std::endl << std::endl;

		std::wcout << "CUDA information" << std::endl;
		int deviceCount = 0;
		cudaStatus = hipGetDeviceCount(&deviceCount);
		if (cudaErrorOccured(cudaStatus)) return 1;
		std::wcout << "Available CUDA device count: " << deviceCount << std::endl << std::endl;

		hipDeviceProp_t devProps;
		for (int i = 0; i < deviceCount; i++) {
			cudaStatus = hipGetDeviceProperties(&devProps, i);
			if (cudaErrorOccured(cudaStatus)) return 1;

			std::wcout
				<< "Device #" << i << ", CUDA version: " << devProps.major << "." << devProps.minor
				<< ", integrated: " << std::boolalpha << devProps.integrated << std::endl
				<< "Name: " << devProps.name << std::endl
				<< "Clockrate: " << (double)devProps.clockRate / 1024 << "MHz" << std::endl
				<< "Total global memory: " << (double)devProps.totalGlobalMem / 1024 / 1024 / 1024 << "GB" << std::endl
				<< "Shared memory per block: " << (double)devProps.sharedMemPerBlock / 1024 << "KB" << std::endl
				<< "Warp size: " << devProps.warpSize << std::endl
				<< "Max threads per block: " << devProps.maxThreadsPerBlock << std::endl
				<< "Max threads dimension: [" 
					<< devProps.maxThreadsDim[0] << ", " 
					<< devProps.maxThreadsDim[1] << ", " 
					<< devProps.maxThreadsDim[2] << "]" << std::endl
				<< "Max grid size: [" 
					<< devProps.maxGridSize[0] << ", " 
					<< devProps.maxGridSize[1] << ", " 
					<< devProps.maxGridSize[0] << "]" << std::endl
				<< std::endl;
		}
		std::wcout << std::endl;
	}

	//1.  
	arr_size = inputArray(&arr);
	if (DEBUG_LEVEL >= 1) std::wcout << "Array generated, size: " << arr_size << ", last element: " << arr[arr_size - 1] << std::endl;

	//2.        
	cudaStatus = hipMalloc((void **)&D_SORTED, sizeof(bool));
	if (cudaErrorOccured(cudaStatus)) return 1;

	cudaStatus = hipMalloc((void **)&d_arr, arr_size * sizeof(int));
	if (cudaErrorOccured(cudaStatus)) return 1;

	cudaStatus = hipMemcpy(d_arr, arr, arr_size * sizeof(int), hipMemcpyHostToDevice);
	if (cudaErrorOccured(cudaStatus)) return 1;

	if (DEBUG_LEVEL >= 1) std::wcout << "Memory allocation and copying host->device finished" << std::endl;

	//3. 
	oddevensort(d_arr, arr_size);

	cudaStatus = hipGetLastError();
	if (cudaErrorOccured(cudaStatus)) return 1;

	cudaStatus = hipDeviceSynchronize();
	if (cudaErrorOccured(cudaStatus)) return 1;


	//4.   
	cudaStatus = hipMemcpy(arr, d_arr, arr_size * sizeof(int), hipMemcpyDeviceToHost);
	if (cudaErrorOccured(cudaStatus)) return 1;

	cudaStatus = hipFree(d_arr);
	if (cudaErrorOccured(cudaStatus)) return 1;

	cudaStatus = hipDeviceReset();;
	if (cudaErrorOccured(cudaStatus)) return 1;

	if (DEBUG_LEVEL >= 1) std::wcout << "Copying device->host and memory releasing finished" << std::endl;

	//5.  
	outputArray(arr, arr_size);
	delete[] arr;
	if (DEBUG_LEVEL >= 1) std::wcout << "Array output finished" << std::endl;
	
	if (DEBUG_LEVEL >= 1) {
		std::wcout << "Program finished" << std::endl;
	}

	if (DEBUG_LEVEL >= 2) pause();
    return 0;
}


	.text
	.file	"kernel.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z10inputArrayPPi               # -- Begin function _Z10inputArrayPPi
	.type	_Z10inputArrayPPi,@function
_Z10inputArrayPPi:                      # @_Z10inputArrayPPi
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rdi, %rbx
	movl	$32768, %edi                    # imm = 0x8000
	callq	_Znam
	movq	%rax, (%rbx)
	xorl	%r14d, %r14d
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
	callq	rand
                                        # kill: def $eax killed $eax def $rax
	leal	8191(%rax), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	andl	$-8192, %ecx                    # imm = 0xE000
	subl	%ecx, %eax
	movq	(%rbx), %rcx
	movl	%eax, (%rcx,%r14,4)
	incq	%r14
	cmpq	$8192, %r14                     # imm = 0x2000
	jne	.LBB0_1
# %bb.2:
	movl	$8192, %eax                     # imm = 0x2000
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z10inputArrayPPi, .Lfunc_end0-_Z10inputArrayPPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z11outputArrayPii              # -- Begin function _Z11outputArrayPii
	.type	_Z11outputArrayPii,@function
_Z11outputArrayPii:                     # @_Z11outputArrayPii
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movb	$1, %bl
	cmpl	$2, %esi
	jl	.LBB1_7
# %bb.1:                                # %.lr.ph.preheader
	movl	4(%rdi), %eax
	cmpl	(%rdi), %eax
	jge	.LBB1_3
# %bb.2:
	xorl	%ebx, %ebx
	jmp	.LBB1_7
.LBB1_3:                                # %.lr.ph12.preheader
	movl	%esi, %eax
	movl	$2, %edx
.LBB1_4:                                # %.lr.ph12
                                        # =>This Inner Loop Header: Depth=1
	movq	%rdx, %rcx
	cmpq	%rdx, %rax
	je	.LBB1_6
# %bb.5:                                # %.lr.ph
                                        #   in Loop: Header=BB1_4 Depth=1
	movl	(%rdi,%rcx,4), %esi
	leaq	1(%rcx), %rdx
	cmpl	-4(%rdi,%rcx,4), %esi
	jge	.LBB1_4
.LBB1_6:                                # %._crit_edge.loopexit
	cmpq	%rax, %rcx
	setae	%bl
.LBB1_7:                                # %._crit_edge
	movl	$_ZSt5wcout, %edi
	movl	$.L.str, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	orl	$1, 24(%rax,%rcx)
	movzbl	%bl, %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIbEERS2_T_
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%rbx,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB1_8
# %bb.9:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv # TAILCALL
.LBB1_8:
	.cfi_def_cfa_offset 16
	callq	_ZSt16__throw_bad_castv
.Lfunc_end1:
	.size	_Z11outputArrayPii, .Lfunc_end1-_Z11outputArrayPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z5pausev                       # -- Begin function _Z5pausev
	.type	_Z5pausev,@function
_Z5pausev:                              # @_Z5pausev
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.1, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%rbx,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB2_1
# %bb.2:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$_ZSt3cin, %edi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	_ZNSi6ignoreEv                  # TAILCALL
.LBB2_1:
	.cfi_def_cfa_offset 16
	callq	_ZSt16__throw_bad_castv
.Lfunc_end2:
	.size	_Z5pausev, .Lfunc_end2-_Z5pausev
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__kernelPii    # -- Begin function _Z21__device_stub__kernelPii
	.type	_Z21__device_stub__kernelPii,@function
_Z21__device_stub__kernelPii:           # @_Z21__device_stub__kernelPii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z6kernelPii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z21__device_stub__kernelPii, .Lfunc_end3-_Z21__device_stub__kernelPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11oddevensortPii              # -- Begin function _Z11oddevensortPii
	.type	_Z11oddevensortPii,@function
_Z11oddevensortPii:                     # @_Z11oddevensortPii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %r14
	movabsq	$4294967304, %r15               # imm = 0x100000008
	xorl	%ebx, %ebx
	leaq	15(%rsp), %r12
	leaq	504(%r15), %r13
.LBB4_1:                                # =>This Inner Loop Header: Depth=1
	movb	$1, 15(%rsp)
	movl	$D_SORTED, %edi
	movl	$1, %edx
	movq	%r12, %rsi
	xorl	%ecx, %ecx
	movl	$1, %r8d
	callq	hipMemcpyToSymbol
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	jne	.LBB4_9
# %bb.2:                                #   in Loop: Header=BB4_1 Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_4
# %bb.3:                                #   in Loop: Header=BB4_1 Depth=1
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	_Z21__device_stub__kernelPii
.LBB4_4:                                #   in Loop: Header=BB4_1 Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_6
# %bb.5:                                #   in Loop: Header=BB4_1 Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	callq	_Z21__device_stub__kernelPii
.LBB4_6:                                #   in Loop: Header=BB4_1 Depth=1
	movl	$D_SORTED, %esi
	movl	$1, %edx
	movq	%r12, %rdi
	xorl	%ecx, %ecx
	movl	$2, %r8d
	callq	hipMemcpyFromSymbol
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	jne	.LBB4_9
# %bb.7:                                #   in Loop: Header=BB4_1 Depth=1
	incl	%ebx
	cmpb	$0, 15(%rsp)
	je	.LBB4_1
# %bb.8:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$30, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	%ebx, %esi
	callq	_ZNSolsEi
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB4_9:                                # %.loopexit
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z11oddevensortPii, .Lfunc_end4-_Z11oddevensortPii
	.cfi_endproc
                                        # -- End function
	.section	.text._Z16cudaErrorOccured10hipError_t,"axG",@progbits,_Z16cudaErrorOccured10hipError_t,comdat
	.weak	_Z16cudaErrorOccured10hipError_t # -- Begin function _Z16cudaErrorOccured10hipError_t
	.type	_Z16cudaErrorOccured10hipError_t,@function
_Z16cudaErrorOccured10hipError_t:       # @_Z16cudaErrorOccured10hipError_t
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	%edi, %ebx
	testl	%edi, %edi
	je	.LBB5_8
# %bb.1:
	movq	_ZSt5wcout(%rip), %rax
	movq	-24(%rax), %rax
	movq	_ZSt5wcout+240(%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB5_9
# %bb.2:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movl	$_ZSt5wcout, %edi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r14,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB5_9
# %bb.3:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit5
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r14, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$.L.str.30, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	$.L.str.31, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rdi
	movl	%ebx, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r14,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB5_9
# %bb.4:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit7
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r14, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$_ZSt5wcout, %edi
	movq	%rax, %rsi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r14,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB5_9
# %bb.5:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit9
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r14, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.30, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r14,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB5_9
# %bb.6:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit11
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r14, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r14,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB5_9
# %bb.7:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit13
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r14, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
.LBB5_8:
	testl	%ebx, %ebx
	setne	%al
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.LBB5_9:
	.cfi_def_cfa_offset 32
	callq	_ZSt16__throw_bad_castv
.Lfunc_end5:
	.size	_Z16cudaErrorOccured10hipError_t, .Lfunc_end5-_Z16cudaErrorOccured10hipError_t
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI6_0:
	.quad	0x3f50000000000000              # double 9.765625E-4
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI6_1:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI6_2:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$1496, %rsp                     # imm = 0x5D8
	.cfi_def_cfa_offset 1536
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	xorl	%eax, %eax
	movq	%rax, 16(%rsp)
	movq	%rax, 8(%rsp)
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.3, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%rbx,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.1:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.4, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%rbx,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.2:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit31
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%rbx,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.3:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit33
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.5, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%rbx,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.4:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit35
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	leaq	4(%rsp), %rdi
	movl	$0, (%rdi)
	callq	hipGetDeviceCount
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	je	.LBB6_6
.LBB6_5:                                # %.thread69
	movl	$1, %ebp
	jmp	.LBB6_34
.LBB6_6:
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.6, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	4(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%rbx,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.7:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit37
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movq	%rax, %rbx
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%rbx,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.8:                                # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit39
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	cmpl	$0, 4(%rsp)
	jle	.LBB6_22
# %bb.9:                                # %.lr.ph
	xorl	%ebx, %ebx
	leaq	24(%rsp), %r14
.LBB6_10:                               # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	hipGetDevicePropertiesR0600
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	jne	.LBB6_5
# %bb.11:                               #   in Loop: Header=BB6_10 Depth=1
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.7, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rdi
	movl	%ebx, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movl	$.L.str.8, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	384(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movl	$.L.str.9, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	388(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movl	$.L.str.10, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	orl	$1, 24(%rax,%rcx)
	movl	420(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r15,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.12:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit41
                                        #   in Loop: Header=BB6_10 Depth=1
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$.L.str.11, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rdi
	movq	%r14, %rsi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r15,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.13:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit43
                                        #   in Loop: Header=BB6_10 Depth=1
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$.L.str.12, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	cvtsi2sdl	372(%rsp), %xmm0
	movsd	.LCPI6_0(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIdEERS2_T_
	movl	$.L.str.13, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r15,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.14:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit45
                                        #   in Loop: Header=BB6_10 Depth=1
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$.L.str.14, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movsd	312(%rsp), %xmm1                # xmm1 = mem[0],zero
	movapd	.LCPI6_1(%rip), %xmm0           # xmm0 = [1127219200,1160773632,0,0]
	unpcklps	%xmm0, %xmm1                    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
	movapd	.LCPI6_2(%rip), %xmm0           # xmm0 = [4.503599627370496E+15,1.9342813113834067E+25]
	subpd	%xmm0, %xmm1
	movapd	%xmm1, %xmm0
	unpckhpd	%xmm1, %xmm0                    # xmm0 = xmm0[1],xmm1[1]
	addsd	%xmm1, %xmm0
	movsd	.LCPI6_0(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	mulsd	%xmm1, %xmm0
	mulsd	%xmm1, %xmm0
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIdEERS2_T_
	movl	$.L.str.15, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r15,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.15:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit47
                                        #   in Loop: Header=BB6_10 Depth=1
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$.L.str.16, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movsd	320(%rsp), %xmm1                # xmm1 = mem[0],zero
	unpcklps	.LCPI6_1(%rip), %xmm1           # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
	subpd	.LCPI6_2(%rip), %xmm1
	movapd	%xmm1, %xmm0
	unpckhpd	%xmm1, %xmm0                    # xmm0 = xmm0[1],xmm1[1]
	addsd	%xmm1, %xmm0
	mulsd	.LCPI6_0(%rip), %xmm0
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIdEERS2_T_
	movl	$.L.str.17, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r15,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.16:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit49
                                        #   in Loop: Header=BB6_10 Depth=1
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$.L.str.18, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	332(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r15,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.17:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit51
                                        #   in Loop: Header=BB6_10 Depth=1
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$.L.str.19, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	344(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r15,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.18:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit53
                                        #   in Loop: Header=BB6_10 Depth=1
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$.L.str.20, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	348(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movl	$.L.str.21, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	352(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movl	$.L.str.21, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	356(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movl	$.L.str.22, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r15,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.19:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit55
                                        #   in Loop: Header=BB6_10 Depth=1
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$.L.str.23, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	360(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movl	$.L.str.21, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	364(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movl	$.L.str.21, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movl	360(%rsp), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movl	$.L.str.22, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r15,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.20:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit57
                                        #   in Loop: Header=BB6_10 Depth=1
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movq	%rax, %r15
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r15,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.21:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit59
                                        #   in Loop: Header=BB6_10 Depth=1
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	incl	%ebx
	cmpl	4(%rsp), %ebx
	jl	.LBB6_10
.LBB6_22:                               # %._crit_edge
	movq	_ZSt5wcout(%rip), %rax
	movq	-24(%rax), %rax
	movq	_ZSt5wcout+240(%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.23:
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movl	$_ZSt5wcout, %edi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	leaq	16(%rsp), %rbx
	movq	%rbx, %rdi
	callq	_Z10inputArrayPPi
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.24, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rdi
	movl	$8192, %esi                     # imm = 0x2000
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movl	$.L.str.25, %esi
	movq	%rax, %rdi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	(%rbx), %rbx
	movl	32764(%rbx), %esi
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEi
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r14,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.24:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit63
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r14, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movl	$D_SORTED, %edi
	movl	$1, %esi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	movl	$1, %ebp
	testb	%al, %al
	jne	.LBB6_34
# %bb.25:
	leaq	8(%rsp), %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	jne	.LBB6_34
# %bb.26:
	movq	8(%rsp), %rdi
	movl	$1, %ebp
	movl	$32768, %edx                    # imm = 0x8000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	jne	.LBB6_34
# %bb.27:
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.26, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	240(%r14,%rax), %rdi
	testq	%rdi, %rdi
	je	.LBB6_35
# %bb.28:                               # %_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_.exit65
	movq	(%rdi), %rax
	movl	$10, %esi
	callq	*80(%rax)
	movq	%r14, %rdi
	movl	%eax, %esi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE3putEw
	movq	%rax, %rdi
	callq	_ZNSt13basic_ostreamIwSt11char_traitsIwEE5flushEv
	movq	8(%rsp), %rdi
	callq	_Z11oddevensortPii
	callq	hipGetLastError
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	jne	.LBB6_34
# %bb.29:
	callq	hipDeviceSynchronize
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	jne	.LBB6_34
# %bb.30:
	movq	8(%rsp), %rsi
	movl	$32768, %edx                    # imm = 0x8000
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	jne	.LBB6_34
# %bb.31:
	movq	8(%rsp), %rdi
	callq	hipFree
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	jne	.LBB6_34
# %bb.32:
	callq	hipDeviceReset
	movl	%eax, %edi
	callq	_Z16cudaErrorOccured10hipError_t
	testb	%al, %al
	jne	.LBB6_34
# %bb.33:
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.27, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_
	movq	%rbx, %rdi
	movl	$8192, %esi                     # imm = 0x2000
	callq	_Z11outputArrayPii
	movq	%rbx, %rdi
	callq	_ZdaPv
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.28, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_
	movl	$_ZSt5wcout, %edi
	movl	$.L.str.29, %esi
	callq	_ZStlsIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIwSt11char_traitsIwEERSt13basic_ostreamIT_T0_ES6_
	callq	_Z5pausev
	xorl	%ebp, %ebp
.LBB6_34:
	movl	%ebp, %eax
	addq	$1496, %rsp                     # imm = 0x5D8
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB6_35:
	.cfi_def_cfa_offset 1536
	callq	_ZSt16__throw_bad_castv
.Lfunc_end6:
	.size	main, .Lfunc_end6-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6kernelPii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$0, (%rsp)
	movl	$D_SORTED, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movl	$1, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB8_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Array sorting check, sorted: "
	.size	.L.str, 30

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Press enter to continue . . . "
	.size	.L.str.1, 31

	.type	D_SORTED,@object                # @D_SORTED
	.local	D_SORTED
	.comm	D_SORTED,1,1
	.type	_Z6kernelPii,@object            # @_Z6kernelPii
	.section	.rodata,"a",@progbits
	.globl	_Z6kernelPii
	.p2align	3, 0x0
_Z6kernelPii:
	.quad	_Z21__device_stub__kernelPii
	.size	_Z6kernelPii, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"Sorting finished, iterations: "
	.size	.L.str.2, 31

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"CUDA realization of odd-even sorting algorithm"
	.size	.L.str.3, 47

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Author: Roman Beltyukov"
	.size	.L.str.4, 24

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"CUDA information"
	.size	.L.str.5, 17

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Available CUDA device count: "
	.size	.L.str.6, 30

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Device #"
	.size	.L.str.7, 9

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	", CUDA version: "
	.size	.L.str.8, 17

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"."
	.size	.L.str.9, 2

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	", integrated: "
	.size	.L.str.10, 15

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Name: "
	.size	.L.str.11, 7

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Clockrate: "
	.size	.L.str.12, 12

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"MHz"
	.size	.L.str.13, 4

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Total global memory: "
	.size	.L.str.14, 22

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"GB"
	.size	.L.str.15, 3

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Shared memory per block: "
	.size	.L.str.16, 26

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"KB"
	.size	.L.str.17, 3

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Warp size: "
	.size	.L.str.18, 12

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"Max threads per block: "
	.size	.L.str.19, 24

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"Max threads dimension: ["
	.size	.L.str.20, 25

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	", "
	.size	.L.str.21, 3

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"]"
	.size	.L.str.22, 2

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"Max grid size: ["
	.size	.L.str.23, 17

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"Array generated, size: "
	.size	.L.str.24, 24

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	", last element: "
	.size	.L.str.25, 17

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"Memory allocation and copying host->device finished"
	.size	.L.str.26, 52

	.type	.L.str.27,@object               # @.str.27
.L.str.27:
	.asciz	"Copying device->host and memory releasing finished"
	.size	.L.str.27, 51

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"Array output finished"
	.size	.L.str.28, 22

	.type	.L.str.29,@object               # @.str.29
.L.str.29:
	.asciz	"Program finished"
	.size	.L.str.29, 17

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	"------------------------------"
	.size	.L.str.30, 31

	.type	.L.str.31,@object               # @.str.31
.L.str.31:
	.asciz	"CUDA error: "
	.size	.L.str.31, 13

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6kernelPii"
	.size	.L__unnamed_1, 13

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"D_SORTED"
	.size	.L__unnamed_2, 9

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z21__device_stub__kernelPii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _ZSt5wcout
	.addrsig_sym _ZSt3cin
	.addrsig_sym D_SORTED
	.addrsig_sym _Z6kernelPii
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z6kernelPii            ; -- Begin function _Z6kernelPii
	.globl	_Z6kernelPii
	.p2align	8
	.type	_Z6kernelPii,@function
_Z6kernelPii:                           ; @_Z6kernelPii
; %bb.0:
	s_clause 0x2
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b64 s[2:3], s[0:1], 0x0
	s_load_b32 s1, s[0:1], 0x8
	v_cmp_eq_u32_e64 s0, 0, v0
	v_mov_b32_e32 v2, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s7, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mul_i32 s6, s15, s7
	s_and_saveexec_b32 s8, s0
	s_cbranch_execz .LBB0_5
; %bb.1:
	s_cmp_eq_u32 s1, 1
	s_cselect_b32 s4, -1, 0
	s_cmpk_eq_i32 s15, 0x1ff
	s_cselect_b32 s5, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s4, s5, s4
	v_cndmask_b32_e64 v1, 0, 1, s4
	s_lshl_b32 s4, s7, 1
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cmp_eq_u32_e32 vcc_lo, s4, v1
	v_readfirstlane_b32 s9, v1
	s_cbranch_vccnz .LBB0_4
; %bb.2:                                ; %.lr.ph
	s_delay_alu instid0(VALU_DEP_1)
	s_sub_i32 s4, s4, s9
	s_lshl_b32 s5, s6, 1
	s_max_u32 s10, s4, 1
	s_add_i32 s4, s1, s5
	s_mov_b32 s11, 0
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	s_ashr_i32 s5, s4, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[12:13], s[4:5], 2
	s_add_u32 s12, s2, s12
	s_addc_u32 s13, s3, s13
	s_add_i32 s10, s10, -1
	s_load_b32 s5, s[12:13], 0x0
	v_mov_b32_e32 v1, s11
	s_add_i32 s11, s11, 4
	s_add_i32 s4, s4, 1
	s_cmp_lg_u32 s10, 0
	s_waitcnt lgkmcnt(0)
	v_mov_b32_e32 v2, s5
	ds_store_b32 v1, v2
	s_cbranch_scc1 .LBB0_3
.LBB0_4:                                ; %Flow46
	s_delay_alu instid0(VALU_DEP_1)
	v_mov_b32_e32 v2, s9
.LBB0_5:                                ; %.loopexit23
	s_or_b32 exec_lo, exec_lo, s8
	v_add_nc_u32_e32 v1, s6, v0
	s_cmp_lg_u32 s1, 1
	s_waitcnt lgkmcnt(0)
	s_cselect_b32 s4, -1, 0
	s_barrier
	v_cmp_ne_u32_e32 vcc_lo, 0xfff, v1
	buffer_gl0_inv
	s_or_b32 s4, s4, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s5, s4
	s_cbranch_execz .LBB0_12
; %bb.6:
	v_lshlrev_b32_e32 v3, 3, v0
	s_mov_b32 s4, exec_lo
	ds_load_b64 v[0:1], v3
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_i32_e64 v0, v1
	s_cbranch_execz .LBB0_8
; %bb.7:
	v_dual_mov_b32 v4, v1 :: v_dual_mov_b32 v5, v0
	v_mov_b32_e32 v0, 0
	s_getpc_b64 s[8:9]
	s_add_u32 s8, s8, D_SORTED@rel32@lo+4
	s_addc_u32 s9, s9, D_SORTED@rel32@hi+12
	ds_store_b64 v3, v[4:5]
	global_store_b8 v0, v0, s[8:9]
.LBB0_8:
	s_or_b32 exec_lo, exec_lo, s4
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_and_b32 exec_lo, exec_lo, s0
	s_cbranch_execz .LBB0_12
; %bb.9:                                ; %.preheader
	s_lshl_b32 s0, s7, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_cmp_ne_u32_e32 vcc_lo, s0, v2
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_12
; %bb.10:                               ; %.lr.ph26
	v_sub_nc_u32_e32 v0, s0, v2
	v_mov_b32_e32 v1, 0
	s_lshl_b32 s0, s6, 1
	s_mov_b32 s4, 0
	s_add_i32 s0, s1, s0
	v_max_u32_e32 v0, 1, v0
	s_mov_b32 s5, 0
.LBB0_11:                               ; =>This Inner Loop Header: Depth=1
	v_mov_b32_e32 v2, s4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e32 v0, -1, v0
	s_ashr_i32 s1, s0, 31
	s_lshl_b64 s[6:7], s[0:1], 2
	ds_load_b32 v2, v2
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_add_u32 s6, s2, s6
	s_addc_u32 s7, s3, s7
	s_add_i32 s4, s4, 4
	s_add_i32 s0, s0, 1
	s_or_b32 s5, vcc_lo, s5
	s_waitcnt lgkmcnt(0)
	global_store_b32 v1, v2, s[6:7]
	s_and_not1_b32 exec_lo, exec_lo, s5
	s_cbranch_execnz .LBB0_11
.LBB0_12:                               ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6kernelPii
		.amdhsa_group_segment_fixed_size 64
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z6kernelPii, .Lfunc_end0-_Z6kernelPii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 520
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 64 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.protected	D_SORTED                ; @D_SORTED
	.type	D_SORTED,@object
	.section	.bss,"aw",@nobits
	.globl	D_SORTED
D_SORTED:
	.byte	0                               ; 0x0
	.size	D_SORTED, 1

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym D_SORTED
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 64
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6kernelPii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z6kernelPii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
