﻿#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <algorithm>

/* Every thread gets exactly one value in the unsorted array. */
#define THREADS 1024 // 2^9
#define BLOCKS 32768 // 2^15
#define NUM_VALS THREADS*BLOCKS

using namespace std;

void print_elapsed(clock_t start, clock_t stop) {
	double elapsed = ((double)(stop - start)) / CLOCKS_PER_SEC;
	printf("Elapsed time: %.3fs\n", elapsed);
}

void array_print(int* arr, int length) {
	int i;
	for (i = 0; i < length; ++i) {
		printf("%1.3f ", arr[i]);
	}
	printf("\n");
}

void array_fill(int* arr, int length) {
	srand(time(NULL));
	int i;
	for (i = 0; i < length; ++i) {
		arr[i] = rand();
	}
}

bool comparison_arrays(int* arr1, int* arr2, int length) {
	for (int i = 0; i < length; i++) {
		if (arr1[i] != arr2[i]) {
			return false;
		}
	}
	return true;
}

int* get_copy_array(int* sourse, int length) {
	int* dest = new int[length];

	for (int i = 0; i < length; i++) {
		dest[i] = sourse[i];
	}
	return dest;
}

int power_ceil(int x) {
	if (x <= 1) return 1;
	int power = 2;
	x--;
	while (x >>= 1) power <<= 1;
	return power;
}

__global__ void bitonic_sort_step(int* dev_values, int j, int k) {
	unsigned int i, ixj;
	i = threadIdx.x + blockDim.x * blockIdx.x;
	ixj = i ^ j;

	if ((ixj) > i) {
		if ((i & k) == 0) {
			/* Sort ascending */
			if (dev_values[i] > dev_values[ixj]) {
				/* exchange(i,ixj); */
				int temp = dev_values[i];
				dev_values[i] = dev_values[ixj];
				dev_values[ixj] = temp;
			}
		}
		if ((i & k) != 0) {
			/* Sort descending */
			if (dev_values[i] < dev_values[ixj]) {
				/* exchange(i,ixj); */
				int temp = dev_values[i];
				dev_values[i] = dev_values[ixj];
				dev_values[ixj] = temp;
			}
		}
	}
}

void bitonic_sort(int* values) {
	int* dev_values;
	size_t size = NUM_VALS * sizeof(int);

	cudaMalloc((void**)&dev_values, size);
	cudaMemcpy(dev_values, values, size, cudaMemcpyHostToDevice);

	dim3 blocks(BLOCKS, 1);
	dim3 threads(THREADS, 1);

	int j, k;
	for (k = 2; k <= NUM_VALS; k <<= 1) {
		for (j = k >> 1; j > 0; j = j >> 1) {
			bitonic_sort_step <<<blocks, threads>>> (dev_values, j, k);
		}
	}
	cudaMemcpy(values, dev_values, size, cudaMemcpyDeviceToHost);
	cudaFree(dev_values);
}

bool is_bitonic(int*v, int length) {
	bool was_decreasing = v[length - 1] > v[0];
	int num_inflections = 0;
	for (int i = 0; i < length && num_inflections <= 2; i++) {
		bool is_decreasing = v[i] > v[(i + 1) % length];
		// Check if this element and next one are an inflection.
		if (was_decreasing != is_decreasing) {
			num_inflections++;
			was_decreasing = is_decreasing;
		}
	}

	return 2 == num_inflections;
}

int main(void)
{
	clock_t start, stop;

	int length = 0;
	cout << "Enter length of the array: ";
	cin >> length;

	int* values = (int*)malloc(NUM_VALS * sizeof(int));
	array_fill(values, NUM_VALS);
	int* temp = get_copy_array(values, NUM_VALS);


	sort(temp, temp + NUM_VALS);


	start = clock();
	bitonic_sort(values);
	stop = clock();

	cout << "is_bitonic: " << is_bitonic(values, NUM_VALS) << endl;;
	cout << "is equals: " << comparison_arrays(values, temp, NUM_VALS) << endl;
	print_elapsed(start, stop);
}

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

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3900:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3900:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.type	_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_.isra.0, @function
_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_.isra.0:
.LFB4595:
	.cfi_startproc
	leaq	-1(%rdx), %rax
	movq	%rsi, %r9
	movl	%ecx, %r8d
	movq	%rdx, %rsi
	movl	$2, %ecx
	cqto
	idivq	%rcx
	movq	%r9, %rcx
.L3:
	cmpq	%rax, %rcx
	jge	.L11
	leaq	1(%rcx), %r10
	movl	-4(%rdi,%r10,8), %r11d
	leaq	(%r10,%r10), %rdx
	cmpl	%r11d, (%rdi,%r10,8)
	jge	.L4
	decq	%rdx
.L4:
	movl	(%rdi,%rdx,4), %r10d
	movl	%r10d, (%rdi,%rcx,4)
	movq	%rdx, %rcx
	jmp	.L3
.L11:
	testl	$1, %esi
	jne	.L6
	leaq	-2(%rsi), %rax
	movl	$2, %esi
	cqto
	idivq	%rsi
	cmpq	%rax, %rcx
	jne	.L6
	leaq	1(%rcx), %rax
	addq	%rax, %rax
	movl	-4(%rdi,%rax,4), %edx
	movl	%edx, (%rdi,%rcx,4)
	leaq	-1(%rax), %rcx
.L6:
	leaq	-1(%rcx), %rax
	movl	$2, %esi
.L9:
	cqto
	idivq	%rsi
	leaq	(%rdi,%rcx,4), %rdx
	cmpq	%rcx, %r9
	jge	.L7
	movl	(%rdi,%rax,4), %ecx
	cmpl	%ecx, %r8d
	jle	.L7
	movl	%ecx, (%rdx)
	leaq	-1(%rax), %rdx
	movq	%rax, %rcx
	movq	%rdx, %rax
	jmp	.L9
.L7:
	movl	%r8d, (%rdx)
	ret
	.cfi_endproc
.LFE4595:
	.size	_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_.isra.0, .-_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_.isra.0
	.type	_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_.isra.0, @function
_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_.isra.0:
.LFB4597:
	.cfi_startproc
	cmpq	%rsi, %rdi
	jne	.L24
	ret
.L24:
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$4, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	4(%rdi), %rbx
.L14:
	cmpq	%rbx, %r12
	je	.L28
	movl	(%rbx), %r13d
	movl	0(%rbp), %eax
	cmpl	%eax, %r13d
	jge	.L22
	movq	%rbx, %rdx
	subq	%rbp, %rdx
	cmpq	$4, %rdx
	jle	.L16
	movq	%r14, %rdi
	movq	%rbp, %rsi
	subq	%rdx, %rdi
	addq	%rbx, %rdi
	call	memmove@PLT
	jmp	.L17
.L16:
	jne	.L17
	movl	%eax, (%rbx)
.L17:
	movl	%r13d, 0(%rbp)
	jmp	.L18
.L22:
	movq	%rbx, %rax
