#include <iostream>
#include <sstream>
#include <stdio.h>
using namespace std;

#define UP 0
#define DOWN 1

#define BLOCK_SIZE 1024
#define NUM_BLOCKS 128
#define SHARED_MEM 8192

/* Cuda memcheck snippets from HW3 
 * http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
 */
#define CUDA_SAFE_CALL_NO_SYNC( call) do {                              \
  cudaError err = call;                                                 \
  if( cudaSuccess != err) {                                             \
    fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n",       \
                __FILE__, __LINE__, cudaGetErrorString( err) );         \
    exit(EXIT_FAILURE);                                                 \
    } } while (0)

#define CUDA_SAFE_CALL( call) do {                                      \
  CUDA_SAFE_CALL_NO_SYNC(call);                                         \
  cudaError err = cudaDeviceSynchronize();                              \
  if( cudaSuccess != err) {                                             \
     fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n",      \
                 __FILE__, __LINE__, cudaGetErrorString( err) );        \
     exit(EXIT_FAILURE);                                                \
     } } while (0)

__device__ int getButtSize(int stageSize, int numButterfly){
    return stageSize >> numButterfly;
}
__device__ int maximum(int firstIn, int secondIn){
    return firstIn >= secondIn ? firstIn : secondIn;
}

__device__ void compare_and_switch(int direction, float *in0, float *in1){
    if (direction == DOWN){
        // printf("direction: UP\tin0: %f\tin1: %f\n", *in0, *in1);
        if(*in1 > *in0){
            float temp = *in0;
            *in0 = *in1;
            *in1 = temp;
        }
    }
    if (direction == UP){
        // printf("direction: DN\tin0: %f\tin1: %f\n", *in0, *in1);
        if(*in0 > *in1){
            float temp = *in0;
            *in0 = *in1;
            *in1 = temp;
        }
    }
}

__device__ void shuffle(int stageSize, float value, int addrOut, int offset, float *array){
    // Actually destination address is addrIn, 
    // it may look unintuitive but the fact is
    // In N' Out (pun intended with the california
    // based fast food chain) are relative terms based 
    // on where you're looking at the code from. In this case 
    // the shuffle function in going to caluculate the input address 
    // (addrIn) for the shared memory based on the output address of
    // the previous comparator (addrOut)
    int addrIn = addrOut; 
    addrIn = addrIn << 1;
    addrIn &= ~(stageSize);
    addrIn |= (addrOut / (stageSize / 2));
    // printf("stageSize: %8d\tvalue: %f\naddrOut: %8d\toffset: %4d\narray[%d + %d] = %f\n\n", stageSize, value, addrOut, offset, addrIn, offset, value);
    array[addrIn + offset] = value;
}

__device__ void butterfly(int stageSize, float value, int addrOut, int offset, float *array){

    int firstBit = addrOut % 2; 
    int lastBit = addrOut / (stageSize / 2);
    int addrIn = addrOut; 
    addrIn = addrIn - (addrIn % 2);
    addrIn &= ~(stageSize / 2);
    addrIn |= (firstBit * stageSize / 2);
    addrIn |= lastBit;
    // printf("stageSize: %8d\tvalue: %f\naddrOut: %8d\toffset: %4d\narray[%d + %d] = %f\n\n", stageSize, value, addrOut, offset, addrIn, offset, value);
    array[addrIn + offset] = value;
}

__global__ void stagingKernel(int stageNum, int stageSize, int numElements, float *arrayIn){

    int quotient = maximum(blockDim.x, stageSize / 2);
    int index = blockIdx.x * quotient + threadIdx.x; 
    int stride = gridDim.x * quotient; 
    __shared__ float buffer[SHARED_MEM];

    int level = stageNum; 
    // printf ("blockIdx.x: %4d\tthreadIdx.x: %4d\nindex: %4d\tstride: %4d\n\n", blockIdx.x, threadIdx.x, index, stride);
    for (int addr = index; addr < (numElements / 2); addr += stride){   
        for (int iteration = 0; iteration < maximum(stageSize / (2 * BLOCK_SIZE), 1); ++iteration){
            int compGlobalAddr = addr + iteration * BLOCK_SIZE;
            int compLocalAddr = threadIdx.x + iteration * BLOCK_SIZE;
            // printf ("blockIdx.x: %4d\tthreadIdx.x: %4d\ncompGlobalAddr: %4d\tcompLocalAddr: %4d\n\n", blockIdx.x, threadIdx.x, compGlobalAddr, compLocalAddr);

            int firstInAddr = compGlobalAddr * 2;
            int secondInAddr = compGlobalAddr * 2 + 1;
            float firstIn = arrayIn[firstInAddr];
            float secondIn = arrayIn[secondInAddr];
            
            int outAddrOffset = (compLocalAddr * 2 / stageSize) * stageSize;
            int firstOutAddr = (compLocalAddr * 2) % stageSize;
            int secondOutAddr = (compLocalAddr * 2 + 1) % stageSize;  

            // printf("compGlobalAddr: %8d\tcompLocalAddr: %4d\noutAddrOffset: %4d\tfirstoutAddr: %4d\tsecondOutAddr: %9d\nfirstIn: %f\tsecondIn: %f\n\n", compGlobalAddr, compLocalAddr, outAddrOffset, firstOutAddr, secondOutAddr, firstIn, secondIn);
         

            int direction = (compGlobalAddr & (1 << level)) == 0 ? UP : DOWN;
            // printf("compGlobalAddr: %4d\tdirection: %d\n", compGlobalAddr, direction);
            compare_and_switch(direction, &firstIn, &secondIn);
        
            shuffle(stageSize, firstIn, firstOutAddr, outAddrOffset, buffer);
            shuffle(stageSize, secondIn, secondOutAddr, outAddrOffset, buffer);
        }

        level++;

        // if (threadIdx.x == 0)
        //     printf("blockIdx.x: %d\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n\n", blockIdx.x,
        //                                                                                buffer[0], buffer[1], buffer[2], buffer[3], 
        //                                                                                buffer[4], buffer[5], buffer[6], buffer[7], 
        //                                                                                buffer[8], buffer[9], buffer[10], buffer[11], 
        //                                                                                buffer[12], buffer[13], buffer[14], buffer[15]);
        // __syncthreads();
        
        for (int iteration = 0; iteration < maximum(stageSize / (2 * BLOCK_SIZE), 1); ++iteration){
            for (int numButterfly = 0; numButterfly <= stageNum; ++numButterfly){

                int butterflySize = getButtSize(stageSize, numButterfly);
                int compGlobalAddr = addr + iteration * BLOCK_SIZE;
                int compLocalAddr = threadIdx.x + iteration * BLOCK_SIZE;

                int firstInAddr = compLocalAddr * 2;
                int secondInAddr = compLocalAddr * 2 + 1;
                float firstIn = buffer[firstInAddr];
                float secondIn = buffer[secondInAddr];   
                
                int outAddrOffset = (compLocalAddr * 2 / butterflySize) * butterflySize;
                int firstOutAddr = (compLocalAddr * 2) % butterflySize;
                int secondOutAddr = (compLocalAddr * 2 + 1) % butterflySize;

                int direction = (compGlobalAddr & (1 << level)) == 0 ? UP : DOWN;
                compare_and_switch(direction, &firstIn, &secondIn);

                butterfly(butterflySize, firstIn, firstOutAddr, outAddrOffset, buffer);
                butterfly(butterflySize, secondIn, secondOutAddr, outAddrOffset, buffer);
               
            }
            __syncthreads();
        }

        // if (threadIdx.x == 0)
        //     printf("blockIdx.x: %d\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n\n", blockIdx.x,
        //                                                                                buffer[0], buffer[1], buffer[2], buffer[3], 
        //                                                                                buffer[4], buffer[5], buffer[6], buffer[7], 
        //                                                                                buffer[8], buffer[9], buffer[10], buffer[11], 
        //                                                                                buffer[12], buffer[13], buffer[14], buffer[15]);
        // __syncthreads();

        for (int iteration = 0; iteration < maximum(stageSize / (2 * BLOCK_SIZE), 1); ++iteration){
            int compGlobalAddr = addr + iteration * BLOCK_SIZE;
            int compLocalAddr = threadIdx.x + iteration * BLOCK_SIZE;

            int firstLocalAddr = compLocalAddr * 2;
            int secondLocalAddr = compLocalAddr * 2 + 1;

            int firstGlobalAddr = compGlobalAddr * 2;
            int secondGlobalAddr = compGlobalAddr * 2 + 1;
            // printf("compGlobalAddr: %d\tcompLocalAddr: %d\nbuffer[%d]: %f\tbuffer[%d]: %f\narrayIn[%d] = buffer[%d] = %f\narrayIn[%d] = buffer[%d] = %f\n\n", compGlobalAddr, compLocalAddr, firstLocalAddr, buffer[firstLocalAddr], secondLocalAddr, buffer[secondLocalAddr], firstGlobalAddr, firstLocalAddr, buffer[firstLocalAddr], secondGlobalAddr, secondLocalAddr, buffer[secondLocalAddr]);
            // printf("compGlobalAddr: %d\tcompLocalAddr: %d\nbuffer[%d]: %f\tbuffer[%d]: %f\narrayIn[%d] = buffer[%d] = %f\narrayIn[%d] = buffer[%d] = %f\n\n", compGlobalAddr, compLocalAddr, firstLocalAddr, secondLocalAddr, firstGlobalAddr, firstLocalAddr, buffer[firstLocalAddr], secondGlobalAddr, secondLocalAddr, buffer[secondLocalAddr]);
            arrayIn[firstGlobalAddr] = buffer[firstLocalAddr];
            arrayIn[secondGlobalAddr] = buffer[secondLocalAddr];
        }

        // if (threadIdx.x == 0)
        //     printf("%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n\n", buffer[0], buffer[1], buffer[2], buffer[3], 
        //                                                                                buffer[4], buffer[5], buffer[6], buffer[7], 
        //                                                                                buffer[8], buffer[9], buffer[10], buffer[11], 
        //                                                                                buffer[12], buffer[13], buffer[14], buffer[15]);
        // __syncthreads();
    }

    // level++;

    // for (int iteration = 0; iteration <= stageNum; ++iteration){    
        // for (int addr = index; addr < (numElements / 2); addr += stride){
            
            // int direction = addr & (1 << level) == 0 ? UP : DOWN;

    //         int outAddrOffset = addr - (addr % (stageSize / 2));
    //         int outAddr0 = (addr * 2) % stageSize;
    //         int outAddr1 = (addr * 2 + 1) % stageSize;
            
    //         float firstIn = buffer[tIndex * 2];
    //         float secondIn = buffer[tIndex * 2 + 1];
            
    //         compare_and_switch(direction, &firstIn, &secondIn);
    //         butterfly(stageSize, firstIn, outAddr0, outAddrOffset, buffer);
    //         butterfly(stageSize, secondIn, outAddr1, outAddrOffset, buffer); 
    //     }
    //     // arrayIn[addr * 2] = buffer[tIndex * 2];
    //     // arrayIn[addr * 2 + 1] = buffer[tIndex * 2 + 1];
    // }

}

__global__ void cleanupKenerl(int numElements, float *arrayIn){
    int index = blockIdx.x * blockDim.x + threadIdx.x; 
    int stride = blockDim.x * gridDim.x; 

    for (int addr = index; addr < (numElements / 2); addr += stride){
        float firstIn = arrayIn[addr * 2];
        float secondIn = arrayIn[addr * 2 + 1];
        compare_and_switch(UP, &firstIn, &secondIn);
        arrayIn[addr * 2] = firstIn;
        arrayIn[addr * 2 + 1] = secondIn;
    }
}

void banyan(float *x, ulong N, uint n){
    int stageSize = 4; 
    for (int stageNum = 0; stageNum < n - 1; stageNum++){
        // printf("stageNum: %4d\t stageSize: %4d\n\n", stageNum, stageSize);
        // stagingKernel<<< 1, 1, 16384 * sizeof(float)>>>(stageNum, stageSize, N, x);
        stagingKernel<<< NUM_BLOCKS, BLOCK_SIZE >>>(stageNum, stageSize, N, x);
        cudaDeviceSynchronize();
        // printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
        stageSize = stageSize * 2;
    }
    cleanupKenerl<<< 80, 1024>>>(N, x);
    cudaDeviceSynchronize();
    
}

// main for debugging individual kernels
int main(int argc, char** argv)
{
  // USAGE: single argument
  // -> n = argv[1]
  // --> e.g. "./banyan 4" would run n=4, N=16

  // params for testing helper functions

  stringstream conv_1(argv[1]);
  stringstream conv_2(argv[2]);
  uint n;
  int thresh;
  if (!(conv_1 >> n))
    n = 4;
  if (!(conv_2 >> thresh))
    thresh = 1;
  ulong N = pow(2,n);
  printf("n=%d // N=%d // thresh=%d:\n",(int)n,(int)N,thresh); // NOTE: might not be exposing issue by casting to int here

  // x = inputs, y = outputs 
  float *x;
  CUDA_SAFE_CALL(cudaMallocManaged(&x, N*sizeof(float)));
  printf("------------------------------------------------------------\n");
  printf("Init input:\n");
  printf("------------------------------------------------------------\n");
  for (int i=0; i<N; i++) {
    x[i]=(float) (N-i-1); // backwards list 
    // x[i]=(float) i; // sorted list
    // x[i]=(float) (rand() % 50); // random list 
    if (i<thresh || i>N-thresh-1)
      printf("for i=%d: x=%f\n", i, x[i]);
  }

  // call batcher-banyan sorting network on N-element array
  banyan(x, N, n);
  cudaDeviceSynchronize();
  printf("------------------------------------------------------------\n");
  printf("Output:\n");
  printf("------------------------------------------------------------\n");
  for (int i=0; i<2*thresh-1; i++) {
    printf("for i=%d: x=%f\n", (i<thresh) ? i : (int)N-(2*thresh-i-1) , (i<thresh) ? x[i] : x[(int)N-(2*thresh-i-1)]);
  }

  CUDA_SAFE_CALL(cudaFree(x));  

  return 0;                           
}

	.file	"tmpxft_0028d027_00000000-6_benes.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3702:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3702:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z11getButtSizeii
	.type	_Z11getButtSizeii, @function
_Z11getButtSizeii:
.LFB3693:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE3693:
	.size	_Z11getButtSizeii, .-_Z11getButtSizeii
	.globl	_Z7maximumii
	.type	_Z7maximumii, @function
_Z7maximumii:
.LFB4414:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z11getButtSizeii
	.cfi_endproc
.LFE4414:
	.size	_Z7maximumii, .-_Z7maximumii
	.globl	_Z18compare_and_switchiPfS_
	.type	_Z18compare_and_switchiPfS_, @function
_Z18compare_and_switchiPfS_:
.LFB3695:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE3695:
	.size	_Z18compare_and_switchiPfS_, .-_Z18compare_and_switchiPfS_
	.globl	_Z7shuffleifiiPf
	.type	_Z7shuffleifiiPf, @function
_Z7shuffleifiiPf:
.LFB3696:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE3696:
	.size	_Z7shuffleifiiPf, .-_Z7shuffleifiiPf
	.globl	_Z9butterflyifiiPf
	.type	_Z9butterflyifiiPf, @function
_Z9butterflyifiiPf:
.LFB4416:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE4416:
	.size	_Z9butterflyifiiPf, .-_Z9butterflyifiiPf
	.globl	_Z36__device_stub__Z13stagingKerneliiiPfiiiPf
	.type	_Z36__device_stub__Z13stagingKerneliiiPfiiiPf, @function
_Z36__device_stub__Z13stagingKerneliiiPfiiiPf:
.LFB3724:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movl	%edi, 28(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 24(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 20(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L12
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z13stagingKerneliiiPf(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L12:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3724:
	.size	_Z36__device_stub__Z13stagingKerneliiiPfiiiPf, .-_Z36__device_stub__Z13stagingKerneliiiPfiiiPf
	.globl	_Z13stagingKerneliiiPf
	.type	_Z13stagingKerneliiiPf, @function
_Z13stagingKerneliiiPf:
.LFB3725:
	.cfi_startproc
	endbr64
	jmp	_Z36__device_stub__Z13stagingKerneliiiPfiiiPf
	.cfi_endproc
.LFE3725:
	.size	_Z13stagingKerneliiiPf, .-_Z13stagingKerneliiiPf
	.globl	_Z34__device_stub__Z13cleanupKenerliPfiPf
	.type	_Z34__device_stub__Z13cleanupKenerliPfiPf, @function
_Z34__device_stub__Z13cleanupKenerliPfiPf:
.LFB3726:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movl	%edi, 12(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%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	.L18
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z13cleanupKenerliPf(%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
.L18:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3726:
	.size	_Z34__device_stub__Z13cleanupKenerliPfiPf, .-_Z34__device_stub__Z13cleanupKenerliPfiPf
	.globl	_Z13cleanupKenerliPf
	.type	_Z13cleanupKenerliPf, @function
_Z13cleanupKenerliPf:
.LFB3727:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z13cleanupKenerliPfiPf
	.cfi_endproc
.LFE3727:
	.size	_Z13cleanupKenerliPf, .-_Z13cleanupKenerliPf
	.globl	_Z6banyanPfmj
	.type	_Z6banyanPfmj, @function
_Z6banyanPfmj:
.LFB3698:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$4, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%edx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movabsq	$4294968320, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
.L24:
	leal	-1(%r14), %eax
	movq	%r12, 20(%rsp)
	movl	$1, 28(%rsp)
	cmpl	%eax, %r13d
	jnb	.L29
	movl	$33554433, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	salq	$7, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movl	$1, 16(%rsp)
	movq	%rdi, 8(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	movq	%rbp, %rcx
	movl	%ebx, %edx
	movl	%r15d, %esi
	movl	%r13d, %edi
	call	_Z36__device_stub__Z13stagingKerneliiiPfiiiPf
.L25:
	call	cudaDeviceSynchronize@PLT
	addl	%r15d, %r15d
	incl	%r13d
	jmp	.L24
.L29:
	movl	$268435461, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	salq	$4, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movl	$1, 16(%rsp)
	movq	%rdi, 8(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L27
	movq	%rbp, %rsi
	movl	%ebx, %edi
	call	_Z34__device_stub__Z13cleanupKenerliPfiPf
.L27:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.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	cudaDeviceSynchronize@PLT
	.cfi_endproc
.LFE3698:
	.size	_Z6banyanPfmj, .-_Z6banyanPfmj
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z13cleanupKenerliPf"
.LC1:
	.string	"_Z13stagingKerneliiiPf"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3729:
	.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	.LC0(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z13cleanupKenerliPf(%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	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC1(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z13stagingKerneliiiPf(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	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	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3729:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.str1.1,"aMS",@progbits,1
.LC2:
	.string	"basic_string: construction from null is not valid"
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IS3_EEPKcRKS3_,comdat
	.align 2
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, @function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_:
.LFB4030:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	16(%rdi), %rax
	movq	%rax, (%rdi)
	testq	%rsi, %rsi
	jne	.L33
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L38
	leaq	.LC2(%rip), %rdi
	call	_ZSt19__throw_logic_errorPKc@PLT
.L33:
	movq	%rdi, %rbx
	movq	%rsi, %rdi
	movq	%rsi, %rbp
	call	strlen@PLT
	movq	%rax, (%rsp)
	leaq	0(%rbp,%rax), %r12
	cmpq	$15, %rax
	jbe	.L35
	movq	%rsp, %rsi
	xorl	%edx, %edx
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@PLT
	movq	%rax, (%rbx)
	movq	(%rsp), %rax
	movq	%rax, 16(%rbx)
.L35:
	movq	(%rbx), %rdi
	movq	%r12, %rdx
	movq	%rbp, %rsi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcPKcS7_@PLT
	movq	(%rsp), %rax
	movq	(%rbx), %rdx
	movq	%rax, 8(%rbx)
	movb	$0, (%rdx,%rax)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L36
.L38:
	call	__stack_chk_fail@PLT
.L36:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4030:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, .-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
	.set	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.section	.rodata.str1.1
.LC5:
	.string	"n=%d // N=%d // thresh=%d:\n"
.LC6:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/mahyarsamani/Bitonic-Sort-Using-Batcher-Network/master/shared_memory/benes.cu"
.LC7:
	.string	"Cuda error in file '%s' in line %i : %s.\n"
.LC8:
	.string	"------------------------------------------------------------\n"
.LC9:
	.string	"Init input:\n"
.LC10:
	.string	"for i=%d: x=%f\n"
.LC11:
	.string	"Output:\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3699:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3699
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$872, %rsp
	.cfi_def_cfa_offset 928
	movq	8(%rsi), %rsi
	movq	%fs:40, %rax
	movq	%rax, 856(%rsp)
	xorl	%eax, %eax
	leaq	464(%rsp), %rbp
	leaq	32(%rsp), %rbx
	movq	%rbx, %rdx
	movq	%rbp, %rdi
.LEHB0:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE0:
	leaq	72(%rsp), %rax
	movl	$24, %edx
	movq	%rbp, %rsi
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
.LEHB1:
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode@PLT
.LEHE1:
	movq	%rbp, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	16(%r12), %rsi
	leaq	40(%rsp), %r12
	movq	%rbx, %rdx
	movq	%r12, %rdi
.LEHB2:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE2:
	movl	$24, %edx
	movq	%r12, %rsi
	movq	%rbp, %rdi
.LEHB3:
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode@PLT
.LEHE3:
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	8(%rsp), %rdi
	leaq	24(%rsp), %rsi
.LEHB4:
	call	_ZNSi10_M_extractIjEERSiRT_@PLT
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	je	.L40
	movl	$4, 24(%rsp)
.L40:
	leaq	28(%rsp), %rsi
	movq	%rbp, %rdi
	call	_ZNSirsERi@PLT
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	je	.L41
	movl	$1, 28(%rsp)
.L41:
	movl	24(%rsp), %eax
	movsd	.LC3(%rip), %xmm0
	cvtsi2sdq	%rax, %xmm1
	movq	%rax, %r13
	call	pow@PLT
	movsd	.LC4(%rip), %xmm1
	comisd	%xmm1, %xmm0
	jnb	.L44
	cvttsd2siq	%xmm0, %r12
	jmp	.L45
.L44:
	subsd	%xmm1, %xmm0
	cvttsd2siq	%xmm0, %r12
	btcq	$63, %r12
.L45:
	movl	28(%rsp), %r8d
	movl	%r12d, %ecx
	movl	%r13d, %edx
	movl	$2, %edi
	leaq	.LC5(%rip), %rsi
	xorl	%eax, %eax
	movl	%r12d, %r14d
	call	__printf_chk@PLT
	leaq	0(,%r12,4), %rsi
	movl	$1, %edx
	movq	%rbx, %rdi
	call	cudaMallocManaged@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L46
.L92:
	call	cudaGetErrorString@PLT
	movq	%rax, %r9
	movl	$265, %r8d
.L86:
	movq	stderr(%rip), %rdi
	leaq	.LC6(%rip), %rcx
	leaq	.LC7(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L46:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	jne	.L92
	leaq	.LC8(%rip), %r13
	movl	$2, %edi
	xorl	%eax, %eax
	movq	%r13, %rsi
	call	__printf_chk@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%ebx, %ebx
	leaq	.LC10(%rip), %r15
.L49:
	movq	32(%rsp), %rdi
	cmpq	%r12, %rbx
	je	.L97
	leaq	-1(%r12), %rax
	subq	%rbx, %rax
	js	.L50
	cvtsi2ssq	%rax, %xmm0
	jmp	.L51
.L50:
	movq	%rax, %rdx
	andl	$1, %eax
	shrq	%rdx
	orq	%rax, %rdx
	cvtsi2ssq	%rdx, %xmm0
	addss	%xmm0, %xmm0
.L51:
	movslq	28(%rsp), %rax
	movss	%xmm0, (%rdi,%rbx,4)
	cmpl	%ebx, %eax
	jg	.L52
	movq	%r12, %rdx
	subq	%rax, %rdx
	leaq	-1(%rdx), %rax
	cmpq	%rbx, %rax
	jnb	.L53
.L52:
	movl	%ebx, %edx
	movq	%r15, %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
.L53:
	incq	%rbx
	jmp	.L49
.L97:
	movl	24(%rsp), %edx
	movq	%rbx, %rsi
	call	_Z6banyanPfmj
	call	cudaDeviceSynchronize@PLT
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%ebx, %ebx
	leaq	.LC10(%rip), %r12
.L55:
	movl	28(%rsp), %ecx
	movq	32(%rsp), %rdi
	movl	%ebx, %edx
	movl	%ebx, %r8d
	leal	(%rcx,%rcx), %eax
	leal	-1(%rax), %esi
	cmpl	%ebx, %esi
	jle	.L98
	cmpl	%ebx, %ecx
	jle	.L56
	movss	(%rdi,%rbx,4), %xmm0
	jmp	.L57
.L56:
	movl	%r14d, %esi
	subl	%eax, %esi
	leal	1(%rsi,%rdx), %esi
	movslq	%esi, %rsi
	movss	(%rdi,%rsi,4), %xmm0
.L57:
	cvtss2sd	%xmm0, %xmm0
	cmpl	%r8d, %ecx
	jg	.L58
	movl	%r14d, %ecx
	subl	%eax, %ecx
	leal	1(%rcx,%rdx), %edx
.L58:
	movq	%r12, %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	incq	%rbx
	jmp	.L55
.L98:
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	jne	.L95
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L61
.L95:
	call	cudaGetErrorString@PLT
.LEHE4:
	movq	%rax, %r9
	movl	$287, %r8d
	jmp	.L86
.L61:
	movq	%rbp, %rdi
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev@PLT
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev@PLT
	movq	856(%rsp), %rax
	subq	%fs:40, %rax
	je	.L68
	jmp	.L83
.L71:
	endbr64
	movq	%rax, %rbx
.L62:
	movq	%rbp, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L96
.L72:
	endbr64
	movq	%rax, %rbx
.L64:
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L65
.L74:
	endbr64
	movq	%rax, %rbx
.L66:
	movq	%rbp, %rdi
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev@PLT
	jmp	.L65
.L73:
	endbr64
	movq	%rax, %rbx
.L65:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev@PLT
.L96:
	movq	856(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L83
	movq	%rbx, %rdi
.LEHB5:
	call	_Unwind_Resume@PLT
.LEHE5:
.L83:
	call	__stack_chk_fail@PLT
.L68:
	addq	$872, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.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
	ret
	.cfi_endproc
.LFE3699:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3699:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3699-.LLSDACSB3699
.LLSDACSB3699:
	.uleb128 .LEHB0-.LFB3699
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3699
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L71-.LFB3699
	.uleb128 0
	.uleb128 .LEHB2-.LFB3699
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L73-.LFB3699
	.uleb128 0
	.uleb128 .LEHB3-.LFB3699
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L72-.LFB3699
	.uleb128 0
	.uleb128 .LEHB4-.LFB3699
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L74-.LFB3699
	.uleb128 0
	.uleb128 .LEHB5-.LFB3699
	.uleb128 .LEHE5-.LEHB5
	.uleb128 0
	.uleb128 0
.LLSDACSE3699:
	.section	.text.startup
	.size	main, .-main
	.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
.LC3:
	.long	0
	.long	1073741824
	.align 8
.LC4:
	.long	0
	.long	1138753536
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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 <iostream>
#include <sstream>
#include <stdio.h>
using namespace std;

#define UP 0
#define DOWN 1

#define BLOCK_SIZE 1024
#define NUM_BLOCKS 128
#define SHARED_MEM 8192

/* Cuda memcheck snippets from HW3 
 * http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
 */
#define CUDA_SAFE_CALL_NO_SYNC( call) do {                              \
  hipError_t err = call;                                                 \
  if( hipSuccess != err) {                                             \
    fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n",       \
                __FILE__, __LINE__, hipGetErrorString( err) );         \
    exit(EXIT_FAILURE);                                                 \
    } } while (0)

#define CUDA_SAFE_CALL( call) do {                                      \
  CUDA_SAFE_CALL_NO_SYNC(call);                                         \
  hipError_t err = hipDeviceSynchronize();                              \
  if( hipSuccess != err) {                                             \
     fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n",      \
                 __FILE__, __LINE__, hipGetErrorString( err) );        \
     exit(EXIT_FAILURE);                                                \
     } } while (0)

__device__ int getButtSize(int stageSize, int numButterfly){
    return stageSize >> numButterfly;
}
__device__ int maximum(int firstIn, int secondIn){
    return firstIn >= secondIn ? firstIn : secondIn;
}

__device__ void compare_and_switch(int direction, float *in0, float *in1){
    if (direction == DOWN){
        // printf("direction: UP\tin0: %f\tin1: %f\n", *in0, *in1);
        if(*in1 > *in0){
            float temp = *in0;
            *in0 = *in1;
            *in1 = temp;
        }
    }
    if (direction == UP){
        // printf("direction: DN\tin0: %f\tin1: %f\n", *in0, *in1);
        if(*in0 > *in1){
            float temp = *in0;
            *in0 = *in1;
            *in1 = temp;
        }
    }
}

__device__ void shuffle(int stageSize, float value, int addrOut, int offset, float *array){
    // Actually destination address is addrIn, 
    // it may look unintuitive but the fact is
    // In N' Out (pun intended with the california
    // based fast food chain) are relative terms based 
    // on where you're looking at the code from. In this case 
    // the shuffle function in going to caluculate the input address 
    // (addrIn) for the shared memory based on the output address of
    // the previous comparator (addrOut)
    int addrIn = addrOut; 
    addrIn = addrIn << 1;
    addrIn &= ~(stageSize);
    addrIn |= (addrOut / (stageSize / 2));
    // printf("stageSize: %8d\tvalue: %f\naddrOut: %8d\toffset: %4d\narray[%d + %d] = %f\n\n", stageSize, value, addrOut, offset, addrIn, offset, value);
    array[addrIn + offset] = value;
}

__device__ void butterfly(int stageSize, float value, int addrOut, int offset, float *array){

    int firstBit = addrOut % 2; 
    int lastBit = addrOut / (stageSize / 2);
    int addrIn = addrOut; 
    addrIn = addrIn - (addrIn % 2);
    addrIn &= ~(stageSize / 2);
    addrIn |= (firstBit * stageSize / 2);
    addrIn |= lastBit;
    // printf("stageSize: %8d\tvalue: %f\naddrOut: %8d\toffset: %4d\narray[%d + %d] = %f\n\n", stageSize, value, addrOut, offset, addrIn, offset, value);
    array[addrIn + offset] = value;
}

__global__ void stagingKernel(int stageNum, int stageSize, int numElements, float *arrayIn){

    int quotient = maximum(blockDim.x, stageSize / 2);
    int index = blockIdx.x * quotient + threadIdx.x; 
    int stride = gridDim.x * quotient; 
    __shared__ float buffer[SHARED_MEM];

    int level = stageNum; 
    // printf ("blockIdx.x: %4d\tthreadIdx.x: %4d\nindex: %4d\tstride: %4d\n\n", blockIdx.x, threadIdx.x, index, stride);
    for (int addr = index; addr < (numElements / 2); addr += stride){   
        for (int iteration = 0; iteration < maximum(stageSize / (2 * BLOCK_SIZE), 1); ++iteration){
            int compGlobalAddr = addr + iteration * BLOCK_SIZE;
            int compLocalAddr = threadIdx.x + iteration * BLOCK_SIZE;
            // printf ("blockIdx.x: %4d\tthreadIdx.x: %4d\ncompGlobalAddr: %4d\tcompLocalAddr: %4d\n\n", blockIdx.x, threadIdx.x, compGlobalAddr, compLocalAddr);

            int firstInAddr = compGlobalAddr * 2;
            int secondInAddr = compGlobalAddr * 2 + 1;
            float firstIn = arrayIn[firstInAddr];
            float secondIn = arrayIn[secondInAddr];
            
            int outAddrOffset = (compLocalAddr * 2 / stageSize) * stageSize;
            int firstOutAddr = (compLocalAddr * 2) % stageSize;
            int secondOutAddr = (compLocalAddr * 2 + 1) % stageSize;  

            // printf("compGlobalAddr: %8d\tcompLocalAddr: %4d\noutAddrOffset: %4d\tfirstoutAddr: %4d\tsecondOutAddr: %9d\nfirstIn: %f\tsecondIn: %f\n\n", compGlobalAddr, compLocalAddr, outAddrOffset, firstOutAddr, secondOutAddr, firstIn, secondIn);
         

            int direction = (compGlobalAddr & (1 << level)) == 0 ? UP : DOWN;
            // printf("compGlobalAddr: %4d\tdirection: %d\n", compGlobalAddr, direction);
            compare_and_switch(direction, &firstIn, &secondIn);
        
            shuffle(stageSize, firstIn, firstOutAddr, outAddrOffset, buffer);
            shuffle(stageSize, secondIn, secondOutAddr, outAddrOffset, buffer);
        }

        level++;

        // if (threadIdx.x == 0)
        //     printf("blockIdx.x: %d\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n\n", blockIdx.x,
        //                                                                                buffer[0], buffer[1], buffer[2], buffer[3], 
        //                                                                                buffer[4], buffer[5], buffer[6], buffer[7], 
        //                                                                                buffer[8], buffer[9], buffer[10], buffer[11], 
        //                                                                                buffer[12], buffer[13], buffer[14], buffer[15]);
        // __syncthreads();
        
        for (int iteration = 0; iteration < maximum(stageSize / (2 * BLOCK_SIZE), 1); ++iteration){
            for (int numButterfly = 0; numButterfly <= stageNum; ++numButterfly){

                int butterflySize = getButtSize(stageSize, numButterfly);
                int compGlobalAddr = addr + iteration * BLOCK_SIZE;
                int compLocalAddr = threadIdx.x + iteration * BLOCK_SIZE;

                int firstInAddr = compLocalAddr * 2;
                int secondInAddr = compLocalAddr * 2 + 1;
                float firstIn = buffer[firstInAddr];
                float secondIn = buffer[secondInAddr];   
                
                int outAddrOffset = (compLocalAddr * 2 / butterflySize) * butterflySize;
                int firstOutAddr = (compLocalAddr * 2) % butterflySize;
                int secondOutAddr = (compLocalAddr * 2 + 1) % butterflySize;

                int direction = (compGlobalAddr & (1 << level)) == 0 ? UP : DOWN;
                compare_and_switch(direction, &firstIn, &secondIn);

                butterfly(butterflySize, firstIn, firstOutAddr, outAddrOffset, buffer);
                butterfly(butterflySize, secondIn, secondOutAddr, outAddrOffset, buffer);
               
            }
            __syncthreads();
        }

        // if (threadIdx.x == 0)
        //     printf("blockIdx.x: %d\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n\n", blockIdx.x,
        //                                                                                buffer[0], buffer[1], buffer[2], buffer[3], 
        //                                                                                buffer[4], buffer[5], buffer[6], buffer[7], 
        //                                                                                buffer[8], buffer[9], buffer[10], buffer[11], 
        //                                                                                buffer[12], buffer[13], buffer[14], buffer[15]);
        // __syncthreads();

        for (int iteration = 0; iteration < maximum(stageSize / (2 * BLOCK_SIZE), 1); ++iteration){
            int compGlobalAddr = addr + iteration * BLOCK_SIZE;
            int compLocalAddr = threadIdx.x + iteration * BLOCK_SIZE;

            int firstLocalAddr = compLocalAddr * 2;
            int secondLocalAddr = compLocalAddr * 2 + 1;

            int firstGlobalAddr = compGlobalAddr * 2;
            int secondGlobalAddr = compGlobalAddr * 2 + 1;
            // printf("compGlobalAddr: %d\tcompLocalAddr: %d\nbuffer[%d]: %f\tbuffer[%d]: %f\narrayIn[%d] = buffer[%d] = %f\narrayIn[%d] = buffer[%d] = %f\n\n", compGlobalAddr, compLocalAddr, firstLocalAddr, buffer[firstLocalAddr], secondLocalAddr, buffer[secondLocalAddr], firstGlobalAddr, firstLocalAddr, buffer[firstLocalAddr], secondGlobalAddr, secondLocalAddr, buffer[secondLocalAddr]);
            // printf("compGlobalAddr: %d\tcompLocalAddr: %d\nbuffer[%d]: %f\tbuffer[%d]: %f\narrayIn[%d] = buffer[%d] = %f\narrayIn[%d] = buffer[%d] = %f\n\n", compGlobalAddr, compLocalAddr, firstLocalAddr, secondLocalAddr, firstGlobalAddr, firstLocalAddr, buffer[firstLocalAddr], secondGlobalAddr, secondLocalAddr, buffer[secondLocalAddr]);
            arrayIn[firstGlobalAddr] = buffer[firstLocalAddr];
            arrayIn[secondGlobalAddr] = buffer[secondLocalAddr];
        }

        // if (threadIdx.x == 0)
        //     printf("%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n%f\t%f\t%f\t%f\n\n", buffer[0], buffer[1], buffer[2], buffer[3], 
        //                                                                                buffer[4], buffer[5], buffer[6], buffer[7], 
        //                                                                                buffer[8], buffer[9], buffer[10], buffer[11], 
        //                                                                                buffer[12], buffer[13], buffer[14], buffer[15]);
        // __syncthreads();
    }

    // level++;

    // for (int iteration = 0; iteration <= stageNum; ++iteration){    
        // for (int addr = index; addr < (numElements / 2); addr += stride){
            
            // int direction = addr & (1 << level) == 0 ? UP : DOWN;

    //         int outAddrOffset = addr - (addr % (stageSize / 2));
    //         int outAddr0 = (addr * 2) % stageSize;
    //         int outAddr1 = (addr * 2 + 1) % stageSize;
            
    //         float firstIn = buffer[tIndex * 2];
    //         float secondIn = buffer[tIndex * 2 + 1];
            
    //         compare_and_switch(direction, &firstIn, &secondIn);
    //         butterfly(stageSize, firstIn, outAddr0, outAddrOffset, buffer);
    //         butterfly(stageSize, secondIn, outAddr1, outAddrOffset, buffer); 
    //     }
    //     // arrayIn[addr * 2] = buffer[tIndex * 2];
    //     // arrayIn[addr * 2 + 1] = buffer[tIndex * 2 + 1];
    // }

}

__global__ void cleanupKenerl(int numElements, float *arrayIn){
    int index = blockIdx.x * blockDim.x + threadIdx.x; 
    int stride = blockDim.x * gridDim.x; 

    for (int addr = index; addr < (numElements / 2); addr += stride){
        float firstIn = arrayIn[addr * 2];
        float secondIn = arrayIn[addr * 2 + 1];
        compare_and_switch(UP, &firstIn, &secondIn);
        arrayIn[addr * 2] = firstIn;
        arrayIn[addr * 2 + 1] = secondIn;
    }
}

void banyan(float *x, ulong N, uint n){
    int stageSize = 4; 
    for (int stageNum = 0; stageNum < n - 1; stageNum++){
        // printf("stageNum: %4d\t stageSize: %4d\n\n", stageNum, stageSize);
        // stagingKernel<<< 1, 1, 16384 * sizeof(float)>>>(stageNum, stageSize, N, x);
        stagingKernel<<< NUM_BLOCKS, BLOCK_SIZE >>>(stageNum, stageSize, N, x);
        hipDeviceSynchronize();
        // printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
        stageSize = stageSize * 2;
    }
    cleanupKenerl<<< 80, 1024>>>(N, x);
    hipDeviceSynchronize();
    
}

// main for debugging individual kernels
int main(int argc, char** argv)
{
  // USAGE: single argument
  // -> n = argv[1]
  // --> e.g. "./banyan 4" would run n=4, N=16

  // params for testing helper functions

  stringstream conv_1(argv[1]);
  stringstream conv_2(argv[2]);
  uint n;
  int thresh;
  if (!(conv_1 >> n))
    n = 4;
  if (!(conv_2 >> thresh))
    thresh = 1;
  ulong N = pow(2,n);
  printf("n=%d // N=%d // thresh=%d:\n",(int)n,(int)N,thresh); // NOTE: might not be exposing issue by casting to int here

  // x = inputs, y = outputs 
  float *x;
  CUDA_SAFE_CALL(hipMallocManaged(&x, N*sizeof(float)));
  printf("------------------------------------------------------------\n");
  printf("Init input:\n");
  printf("------------------------------------------------------------\n");
  for (int i=0; i<N; i++) {
    x[i]=(float) (N-i-1); // backwards list 
    // x[i]=(float) i; // sorted list
    // x[i]=(float) (rand() % 50); // random list 
    if (i<thresh || i>N-thresh-1)
      printf("for i=%d: x=%f\n", i, x[i]);
  }

  // call batcher-banyan sorting network on N-element array
  banyan(x, N, n);
  hipDeviceSynchronize();
  printf("------------------------------------------------------------\n");
  printf("Output:\n");
  printf("------------------------------------------------------------\n");
  for (int i=0; i<2*thresh-1; i++) {
    printf("for i=%d: x=%f\n", (i<thresh) ? i : (int)N-(2*thresh-i-1) , (i<thresh) ? x[i] : x[(int)N-(2*thresh-i-1)]);
  }

  CUDA_SAFE_CALL(hipFree(x));  

  return 0;                           
}

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

                                        # End of file scope inline assembly
	.globl	_Z28__device_stub__stagingKerneliiiPf # -- Begin function _Z28__device_stub__stagingKerneliiiPf
	.type	_Z28__device_stub__stagingKerneliiiPf,@function
_Z28__device_stub__stagingKerneliiiPf:  # @_Z28__device_stub__stagingKerneliiiPf
	.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	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	20(%rsp), %rax
	movl	%edi, (%rax)
	leaq	16(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z13stagingKerneliiiPf, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	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_end0:
	.size	_Z28__device_stub__stagingKerneliiiPf, .Lfunc_end0-_Z28__device_stub__stagingKerneliiiPf
	.cfi_endproc
                                        # -- End function
	.globl	_Z28__device_stub__cleanupKenerliPf # -- Begin function _Z28__device_stub__cleanupKenerliPf
	.type	_Z28__device_stub__cleanupKenerliPf,@function
_Z28__device_stub__cleanupKenerliPf:    # @_Z28__device_stub__cleanupKenerliPf
	.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	4(%rsp), %rax
	movl	%edi, (%rax)
	leaq	24(%rsp), %rcx
	movq	%rsi, (%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	$_Z13cleanupKenerliPf, %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_end1:
	.size	_Z28__device_stub__cleanupKenerliPf, .Lfunc_end1-_Z28__device_stub__cleanupKenerliPf
	.cfi_endproc
                                        # -- End function
	.globl	_Z6banyanPfmj                   # -- Begin function _Z6banyanPfmj
	.type	_Z6banyanPfmj,@function
_Z6banyanPfmj:                          # @_Z6banyanPfmj
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebp
	movq	%rsi, %r14
	movq	%rdi, (%rsp)                    # 8-byte Spill
	movabsq	$4294968320, %r15               # imm = 0x100000400
	decl	%ebp
	je	.LBB2_5
# %bb.1:                                # %.lr.ph
	xorl	%r12d, %r12d
	movl	$4, %r13d
	leaq	-896(%r15), %rbx
.LBB2_2:                                # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_4
# %bb.3:                                #   in Loop: Header=BB2_2 Depth=1
	movl	%r12d, %edi
	movl	%r13d, %esi
	movl	%r14d, %edx
	movq	(%rsp), %rcx                    # 8-byte Reload
	callq	_Z28__device_stub__stagingKerneliiiPf
.LBB2_4:                                #   in Loop: Header=BB2_2 Depth=1
	callq	hipDeviceSynchronize
	addl	%r13d, %r13d
	incl	%r12d
	cmpl	%r12d, %ebp
	jne	.LBB2_2
.LBB2_5:                                # %._crit_edge
	leaq	-944(%r15), %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_7
# %bb.6:
	movl	%r14d, %edi
	movq	(%rsp), %rsi                    # 8-byte Reload
	callq	_Z28__device_stub__cleanupKenerliPf
.LBB2_7:
	addq	$8, %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
	jmp	hipDeviceSynchronize            # TAILCALL
.Lfunc_end2:
	.size	_Z6banyanPfmj, .Lfunc_end2-_Z6banyanPfmj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x43e0000000000000              # double 9.2233720368547758E+18
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$832, %rsp                      # imm = 0x340
	.cfi_def_cfa_offset 880
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	8(%rsi), %rsi
.Ltmp0:
	leaq	48(%rsp), %rdi
	leaq	16(%rsp), %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
.Ltmp1:
# %bb.1:
.Ltmp3:
	leaq	440(%rsp), %rdi
	leaq	48(%rsp), %rsi
	movl	$24, %edx
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode
.Ltmp4:
# %bb.2:
	leaq	64(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB3_4
# %bb.3:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
	callq	_ZdlPv
.LBB3_4:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
	movq	16(%rbx), %rsi
.Ltmp6:
	leaq	16(%rsp), %rdi
	leaq	12(%rsp), %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
.Ltmp7:
# %bb.5:
.Ltmp9:
	leaq	48(%rsp), %rdi
	leaq	16(%rsp), %rsi
	movl	$24, %edx
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode
.Ltmp10:
# %bb.6:
	leaq	32(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB3_8
# %bb.7:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i69
	callq	_ZdlPv
.LBB3_8:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit71
.Ltmp12:
	leaq	440(%rsp), %rbx
	leaq	12(%rsp), %rsi
	movq	%rbx, %rdi
	callq	_ZNSi10_M_extractIjEERSiRT_
.Ltmp13:
# %bb.9:
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	je	.LBB3_11
# %bb.10:
	movl	$4, 12(%rsp)
.LBB3_11:
.Ltmp14:
	leaq	48(%rsp), %r14
	leaq	8(%rsp), %rsi
	movq	%r14, %rdi
	callq	_ZNSirsERi
.Ltmp15:
# %bb.12:
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	je	.LBB3_14
# %bb.13:
	movl	$1, 8(%rsp)
.LBB3_14:
	movl	12(%rsp), %eax
	cvtsi2sd	%rax, %xmm0
	callq	exp2@PLT
	cvttsd2si	%xmm0, %rax
	movq	%rax, %rcx
	sarq	$63, %rcx
	subsd	.LCPI3_0(%rip), %xmm0
	cvttsd2si	%xmm0, %r15
	andq	%rcx, %r15
	orq	%rax, %r15
	movl	12(%rsp), %esi
	movl	8(%rsp), %ecx
	movl	$.L.str, %edi
	movl	%r15d, %edx
	xorl	%eax, %eax
	callq	printf
	leaq	(,%r15,4), %rsi
.Ltmp17:
	leaq	16(%rsp), %rdi
	movl	$1, %edx
	callq	hipMallocManaged
.Ltmp18:
# %bb.15:                               # %_ZL16hipMallocManagedIfE10hipError_tPPT_mj.exit
	testl	%eax, %eax
	jne	.LBB3_16
# %bb.26:
.Ltmp22:
	callq	hipDeviceSynchronize
.Ltmp23:
# %bb.27:
	testl	%eax, %eax
	jne	.LBB3_28
# %bb.30:
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	testq	%r15, %r15
	je	.LBB3_39
# %bb.31:                               # %.lr.ph.preheader
	leaq	-1(%r15), %r13
	xorl	%r12d, %r12d
.LBB3_32:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	testq	%r13, %r13
	js	.LBB3_33
# %bb.34:                               # %.lr.ph
                                        #   in Loop: Header=BB3_32 Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r13, %xmm0
	jmp	.LBB3_35
.LBB3_33:                               #   in Loop: Header=BB3_32 Depth=1
	movq	%r13, %rax
	shrq	%rax
	movl	%r13d, %ecx
	andl	$1, %ecx
	orq	%rax, %rcx
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rcx, %xmm0
	addss	%xmm0, %xmm0
.LBB3_35:                               # %.lr.ph
                                        #   in Loop: Header=BB3_32 Depth=1
	movq	16(%rsp), %rax
	movss	%xmm0, (%rax,%r12,4)
	movslq	8(%rsp), %rax
	cmpq	%rax, %r12
	jl	.LBB3_37
# %bb.36:                               #   in Loop: Header=BB3_32 Depth=1
	notl	%eax
	cltq
	addq	%r15, %rax
	cmpq	%r12, %rax
	jae	.LBB3_38
.LBB3_37:                               #   in Loop: Header=BB3_32 Depth=1
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.5, %edi
	movl	%r12d, %esi
	movb	$1, %al
	callq	printf
.LBB3_38:                               #   in Loop: Header=BB3_32 Depth=1
	incq	%r12
	addq	$-1, %r13
	jb	.LBB3_32
.LBB3_39:                               # %._crit_edge
	movq	16(%rsp), %rdi
	movl	12(%rsp), %edx
.Ltmp27:
	movq	%r15, %rsi
	callq	_Z6banyanPfmj
.Ltmp28:
# %bb.40:
.Ltmp29:
	callq	hipDeviceSynchronize
.Ltmp30:
# %bb.41:
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.LBB3_44
# %bb.42:                               # %.lr.ph85.preheader
	leal	(%rax,%rax), %ecx
	incl	%r15d
	xorl	%edx, %edx
.LBB3_43:                               # %.lr.ph85
                                        # =>This Inner Loop Header: Depth=1
	cltq
	leaq	1(%rdx), %r12
	leal	(%r15,%rdx), %esi
	subl	%ecx, %esi
	cmpq	%rax, %rdx
	movq	16(%rsp), %rax
	movslq	%esi, %rcx
	cmovll	%edx, %esi
	cmovlq	%rdx, %rcx
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rax,%rcx,4), %xmm0
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	movslq	8(%rsp), %rax
	leaq	-1(,%rax,2), %rsi
	movq	%rax, %rcx
	addq	%rax, %rcx
	movq	%r12, %rdx
	cmpq	%rsi, %r12
	jl	.LBB3_43
.LBB3_44:                               # %._crit_edge86
	movq	16(%rsp), %rdi
.Ltmp32:
	callq	hipFree
.Ltmp33:
# %bb.45:
	testl	%eax, %eax
	jne	.LBB3_46
# %bb.49:
.Ltmp37:
	callq	hipDeviceSynchronize
.Ltmp38:
# %bb.50:
	testl	%eax, %eax
	jne	.LBB3_51
# %bb.53:
	movl	$_ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE, %esi
	movq	%r14, %rdi
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED2Ev
	movl	$128, %r15d
	addq	%r15, %r14
	movq	%r14, %rdi
	callq	_ZNSt8ios_baseD2Ev
	movl	$_ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE, %esi
	movq	%rbx, %rdi
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED2Ev
	addq	%r15, %rbx
	movq	%rbx, %rdi
	callq	_ZNSt8ios_baseD2Ev
	xorl	%eax, %eax
	addq	$832, %rsp                      # imm = 0x340
	.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
.LBB3_16:
	.cfi_def_cfa_offset 880
	movq	stderr(%rip), %rbx
.Ltmp19:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp20:
	jmp	.LBB3_17
.LBB3_28:
	movq	stderr(%rip), %rbx
.Ltmp24:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp25:
.LBB3_17:
	movl	$.L.str.1, %esi
	movl	$.L.str.2, %edx
	movq	%rbx, %rdi
	movl	$267, %ecx                      # imm = 0x10B
	jmp	.LBB3_18
.LBB3_46:
	movq	stderr(%rip), %rbx
.Ltmp34:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp35:
	jmp	.LBB3_47
.LBB3_51:
	movq	stderr(%rip), %rbx
.Ltmp39:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp40:
.LBB3_47:
	movl	$.L.str.1, %esi
	movl	$.L.str.2, %edx
	movq	%rbx, %rdi
	movl	$289, %ecx                      # imm = 0x121
.LBB3_18:
	movq	%rax, %r8
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.LBB3_23:
.Ltmp11:
	movq	%rax, %rbx
	leaq	32(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB3_56
# %bb.24:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i75
	callq	_ZdlPv
	jmp	.LBB3_56
.LBB3_22:
.Ltmp8:
	movq	%rax, %rbx
	jmp	.LBB3_56
.LBB3_20:
.Ltmp5:
	movq	%rax, %rbx
	leaq	64(%rsp), %rax
	movq	-16(%rax), %rdi
	cmpq	%rax, %rdi
	je	.LBB3_57
# %bb.21:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i72
	callq	_ZdlPv
	jmp	.LBB3_57
.LBB3_19:
.Ltmp2:
	movq	%rax, %rbx
	jmp	.LBB3_57
.LBB3_52:
.Ltmp41:
	jmp	.LBB3_55
.LBB3_48:
.Ltmp36:
	jmp	.LBB3_55
.LBB3_29:
.Ltmp26:
	jmp	.LBB3_55
.LBB3_54:
.Ltmp21:
	jmp	.LBB3_55
.LBB3_58:
.Ltmp31:
	jmp	.LBB3_55
.LBB3_25:
.Ltmp16:
.LBB3_55:
	movq	%rax, %rbx
	leaq	48(%rsp), %rdi
	movl	$_ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE, %esi
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED2Ev
	leaq	176(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
.LBB3_56:
	leaq	440(%rsp), %rdi
	movl	$_ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE, %esi
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED2Ev
	leaq	568(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
.LBB3_57:
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table3:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 1 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin0           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp7-.Ltmp6                  #   Call between .Ltmp6 and .Ltmp7
	.uleb128 .Ltmp8-.Lfunc_begin0           #     jumps to .Ltmp8
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp10-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp10
	.uleb128 .Ltmp11-.Lfunc_begin0          #     jumps to .Ltmp11
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp12-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp15-.Ltmp12                #   Call between .Ltmp12 and .Ltmp15
	.uleb128 .Ltmp16-.Lfunc_begin0          #     jumps to .Ltmp16
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp15-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp17-.Ltmp15                #   Call between .Ltmp15 and .Ltmp17
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp17-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp18-.Ltmp17                #   Call between .Ltmp17 and .Ltmp18
	.uleb128 .Ltmp21-.Lfunc_begin0          #     jumps to .Ltmp21
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp22-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp23-.Ltmp22                #   Call between .Ltmp22 and .Ltmp23
	.uleb128 .Ltmp26-.Lfunc_begin0          #     jumps to .Ltmp26
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp27-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp30-.Ltmp27                #   Call between .Ltmp27 and .Ltmp30
	.uleb128 .Ltmp31-.Lfunc_begin0          #     jumps to .Ltmp31
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp32-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp33-.Ltmp32                #   Call between .Ltmp32 and .Ltmp33
	.uleb128 .Ltmp36-.Lfunc_begin0          #     jumps to .Ltmp36
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp37-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp38-.Ltmp37                #   Call between .Ltmp37 and .Ltmp38
	.uleb128 .Ltmp41-.Lfunc_begin0          #     jumps to .Ltmp41
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp19-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp20-.Ltmp19                #   Call between .Ltmp19 and .Ltmp20
	.uleb128 .Ltmp21-.Lfunc_begin0          #     jumps to .Ltmp21
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp24-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Ltmp25-.Ltmp24                #   Call between .Ltmp24 and .Ltmp25
	.uleb128 .Ltmp26-.Lfunc_begin0          #     jumps to .Ltmp26
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp34-.Lfunc_begin0          # >> Call Site 14 <<
	.uleb128 .Ltmp35-.Ltmp34                #   Call between .Ltmp34 and .Ltmp35
	.uleb128 .Ltmp36-.Lfunc_begin0          #     jumps to .Ltmp36
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp39-.Lfunc_begin0          # >> Call Site 15 <<
	.uleb128 .Ltmp40-.Ltmp39                #   Call between .Ltmp39 and .Ltmp40
	.uleb128 .Ltmp41-.Lfunc_begin0          #     jumps to .Ltmp41
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp40-.Lfunc_begin0          # >> Call Site 16 <<
	.uleb128 .Lfunc_end3-.Ltmp40            #   Call between .Ltmp40 and .Lfunc_end3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_ # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.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
	leaq	16(%rdi), %rax
	movq	%rax, (%rdi)
	testq	%rsi, %rsi
	je	.LBB4_1
# %bb.2:
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movq	%rsi, %rdi
	callq	strlen
	leaq	(%rax,%rbx), %rdx
	movq	%r14, %rdi
	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	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag # TAILCALL
.LBB4_1:
	.cfi_def_cfa_offset 32
	movl	$.L.str.7, %edi
	callq	_ZSt19__throw_logic_errorPKc
.Lfunc_end4:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, .Lfunc_end4-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.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 %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %rbx
	subq	%rsi, %r14
	movq	%r14, (%rsp)
	cmpq	$15, %r14
	jbe	.LBB5_1
# %bb.2:
	movq	%rsp, %r12
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm
	movq	%rax, (%rbx)
	movq	(%r12), %rcx
	movq	%rcx, 16(%rbx)
	jmp	.LBB5_3
.LBB5_1:                                # %._crit_edge
	movq	(%rbx), %rax
.LBB5_3:
	testq	%r14, %r14
	je	.LBB5_7
# %bb.4:
	cmpq	$1, %r14
	jne	.LBB5_6
# %bb.5:
	movb	(%r15), %cl
	movb	%cl, (%rax)
	jmp	.LBB5_7
.LBB5_6:
	movq	%rax, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
.LBB5_7:                                # %_ZZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tagEN6_GuardD2Ev.exit
	movq	(%rsp), %rax
	movq	%rax, 8(%rbx)
	movq	(%rbx), %rcx
	movb	$0, (%rcx,%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag, .Lfunc_end5-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.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:
	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	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13stagingKerneliiiPf, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13cleanupKenerliPf, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z13stagingKerneliiiPf,@object  # @_Z13stagingKerneliiiPf
	.section	.rodata,"a",@progbits
	.globl	_Z13stagingKerneliiiPf
	.p2align	3, 0x0
_Z13stagingKerneliiiPf:
	.quad	_Z28__device_stub__stagingKerneliiiPf
	.size	_Z13stagingKerneliiiPf, 8

	.type	_Z13cleanupKenerliPf,@object    # @_Z13cleanupKenerliPf
	.globl	_Z13cleanupKenerliPf
	.p2align	3, 0x0
_Z13cleanupKenerliPf:
	.quad	_Z28__device_stub__cleanupKenerliPf
	.size	_Z13cleanupKenerliPf, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"n=%d // N=%d // thresh=%d:\n"
	.size	.L.str, 28

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Cuda error in file '%s' in line %i : %s.\n"
	.size	.L.str.1, 42

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/mahyarsamani/Bitonic-Sort-Using-Batcher-Network/master/shared_memory/benes.hip"
	.size	.L.str.2, 141

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"for i=%d: x=%f\n"
	.size	.L.str.5, 16

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"basic_string: construction from null is not valid"
	.size	.L.str.7, 50

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13stagingKerneliiiPf"
	.size	.L__unnamed_1, 23

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z13cleanupKenerliPf"
	.size	.L__unnamed_2, 21

	.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

	.type	.Lstr.1,@object                 # @str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr.1:
	.asciz	"Init input:"
	.size	.Lstr.1, 12

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Output:"
	.size	.Lstr.4, 8

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"------------------------------------------------------------"
	.size	.Lstr.5, 61

	.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 _Z28__device_stub__stagingKerneliiiPf
	.addrsig_sym _Z28__device_stub__cleanupKenerliPf
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z13stagingKerneliiiPf
	.addrsig_sym _Z13cleanupKenerliPf
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13stagingKerneliiiPf  ; -- Begin function _Z13stagingKerneliiiPf
	.globl	_Z13stagingKerneliiiPf
	.p2align	8
	.type	_Z13stagingKerneliiiPf,@function
_Z13stagingKerneliiiPf:                 ; @_Z13stagingKerneliiiPf
; %bb.0:
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b32 s8, s[0:1], 0x24
	s_add_u32 s2, s0, 24
	s_addc_u32 s3, s1, 0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s7, s5, 31
	s_and_b32 s8, s8, 0xffff
	s_add_i32 s9, s5, s7
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s11, s9, 1
	s_max_i32 s16, s8, s11
	s_lshr_b32 s8, s6, 31
	s_mul_i32 s17, s16, s15
	s_add_i32 s6, s6, s8
	v_add_nc_u32_e32 v3, s17, v0
	s_ashr_i32 s6, s6, 1
	s_mov_b32 s8, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s6, v3
	s_cbranch_execz .LBB0_23
; %bb.1:                                ; %.preheader116.lr.ph
	s_ashr_i32 s12, s5, 31
	s_load_b32 s18, s[2:3], 0x0
	s_lshr_b32 s8, s12, 21
	v_lshlrev_b32_e32 v6, 1, v3
	s_add_i32 s9, s5, s8
	s_not_b32 s8, s5
	s_ashr_i32 s14, s9, 11
	s_cmp_gt_i32 s4, -1
	s_cselect_b32 s9, -1, 0
	s_ashr_i32 s10, s11, 31
	s_add_i32 s13, s5, s12
	s_add_i32 s15, s11, s10
	s_xor_b32 s11, s13, s12
	s_xor_b32 s12, s15, s10
	v_cvt_f32_u32_e32 v1, s11
	v_cvt_f32_u32_e32 v2, s12
	s_sub_i32 s2, 0, s11
	s_sub_i32 s3, 0, s12
	s_max_i32 s14, s14, 1
	v_rcp_iflag_f32_e32 v1, v1
	v_rcp_iflag_f32_e32 v2, v2
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s16, s16, s18
	s_mov_b32 s13, 0
	s_lshl_b32 s15, s14, 10
	s_lshl_b32 s17, s17, 1
	s_lshl_b32 s18, s16, 1
	s_add_i32 s19, s4, 1
	s_waitcnt_depctr 0xfff
	v_dual_mul_f32 v1, 0x4f7ffffe, v1 :: v_dual_mul_f32 v2, 0x4f7ffffe, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cvt_u32_f32_e32 v1, v1
	v_cvt_u32_f32_e32 v2, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v4, s2, v1
	v_mul_lo_u32 v5, s3, v2
	s_load_b64 s[2:3], s[0:1], 0x10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_hi_u32 v7, v1, v4
	v_mul_hi_u32 v8, v2, v5
	v_lshlrev_b32_e32 v4, 1, v0
	v_lshlrev_b32_e32 v5, 3, v0
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_nc_u32_e32 v7, v1, v7
	v_add_nc_u32_e32 v8, v2, v8
.LBB0_2:                                ; %.preheader116
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_3 Depth 2
                                        ;     Child Loop BB0_11 Depth 2
                                        ;       Child Loop BB0_13 Depth 3
                                        ;     Child Loop BB0_21 Depth 2
	s_delay_alu instid0(VALU_DEP_4)
	v_mov_b32_e32 v9, v4
	s_lshl_b32 s1, 1, s4
	s_mov_b32 s20, 0
.LBB0_3:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v1, s17, v9
	v_add_nc_u32_e32 v10, s20, v3
	s_mov_b32 s0, 0
	s_mov_b32 s21, exec_lo
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_and_b32_e32 v10, s1, v10
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v1, vcc_lo, s2, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s3, v2, vcc_lo
	global_load_b64 v[1:2], v[1:2], off
	v_cmpx_ne_u32_e32 0, v10
	s_xor_b32 s21, exec_lo, s21
	s_cbranch_execz .LBB0_5
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=2
	s_waitcnt vmcnt(0)
	v_cmp_gt_f32_e32 vcc_lo, v2, v1
	s_and_b32 s0, vcc_lo, exec_lo
.LBB0_5:                                ; %Flow154
                                        ;   in Loop: Header=BB0_3 Depth=2
	s_and_not1_saveexec_b32 s21, s21
	s_cbranch_execz .LBB0_7
; %bb.6:                                ;   in Loop: Header=BB0_3 Depth=2
	s_waitcnt vmcnt(0)
	v_cmp_gt_f32_e32 vcc_lo, v1, v2
	s_and_not1_b32 s0, s0, exec_lo
	s_and_b32 s22, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s0, s0, s22
.LBB0_7:                                ; %Flow155
                                        ;   in Loop: Header=BB0_3 Depth=2
	s_or_b32 exec_lo, exec_lo, s21
	s_waitcnt vmcnt(0)
	v_mov_b32_e32 v10, v1
	s_and_saveexec_b32 s21, s0
; %bb.8:                                ; %.sink.split.i
                                        ;   in Loop: Header=BB0_3 Depth=2
	v_mov_b32_e32 v10, v2
	v_mov_b32_e32 v2, v1
; %bb.9:                                ; %_Z18compare_and_switchiPfS_.exit
                                        ;   in Loop: Header=BB0_3 Depth=2
	s_or_b32 exec_lo, exec_lo, s21
	v_ashrrev_i32_e32 v11, 31, v9
	s_addk_i32 s20, 0x400
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s15, s20
	v_add_nc_u32_e32 v13, v9, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_xor_b32_e32 v14, v13, v11
	v_mul_hi_u32 v15, v14, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v15, v15, s11
	v_sub_nc_u32_e32 v14, v14, v15
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_subrev_nc_u32_e32 v15, s11, v14
	v_cmp_le_u32_e32 vcc_lo, s11, v14
	v_add_nc_u32_e32 v1, 1, v9
	v_dual_cndmask_b32 v14, v14, v15 :: v_dual_add_nc_u32 v9, 0x800, v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v12, 31, v1
	v_subrev_nc_u32_e32 v15, s11, v14
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v1, v1, v12
	v_xor_b32_e32 v1, v1, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v16, v1, v7
	v_mul_lo_u32 v16, v16, s11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v1, v1, v16
	v_subrev_nc_u32_e32 v16, s11, v1
	v_cmp_le_u32_e32 vcc_lo, s11, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v1, v1, v16, vcc_lo
	v_cmp_le_u32_e32 vcc_lo, s11, v14
	v_subrev_nc_u32_e32 v16, s11, v1
	v_cndmask_b32_e32 v14, v14, v15, vcc_lo
	v_cmp_le_u32_e32 vcc_lo, s11, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_xor_b32_e32 v14, v14, v11
	v_cndmask_b32_e32 v1, v1, v16, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v11, v14, v11
	v_xor_b32_e32 v1, v1, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_sub_nc_u32_e32 v1, v1, v12
	v_ashrrev_i32_e32 v12, 31, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v15, 31, v1
	v_add_nc_u32_e32 v16, v11, v12
	v_lshlrev_b32_e32 v11, 1, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_xor_b32_e32 v16, v16, v12
	v_xor_b32_e32 v12, s10, v12
	v_mul_hi_u32 v18, v16, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v20, v18, s12
	v_sub_nc_u32_e32 v16, v16, v20
	v_add_nc_u32_e32 v20, 1, v18
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_le_u32_e32 vcc_lo, s12, v16
	v_cndmask_b32_e32 v18, v18, v20, vcc_lo
	v_subrev_nc_u32_e32 v20, s12, v16
	v_add_nc_u32_e32 v17, v1, v15
	v_sub_nc_u32_e32 v13, v13, v14
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_dual_cndmask_b32 v16, v16, v20 :: v_dual_lshlrev_b32 v1, 1, v1
	v_xor_b32_e32 v17, v17, v15
	v_add_nc_u32_e32 v20, 1, v18
	v_xor_b32_e32 v15, s10, v15
	v_lshlrev_b32_e32 v13, 2, v13
	v_cmp_le_u32_e32 vcc_lo, s12, v16
	v_mul_hi_u32 v19, v17, v8
	v_cndmask_b32_e32 v16, v18, v20, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v21, v19, s12
	v_xor_b32_e32 v16, v16, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_sub_nc_u32_e32 v12, v16, v12
	v_sub_nc_u32_e32 v17, v17, v21
	v_add_nc_u32_e32 v21, 1, v19
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_and_or_b32 v11, v11, s8, v12
	v_subrev_nc_u32_e32 v22, s12, v17
	v_cmp_le_u32_e64 s0, s12, v17
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshl_add_u32 v11, v11, 2, v13
	v_cndmask_b32_e64 v19, v19, v21, s0
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cndmask_b32_e64 v17, v17, v22, s0
	v_add_nc_u32_e32 v21, 1, v19
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_le_u32_e32 vcc_lo, s12, v17
	v_cndmask_b32_e32 v17, v19, v21, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_xor_b32_e32 v17, v17, v15
	v_sub_nc_u32_e32 v14, v17, v15
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_and_or_b32 v1, v1, s8, v14
	v_lshl_add_u32 v1, v1, 2, v13
	ds_store_b32 v11, v10
	ds_store_b32 v1, v2
	s_cbranch_scc0 .LBB0_3
; %bb.10:                               ;   in Loop: Header=BB0_2 Depth=1
	s_add_i32 s4, s4, 1
	s_mov_b32 s21, 0
	s_lshl_b32 s20, 1, s4
.LBB0_11:                               ; %.preheader
                                        ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB0_13 Depth 3
	s_and_not1_b32 vcc_lo, exec_lo, s9
	s_cbranch_vccnz .LBB0_20
; %bb.12:                               ; %.lr.ph
                                        ;   in Loop: Header=BB0_11 Depth=2
	s_lshl_b32 s0, s21, 10
	s_mov_b32 s22, 0
	v_or_b32_e32 v1, s0, v0
	v_add_nc_u32_e32 v2, s0, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_lshlrev_b32_e32 v9, 1, v1
	v_bfe_i32 v10, v1, 30, 1
	v_and_b32_e32 v2, s20, v2
	v_lshlrev_b32_e32 v11, 3, v1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v12, v9, v10
	v_cmp_ne_u32_e32 vcc_lo, 0, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v13, 1, v12
	v_xor_b32_e32 v12, v12, v10
	v_xor_b32_e32 v13, v13, v10
.LBB0_13:                               ;   Parent Loop BB0_2 Depth=1
                                        ;     Parent Loop BB0_11 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	ds_load_b64 v[1:2], v11
	s_mov_b32 s1, 0
	s_and_saveexec_b32 s0, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s23, exec_lo, s0
	s_cbranch_execz .LBB0_15
; %bb.14:                               ;   in Loop: Header=BB0_13 Depth=3
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_f32_e64 s0, v2, v1
	s_delay_alu instid0(VALU_DEP_1)
	s_and_b32 s1, s0, exec_lo
.LBB0_15:                               ; %Flow
                                        ;   in Loop: Header=BB0_13 Depth=3
	s_and_not1_saveexec_b32 s23, s23
	s_cbranch_execz .LBB0_17
; %bb.16:                               ;   in Loop: Header=BB0_13 Depth=3
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_f32_e64 s0, v1, v2
	s_and_not1_b32 s1, s1, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, s0, exec_lo
	s_or_b32 s1, s1, s0
.LBB0_17:                               ; %Flow151
                                        ;   in Loop: Header=BB0_13 Depth=3
	s_or_b32 exec_lo, exec_lo, s23
	s_waitcnt lgkmcnt(0)
	v_mov_b32_e32 v14, v1
	s_and_saveexec_b32 s0, s1
; %bb.18:                               ; %.sink.split.i92
                                        ;   in Loop: Header=BB0_13 Depth=3
	v_mov_b32_e32 v14, v2
	v_mov_b32_e32 v2, v1
; %bb.19:                               ; %_Z18compare_and_switchiPfS_.exit95
                                        ;   in Loop: Header=BB0_13 Depth=3
	s_or_b32 exec_lo, exec_lo, s0
	s_ashr_i32 s1, s5, s22
	s_add_i32 s22, s22, 1
	s_ashr_i32 s0, s1, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s23, s1, s0
	s_xor_b32 s23, s23, s0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_f32_u32_e32 v1, s23
	s_sub_i32 s0, 0, s23
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v1, v1
	v_mul_lo_u32 v15, s0, v1
	s_add_i32 s0, s1, s7
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s24, s0, 1
	s_ashr_i32 s25, s0, 31
	s_add_i32 s0, s24, s25
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_xor_b32 s26, s0, s25
	v_mul_hi_u32 v15, v1, v15
	v_cvt_f32_u32_e32 v16, s26
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_rcp_iflag_f32_e32 v16, v16
	v_add_nc_u32_e32 v1, v1, v15
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v15, v12, v1
	v_mul_hi_u32 v1, v13, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v16, 0x4f7ffffe, v16
	v_cvt_u32_f32_e32 v16, v16
	v_mul_lo_u32 v15, v15, s23
	v_mul_lo_u32 v1, v1, s23
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v15, v12, v15
	v_sub_nc_u32_e32 v1, v13, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_subrev_nc_u32_e32 v17, s23, v15
	v_cmp_le_u32_e64 s0, s23, v15
	v_subrev_nc_u32_e32 v18, s23, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e64 v15, v15, v17, s0
	v_cmp_le_u32_e64 s0, s23, v1
	v_subrev_nc_u32_e32 v17, s23, v15
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e64 v1, v1, v18, s0
	v_cmp_le_u32_e64 s0, s23, v15
	v_subrev_nc_u32_e32 v18, s23, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_cndmask_b32_e64 v15, v15, v17, s0
	v_cmp_le_u32_e64 s0, s23, v1
	s_not_b32 s23, s24
	v_xor_b32_e32 v15, v15, v10
	s_delay_alu instid0(VALU_DEP_2)
	v_cndmask_b32_e64 v1, v1, v18, s0
	s_sub_i32 s0, 0, s26
	s_cmp_eq_u32 s19, s22
	v_mul_lo_u32 v17, s0, v16
	v_sub_nc_u32_e32 v15, v15, v10
	v_xor_b32_e32 v1, v1, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v18, 31, v15
	v_sub_nc_u32_e32 v1, v1, v10
	v_mul_hi_u32 v17, v16, v17
	v_lshrrev_b32_e32 v21, 31, v15
	v_sub_nc_u32_e32 v25, v9, v15
	v_add_nc_u32_e32 v20, v15, v18
	v_ashrrev_i32_e32 v19, 31, v1
	v_lshrrev_b32_e32 v22, 31, v1
	v_add_nc_u32_e32 v21, v15, v21
	v_add_nc_u32_e32 v16, v16, v17
	v_xor_b32_e32 v20, v20, v18
	v_add_nc_u32_e32 v17, v1, v19
	v_add_nc_u32_e32 v22, v1, v22
	v_and_b32_e32 v21, -2, v21
	v_xor_b32_e32 v18, s25, v18
	v_mul_hi_u32 v23, v20, v16
	v_xor_b32_e32 v17, v17, v19
	v_and_b32_e32 v22, -2, v22
	v_sub_nc_u32_e32 v15, v15, v21
	v_xor_b32_e32 v19, s25, v19
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_mul_hi_u32 v16, v17, v16
	v_sub_nc_u32_e32 v1, v1, v22
	v_mul_lo_u32 v24, v23, s26
	v_mul_lo_u32 v15, v15, s1
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_mul_lo_u32 v1, v1, s1
	v_mul_lo_u32 v26, v16, s26
	v_sub_nc_u32_e32 v20, v20, v24
	v_add_nc_u32_e32 v24, 1, v23
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshrrev_b32_e32 v28, 31, v1
	v_cmp_le_u32_e64 s0, s26, v20
	v_sub_nc_u32_e32 v17, v17, v26
	v_add_nc_u32_e32 v26, 1, v16
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_nc_u32_e32 v1, v1, v28
	v_cndmask_b32_e64 v23, v23, v24, s0
	v_subrev_nc_u32_e32 v24, s26, v20
	v_subrev_nc_u32_e32 v27, s26, v17
	v_cmp_le_u32_e64 s1, s26, v17
	v_lshrrev_b32_e32 v1, 1, v1
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_cndmask_b32_e64 v20, v20, v24, s0
	v_add_nc_u32_e32 v24, 1, v23
	v_cndmask_b32_e64 v16, v16, v26, s1
	v_cndmask_b32_e64 v17, v17, v27, s1
	v_lshrrev_b32_e32 v26, 31, v15
	v_cmp_le_u32_e64 s0, s26, v20
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v27, 1, v16
	v_add_nc_u32_e32 v15, v15, v26
	s_delay_alu instid0(VALU_DEP_3)
	v_cndmask_b32_e64 v20, v23, v24, s0
	v_cmp_le_u32_e64 s0, s26, v17
	v_and_b32_e32 v17, s23, v21
	v_and_b32_e32 v21, s23, v22
	v_lshrrev_b32_e32 v15, 1, v15
	v_xor_b32_e32 v20, v20, v18
	v_cndmask_b32_e64 v16, v16, v27, s0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v18, v20, v18
	v_xor_b32_e32 v16, v16, v19
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_or3_b32 v15, v17, v15, v18
	v_sub_nc_u32_e32 v16, v16, v19
	v_lshlrev_b32_e32 v19, 2, v25
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_or3_b32 v1, v21, v1, v16
	v_lshl_add_u32 v15, v15, 2, v19
	s_delay_alu instid0(VALU_DEP_2)
	v_lshl_add_u32 v1, v1, 2, v19
	ds_store_b32 v15, v14
	ds_store_b32 v1, v2
	s_cbranch_scc0 .LBB0_13
.LBB0_20:                               ; %._crit_edge
                                        ;   in Loop: Header=BB0_11 Depth=2
	v_mov_b32_e32 v1, v6
	v_mov_b32_e32 v9, v5
	s_add_i32 s21, s21, 1
	s_mov_b32 s0, s14
	s_cmp_lg_u32 s21, s14
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_11
.LBB0_21:                               ; %.preheader115
                                        ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ds_load_b64 v[10:11], v9
	v_ashrrev_i32_e32 v2, 31, v1
	v_add_nc_u32_e32 v9, 0x2000, v9
	s_add_i32 s0, s0, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	s_cmp_eq_u32 s0, 0
	v_lshlrev_b64 v[12:13], 2, v[1:2]
	v_add_nc_u32_e32 v1, 0x800, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v12, vcc_lo, s2, v12
	v_add_co_ci_u32_e32 v13, vcc_lo, s3, v13, vcc_lo
	s_waitcnt lgkmcnt(0)
	global_store_b64 v[12:13], v[10:11], off
	s_cbranch_scc0 .LBB0_21
; %bb.22:                               ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v3, s16, v3
	v_add_nc_u32_e32 v6, s18, v6
	s_add_i32 s17, s17, s18
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_le_i32_e32 vcc_lo, s6, v3
	s_or_b32 s13, vcc_lo, s13
	s_and_not1_b32 exec_lo, exec_lo, s13
	s_cbranch_execnz .LBB0_2
.LBB0_23:                               ; %._crit_edge124
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13stagingKerneliiiPf
		.amdhsa_group_segment_fixed_size 32768
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 29
		.amdhsa_next_free_sgpr 27
		.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	_Z13stagingKerneliiiPf, .Lfunc_end0-_Z13stagingKerneliiiPf
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 2040
; NumSgprs: 29
; NumVgprs: 29
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 32768 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 3
; NumSGPRsForWavesPerEU: 29
; NumVGPRsForWavesPerEU: 29
; 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
	.protected	_Z13cleanupKenerliPf    ; -- Begin function _Z13cleanupKenerliPf
	.globl	_Z13cleanupKenerliPf
	.p2align	8
	.type	_Z13cleanupKenerliPf,@function
_Z13cleanupKenerliPf:                   ; @_Z13cleanupKenerliPf
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b32 s6, s[0:1], 0x0
	s_add_u32 s2, s0, 16
	s_addc_u32 s3, s1, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s5, s4, 0xffff
	s_lshr_b32 s4, s6, 31
	v_mad_u64_u32 v[1:2], null, s15, s5, v[0:1]
	s_add_i32 s6, s6, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	s_ashr_i32 s4, s6, 1
	s_mov_b32 s6, exec_lo
	v_cmpx_gt_i32_e64 s4, v1
	s_cbranch_execz .LBB1_3
; %bb.1:                                ; %_Z18compare_and_switchiPfS_.exit.preheader
	s_load_b32 s6, s[2:3], 0x0
	s_load_b64 s[2:3], s[0:1], 0x8
	v_lshlrev_b32_e32 v2, 1, v1
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s1, s6, s5
	s_mov_b32 s6, 0
	s_lshl_b32 s5, s1, 1
.LBB1_2:                                ; %_Z18compare_and_switchiPfS_.exit
                                        ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v3, 31, v2
	v_add_nc_u32_e32 v1, s1, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[3:4], 2, v[2:3]
	v_cmp_le_i32_e64 s0, s4, v1
	v_add_nc_u32_e32 v2, s5, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	s_or_b32 s6, s0, s6
	v_add_co_u32 v3, vcc_lo, s2, v3
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v4, vcc_lo, s3, v4, vcc_lo
	global_load_b64 v[5:6], v[3:4], off
	s_waitcnt vmcnt(0)
	v_cmp_gt_f32_e32 vcc_lo, v5, v6
	v_dual_cndmask_b32 v7, v5, v6 :: v_dual_cndmask_b32 v8, v6, v5
	global_store_b64 v[3:4], v[7:8], off
	s_and_not1_b32 exec_lo, exec_lo, s6
	s_cbranch_execnz .LBB1_2
.LBB1_3:                                ; %Flow22
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13cleanupKenerliPf
		.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 9
		.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_end1:
	.size	_Z13cleanupKenerliPf, .Lfunc_end1-_Z13cleanupKenerliPf
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 224
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; 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:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 32768
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z13stagingKerneliiiPf
    .private_segment_fixed_size: 0
    .sgpr_count:     29
    .sgpr_spill_count: 0
    .symbol:         _Z13stagingKerneliiiPf.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     29
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .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:           _Z13cleanupKenerliPf
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z13cleanupKenerliPf.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
