#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#define THREADS 1024
#define BLOCKS 65536
#define NUM_VALS THREADS*BLOCKS
#define ASCENDING 1
#define DESCENDING 0

void rand_nums(int *values, unsigned long length) {
				int i;
				for (i = 0; i < length; ++i) {
								values[i] = rand() % INT_MAX + 1;;
				}
}

void compAndSwap(int *a, int i, int j, int dir)
{
				int temp;
				if (dir==(a[i]>a[j])) {
								temp = a[j];
								a[j] = a[i];
								a[i] = temp;
				}
}

void bitonicMerge(int *a, int low, int cnt, int dir) {
				if (cnt > 1) {
								int k = cnt / 2;
								for (int i = low; i < low + k; i++)
												compAndSwap(a, i, i + k, dir);
								bitonicMerge(a, low, k, dir);
								bitonicMerge(a, low + k, k, dir);
				}
}

void bitonicSort(int *values, int low, unsigned long n, int dir) {
				if(n>1) {
								int k = n/2;

								bitonicSort(values, low, k, ASCENDING);
								bitonicSort(values, low+k, k, DESCENDING);

								bitonicMerge(values, low, n, dir);
				}

}

int main(int argc, char *argv[]) {
				unsigned long n;
				double time_spent;
				clock_t begin, end;

				int k = 10;
				if(argc==2)
								k = atoi(argv[1]);

				n = pow(2,k);

				int *values = (int *) malloc(NUM_VALS * sizeof(int));
				int *origValues = (int *) malloc(NUM_VALS * sizeof(int));

				printf("\nk = %d, n = %ld\n", k, n); 

				rand_nums(values, n);

				for (unsigned long i = 0; i < n; i++)
								origValues[i] = values[i];

				time_spent = 0.0; 
				begin = clock(); 
				bitonicSort(values, 0, n, ASCENDING);
				end = clock();
				time_spent += (double)(end-begin) / CLOCKS_PER_SEC; 
				printf("\tElapsed time: %f seconds\n", time_spent); 

				free(values); 
				free(origValues); 
}





	.file	"tmpxft_0029a3ec_00000000-6_bitonicSerialSorting.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2034:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z9rand_numsPim
	.type	_Z9rand_numsPim, @function
_Z9rand_numsPim:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$2147483647, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 48
.L3:
	cmpq	%rbx, %rbp
	je	.L7
	call	rand@PLT
	cltd
	idivl	%r13d
	incl	%edx
	movl	%edx, (%r12,%rbx,4)
	incq	%rbx
	jmp	.L3
.L7:
	popq	%rax
	.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
.LFE2027:
	.size	_Z9rand_numsPim, .-_Z9rand_numsPim
	.globl	_Z11compAndSwapPiiii
	.type	_Z11compAndSwapPiiii, @function
_Z11compAndSwapPiiii:
.LFB2028:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	movl	%ecx, %r8d
	leaq	(%rdi,%rsi,4), %rax
	leaq	(%rdi,%rdx,4), %rcx
	xorl	%edi, %edi
	movl	(%rax), %esi
	movl	(%rcx), %edx
	cmpl	%edx, %esi
	setg	%dil
	cmpl	%r8d, %edi
	jne	.L8
	movl	%esi, (%rcx)
	movl	%edx, (%rax)
.L8:
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z11compAndSwapPiiii, .-_Z11compAndSwapPiiii
	.globl	_Z12bitonicMergePiiii
	.type	_Z12bitonicMergePiiii, @function
_Z12bitonicMergePiiii:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%esi, %r9d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%ecx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%edx, %ebx
	pushq	%r8
	.cfi_def_cfa_offset 48
.L13:
	cmpl	$1, %ebx
	jle	.L10
	sarl	%ebx
	movl	%r9d, %r10d
	leal	(%rbx,%r9), %r13d
.L12:
	leal	(%r10,%rbx), %edx
	movl	%r10d, %esi
	movl	%r12d, %ecx
	movq	%rbp, %rdi
	call	_Z11compAndSwapPiiii
	incl	%r10d
	cmpl	%r13d, %r10d
	jl	.L12
	movl	%r9d, %esi
	movl	%r12d, %ecx
	movl	%ebx, %edx
	movq	%rbp, %rdi
	call	_Z12bitonicMergePiiii
	movl	%r13d, %r9d
	jmp	.L13
.L10:
	popq	%rax
	.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