.L15:
	movl	-4(%rax), %edx
	cmpl	%edx, %r13d
	jge	.L29
	movl	%edx, (%rax)
	subq	$4, %rax
	jmp	.L15
.L29:
	movl	%r13d, (%rax)
.L18:
	addq	$4, %rbx
	jmp	.L14
.L28:
	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
.LFE4597:
	.size	_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_.isra.0, .-_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_.isra.0
	.type	_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_.isra.0, @function
_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_.isra.0:
.LFB4601:
	.cfi_startproc
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rdi, %rbx
.L31:
	movq	%rbp, %rax
	subq	%rbx, %rax
	cmpq	$64, %rax
	jle	.L30
	movq	%rax, %r14
	sarq	$2, %r14
	testq	%r13, %r13
	jne	.L32
	leaq	-2(%r14), %r12
	sarq	%r12
.L34:
	movl	(%rbx,%r12,4), %ecx
	movq	%r14, %rdx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_.isra.0
	testq	%r12, %r12
	je	.L33
	decq	%r12
	jmp	.L34
.L33:
	movq	%rbp, %rax
	subq	%rbx, %rax
	cmpq	$4, %rax
	jle	.L30
	movl	(%rbx), %eax
	subq	$4, %rbp
	movl	0(%rbp), %ecx
	xorl	%esi, %esi
	movq	%rbp, %rdx
	movq	%rbx, %rdi
	movl	%eax, 0(%rbp)
	subq	%rbx, %rdx
	sarq	$2, %rdx
	call	_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_.isra.0
	jmp	.L33
.L32:
	sarq	$3, %rax
	movl	4(%rbx), %esi
	movl	-4(%rbp), %edx
	leaq	4(%rbx), %r12
	leaq	(%rbx,%rax,4), %rdi
	movl	(%rbx), %eax
	movl	(%rdi), %ecx
	cmpl	%ecx, %esi
	jge	.L36
	cmpl	%edx, %ecx
	jge	.L37
.L54:
	movl	%ecx, (%rbx)
	movl	%eax, (%rdi)
.L40:
	movq	%rbp, %rax
	jmp	.L38
.L37:
	cmpl	%edx, %esi
	jge	.L55
	jmp	.L53
.L36:
	cmpl	%edx, %esi
	jge	.L41
.L55:
	movl	%esi, (%rbx)
	movl	%eax, 4(%rbx)
	jmp	.L40
.L41:
	cmpl	%edx, %ecx
	jge	.L54
.L53:
	movl	%edx, (%rbx)
	movl	%eax, -4(%rbp)
	jmp	.L40
.L47:
	movl	%ecx, (%r12)
	addq	$4, %r12
	movl	%edx, (%rax)
.L38:
	movl	(%rbx), %esi
.L43:
	movl	(%r12), %edx
	cmpl	%esi, %edx
	jge	.L46
	addq	$4, %r12
	jmp	.L43
.L46:
	movl	-4(%rax), %ecx
	subq	$4, %rax
	cmpl	%ecx, %esi
	jl	.L46
	cmpq	%rax, %r12
	jb	.L47
	decq	%r13
	movq	%rbp, %rsi
	movq	%r12, %rdi
	movq	%r12, %rbp
	movq	%r13, %rdx
	call	_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_.isra.0
	jmp	.L31
.L30:
	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
.LFE4601:
	.size	_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_.isra.0, .-_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_.isra.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"Elapsed time: %.3fs\n"
	.text
	.globl	_Z13print_elapsedll
	.type	_Z13print_elapsedll, @function
_Z13print_elapsedll:
.LFB3889:
	.cfi_startproc
	endbr64
	subq	%rdi, %rsi
	movb	$1, %al
	movl	$2, %edi
	cvtsi2sdq	%rsi, %xmm0
	leaq	.LC1(%rip), %rsi
	divsd	.LC0(%rip), %xmm0
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE3889:
	.size	_Z13print_elapsedll, .-_Z13print_elapsedll
	.section	.rodata.str1.1
.LC2:
	.string	"%1.3f "
.LC3:
	.string	"\n"
	.text
	.globl	_Z11array_printPii
	.type	_Z11array_printPii, @function
_Z11array_printPii:
.LFB3890:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC2(%rip), %r13
	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
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
.L58:
	cmpl	%ebx, %ebp
	jle	.L61
	movl	(%r12,%rbx,4), %edx
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbx
	call	__printf_chk@PLT
	jmp	.L58
.L61:
	popq	%rdx
	.cfi_def_cfa_offset 40
	leaq	.LC3(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE3890:
	.size	_Z11array_printPii, .-_Z11array_printPii
	.globl	_Z10array_fillPii
	.type	_Z10array_fillPii, @function
_Z10array_fillPii:
.LFB3891:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	xorl	%edi, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
.L63:
	cmpl	%ebx, %ebp
	jle	.L66
	call	rand@PLT
	movl	%eax, (%r12,%rbx,4)
	incq	%rbx
	jmp	.L63
.L66:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3891:
	.size	_Z10array_fillPii, .-_Z10array_fillPii
	.globl	_Z17comparison_arraysPiS_i
	.type	_Z17comparison_arraysPiS_i, @function
_Z17comparison_arraysPiS_i:
.LFB3892:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L68:
	cmpl	%eax, %edx
	jle	.L72
	movl	(%rdi,%rax,4), %ecx
	incq	%rax
	cmpl	-4(%rsi,%rax,4), %ecx
	je	.L68
	xorl	%eax, %eax
	ret
.L72:
	movb	$1, %al
	ret
	.cfi_endproc
.LFE3892:
	.size	_Z17comparison_arraysPiS_i, .-_Z17comparison_arraysPiS_i
	.globl	_Z14get_copy_arrayPii
	.type	_Z14get_copy_arrayPii, @function
_Z14get_copy_arrayPii:
.LFB3893:
	.cfi_startproc
	endbr64
	movabsq	$2305843009213693950, %rax
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	movslq	%esi, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rcx
	.cfi_def_cfa_offset 32
	cmpq	%rdi, %rax
	jb	.L74
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	_Znam@PLT
	xorl	%edx, %edx
	jmp	.L75
.L74:
	call	__cxa_throw_bad_array_new_length@PLT
.L75:
	cmpl	%edx, %ebx
	jle	.L78
	movl	0(%rbp,%rdx,4), %ecx
	movl	%ecx, (%rax,%rdx,4)
	incq	%rdx
	jmp	.L75
.L78:
	popq	%rdx
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3893:
	.size	_Z14get_copy_arrayPii, .-_Z14get_copy_arrayPii
	.globl	_Z10power_ceili
	.type	_Z10power_ceili, @function
_Z10power_ceili:
.LFB3894:
	.cfi_startproc
	endbr64
	movl	$1, %eax
	cmpl	$1, %edi
	jle	.L79
	decl	%edi
	movl	$2, %eax
.L81:
	sarl	%edi
	je	.L79
	addl	%eax, %eax
	jmp	.L81
.L79:
	ret
	.cfi_endproc
.LFE3894:
	.size	_Z10power_ceili, .-_Z10power_ceili
	.globl	_Z10is_bitonicPii
	.type	_Z10is_bitonicPii, @function
_Z10is_bitonicPii:
.LFB3896:
	.cfi_startproc
	endbr64
	movslq	%esi, %rax
	movl	(%rdi), %edx
	cmpl	%edx, -4(%rdi,%rax,4)
	setg	%r9b
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
.L85:
	cmpl	%ecx, %esi
	jle	.L89
	cmpl	$2, %r8d
	jg	.L89
	leal	1(%rcx), %eax
	cltd
	idivl	%esi
	movslq	%edx, %rdx
	movl	(%rdi,%rdx,4), %eax
	cmpl	%eax, (%rdi,%rcx,4)
	setg	%al
	cmpb	%al, %r9b
	je	.L86
	incl	%r8d
.L86:
	incq	%rcx
	movl	%eax, %r9d
	jmp	.L85
.L89:
	cmpl	$2, %r8d
	sete	%al
	ret
	.cfi_endproc
.LFE3896:
	.size	_Z10is_bitonicPii, .-_Z10is_bitonicPii
	.globl	_Z39__device_stub__Z17bitonic_sort_stepPiiiPiii
	.type	_Z39__device_stub__Z17bitonic_sort_stepPiiiPiii, @function
_Z39__device_stub__Z17bitonic_sort_stepPiiiPiii:
.LFB3922:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movl	%esi, 4(%rsp)
	leaq	44(%rsp), %rsi
	movl	%edx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L93
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z17bitonic_sort_stepPiii(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L93:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L95
	call	__stack_chk_fail@PLT
.L95:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3922:
	.size	_Z39__device_stub__Z17bitonic_sort_stepPiiiPiii, .-_Z39__device_stub__Z17bitonic_sort_stepPiiiPiii
	.globl	_Z17bitonic_sort_stepPiii
	.type	_Z17bitonic_sort_stepPiii, @function
_Z17bitonic_sort_stepPiii:
.LFB3923:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z17bitonic_sort_stepPiiiPiii
	.cfi_endproc
.LFE3923:
	.size	_Z17bitonic_sort_stepPiii, .-_Z17bitonic_sort_stepPiii
	.globl	_Z12bitonic_sortPi
	.type	_Z12bitonic_sortPi, @function
_Z12bitonic_sortPi:
.LFB3895:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$134217728, %esi
	movl	$25, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	$2, %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
	leaq	8(%rsp), %rdi
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$134217728, %edx
	call	cudaMemcpy@PLT
	movl	$131073, %eax
	movl	$1, 24(%rsp)
	salq	$15, %rax
	movl	$1, 36(%rsp)
	movq	%rax, 16(%rsp)
	subq	$31744, %rax
	movq	%rax, 28(%rsp)
.L102:
	movl	%ebp, %r12d
.L100:
	sarl	%r12d
	testl	%r12d, %r12d
	jle	.L106
	movl	36(%rsp), %ecx
	movq	28(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	16(%rsp), %rdi
	movl	24(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L100
	movq	8(%rsp), %rdi
	movl	%ebp, %edx
	movl	%r12d, %esi
	call	_Z39__device_stub__Z17bitonic_sort_stepPiiiPiii
	jmp	.L100
.L106:
	addl	%ebp, %ebp
	decl	%r13d
	jne	.L102
	movq	8(%rsp), %rsi
	movq	%rbx, %rdi
	movl	$2, %ecx
	movl	$134217728, %edx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L103
	call	__stack_chk_fail@PLT
.L103:
	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
.LFE3895:
	.size	_Z12bitonic_sortPi, .-_Z12bitonic_sortPi
	.section	.rodata.str1.1
.LC4:
	.string	"Enter length of the array: "
.LC5:
	.string	"is_bitonic: "
.LC6:
	.string	"is equals: "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3897:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%edi, %edi
	leaq	.LC4(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	_ZSt4cout(%rip), %r13
	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
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movl	%edi, 4(%rsp)
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	4(%rsp), %rsi
	leaq	_ZSt3cin(%rip), %rdi
	call	_ZNSirsERi@PLT
	movl	$134217728, %edi
	call	malloc@PLT
	movl	$33554432, %esi
	movq	%rax, %rbx
	movq	%rax, %rdi
	call	_Z10array_fillPii
	movl	$33554432, %esi
	movq	%rbx, %rdi
	call	_Z14get_copy_arrayPii
	movl	$50, %edx
	movq	%rax, %rbp
	leaq	134217728(%rax), %r14
	movq	%rax, %rdi
	movq	%r14, %rsi
	leaq	64(%rbp), %r12
	call	_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_.isra.0
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_.isra.0
.L108:
	cmpq	%r12, %r14
	je	.L114
	movl	(%r12), %edx
	movq	%r12, %rax
.L109:
	movl	-4(%rax), %ecx
	cmpl	%ecx, %edx
	jge	.L115
	movl	%ecx, (%rax)
	subq	$4, %rax
	jmp	.L109
.L115:
	movl	%edx, (%rax)
	addq	$4, %r12
	jmp	.L108
.L114:
	call	clock@PLT
	movq	%rbx, %rdi
	movq	%rax, %r12
	call	_Z12bitonic_sortPi
	call	clock@PLT
	leaq	.LC5(%rip), %rsi
	movq	%r13, %rdi
	movq	%rax, %r14
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$33554432, %esi
	movq	%rbx, %rdi
	movq	%rax, %r10
	call	_Z10is_bitonicPii
	movq	%r10, %rdi
	movzbl	%al, %esi
	call	_ZNSo9_M_insertIbEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	leaq	.LC6(%rip), %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$33554432, %edx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	movq	%rax, %r8
	call	_Z17comparison_arraysPiS_i
	movq	%r8, %rdi
	movzbl	%al, %esi
	call	_ZNSo9_M_insertIbEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movq	%r14, %rsi
	movq	%r12, %rdi
	call	_Z13print_elapsedll
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L112
	call	__stack_chk_fail@PLT
.L112:
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
.LFE3897:
	.size	main, .-main
	.section	.rodata.str1.1
.LC7:
	.string	"_Z17bitonic_sort_stepPiii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3925:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 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	.LC7(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z17bitonic_sort_stepPiii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3925:
	.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	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>
#include <iostream>
#include <algorithm>

/* Every thread gets exactly one value in the unsorted array. */
#define THREADS 1024 // 2^9
#define BLOCKS 32768 // 2^15
#define NUM_VALS THREADS*BLOCKS

using namespace std;

void print_elapsed(clock_t start, clock_t stop) {
	double elapsed = ((double)(stop - start)) / CLOCKS_PER_SEC;
	printf("Elapsed time: %.3fs\n", elapsed);
}

void array_print(int* arr, int length) {
	int i;
	for (i = 0; i < length; ++i) {
		printf("%1.3f ", arr[i]);
	}
	printf("\n");
}

void array_fill(int* arr, int length) {
	srand(time(NULL));
	int i;
	for (i = 0; i < length; ++i) {
		arr[i] = rand();
	}
}

bool comparison_arrays(int* arr1, int* arr2, int length) {
	for (int i = 0; i < length; i++) {
		if (arr1[i] != arr2[i]) {
			return false;
		}
	}
	return true;
}

int* get_copy_array(int* sourse, int length) {
	int* dest = new int[length];

	for (int i = 0; i < length; i++) {
		dest[i] = sourse[i];
	}
	return dest;
}

int power_ceil(int x) {
	if (x <= 1) return 1;
	int power = 2;
	x--;
	while (x >>= 1) power <<= 1;
	return power;
}

__global__ void bitonic_sort_step(int* dev_values, int j, int k) {
	unsigned int i, ixj;
	i = threadIdx.x + blockDim.x * blockIdx.x;
	ixj = i ^ j;

	if ((ixj) > i) {
		if ((i & k) == 0) {
			/* Sort ascending */
			if (dev_values[i] > dev_values[ixj]) {
				/* exchange(i,ixj); */
				int temp = dev_values[i];
				dev_values[i] = dev_values[ixj];
				dev_values[ixj] = temp;
			}
		}
		if ((i & k) != 0) {
			/* Sort descending */
			if (dev_values[i] < dev_values[ixj]) {
				/* exchange(i,ixj); */
				int temp = dev_values[i];
				dev_values[i] = dev_values[ixj];
				dev_values[ixj] = temp;
			}
		}
	}
}

void bitonic_sort(int* values) {
	int* dev_values;
	size_t size = NUM_VALS * sizeof(int);

	hipMalloc((void**)&dev_values, size);
	hipMemcpy(dev_values, values, size, hipMemcpyHostToDevice);

	dim3 blocks(BLOCKS, 1);
	dim3 threads(THREADS, 1);

	int j, k;
	for (k = 2; k <= NUM_VALS; k <<= 1) {
		for (j = k >> 1; j > 0; j = j >> 1) {
			bitonic_sort_step <<<blocks, threads>>> (dev_values, j, k);
		}
	}
	hipMemcpy(values, dev_values, size, hipMemcpyDeviceToHost);
	hipFree(dev_values);
}

bool is_bitonic(int*v, int length) {
	bool was_decreasing = v[length - 1] > v[0];
	int num_inflections = 0;
	for (int i = 0; i < length && num_inflections <= 2; i++) {
		bool is_decreasing = v[i] > v[(i + 1) % length];
		// Check if this element and next one are an inflection.
		if (was_decreasing != is_decreasing) {
			num_inflections++;
			was_decreasing = is_decreasing;
		}
	}

	return 2 == num_inflections;
}

int main(void)
{
	clock_t start, stop;

	int length = 0;
	cout << "Enter length of the array: ";
	cin >> length;

	int* values = (int*)malloc(NUM_VALS * sizeof(int));
	array_fill(values, NUM_VALS);
	int* temp = get_copy_array(values, NUM_VALS);


	sort(temp, temp + NUM_VALS);


	start = clock();
	bitonic_sort(values);
	stop = clock();

	cout << "is_bitonic: " << is_bitonic(values, NUM_VALS) << endl;;
	cout << "is equals: " << comparison_arrays(values, temp, NUM_VALS) << endl;
	print_elapsed(start, stop);
}

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

                                        # End of file scope inline assembly
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z13print_elapsedll
.LCPI0_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z13print_elapsedll
	.type	_Z13print_elapsedll,@function
_Z13print_elapsedll:                    # @_Z13print_elapsedll
	.cfi_startproc
# %bb.0:
	subq	%rdi, %rsi
	cvtsi2sd	%rsi, %xmm0
	divsd	.LCPI0_0(%rip), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	jmp	printf                          # TAILCALL
.Lfunc_end0:
	.size	_Z13print_elapsedll, .Lfunc_end0-_Z13print_elapsedll
	.cfi_endproc
                                        # -- End function
	.globl	_Z11array_printPii              # -- Begin function _Z11array_printPii
	.type	_Z11array_printPii,@function
_Z11array_printPii:                     # @_Z11array_printPii
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB1_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	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx,%r15,4), %esi
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB1_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
.LBB1_4:                                # %._crit_edge
	movl	$10, %edi
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end1:
	.size	_Z11array_printPii, .Lfunc_end1-_Z11array_printPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10array_fillPii               # -- Begin function _Z10array_fillPii
	.type	_Z10array_fillPii,@function
_Z10array_fillPii:                      # @_Z10array_fillPii
	.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	%esi, %ebp
	movq	%rdi, %rbx
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	testl	%ebp, %ebp
	jle	.LBB2_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	movl	%eax, (%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB2_2
.LBB2_3:                                # %._crit_edge
	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_end2:
	.size	_Z10array_fillPii, .Lfunc_end2-_Z10array_fillPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z17comparison_arraysPiS_i      # -- Begin function _Z17comparison_arraysPiS_i
	.type	_Z17comparison_arraysPiS_i,@function
_Z17comparison_arraysPiS_i:             # @_Z17comparison_arraysPiS_i
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB3_6
# %bb.1:                                # %.lr.ph.preheader
	movl	(%rdi), %eax
	cmpl	(%rsi), %eax
	jne	.LBB3_8
# %bb.2:                                # %.lr.ph15.preheader
	movl	%edx, %eax
	movl	$1, %edx
.LBB3_3:                                # %.lr.ph15
                                        # =>This Inner Loop Header: Depth=1
	movq	%rdx, %rcx
	cmpq	%rdx, %rax
	je	.LBB3_5
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB3_3 Depth=1
	movl	(%rdi,%rcx,4), %r8d
	leaq	1(%rcx), %rdx
	cmpl	(%rsi,%rcx,4), %r8d
	je	.LBB3_3
.LBB3_5:                                # %._crit_edge.loopexit
	cmpq	%rax, %rcx
	setae	%al
                                        # kill: def $al killed $al killed $eax
	retq
.LBB3_6:
	movb	$1, %al
                                        # kill: def $al killed $al killed $eax
	retq
.LBB3_8:
	xorl	%eax, %eax
                                        # kill: def $al killed $al killed $eax
	retq
.Lfunc_end3:
	.size	_Z17comparison_arraysPiS_i, .Lfunc_end3-_Z17comparison_arraysPiS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z14get_copy_arrayPii           # -- Begin function _Z14get_copy_arrayPii
	.type	_Z14get_copy_arrayPii,@function
_Z14get_copy_arrayPii:                  # @_Z14get_copy_arrayPii
	.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	%esi, %ebp
	movq	%rdi, %r14
	movl	%esi, %ebx
	shlq	$2, %rbx
	testl	%esi, %esi
	movq	$-1, %rdi
	cmovnsq	%rbx, %rdi
	callq	_Znam
	movq	%rax, %r15
	testl	%ebp, %ebp
	jle	.LBB4_2
# %bb.1:                                # %.lr.ph.preheader
	movq	%r15, %rdi
	movq	%r14, %rsi
	movq	%rbx, %rdx
	callq	memcpy@PLT
.LBB4_2:                                # %._crit_edge
	movq	%r15, %rax
	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	_Z14get_copy_arrayPii, .Lfunc_end4-_Z14get_copy_arrayPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z10power_ceili                 # -- Begin function _Z10power_ceili
	.type	_Z10power_ceili,@function
_Z10power_ceili:                        # @_Z10power_ceili
	.cfi_startproc
# %bb.0:
	movl	$1, %eax
	cmpl	$2, %edi
	jl	.LBB5_4
# %bb.1:
	movl	$2, %eax
	je	.LBB5_4
# %bb.2:                                # %.lr.ph.preheader
	decl	%edi
	movl	%edi, %ecx
.LBB5_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	shrl	%ecx
	addl	%eax, %eax
	cmpl	$3, %edi
	movl	%ecx, %edi
	ja	.LBB5_3
.LBB5_4:                                # %.loopexit
	retq
.Lfunc_end5:
	.size	_Z10power_ceili, .Lfunc_end5-_Z10power_ceili
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__bitonic_sort_stepPiii # -- Begin function _Z32__device_stub__bitonic_sort_stepPiii
	.type	_Z32__device_stub__bitonic_sort_stepPiii,@function
_Z32__device_stub__bitonic_sort_stepPiii: # @_Z32__device_stub__bitonic_sort_stepPiii
	.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	$96, %rsp
	.cfi_def_cfa_offset 144
	.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)
	movq	%rsp, %rsi
	movl	%edx, (%rsi)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%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	$_Z17bitonic_sort_stepPiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	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_end6:
	.size	_Z32__device_stub__bitonic_sort_stepPiii, .Lfunc_end6-_Z32__device_stub__bitonic_sort_stepPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z12bitonic_sortPi              # -- Begin function _Z12bitonic_sortPi
	.type	_Z12bitonic_sortPi,@function
_Z12bitonic_sortPi:                     # @_Z12bitonic_sortPi
	.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
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, %rbx
	movabsq	$4294968320, %r14               # imm = 0x100000400
	leaq	8(%rsp), %r15
	movl	$134217728, %esi                # imm = 0x8000000
	movq	%r15, %rdi
	callq	hipMalloc
	movq	(%r15), %rdi
	movl	$134217728, %edx                # imm = 0x8000000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$2, %ebp
	leaq	31744(%r14), %r15
.LBB7_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_2 Depth 2
	movl	%ebp, %r12d
	sarl	%r12d
	testl	%r12d, %r12d
	jle	.LBB7_5
.LBB7_2:                                # %.lr.ph
                                        #   Parent Loop BB7_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_4
# %bb.3:                                #   in Loop: Header=BB7_2 Depth=2
	movq	8(%rsp), %rdi
	movl	%r12d, %esi
	movl	%ebp, %edx
	callq	_Z32__device_stub__bitonic_sort_stepPiii
.LBB7_4:                                #   in Loop: Header=BB7_2 Depth=2
	movl	%r12d, %eax
	shrl	%eax
	cmpl	$1, %r12d
	movl	%eax, %r12d
	ja	.LBB7_2
.LBB7_5:                                # %._crit_edge
                                        #   in Loop: Header=BB7_1 Depth=1
	addl	%ebp, %ebp
	cmpl	$33554433, %ebp                 # imm = 0x2000001
	jl	.LBB7_1
# %bb.6:
	movq	8(%rsp), %rsi
	movl	$134217728, %edx                # imm = 0x8000000
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rdi
	callq	hipFree
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	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_end7:
	.size	_Z12bitonic_sortPi, .Lfunc_end7-_Z12bitonic_sortPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z10is_bitonicPii               # -- Begin function _Z10is_bitonicPii
	.type	_Z10is_bitonicPii,@function
_Z10is_bitonicPii:                      # @_Z10is_bitonicPii
	.cfi_startproc
# %bb.0:
	xorl	%ecx, %ecx
	testl	%esi, %esi
	jle	.LBB8_8
# %bb.1:                                # %.lr.ph.preheader
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movslq	%esi, %r9
	movl	-4(%rdi,%r9,4), %eax
	cmpl	(%rdi), %eax
	setg	%r10b
	movl	$1, %r8d
.LBB8_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	-4(%rdi,%r8,4), %ebx
	movl	%r8d, %eax
	xorl	%edx, %edx
	divl	%esi
                                        # kill: def $edx killed $edx def $rdx
	xorl	%r11d, %r11d
	cmpl	(%rdi,%rdx,4), %ebx
	setg	%dl
	testb	$1, %r10b
	sete	%al
	xorb	%dl, %al
	jne	.LBB8_3
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB8_2 Depth=1
	movb	%dl, %r11b
	movl	%r11d, %r10d
	jmp	.LBB8_5
.LBB8_3:                                #   in Loop: Header=BB8_2 Depth=1
	movzbl	%r10b, %r10d
.LBB8_5:                                # %.lr.ph
                                        #   in Loop: Header=BB8_2 Depth=1
	xorb	$1, %al
	movzbl	%al, %eax
	addl	%eax, %ecx
	cmpq	%r9, %r8
	jge	.LBB8_7
# %bb.6:                                # %.lr.ph
                                        #   in Loop: Header=BB8_2 Depth=1
	incq	%r8
	cmpl	$3, %ecx
	jb	.LBB8_2
.LBB8_7:                                # %._crit_edge.loopexit
	cmpl	$2, %ecx
	sete	%cl
	popq	%rbx
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
.LBB8_8:                                # %._crit_edge
	movl	%ecx, %eax
	retq
.Lfunc_end8:
	.size	_Z10is_bitonicPii, .Lfunc_end8-_Z10is_bitonicPii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI9_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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
	leaq	12(%rsp), %rbx
	movl	$0, (%rbx)
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$27, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt3cin, %edi
	movq	%rbx, %rsi
	callq	_ZNSirsERi
	movl	$134217728, %edi                # imm = 0x8000000
	callq	malloc
	movq	%rax, %r14
	movq	%rax, %rdi
	movl	$33554432, %esi                 # imm = 0x2000000
	callq	_Z10array_fillPii
	movl	$134217728, %edi                # imm = 0x8000000
	callq	_Znam
	movq	%rax, %r12
	movl	$134217728, %edx                # imm = 0x8000000
	movq	%rax, %rdi
	movq	%r14, %rsi
	callq	memcpy@PLT
	leaq	134217728(%r12), %rbx
	movl	$50, %edx
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	_ZSt22__final_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_
	callq	clock
	movq	%rax, %rbx
	movq	%r14, %rdi
	callq	_Z12bitonic_sortPi
	callq	clock
	movq	%rax, %r15
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%r14, %rdi
	movl	$33554432, %esi                 # imm = 0x2000000
	callq	_Z10is_bitonicPii
	movzbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIbEERSoT_
	movq	%rax, %r13
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r13, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	(%r14), %eax
	cmpl	(%r12), %eax
	jne	.LBB9_1
# %bb.2:                                # %.lr.ph.preheader
	xorl	%ecx, %ecx
.LBB9_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%rcx, %rax
	cmpq	$33554431, %rcx                 # imm = 0x1FFFFFF
	je	.LBB9_5
# %bb.4:                                # %.lr.ph.i
                                        #   in Loop: Header=BB9_3 Depth=1
	movl	4(%r14,%rax,4), %edx
	leaq	1(%rax), %rcx
	cmpl	4(%r12,%rax,4), %edx
	je	.LBB9_3
.LBB9_5:                                # %_Z17comparison_arraysPiS_i.exit.loopexit
	cmpq	$33554431, %rax                 # imm = 0x1FFFFFF
	setae	%al
	jmp	.LBB9_6
.LBB9_1:
	xorl	%eax, %eax
.LBB9_6:                                # %_Z17comparison_arraysPiS_i.exit
	movzbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIbEERSoT_
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	subq	%rbx, %r15
	cvtsi2sd	%r15, %xmm0
	divsd	.LCPI9_0(%rip), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	xorl	%eax, %eax
	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_end9:
	.size	main, .Lfunc_end9-main
	.cfi_endproc
                                        # -- End function
	.section	.text._ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_,"axG",@progbits,_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_,comdat
	.weak	_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_ # -- Begin function _ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_
	.type	_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_,@function
_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_: # @_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_
	.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	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r14
	subq	%rdi, %r14
	cmpq	$65, %r14
	jl	.LBB10_12
# %bb.1:                                # %.lr.ph
	movq	%rdx, %r15
	movq	%rsi, %r12
	movq	%rdi, %rbx
	leaq	4(%rdi), %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movq	$-4, %rbp
	subq	%rdi, %rbp
.LBB10_2:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_5 Depth 2
                                        #       Child Loop BB10_6 Depth 3
                                        #       Child Loop BB10_8 Depth 3
	subq	$1, %r15
	jb	.LBB10_3
# %bb.4:                                #   in Loop: Header=BB10_2 Depth=1
	shrq	$3, %r14
	leaq	(%rbx,%r14,4), %rdx
	leaq	-4(%r12), %rcx
	movq	%rbx, %rdi
	movq	16(%rsp), %r14                  # 8-byte Reload
	movq	%r14, %rsi
	callq	_ZSt22__move_median_to_firstIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_S4_S4_T0_
	movq	%r12, %rax
	movq	%r14, %rcx
.LBB10_5:                               #   Parent Loop BB10_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB10_6 Depth 3
                                        #       Child Loop BB10_8 Depth 3
	movl	(%rbx), %edx
	leaq	(%rcx,%rbp), %r14
.LBB10_6:                               #   Parent Loop BB10_2 Depth=1
                                        #     Parent Loop BB10_5 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	(%rcx), %esi
	addq	$4, %rcx
	addq	$4, %r14
	cmpl	%edx, %esi
	jl	.LBB10_6
# %bb.7:                                # %.preheader.i.i.preheader
                                        #   in Loop: Header=BB10_5 Depth=2
	leaq	-4(%rcx), %r13
.LBB10_8:                               # %.preheader.i.i
                                        #   Parent Loop BB10_2 Depth=1
                                        #     Parent Loop BB10_5 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movl	-4(%rax), %edi
	addq	$-4, %rax
	cmpl	%edi, %edx
	jl	.LBB10_8
# %bb.9:                                #   in Loop: Header=BB10_5 Depth=2
	cmpq	%rax, %r13
	jae	.LBB10_11
# %bb.10:                               #   in Loop: Header=BB10_5 Depth=2
	movl	%edi, (%r13)
	movl	%esi, (%rax)
	jmp	.LBB10_5
.LBB10_11:                              # %_ZSt27__unguarded_partition_pivotIPiN9__gnu_cxx5__ops15_Iter_less_iterEET_S4_S4_T0_.exit
                                        #   in Loop: Header=BB10_2 Depth=1
	movq	%r13, %rdi
	movq	%r12, %rsi
	movq	%r15, %rdx
	callq	_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_
	movq	%r13, %r12
	cmpq	$64, %r14
	jg	.LBB10_2
	jmp	.LBB10_12
.LBB10_3:
	leaq	15(%rsp), %rdx
	movq	%rbx, %rdi
	movq	%r12, %rsi
	callq	_ZSt11__make_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_
	leaq	14(%rsp), %rdx
	movq	%rbx, %rdi
	movq	%r12, %rsi
	callq	_ZSt11__sort_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_
.LBB10_12:                              # %.loopexit
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.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_end10:
	.size	_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_, .Lfunc_end10-_ZSt16__introsort_loopIPilN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_T1_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZSt22__final_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_,"axG",@progbits,_ZSt22__final_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_,comdat
	.weak	_ZSt22__final_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_ # -- Begin function _ZSt22__final_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_
	.type	_ZSt22__final_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_,@function
_ZSt22__final_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_: # @_ZSt22__final_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_
	.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	%rsi, %rbx
	movq	%rsi, %rax
	subq	%rdi, %rax
	cmpq	$65, %rax
	jl	.LBB11_8
# %bb.1:
	leaq	64(%rdi), %r14
	movq	%r14, %rsi
	callq	_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_
.LBB11_2:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB11_5 Depth 2
	cmpq	%rbx, %r14
	je	.LBB11_7
# %bb.3:                                # %.lr.ph.i
                                        #   in Loop: Header=BB11_2 Depth=1
	movl	-4(%r14), %ecx
	movl	(%r14), %eax
	movq	%r14, %rdx
	cmpl	%ecx, %eax
	jge	.LBB11_6
# %bb.4:                                # %.lr.ph.i.i.preheader
                                        #   in Loop: Header=BB11_2 Depth=1
	movq	%r14, %rdx
.LBB11_5:                               # %.lr.ph.i.i
                                        #   Parent Loop BB11_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ecx, (%rdx)
	movl	-8(%rdx), %ecx
	addq	$-4, %rdx
	cmpl	%ecx, %eax
	jl	.LBB11_5
.LBB11_6:                               # %_ZSt25__unguarded_linear_insertIPiN9__gnu_cxx5__ops14_Val_less_iterEEvT_T0_.exit.i
                                        #   in Loop: Header=BB11_2 Depth=1
	movl	%eax, (%rdx)
	addq	$4, %r14
	jmp	.LBB11_2
.LBB11_8:
	movq	%rbx, %rsi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_ # TAILCALL
.LBB11_7:                               # %_ZSt26__unguarded_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_.exit
	.cfi_def_cfa_offset 32
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end11:
	.size	_ZSt22__final_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_, .Lfunc_end11-_ZSt22__final_insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZSt11__sort_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_,"axG",@progbits,_ZSt11__sort_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_,comdat
	.weak	_ZSt11__sort_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_ # -- Begin function _ZSt11__sort_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_
	.type	_ZSt11__sort_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_,@function
_ZSt11__sort_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_: # @_ZSt11__sort_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_
	.cfi_startproc
# %bb.0:
	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, %r15
	subq	%rdi, %r15
	cmpq	$5, %r15
	jl	.LBB12_3
# %bb.1:                                # %.lr.ph.preheader
	movq	%rsi, %rbx
	movq	%rdi, %r14
	addq	$-4, %rbx
.LBB12_2:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	(%rbx), %ecx
	movl	(%r14), %eax
	movl	%eax, (%rbx)
	addq	$-4, %r15
	movq	%r15, %rdx
	sarq	$2, %rdx
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_
	addq	$-4, %rbx
	cmpq	$4, %r15
	jg	.LBB12_2
.LBB12_3:                               # %._crit_edge
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end12:
	.size	_ZSt11__sort_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_, .Lfunc_end12-_ZSt11__sort_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZSt11__make_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_,"axG",@progbits,_ZSt11__make_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_,comdat
	.weak	_ZSt11__make_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_ # -- Begin function _ZSt11__make_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_
	.type	_ZSt11__make_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_,@function
_ZSt11__make_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_: # @_ZSt11__make_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_
	.cfi_startproc
# %bb.0:
	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
	subq	%rdi, %rbx
	sarq	$2, %rbx
	cmpq	$2, %rbx
	jl	.LBB13_3
# %bb.1:
	movq	%rdi, %r14
	leaq	-2(%rbx), %r15
	shrq	%r15
.LBB13_2:                               # =>This Inner Loop Header: Depth=1
	movl	(%r14,%r15,4), %ecx
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%rbx, %rdx
	callq	_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_
	addq	$-1, %r15
	jb	.LBB13_2
.LBB13_3:                               # %.loopexit
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end13:
	.size	_ZSt11__make_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_, .Lfunc_end13-_ZSt11__make_heapIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_RT0_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_,"axG",@progbits,_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_,comdat
	.weak	_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_ # -- Begin function _ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_
	.type	_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_,@function
_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_: # @_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_
	.cfi_startproc
# %bb.0:
	leaq	-1(%rdx), %rax
	shrq	$63, %rax
	leaq	(%rdx,%rax), %r8
	decq	%r8
	sarq	%r8
	movq	%rsi, %rax
	cmpq	%rsi, %r8
	jle	.LBB14_6
# %bb.1:                                # %.lr.ph.preheader
	movq	%rsi, %r9
.LBB14_2:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	leaq	(%r9,%r9), %rax
	movl	8(%rdi,%rax,4), %r10d
	cmpl	4(%rdi,%rax,4), %r10d
	jl	.LBB14_3
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB14_2 Depth=1
	leaq	2(,%r9,2), %rax
	jmp	.LBB14_5
.LBB14_3:                               #   in Loop: Header=BB14_2 Depth=1
	leaq	1(,%r9,2), %rax
.LBB14_5:                               # %.lr.ph
                                        #   in Loop: Header=BB14_2 Depth=1
	movl	(%rdi,%rax,4), %r10d
	movl	%r10d, (%rdi,%r9,4)
	movq	%rax, %r9
	cmpq	%r8, %rax
	jl	.LBB14_2
.LBB14_6:                               # %._crit_edge
	testb	$1, %dl
	jne	.LBB14_9
# %bb.7:
	addq	$-2, %rdx
	sarq	%rdx
	cmpq	%rdx, %rax
	jne	.LBB14_9
# %bb.8:
	leaq	(%rax,%rax), %rdx
	movl	4(%rdi,%rdx,4), %edx
	movl	%edx, (%rdi,%rax,4)
	leaq	1(,%rax,2), %rax
.LBB14_9:
	cmpq	%rsi, %rax
	jle	.LBB14_10
.LBB14_11:                              # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	leaq	-1(%rax), %rdx
	shrq	$63, %rdx
	addq	%rax, %rdx
	decq	%rdx
	sarq	%rdx
	movl	(%rdi,%rdx,4), %r8d
	cmpl	%ecx, %r8d
	jge	.LBB14_10
# %bb.12:                               #   in Loop: Header=BB14_11 Depth=1
	movl	%r8d, (%rdi,%rax,4)
	movq	%rdx, %rax
	cmpq	%rsi, %rdx
	jg	.LBB14_11
	jmp	.LBB14_13
.LBB14_10:
	movq	%rax, %rdx
.LBB14_13:                              # %_ZSt11__push_heapIPiliN9__gnu_cxx5__ops14_Iter_less_valEEvT_T0_S5_T1_RT2_.exit
	movl	%ecx, (%rdi,%rdx,4)
	retq
.Lfunc_end14:
	.size	_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_, .Lfunc_end14-_ZSt13__adjust_heapIPiliN9__gnu_cxx5__ops15_Iter_less_iterEEvT_T0_S5_T1_T2_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZSt22__move_median_to_firstIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_S4_S4_T0_,"axG",@progbits,_ZSt22__move_median_to_firstIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_S4_S4_T0_,comdat
	.weak	_ZSt22__move_median_to_firstIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_S4_S4_T0_ # -- Begin function _ZSt22__move_median_to_firstIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_S4_S4_T0_
	.type	_ZSt22__move_median_to_firstIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_S4_S4_T0_,@function
_ZSt22__move_median_to_firstIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_S4_S4_T0_: # @_ZSt22__move_median_to_firstIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_S4_S4_T0_
	.cfi_startproc
# %bb.0:
	movl	(%rsi), %r8d
	movl	(%rdx), %r9d
	movl	(%rcx), %eax
	cmpl	%r9d, %r8d
	jge	.LBB15_6
# %bb.1:
	cmpl	%eax, %r9d
	jge	.LBB15_3
# %bb.2:
	movl	(%rdi), %eax
	movl	%r9d, (%rdi)
	movl	%eax, (%rdx)
	retq
.LBB15_6:
	cmpl	%eax, %r8d
	jge	.LBB15_8
# %bb.7:
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	%eax, (%rsi)
	retq
.LBB15_3:
	movl	(%rdi), %edx
	cmpl	%eax, %r8d
	jge	.LBB15_5
# %bb.4:
	movl	%eax, (%rdi)
	movl	%edx, (%rcx)
	retq
.LBB15_8:
	movl	(%rdi), %esi
	cmpl	%eax, %r9d
	jge	.LBB15_10
# %bb.9:
	movl	%eax, (%rdi)
	movl	%esi, (%rcx)
	retq
.LBB15_5:
	movl	%r8d, (%rdi)
	movl	%edx, (%rsi)
	retq
.LBB15_10:
	movl	%r9d, (%rdi)
	movl	%esi, (%rdx)
	retq
.Lfunc_end15:
	.size	_ZSt22__move_median_to_firstIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_S4_S4_T0_, .Lfunc_end15-_ZSt22__move_median_to_firstIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_S4_S4_T0_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_,"axG",@progbits,_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_,comdat
	.weak	_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_ # -- Begin function _ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_
	.type	_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_,@function
_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_: # @_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_
	.cfi_startproc
# %bb.0:
	cmpq	%rsi, %rdi
	je	.LBB16_14
# %bb.1:                                # %.preheader
	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
	movq	%rsi, %rbx
	movq	%rdi, %r14
	leaq	4(%rdi), %rax
	cmpq	%rsi, %rax
	je	.LBB16_13
# %bb.2:                                # %.lr.ph
	movq	%r14, %r15
.LBB16_3:                               # =>This Loop Header: Depth=1
                                        #     Child Loop BB16_8 Depth 2
	movq	%r15, %rdi
	movq	%rax, %r15
	movl	4(%rdi), %ebp
	movl	(%r14), %ecx
	cmpl	%ecx, %ebp
	jge	.LBB16_6
# %bb.4:                                #   in Loop: Header=BB16_3 Depth=1
	movq	%r15, %rdx
	subq	%r14, %rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	cmpq	$2, %rax
	jl	.LBB16_10
# %bb.5:                                #   in Loop: Header=BB16_3 Depth=1
	shlq	$2, %rax
	subq	%rax, %rdi
	addq	$8, %rdi
	movq	%r14, %rsi
	callq	memmove@PLT
.LBB16_12:                              # %_ZSt13move_backwardIPiS0_ET0_T_S2_S1_.exit
                                        #   in Loop: Header=BB16_3 Depth=1
	movq	%r14, %rax
	jmp	.LBB16_9
.LBB16_6:                               #   in Loop: Header=BB16_3 Depth=1
	movl	(%rdi), %ecx
	movq	%r15, %rax
	cmpl	%ecx, %ebp
	jge	.LBB16_9
# %bb.7:                                # %.lr.ph.i.preheader
                                        #   in Loop: Header=BB16_3 Depth=1
	movq	%r15, %rax
.LBB16_8:                               # %.lr.ph.i
                                        #   Parent Loop BB16_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ecx, (%rax)
	movl	-8(%rax), %ecx
	addq	$-4, %rax
	cmpl	%ecx, %ebp
	jl	.LBB16_8
.LBB16_9:                               # %_ZSt13move_backwardIPiS0_ET0_T_S2_S1_.exit
                                        #   in Loop: Header=BB16_3 Depth=1
	movl	%ebp, (%rax)
	leaq	4(%r15), %rax
	cmpq	%rbx, %rax
	jne	.LBB16_3
	jmp	.LBB16_13
.LBB16_10:                              #   in Loop: Header=BB16_3 Depth=1
	movq	%r14, %rax
	cmpq	$4, %rdx
	jne	.LBB16_9
# %bb.11:                               #   in Loop: Header=BB16_3 Depth=1
	movl	%ecx, 4(%rdi)
	jmp	.LBB16_12
.LBB16_13:
	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
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB16_14:                              # %.loopexit
	retq
.Lfunc_end16:
	.size	_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_, .Lfunc_end16-_ZSt16__insertion_sortIPiN9__gnu_cxx5__ops15_Iter_less_iterEEvT_S4_T0_
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB17_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB17_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z17bitonic_sort_stepPiii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end17:
	.size	__hip_module_ctor, .Lfunc_end17-__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	.LBB18_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
.LBB18_2:
	retq
.Lfunc_end18:
	.size	__hip_module_dtor, .Lfunc_end18-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Elapsed time: %.3fs\n"
	.size	.L.str, 21

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"%1.3f "
	.size	.L.str.1, 7

	.type	_Z17bitonic_sort_stepPiii,@object # @_Z17bitonic_sort_stepPiii
	.section	.rodata,"a",@progbits
	.globl	_Z17bitonic_sort_stepPiii
	.p2align	3, 0x0
_Z17bitonic_sort_stepPiii:
	.quad	_Z32__device_stub__bitonic_sort_stepPiii
	.size	_Z17bitonic_sort_stepPiii, 8

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"Enter length of the array: "
	.size	.L.str.3, 28

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

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"is equals: "
	.size	.L.str.5, 12

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z17bitonic_sort_stepPiii"
	.size	.L__unnamed_1, 26

	.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 _Z32__device_stub__bitonic_sort_stepPiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z17bitonic_sort_stepPiii
	.addrsig_sym _ZSt4cout
	.addrsig_sym _ZSt3cin
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z17bitonic_sort_stepPiii ; -- Begin function _Z17bitonic_sort_stepPiii
	.globl	_Z17bitonic_sort_stepPiii
	.p2align	8
	.type	_Z17bitonic_sort_stepPiii,@function
_Z17bitonic_sort_stepPiii:              ; @_Z17bitonic_sort_stepPiii
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b64 s[2:3], s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[4:5], null, s15, s4, v[0:1]
	v_xor_b32_e32 v0, s2, v4
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_u32_e64 v0, v4
	s_cbranch_execz .LBB0_7
; %bb.1:
	s_load_b64 s[0:1], s[0:1], 0x0
	v_mov_b32_e32 v5, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[4:5]
	v_dual_mov_b32 v1, v5 :: v_dual_and_b32 v4, s3, v4
	v_lshlrev_b64 v[5:6], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v0, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v2, vcc_lo, s0, v5
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v6, vcc_lo
	s_mov_b32 s0, 0
	s_clause 0x1
	global_load_b32 v5, v[0:1], off
	global_load_b32 v6, v[2:3], off
	s_mov_b32 s1, exec_lo
	v_cmpx_ne_u32_e32 0, v4
	s_xor_b32 s1, exec_lo, s1
	s_cbranch_execz .LBB0_3
; %bb.2:
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, v5, v6
	s_and_b32 s0, vcc_lo, exec_lo
.LBB0_3:                                ; %Flow
	s_and_not1_saveexec_b32 s1, s1
	s_cbranch_execz .LBB0_5
; %bb.4:
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, v5, v6
	s_and_not1_b32 s0, s0, exec_lo
	s_and_b32 s2, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s0, s0, s2
.LBB0_5:                                ; %Flow46
	s_or_b32 exec_lo, exec_lo, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 exec_lo, exec_lo, s0
	s_cbranch_execz .LBB0_7
; %bb.6:                                ; %.sink.split
	s_waitcnt vmcnt(0)
	s_clause 0x1
	global_store_b32 v[0:1], v6, off
	global_store_b32 v[2:3], v5, off
.LBB0_7:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17bitonic_sort_stepPiii
		.amdhsa_group_segment_fixed_size 0
		.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 7
		.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	_Z17bitonic_sort_stepPiii, .Lfunc_end0-_Z17bitonic_sort_stepPiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 280
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; 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
	.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_
	.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:         12
        .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: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17bitonic_sort_stepPiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z17bitonic_sort_stepPiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