.LFE2029:
	.size	_Z12bitonicMergePiiii, .-_Z12bitonicMergePiiii
	.globl	_Z11bitonicSortPiimi
	.type	_Z11bitonicSortPiimi, @function
_Z11bitonicSortPiimi:
.LFB2030:
	.cfi_startproc
	endbr64
	cmpq	$1, %rdx
	jbe	.L16
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%ecx, %r14d
	movl	$1, %ecx
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	shrq	%r13
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movslq	%r13d, %r15
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdx, %rbx
	movq	%r15, %rdx
	pushq	%rax
	.cfi_def_cfa_offset 64
	call	_Z11bitonicSortPiimi
	leal	(%r12,%r13), %esi
	movq	%r15, %rdx
	movq	%rbp, %rdi
	xorl	%ecx, %ecx
	call	_Z11bitonicSortPiimi
	popq	%r8
	.cfi_def_cfa_offset 56
	movl	%r14d, %ecx
	movl	%ebx, %edx
	movl	%r12d, %esi
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 48
	movq	%rbp, %rdi
	popq	%rbp
	.cfi_restore 6
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_restore 12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_restore 13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_restore 14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_restore 15
	.cfi_def_cfa_offset 8
	jmp	_Z12bitonicMergePiiii
.L16:
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z11bitonicSortPiimi, .-_Z11bitonicSortPiimi
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"\nk = %d, n = %ld\n"
.LC5:
	.string	"\tElapsed time: %f seconds\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2031:
	.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
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	$10, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%rcx
	.cfi_def_cfa_offset 48
	cmpl	$2, %edi
	jne	.L22
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movl	%eax, %ebp
.L22:
	cvtsi2sdl	%ebp, %xmm1
	movsd	.LC0(%rip), %xmm0
	call	pow@PLT
	movsd	.LC1(%rip), %xmm1
	comisd	%xmm1, %xmm0
	jnb	.L23
	cvttsd2siq	%xmm0, %r12
	jmp	.L24
.L23:
	subsd	%xmm1, %xmm0
	cvttsd2siq	%xmm0, %r12
	btcq	$63, %r12
.L24:
	movl	$268435456, %edi
	call	malloc@PLT
	movl	$268435456, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	%ebp, %edx
	movq	%r12, %rcx
	movl	$2, %edi
	leaq	.LC2(%rip), %rsi
	movq	%rax, %r13
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	call	__printf_chk@PLT
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	_Z9rand_numsPim
.L25:
	cmpq	%r12, %rbp
	je	.L30
	movl	(%rbx,%rbp,4), %eax
	movl	%eax, 0(%r13,%rbp,4)
	incq	%rbp
	jmp	.L25
.L30:
	call	clock@PLT
	movq	%rbp, %rdx
	movl	$1, %ecx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	movq	%rax, %r12
	call	_Z11bitonicSortPiimi
	call	clock@PLT
	xorps	%xmm1, %xmm1
	movl	$2, %edi
	leaq	.LC5(%rip), %rsi
	subq	%r12, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC3(%rip), %xmm0
	movb	$1, %al
	addsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	popq	%rdx
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
.LFE2031:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2057:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2057:
	.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
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1073741824
	.align 8
.LC1:
	.long	0
	.long	1138753536
	.align 8
.LC3:
	.long	0
	.long	1093567616
	.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 <stdlib.h>
#include <stdio.h>
#include <time.h>

#define THREADS 1024
#define BLOCKS 65536
#define NUM_VALS THREADS*BLOCKS
#define ASCENDING 1
#define DESCENDING 0

void rand_nums(int *values, unsigned long length) {
				int i;
				for (i = 0; i < length; ++i) {
								values[i] = rand() % INT_MAX + 1;;
				}
}

void compAndSwap(int *a, int i, int j, int dir)
{
				int temp;
				if (dir==(a[i]>a[j])) {
								temp = a[j];
								a[j] = a[i];
								a[i] = temp;
				}
}

void bitonicMerge(int *a, int low, int cnt, int dir) {
				if (cnt > 1) {
								int k = cnt / 2;
								for (int i = low; i < low + k; i++)
												compAndSwap(a, i, i + k, dir);
								bitonicMerge(a, low, k, dir);
								bitonicMerge(a, low + k, k, dir);
				}
}

void bitonicSort(int *values, int low, unsigned long n, int dir) {
				if(n>1) {
								int k = n/2;

								bitonicSort(values, low, k, ASCENDING);
								bitonicSort(values, low+k, k, DESCENDING);

								bitonicMerge(values, low, n, dir);
				}

}

int main(int argc, char *argv[]) {
				unsigned long n;
				double time_spent;
				clock_t begin, end;

				int k = 10;
				if(argc==2)
								k = atoi(argv[1]);

				n = pow(2,k);

				int *values = (int *) malloc(NUM_VALS * sizeof(int));
				int *origValues = (int *) malloc(NUM_VALS * sizeof(int));

				printf("\nk = %d, n = %ld\n", k, n); 

				rand_nums(values, n);

				for (unsigned long i = 0; i < n; i++)
								origValues[i] = values[i];

				time_spent = 0.0; 
				begin = clock(); 
				bitonicSort(values, 0, n, ASCENDING);
				end = clock();
				time_spent += (double)(end-begin) / CLOCKS_PER_SEC; 
				printf("\tElapsed time: %f seconds\n", time_spent); 

				free(values); 
				free(origValues); 
}





	.text
	.file	"bitonicSerialSorting.hip"
	.globl	_Z9rand_numsPim                 # -- Begin function _Z9rand_numsPim
	.type	_Z9rand_numsPim,@function
_Z9rand_numsPim:                        # @_Z9rand_numsPim
	.cfi_startproc
# %bb.0:
	testq	%rsi, %rsi
	je	.LBB0_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	xorl	%r15d, %r15d
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	movq	%rax, %rcx
	shlq	$30, %rcx
	addq	%rax, %rcx
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$61, %rcx
	addl	%edx, %ecx
	movl	%ecx, %edx
	shll	$31, %edx
	addl	%ecx, %edx
	addl	%edx, %eax
	incl	%eax
	movl	%eax, (%r14,%r15,4)
	incq	%r15
	cmpq	%r15, %rbx
	jne	.LBB0_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB0_4:                                # %._crit_edge
	retq
.Lfunc_end0:
	.size	_Z9rand_numsPim, .Lfunc_end0-_Z9rand_numsPim
	.cfi_endproc
                                        # -- End function
	.globl	_Z11compAndSwapPiiii            # -- Begin function _Z11compAndSwapPiiii
	.type	_Z11compAndSwapPiiii,@function
_Z11compAndSwapPiiii:                   # @_Z11compAndSwapPiiii
	.cfi_startproc
# %bb.0:
	movslq	%esi, %rax
	movl	(%rdi,%rax,4), %esi
	movslq	%edx, %rdx
	movl	(%rdi,%rdx,4), %r8d
	xorl	%r9d, %r9d
	cmpl	%r8d, %esi
	setg	%r9b
	cmpl	%ecx, %r9d
	jne	.LBB1_2
# %bb.1:
	movl	%esi, (%rdi,%rdx,4)
	movl	%r8d, (%rdi,%rax,4)
.LBB1_2:
	retq
.Lfunc_end1:
	.size	_Z11compAndSwapPiiii, .Lfunc_end1-_Z11compAndSwapPiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z12bitonicMergePiiii           # -- Begin function _Z12bitonicMergePiiii
	.type	_Z12bitonicMergePiiii,@function
_Z12bitonicMergePiiii:                  # @_Z12bitonicMergePiiii
	.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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %ebx
	movl	%edx, %ebp
                                        # kill: def $esi killed $esi def $rsi
	movq	%rdi, %r14
.LBB2_1:                                # %tailrecurse39
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_3 Depth 2
                                        #       Child Loop BB2_6 Depth 3
	cmpl	$2, %ebp
	jl	.LBB2_10
# %bb.2:                                # %.lr.ph29.preheader
                                        #   in Loop: Header=BB2_1 Depth=1
	movl	%ebp, %r15d
.LBB2_3:                                # %.lr.ph29
                                        #   Parent Loop BB2_1 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_6 Depth 3
	shrl	%r15d
	leal	(%r15,%rsi), %r12d
	cmpl	$2, %ebp
	jb	.LBB2_4
# %bb.5:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB2_3 Depth=2
	movslq	%esi, %rax
	movl	%r15d, %edx
	movslq	%r12d, %rcx
	leaq	(%r14,%rdx,4), %rdx
.LBB2_6:                                # %.lr.ph
                                        #   Parent Loop BB2_1 Depth=1
                                        #     Parent Loop BB2_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%r14,%rax,4), %edi
	movl	(%rdx,%rax,4), %r8d
	xorl	%r9d, %r9d
	cmpl	%r8d, %edi
	setg	%r9b
	cmpl	%ebx, %r9d
	jne	.LBB2_8
# %bb.7:                                #   in Loop: Header=BB2_6 Depth=3
	movl	%edi, (%rdx,%rax,4)
	movl	%r8d, (%r14,%rax,4)
.LBB2_8:                                # %_Z11compAndSwapPiiii.exit
                                        #   in Loop: Header=BB2_6 Depth=3
	incq	%rax
	cmpq	%rcx, %rax
	jl	.LBB2_6
# %bb.9:                                # %tailrecurse
                                        #   in Loop: Header=BB2_3 Depth=2
	movq	%r14, %rdi
                                        # kill: def $esi killed $esi killed $rsi
	movl	%r15d, %edx
	movl	%ebx, %ecx
	callq	_Z12bitonicMergePiiii
	movl	%r12d, %esi
	cmpl	$3, %ebp
	movl	%r15d, %ebp
	ja	.LBB2_3
	jmp	.LBB2_10
.LBB2_4:                                #   in Loop: Header=BB2_1 Depth=1
	movl	%r15d, %ebp
	jmp	.LBB2_1
.LBB2_10:                               # %tailrecurse._crit_edge
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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
.Lfunc_end2:
	.size	_Z12bitonicMergePiiii, .Lfunc_end2-_Z12bitonicMergePiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11bitonicSortPiimi            # -- Begin function _Z11bitonicSortPiimi
	.type	_Z11bitonicSortPiimi,@function
_Z11bitonicSortPiimi:                   # @_Z11bitonicSortPiimi
	.cfi_startproc
# %bb.0:
	cmpq	$1, %rdx
	jbe	.LBB3_1
# %bb.2:
	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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%ecx, %ebx
	movq	%rdx, %r14
	movl	%esi, %r15d
	movq	%rdi, %r12
	movq	%rdx, %rax
	shrq	%rax
	movslq	%eax, %r13
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	_Z11bitonicSortPiimi
	leal	(%r15,%r13), %esi
	movq	%r12, %rdi
	movq	%r13, %rdx
	xorl	%ecx, %ecx
	callq	_Z11bitonicSortPiimi
	movq	%r12, %rdi
	movl	%r15d, %esi
	movl	%r14d, %edx
	movl	%ebx, %ecx
	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
	jmp	_Z12bitonicMergePiiii           # TAILCALL
.LBB3_1:                                # %common.ret12
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	retq
.Lfunc_end3:
	.size	_Z11bitonicSortPiimi, .Lfunc_end3-_Z11bitonicSortPiimi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI4_0:
	.quad	0x3ff0000000000000              # double 1
.LCPI4_1:
	.quad	0x43e0000000000000              # double 9.2233720368547758E+18
.LCPI4_2:
	.quad	0x412e848000000000              # double 1.0E+6
	.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
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$10, %ebp
	cmpl	$2, %edi
	jne	.LBB4_2
# %bb.1:
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %ebp
.LBB4_2:
	movsd	.LCPI4_0(%rip), %xmm0           # xmm0 = mem[0],zero
	movl	%ebp, %edi
	callq	ldexp@PLT
	cvttsd2si	%xmm0, %rax
	movq	%rax, %rcx
	sarq	$63, %rcx
	subsd	.LCPI4_1(%rip), %xmm0
	cvttsd2si	%xmm0, %r14
	andq	%rcx, %r14
	orq	%rax, %r14
	movl	$268435456, %edi                # imm = 0x10000000
	callq	malloc
	movq	%rax, %rbx
	movl	$.L.str, %edi
	movl	%ebp, %esi
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	printf
	testq	%r14, %r14
	je	.LBB4_5
# %bb.3:                                # %.lr.ph.i.preheader
	xorl	%r15d, %r15d
.LBB4_4:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	movq	%rax, %rcx
	shlq	$30, %rcx
	addq	%rax, %rcx
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$61, %rcx
	addl	%edx, %ecx
	movl	%ecx, %edx
	shll	$31, %edx
	addl	%ecx, %edx
	addl	%edx, %eax
	incl	%eax
	movl	%eax, (%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB4_4
.LBB4_5:                                # %_Z9rand_numsPim.exit
	callq	clock
	movq	%rax, %r15
	movq	%rbx, %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	_Z11bitonicSortPiimi
	callq	clock
	subq	%r15, %rax
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI4_2(%rip), %xmm1
	xorpd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	movq	%rbx, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$8, %rsp
	.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
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"\nk = %d, n = %ld\n"
	.size	.L.str, 18

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"\tElapsed time: %f seconds\n"
	.size	.L.str.1, 27

	.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 __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.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 __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
