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

#define THREADS 256 // 2^9
#define BLOCKS 32 // 2^15
#define NUM THREADS*BLOCKS

int seed_var =1239;

int random_int()
{
  return (int)rand()%(int)9 +1;
}

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

void print_array(int *arr1,int *arr2 ,int *arr3,int *arr4, int length)
{
  //srand(time(NULL));
  int i;
  for (i = 0; i < length; ++i) {
    //arr[i] = random_float();
    printf("%d\t%d\t%d\t%d\t%d\n",i+1,arr1[i],arr2[i],arr3[i],arr4[i]);
  }
}

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

__device__ void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
__global__ void bitonic_sort_step(int *d_pr, int *d_bt, int j, int k)
{
  int i, ixj; /* Sorting partners: i and ixj */
  i = threadIdx.x + blockDim.x * blockIdx.x;
  ixj = i^j;

  /* The threads with the lowest ids sort the array. */
  if ((ixj)>i) 
  {
    if ((i&k)==0) 
    {
      /* Sort ascending */
      if (d_pr[i]>d_pr[ixj]) 
      {
        /* exchange(i,ixj); */
        swap(&d_pr[i],&d_pr[ixj]);
        swap(&d_bt[i],&d_bt[ixj]);
      }
    }
    if ((i&k)!=0)
    {
      /* Sort descending */
      if (d_pr[i]<d_pr[ixj])
      {
        /* exchange(i,ixj); */
        swap(&d_pr[i], &d_pr[ixj]);
        swap(&d_bt[i], &d_bt[ixj]);
      }
    }
  }
}

void sorting_first(int *pr, int *bt)
{
  
  dim3 blocks(BLOCKS,1);
  dim3 threads(THREADS,1);

  int k;
  
  //Major step priority time basis sorting
  for(k = 2; k <= NUM; k <<= 1)
  {
    for (int j = k>>1; j > 0; j = j>>1)
    {
      bitonic_sort_step<<<blocks,threads>>>(pr,bt,j,k);
    }
  }
}


__global__ void inclusive_scan(int *X, int *Y, int N)
{
  extern __shared__ int XY[];
  int i = blockIdx.x * blockDim.x + threadIdx.x;
  // load input into __shared__ memory
  if(i<N)
  {  
    XY[threadIdx.x] =X[i];  
  }  
    /*Note here stride <= threadIdx.x, means that everytime the threads with threadIdx.x less than 
    stride do not participate in loop*/
  for(int stride = 1; stride <= threadIdx.x; stride *= 2) {
    __syncthreads();
    XY[threadIdx.x]+= XY[threadIdx.x - stride];
  }
  /*This is executed by all threads, so that they store the final prefix sum to 
  corresponding locations in global   memory*/
    Y[i]=XY[threadIdx.x];

// wait until all threads of this block writes the output for all prefix sum within the block 
  __syncthreads();
  if (threadIdx.x < blockIdx.x) //for 1st block onwards
  {
  //update the shared memory to keep prefix sum of last elements of previous block's
  XY[threadIdx.x] = Y[threadIdx.x * blockDim.x + THREADS - 1];
   }
   __syncthreads();
  for (int stride = 0; stride < blockIdx.x; stride++) 
  {    //add all previous las elements to this block elements
    Y[threadIdx.x + blockDim.x * blockIdx.x] += XY[stride];
    __syncthreads();
    
  }
}

__global__ void work_inefficient_scan_kernel(int *X, int *Y, int InputSize)
{
  __shared__ int XY[THREADS];
  int i= blockIdx.x*blockDim.x+ threadIdx.x;
  {
    XY[threadIdx.x] = X[i];
  }
  // the code below performs iterative scan on XY
  for (unsigned int stride = 1; stride <= threadIdx.x; stride *= 2)
  {
    __syncthreads();
    XY[threadIdx.x] += XY[threadIdx.x-stride];
  }
  Y[i] = XY[threadIdx.x];
}

__global__ void work_efficient_scan_kernel(int *X, int *Y, int InputSize)
{
  __shared__ int XY[THREADS];
  int i= blockIdx.x*blockDim.x+ threadIdx.x;
  if (i < InputSize)
  {
    XY[threadIdx.x] = X[i];
  }
  for (unsigned int stride = 1; stride < blockDim.x; stride *= 2)
  {
    __syncthreads();
    int index = (threadIdx.x+1) * 2* stride -1;
    if (index < blockDim.x)
    {
      XY[index] += XY[index -stride];
    }
  }
  for (int stride = THREADS/4; stride > 0; stride /= 2)
  {
    __syncthreads();
    int index = (threadIdx.x+1)*stride*2 -1;
    if(index + stride < THREADS)
    {
     XY[index + stride] += XY[index];
    }
  }
  __syncthreads();
  Y[i] = XY[threadIdx.x];

  //OWN CODE
  __syncthreads();
  if(threadIdx.x < blockIdx.x)
  {
    XY[threadIdx.x] = Y[threadIdx.x*blockDim.x + (blockDim.x-1)];
  }
  __syncthreads();
  for(unsigned int stride =0; stride < blockIdx.x; stride++)
  {
    Y[i] += XY[stride];
  }
  __syncthreads();
}

void scan_next(int *bt, int *tat)
{
  dim3 blocks(BLOCKS,1);
  dim3 threads(THREADS,1);

  work_efficient_scan_kernel<<<blocks, threads, THREADS * sizeof(int)>>>(bt, tat,NUM);
}

int main()
{
  //int h_pid[NUM],h_wt[NUM],h_tat[NUM],i,j,n,total=0,pos,temp,avg_wt,avg_tat;
  // printf("Enter Total Number of Process:");
  // scanf("%d",&n);

  //printf("\nEnter Burst Time and Priority\n");
  clock_t start, stop;
  int *h_bt = (int*) malloc( NUM * sizeof(int));
  int *h_pr = (int*) malloc( NUM * sizeof(int));
  int *h_tat = (int*) malloc( NUM * sizeof(int));
  int *h_wt = (int*) malloc( NUM * sizeof(int));
  array_fill(h_bt, NUM);
  array_fill(h_pr, NUM);
  printf("INITIAL\n");
  printf("\tPR\tBT\tWT\tTAT\n");
  print_array(h_pr,h_bt,h_wt,h_tat,NUM);

  int *d_bt, *d_pr, *d_wt, *d_tat;
  size_t size = NUM * sizeof(int);

  cudaMalloc((void**) &d_bt, size);
  cudaMalloc((void**) &d_pr, size);
  cudaMalloc((void**) &d_wt, size);
  cudaMalloc((void**) &d_tat, size);

  cudaMemcpy(d_bt, h_bt, size, cudaMemcpyHostToDevice);
  cudaMemcpy(d_pr, h_pr, size, cudaMemcpyHostToDevice);


  start = clock();
  sorting_first(d_pr, d_bt);
  
  scan_next(d_bt, d_tat);
  
  //work_inefficient_scan_kernel<<<BLOCKS,THREADS,size>>>(d_bt,d_tat,NUM);


  cudaMemcpy(h_bt, d_bt, size, cudaMemcpyDeviceToHost);
  cudaMemcpy(h_pr, d_pr, size, cudaMemcpyDeviceToHost);
  cudaMemcpy(&h_wt[1], d_tat, size, cudaMemcpyDeviceToHost);
  cudaMemcpy(h_tat, d_tat, size, cudaMemcpyDeviceToHost);

  cudaFree(d_pr);
  cudaFree(d_bt);
  cudaFree(d_wt);
  cudaFree(d_tat);
  
  stop = clock();

  printf("\nFINAL\n");
  printf("\tPR\tBT\tWT\tTAT\n");
  print_array(h_pr,h_bt,h_wt,h_tat,NUM);
  print_elapsed(start, stop);

} 
	.file	"tmpxft_0031960d_00000000-6_priority.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2037:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2037:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z10random_intv
	.type	_Z10random_intv, @function
_Z10random_intv:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	rand@PLT
	movl	$9, %ecx
	cltd
	idivl	%ecx
	leal	1(%rdx), %eax
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z10random_intv, .-_Z10random_intv
	.globl	_Z10array_fillPii
	.type	_Z10array_fillPii, @function
_Z10array_fillPii:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	seed_var(%rip), %eax
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leal	1(%rax), %edi
	xorl	%ebx, %ebx
	movl	%edi, seed_var(%rip)
	call	srand@PLT
.L5:
	cmpl	%ebx, %ebp
	jle	.L9
	call	_Z10random_intv
	movl	%eax, (%r12,%rbx,4)
	incq	%rbx
	jmp	.L5
.L9:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z10array_fillPii, .-_Z10array_fillPii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\t%d\t%d\t%d\t%d\n"
	.text
	.globl	_Z11print_arrayPiS_S_S_i
	.type	_Z11print_arrayPiS_S_S_i, @function
_Z11print_arrayPiS_S_S_i:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rcx, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdx, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%r8d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%r9
	.cfi_def_cfa_offset 64
.L11:
	cmpl	%ebx, %ebp
	jle	.L14
	movl	(%r12,%rbx,4), %ecx
	pushq	%rsi
	.cfi_def_cfa_offset 72
	leal	1(%rbx), %edx
	movl	$2, %edi
	movl	(%r15,%rbx,4), %eax
	leaq	.LC0(%rip), %rsi
	pushq	%rax
	.cfi_def_cfa_offset 80
	movl	0(%r13,%rbx,4), %r8d
	xorl	%eax, %eax
	movl	(%r14,%rbx,4), %r9d
	incq	%rbx
	call	__printf_chk@PLT
	popq	%rdi
	.cfi_def_cfa_offset 72
	popq	%r8
	.cfi_def_cfa_offset 64
	jmp	.L11
.L14:
	popq	%rax
	.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
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z11print_arrayPiS_S_S_i, .-_Z11print_arrayPiS_S_S_i
	.section	.rodata.str1.1
.LC2:
	.string	"Elapsed time: %.3fs\n"
	.text
	.globl	_Z13print_elapsedll
	.type	_Z13print_elapsedll, @function
_Z13print_elapsedll:
.LFB2030:
	.cfi_startproc
	endbr64
	subq	%rdi, %rsi
	movb	$1, %al
	movl	$2, %edi
	cvtsi2sdq	%rsi, %xmm0
	leaq	.LC2(%rip), %rsi
	divsd	.LC1(%rip), %xmm0
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2030:
	.size	_Z13print_elapsedll, .-_Z13print_elapsedll
	.globl	_Z4swapPiS_
	.type	_Z4swapPiS_, @function
_Z4swapPiS_:
.LFB2031:
	.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
.LFE2031:
	.size	_Z4swapPiS_, .-_Z4swapPiS_
	.globl	_Z41__device_stub__Z17bitonic_sort_stepPiS_iiPiS_ii
	.type	_Z41__device_stub__Z17bitonic_sort_stepPiS_iiPiS_ii, @function
_Z41__device_stub__Z17bitonic_sort_stepPiS_iiPiS_ii:
.LFB2059:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%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	.L18
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z17bitonic_sort_stepPiS_ii(%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
.L18:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z41__device_stub__Z17bitonic_sort_stepPiS_iiPiS_ii, .-_Z41__device_stub__Z17bitonic_sort_stepPiS_iiPiS_ii
	.globl	_Z17bitonic_sort_stepPiS_ii
	.type	_Z17bitonic_sort_stepPiS_ii, @function
_Z17bitonic_sort_stepPiS_ii:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z41__device_stub__Z17bitonic_sort_stepPiS_iiPiS_ii
	.cfi_endproc
.LFE2060:
	.size	_Z17bitonic_sort_stepPiS_ii, .-_Z17bitonic_sort_stepPiS_ii
	.globl	_Z13sorting_firstPiS_
	.type	_Z13sorting_firstPiS_, @function
_Z13sorting_firstPiS_:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$134217729, %eax
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	salq	$5, %rax
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	$13, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	$2, %ebx
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%rax, 8(%rsp)
	addq	$224, %rax
	movl	$1, 16(%rsp)
	movq	%rax, 20(%rsp)
	movl	$1, 28(%rsp)
.L27:
	movl	%ebx, %ebp
.L25:
	sarl	%ebp
	testl	%ebp, %ebp
	jle	.L30
	movl	28(%rsp), %ecx
	movq	20(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	8(%rsp), %rdi
	movl	16(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	movl	%ebx, %ecx
	movl	%ebp, %edx
	movq	%r14, %rsi
	movq	%r13, %rdi
	call	_Z41__device_stub__Z17bitonic_sort_stepPiS_iiPiS_ii
	jmp	.L25
.L30:
	addl	%ebx, %ebx
	decl	%r12d
	jne	.L27
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z13sorting_firstPiS_, .-_Z13sorting_firstPiS_
	.globl	_Z37__device_stub__Z14inclusive_scanPiS_iPiS_i
	.type	_Z37__device_stub__Z14inclusive_scanPiS_iPiS_i, @function
_Z37__device_stub__Z14inclusive_scanPiS_iPiS_i:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L31
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z14inclusive_scanPiS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L31:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L33
	call	__stack_chk_fail@PLT
.L33:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z37__device_stub__Z14inclusive_scanPiS_iPiS_i, .-_Z37__device_stub__Z14inclusive_scanPiS_iPiS_i
	.globl	_Z14inclusive_scanPiS_i
	.type	_Z14inclusive_scanPiS_i, @function
_Z14inclusive_scanPiS_i:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z14inclusive_scanPiS_iPiS_i
	.cfi_endproc
.LFE2062:
	.size	_Z14inclusive_scanPiS_i, .-_Z14inclusive_scanPiS_i
	.globl	_Z51__device_stub__Z28work_inefficient_scan_kernelPiS_iPiS_i
	.type	_Z51__device_stub__Z28work_inefficient_scan_kernelPiS_iPiS_i, @function
_Z51__device_stub__Z28work_inefficient_scan_kernelPiS_iPiS_i:
.LFB2063:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L36
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z28work_inefficient_scan_kernelPiS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L36:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2063:
	.size	_Z51__device_stub__Z28work_inefficient_scan_kernelPiS_iPiS_i, .-_Z51__device_stub__Z28work_inefficient_scan_kernelPiS_iPiS_i
	.globl	_Z28work_inefficient_scan_kernelPiS_i
	.type	_Z28work_inefficient_scan_kernelPiS_i, @function
_Z28work_inefficient_scan_kernelPiS_i:
.LFB2064:
	.cfi_startproc
	endbr64
	jmp	_Z51__device_stub__Z28work_inefficient_scan_kernelPiS_iPiS_i
	.cfi_endproc
.LFE2064:
	.size	_Z28work_inefficient_scan_kernelPiS_i, .-_Z28work_inefficient_scan_kernelPiS_i
	.globl	_Z49__device_stub__Z26work_efficient_scan_kernelPiS_iPiS_i
	.type	_Z49__device_stub__Z26work_efficient_scan_kernelPiS_iPiS_i, @function
_Z49__device_stub__Z26work_efficient_scan_kernelPiS_iPiS_i:
.LFB2065:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L41
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z26work_efficient_scan_kernelPiS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L41:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L43
	call	__stack_chk_fail@PLT
.L43:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2065:
	.size	_Z49__device_stub__Z26work_efficient_scan_kernelPiS_iPiS_i, .-_Z49__device_stub__Z26work_efficient_scan_kernelPiS_iPiS_i
	.globl	_Z26work_efficient_scan_kernelPiS_i
	.type	_Z26work_efficient_scan_kernelPiS_i, @function
_Z26work_efficient_scan_kernelPiS_i:
.LFB2066:
	.cfi_startproc
	endbr64
	jmp	_Z49__device_stub__Z26work_efficient_scan_kernelPiS_iPiS_i
	.cfi_endproc
.LFE2066:
	.size	_Z26work_efficient_scan_kernelPiS_i, .-_Z26work_efficient_scan_kernelPiS_i
	.globl	_Z9scan_nextPiS_
	.type	_Z9scan_nextPiS_, @function
_Z9scan_nextPiS_:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	$16777217, %edx
	movq	%rsi, %rbp
	xorl	%r9d, %r9d
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	movl	$134217729, %edi
	salq	$8, %rdx
	salq	$5, %rdi
	movl	$1024, %r8d
	movl	$1, %ecx
	movl	$1, %esi
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L46
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	movl	$8192, %edx
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_Z49__device_stub__Z26work_efficient_scan_kernelPiS_iPiS_i
.L46:
	.cfi_restore_state
	addq	$40, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z9scan_nextPiS_, .-_Z9scan_nextPiS_
	.section	.rodata.str1.1
.LC3:
	.string	"INITIAL\n"
.LC4:
	.string	"\tPR\tBT\tWT\tTAT\n"
.LC5:
	.string	"\nFINAL\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$32768, %edi
	leaq	.LC4(%rip), %r15
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movl	$32768, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movl	$32768, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movl	$32768, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movl	$8192, %esi
	movq	%rbp, %rdi
	movq	%rax, %r12
	call	_Z10array_fillPii
	movl	$8192, %esi
	movq	%rbx, %rdi
	call	_Z10array_fillPii
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r13, %rcx
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movl	$8192, %r8d
	movq	%rbx, %rdi
	call	_Z11print_arrayPiS_S_S_i
	leaq	24(%rsp), %rdi
	movl	$32768, %esi
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movl	$32768, %esi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movl	$32768, %esi
	call	cudaMalloc@PLT
	leaq	48(%rsp), %rdi
	movl	$32768, %esi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$32768, %edx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$32768, %edx
	call	cudaMemcpy@PLT
	call	clock@PLT
	movq	24(%rsp), %rsi
	movq	32(%rsp), %rdi
	movq	%rax, 8(%rsp)
	call	_Z13sorting_firstPiS_
	movq	48(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z9scan_nextPiS_
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	movl	$32768, %edx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$32768, %edx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rsi
	leaq	4(%r12), %rdi
	movl	$2, %ecx
	movl	$32768, %edx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rsi
	movl	$2, %ecx
	movq	%r13, %rdi
	movl	$32768, %edx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	call	clock@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r14
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	movq	%r13, %rcx
	movl	$8192, %r8d
	movq	%r12, %rdx
	call	_Z11print_arrayPiS_S_S_i
	movq	8(%rsp), %rdi
	movq	%r14, %rsi
	call	_Z13print_elapsedll
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L50
	call	__stack_chk_fail@PLT
.L50:
	addq	$72, %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
.LFE2034:
	.size	main, .-main
	.section	.rodata.str1.1
.LC6:
	.string	"_Z26work_efficient_scan_kernelPiS_i"
.LC7:
	.string	"_Z28work_inefficient_scan_kernelPiS_i"
.LC8:
	.string	"_Z14inclusive_scanPiS_i"
.LC9:
	.string	"_Z17bitonic_sort_stepPiS_ii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2068:
	.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	.LC6(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z26work_efficient_scan_kernelPiS_i(%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	.LC7(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z28work_inefficient_scan_kernelPiS_i(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC8(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z14inclusive_scanPiS_i(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC9(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z17bitonic_sort_stepPiS_ii(%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
.LFE2068:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	seed_var
	.data
	.align 4
	.type	seed_var, @object
	.size	seed_var, 4
seed_var:
	.long	1239
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1093567616
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#define THREADS 256 // 2^9
#define BLOCKS 32 // 2^15
#define NUM THREADS*BLOCKS

int seed_var =1239;

int random_int()
{
  return (int)rand()%(int)9 +1;
}

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

void print_array(int *arr1,int *arr2 ,int *arr3,int *arr4, int length)
{
  //srand(time(NULL));
  int i;
  for (i = 0; i < length; ++i) {
    //arr[i] = random_float();
    printf("%d\t%d\t%d\t%d\t%d\n",i+1,arr1[i],arr2[i],arr3[i],arr4[i]);
  }
}

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

__device__ void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
__global__ void bitonic_sort_step(int *d_pr, int *d_bt, int j, int k)
{
  int i, ixj; /* Sorting partners: i and ixj */
  i = threadIdx.x + blockDim.x * blockIdx.x;
  ixj = i^j;

  /* The threads with the lowest ids sort the array. */
  if ((ixj)>i) 
  {
    if ((i&k)==0) 
    {
      /* Sort ascending */
      if (d_pr[i]>d_pr[ixj]) 
      {
        /* exchange(i,ixj); */
        swap(&d_pr[i],&d_pr[ixj]);
        swap(&d_bt[i],&d_bt[ixj]);
      }
    }
    if ((i&k)!=0)
    {
      /* Sort descending */
      if (d_pr[i]<d_pr[ixj])
      {
        /* exchange(i,ixj); */
        swap(&d_pr[i], &d_pr[ixj]);
        swap(&d_bt[i], &d_bt[ixj]);
      }
    }
  }
}

void sorting_first(int *pr, int *bt)
{
  
  dim3 blocks(BLOCKS,1);
  dim3 threads(THREADS,1);

  int k;
  
  //Major step priority time basis sorting
  for(k = 2; k <= NUM; k <<= 1)
  {
    for (int j = k>>1; j > 0; j = j>>1)
    {
      bitonic_sort_step<<<blocks,threads>>>(pr,bt,j,k);
    }
  }
}


__global__ void inclusive_scan(int *X, int *Y, int N)
{
  extern __shared__ int XY[];
  int i = blockIdx.x * blockDim.x + threadIdx.x;
  // load input into __shared__ memory
  if(i<N)
  {  
    XY[threadIdx.x] =X[i];  
  }  
    /*Note here stride <= threadIdx.x, means that everytime the threads with threadIdx.x less than 
    stride do not participate in loop*/
  for(int stride = 1; stride <= threadIdx.x; stride *= 2) {
    __syncthreads();
    XY[threadIdx.x]+= XY[threadIdx.x - stride];
  }
  /*This is executed by all threads, so that they store the final prefix sum to 
  corresponding locations in global   memory*/
    Y[i]=XY[threadIdx.x];

// wait until all threads of this block writes the output for all prefix sum within the block 
  __syncthreads();
  if (threadIdx.x < blockIdx.x) //for 1st block onwards
  {
  //update the shared memory to keep prefix sum of last elements of previous block's
  XY[threadIdx.x] = Y[threadIdx.x * blockDim.x + THREADS - 1];
   }
   __syncthreads();
  for (int stride = 0; stride < blockIdx.x; stride++) 
  {    //add all previous las elements to this block elements
    Y[threadIdx.x + blockDim.x * blockIdx.x] += XY[stride];
    __syncthreads();
    
  }
}

__global__ void work_inefficient_scan_kernel(int *X, int *Y, int InputSize)
{
  __shared__ int XY[THREADS];
  int i= blockIdx.x*blockDim.x+ threadIdx.x;
  {
    XY[threadIdx.x] = X[i];
  }
  // the code below performs iterative scan on XY
  for (unsigned int stride = 1; stride <= threadIdx.x; stride *= 2)
  {
    __syncthreads();
    XY[threadIdx.x] += XY[threadIdx.x-stride];
  }
  Y[i] = XY[threadIdx.x];
}

__global__ void work_efficient_scan_kernel(int *X, int *Y, int InputSize)
{
  __shared__ int XY[THREADS];
  int i= blockIdx.x*blockDim.x+ threadIdx.x;
  if (i < InputSize)
  {
    XY[threadIdx.x] = X[i];
  }
  for (unsigned int stride = 1; stride < blockDim.x; stride *= 2)
  {
    __syncthreads();
    int index = (threadIdx.x+1) * 2* stride -1;
    if (index < blockDim.x)
    {
      XY[index] += XY[index -stride];
    }
  }
  for (int stride = THREADS/4; stride > 0; stride /= 2)
  {
    __syncthreads();
    int index = (threadIdx.x+1)*stride*2 -1;
    if(index + stride < THREADS)
    {
     XY[index + stride] += XY[index];
    }
  }
  __syncthreads();
  Y[i] = XY[threadIdx.x];

  //OWN CODE
  __syncthreads();
  if(threadIdx.x < blockIdx.x)
  {
    XY[threadIdx.x] = Y[threadIdx.x*blockDim.x + (blockDim.x-1)];
  }
  __syncthreads();
  for(unsigned int stride =0; stride < blockIdx.x; stride++)
  {
    Y[i] += XY[stride];
  }
  __syncthreads();
}

void scan_next(int *bt, int *tat)
{
  dim3 blocks(BLOCKS,1);
  dim3 threads(THREADS,1);

  work_efficient_scan_kernel<<<blocks, threads, THREADS * sizeof(int)>>>(bt, tat,NUM);
}

int main()
{
  //int h_pid[NUM],h_wt[NUM],h_tat[NUM],i,j,n,total=0,pos,temp,avg_wt,avg_tat;
  // printf("Enter Total Number of Process:");
  // scanf("%d",&n);

  //printf("\nEnter Burst Time and Priority\n");
  clock_t start, stop;
  int *h_bt = (int*) malloc( NUM * sizeof(int));
  int *h_pr = (int*) malloc( NUM * sizeof(int));
  int *h_tat = (int*) malloc( NUM * sizeof(int));
  int *h_wt = (int*) malloc( NUM * sizeof(int));
  array_fill(h_bt, NUM);
  array_fill(h_pr, NUM);
  printf("INITIAL\n");
  printf("\tPR\tBT\tWT\tTAT\n");
  print_array(h_pr,h_bt,h_wt,h_tat,NUM);

  int *d_bt, *d_pr, *d_wt, *d_tat;
  size_t size = NUM * sizeof(int);

  hipMalloc((void**) &d_bt, size);
  hipMalloc((void**) &d_pr, size);
  hipMalloc((void**) &d_wt, size);
  hipMalloc((void**) &d_tat, size);

  hipMemcpy(d_bt, h_bt, size, hipMemcpyHostToDevice);
  hipMemcpy(d_pr, h_pr, size, hipMemcpyHostToDevice);


  start = clock();
  sorting_first(d_pr, d_bt);
  
  scan_next(d_bt, d_tat);
  
  //work_inefficient_scan_kernel<<<BLOCKS,THREADS,size>>>(d_bt,d_tat,NUM);


  hipMemcpy(h_bt, d_bt, size, hipMemcpyDeviceToHost);
  hipMemcpy(h_pr, d_pr, size, hipMemcpyDeviceToHost);
  hipMemcpy(&h_wt[1], d_tat, size, hipMemcpyDeviceToHost);
  hipMemcpy(h_tat, d_tat, size, hipMemcpyDeviceToHost);

  hipFree(d_pr);
  hipFree(d_bt);
  hipFree(d_wt);
  hipFree(d_tat);
  
  stop = clock();

  printf("\nFINAL\n");
  printf("\tPR\tBT\tWT\tTAT\n");
  print_array(h_pr,h_bt,h_wt,h_tat,NUM);
  print_elapsed(start, stop);

} 
	.text
	.file	"priority.hip"
	.globl	_Z10random_intv                 # -- Begin function _Z10random_intv
	.type	_Z10random_intv,@function
_Z10random_intv:                        # @_Z10random_intv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	rand
	cltq
	imulq	$954437177, %rax, %rcx          # imm = 0x38E38E39
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$33, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,8), %ecx
	negl	%ecx
	addl	%ecx, %eax
	incl	%eax
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z10random_intv, .Lfunc_end0-_Z10random_intv
	.cfi_endproc
                                        # -- End function
	.globl	_Z10array_fillPii               # -- Begin function _Z10array_fillPii
	.type	_Z10array_fillPii,@function
_Z10array_fillPii:                      # @_Z10array_fillPii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movl	seed_var(%rip), %edi
	incl	%edi
	movl	%edi, seed_var(%rip)
	callq	srand
	testl	%ebp, %ebp
	jle	.LBB1_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$954437177, %rax, %rcx          # imm = 0x38E38E39
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$33, %rcx
	addl	%edx, %ecx
	leal	(%rcx,%rcx,8), %ecx
	negl	%ecx
	addl	%ecx, %eax
	incl	%eax
	movl	%eax, (%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB1_2
.LBB1_3:                                # %._crit_edge
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z10array_fillPii, .Lfunc_end1-_Z10array_fillPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z11print_arrayPiS_S_S_i        # -- Begin function _Z11print_arrayPiS_S_S_i
	.type	_Z11print_arrayPiS_S_S_i,@function
_Z11print_arrayPiS_S_S_i:               # @_Z11print_arrayPiS_S_S_i
	.cfi_startproc
# %bb.0:
	testl	%r8d, %r8d
	jle	.LBB2_4
# %bb.1:                                # %.lr.ph.preheader
	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
	movq	%rcx, %rbx
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %r12
	movl	%r8d, %ebp
	xorl	%eax, %eax
.LBB2_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	leaq	1(%rax), %r13
	movl	(%r12,%rax,4), %edx
	movl	(%r15,%rax,4), %ecx
	movl	(%r14,%rax,4), %r8d
	movl	(%rbx,%rax,4), %r9d
	movl	$.L.str, %edi
	movl	%r13d, %esi
	xorl	%eax, %eax
	callq	printf
	movq	%r13, %rax
	cmpq	%r13, %rbp
	jne	.LBB2_2
# %bb.3:
	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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB2_4:                                # %._crit_edge
	retq
.Lfunc_end2:
	.size	_Z11print_arrayPiS_S_S_i, .Lfunc_end2-_Z11print_arrayPiS_S_S_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z13print_elapsedll
.LCPI3_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z13print_elapsedll
	.type	_Z13print_elapsedll,@function
_Z13print_elapsedll:                    # @_Z13print_elapsedll
	.cfi_startproc
# %bb.0:
	subq	%rdi, %rsi
	cvtsi2sd	%rsi, %xmm0
	divsd	.LCPI3_0(%rip), %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	jmp	printf                          # TAILCALL
.Lfunc_end3:
	.size	_Z13print_elapsedll, .Lfunc_end3-_Z13print_elapsedll
	.cfi_endproc
                                        # -- End function
	.globl	_Z32__device_stub__bitonic_sort_stepPiS_ii # -- Begin function _Z32__device_stub__bitonic_sort_stepPiS_ii
	.type	_Z32__device_stub__bitonic_sort_stepPiS_ii,@function
_Z32__device_stub__bitonic_sort_stepPiS_ii: # @_Z32__device_stub__bitonic_sort_stepPiS_ii
	.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	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%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	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z17bitonic_sort_stepPiS_ii, %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_end4:
	.size	_Z32__device_stub__bitonic_sort_stepPiS_ii, .Lfunc_end4-_Z32__device_stub__bitonic_sort_stepPiS_ii
	.cfi_endproc
                                        # -- End function
	.globl	_Z13sorting_firstPiS_           # -- Begin function _Z13sorting_firstPiS_
	.type	_Z13sorting_firstPiS_,@function
_Z13sorting_firstPiS_:                  # @_Z13sorting_firstPiS_
	.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
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	$2, %ebp
	movabsq	$4294967328, %r15               # imm = 0x100000020
	leaq	224(%r15), %r12
.LBB5_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_4 Depth 2
	movl	%ebp, %r13d
	sarl	%r13d
	testl	%r13d, %r13d
	jle	.LBB5_2
.LBB5_4:                                # %.lr.ph
                                        #   Parent Loop BB5_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_6
# %bb.5:                                #   in Loop: Header=BB5_4 Depth=2
	movq	%r14, %rdi
	movq	%rbx, %rsi
	movl	%r13d, %edx
	movl	%ebp, %ecx
	callq	_Z32__device_stub__bitonic_sort_stepPiS_ii
.LBB5_6:                                #   in Loop: Header=BB5_4 Depth=2
	movl	%r13d, %eax
	shrl	%eax
	cmpl	$2, %r13d
	movl	%eax, %r13d
	jae	.LBB5_4
.LBB5_2:                                # %._crit_edge
                                        #   in Loop: Header=BB5_1 Depth=1
	addl	%ebp, %ebp
	cmpl	$8193, %ebp                     # imm = 0x2001
	jl	.LBB5_1
# %bb.3:
	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
	retq
.Lfunc_end5:
	.size	_Z13sorting_firstPiS_, .Lfunc_end5-_Z13sorting_firstPiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z29__device_stub__inclusive_scanPiS_i # -- Begin function _Z29__device_stub__inclusive_scanPiS_i
	.type	_Z29__device_stub__inclusive_scanPiS_i,@function
_Z29__device_stub__inclusive_scanPiS_i: # @_Z29__device_stub__inclusive_scanPiS_i
	.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	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z14inclusive_scanPiS_i, %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_end6:
	.size	_Z29__device_stub__inclusive_scanPiS_i, .Lfunc_end6-_Z29__device_stub__inclusive_scanPiS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z43__device_stub__work_inefficient_scan_kernelPiS_i # -- Begin function _Z43__device_stub__work_inefficient_scan_kernelPiS_i
	.type	_Z43__device_stub__work_inefficient_scan_kernelPiS_i,@function
_Z43__device_stub__work_inefficient_scan_kernelPiS_i: # @_Z43__device_stub__work_inefficient_scan_kernelPiS_i
	.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	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z28work_inefficient_scan_kernelPiS_i, %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_end7:
	.size	_Z43__device_stub__work_inefficient_scan_kernelPiS_i, .Lfunc_end7-_Z43__device_stub__work_inefficient_scan_kernelPiS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z41__device_stub__work_efficient_scan_kernelPiS_i # -- Begin function _Z41__device_stub__work_efficient_scan_kernelPiS_i
	.type	_Z41__device_stub__work_efficient_scan_kernelPiS_i,@function
_Z41__device_stub__work_efficient_scan_kernelPiS_i: # @_Z41__device_stub__work_efficient_scan_kernelPiS_i
	.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	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%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	$_Z26work_efficient_scan_kernelPiS_i, %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_end8:
	.size	_Z41__device_stub__work_efficient_scan_kernelPiS_i, .Lfunc_end8-_Z41__device_stub__work_efficient_scan_kernelPiS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z9scan_nextPiS_                # -- Begin function _Z9scan_nextPiS_
	.type	_Z9scan_nextPiS_,@function
_Z9scan_nextPiS_:                       # @_Z9scan_nextPiS_
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movabsq	$4294967328, %rdi               # imm = 0x100000020
	leaq	224(%rdi), %rdx
	movl	$1024, %r8d                     # imm = 0x400
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	je	.LBB9_2
# %bb.1:
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.LBB9_2:
	.cfi_def_cfa_offset 32
	movq	%r14, %rdi
	movq	%rbx, %rsi
	movl	$8192, %edx                     # imm = 0x2000
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_Z41__device_stub__work_efficient_scan_kernelPiS_i # TAILCALL
.Lfunc_end9:
	.size	_Z9scan_nextPiS_, .Lfunc_end9-_Z9scan_nextPiS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI10_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.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	$32768, %edi                    # imm = 0x8000
	callq	malloc
	movq	%rax, %rbx
	movl	$32768, %edi                    # imm = 0x8000
	callq	malloc
	movq	%rax, %r14
	movl	$32768, %edi                    # imm = 0x8000
	callq	malloc
	movq	%rax, %r15
	movl	$32768, %edi                    # imm = 0x8000
	callq	malloc
	movq	%rax, %r12
	movq	%rbx, %rdi
	movl	$8192, %esi                     # imm = 0x2000
	callq	_Z10array_fillPii
	movq	%r14, %rdi
	movl	$8192, %esi                     # imm = 0x2000
	callq	_Z10array_fillPii
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	xorl	%eax, %eax
.LBB10_1:                               # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	leaq	1(%rax), %r13
	movl	(%r14,%rax,4), %edx
	movl	(%rbx,%rax,4), %ecx
	movl	(%r12,%rax,4), %r8d
	movl	(%r15,%rax,4), %r9d
	movl	$.L.str, %edi
	movl	%r13d, %esi
	xorl	%eax, %eax
	callq	printf
	movq	%r13, %rax
	cmpq	$8192, %r13                     # imm = 0x2000
	jne	.LBB10_1
# %bb.2:                                # %_Z11print_arrayPiS_S_S_i.exit
	leaq	24(%rsp), %r13
	movl	$32768, %esi                    # imm = 0x8000
	movq	%r13, %rdi
	callq	hipMalloc
	leaq	32(%rsp), %rbp
	movl	$32768, %esi                    # imm = 0x8000
	movq	%rbp, %rdi
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
	movq	%rsp, %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
	movq	(%r13), %rdi
	movl	$32768, %edx                    # imm = 0x8000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rbp), %rdi
	movl	$32768, %edx                    # imm = 0x8000
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	callq	clock
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movq	(%rbp), %rdi
	movq	(%r13), %rsi
	callq	_Z13sorting_firstPiS_
	movq	(%r13), %rdi
	movq	%rsp, %rax
	movq	(%rax), %rsi
	callq	_Z9scan_nextPiS_
	movq	(%r13), %rsi
	movl	$32768, %edx                    # imm = 0x8000
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	(%rbp), %rsi
	movl	$32768, %edx                    # imm = 0x8000
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%r12, %rdi
	addq	$4, %rdi
	movq	%rsp, %rax
	movq	(%rax), %rsi
	movl	$32768, %edx                    # imm = 0x8000
	movl	$2, %ecx
	callq	hipMemcpy
	movq	%rsp, %r13
	movq	(%r13), %rsi
	movl	$32768, %edx                    # imm = 0x8000
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movq	(%rbp), %rdi
	callq	hipFree
	leaq	24(%rsp), %rax
	movq	(%rax), %rdi
	callq	hipFree
	leaq	16(%rsp), %rax
	movq	(%rax), %rdi
	callq	hipFree
	movq	(%r13), %rdi
	callq	hipFree
	callq	clock
	movq	%rax, %r13
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	xorl	%eax, %eax
.LBB10_3:                               # %.lr.ph.i30
                                        # =>This Inner Loop Header: Depth=1
	leaq	1(%rax), %rbp
	movl	(%r14,%rax,4), %edx
	movl	(%rbx,%rax,4), %ecx
	movl	(%r12,%rax,4), %r8d
	movl	(%r15,%rax,4), %r9d
	movl	$.L.str, %edi
	movl	%ebp, %esi
	xorl	%eax, %eax
	callq	printf
	movq	%rbp, %rax
	cmpq	$8192, %rbp                     # imm = 0x2000
	jne	.LBB10_3
# %bb.4:                                # %_Z11print_arrayPiS_S_S_i.exit34
	subq	8(%rsp), %r13                   # 8-byte Folded Reload
	cvtsi2sd	%r13, %xmm0
	divsd	.LCPI10_0(%rip), %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end10:
	.size	main, .Lfunc_end10-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB11_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB11_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z17bitonic_sort_stepPiS_ii, %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	$_Z14inclusive_scanPiS_i, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z28work_inefficient_scan_kernelPiS_i, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z26work_efficient_scan_kernelPiS_i, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %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_end11:
	.size	__hip_module_ctor, .Lfunc_end11-__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	.LBB12_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
.LBB12_2:
	retq
.Lfunc_end12:
	.size	__hip_module_dtor, .Lfunc_end12-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	seed_var,@object                # @seed_var
	.data
	.globl	seed_var
	.p2align	2, 0x0
seed_var:
	.long	1239                            # 0x4d7
	.size	seed_var, 4

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%d\t%d\t%d\t%d\t%d\n"
	.size	.L.str, 16

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Elapsed time: %.3fs\n"
	.size	.L.str.1, 21

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

	.type	_Z14inclusive_scanPiS_i,@object # @_Z14inclusive_scanPiS_i
	.globl	_Z14inclusive_scanPiS_i
	.p2align	3, 0x0
_Z14inclusive_scanPiS_i:
	.quad	_Z29__device_stub__inclusive_scanPiS_i
	.size	_Z14inclusive_scanPiS_i, 8

	.type	_Z28work_inefficient_scan_kernelPiS_i,@object # @_Z28work_inefficient_scan_kernelPiS_i
	.globl	_Z28work_inefficient_scan_kernelPiS_i
	.p2align	3, 0x0
_Z28work_inefficient_scan_kernelPiS_i:
	.quad	_Z43__device_stub__work_inefficient_scan_kernelPiS_i
	.size	_Z28work_inefficient_scan_kernelPiS_i, 8

	.type	_Z26work_efficient_scan_kernelPiS_i,@object # @_Z26work_efficient_scan_kernelPiS_i
	.globl	_Z26work_efficient_scan_kernelPiS_i
	.p2align	3, 0x0
_Z26work_efficient_scan_kernelPiS_i:
	.quad	_Z41__device_stub__work_efficient_scan_kernelPiS_i
	.size	_Z26work_efficient_scan_kernelPiS_i, 8

	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"_Z17bitonic_sort_stepPiS_ii"
	.size	.L__unnamed_1, 28

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z14inclusive_scanPiS_i"
	.size	.L__unnamed_2, 24

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z28work_inefficient_scan_kernelPiS_i"
	.size	.L__unnamed_3, 38

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"_Z26work_efficient_scan_kernelPiS_i"
	.size	.L__unnamed_4, 36

	.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,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"INITIAL"
	.size	.Lstr, 8

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"\nFINAL"
	.size	.Lstr.2, 7

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\tPR\tBT\tWT\tTAT"
	.size	.Lstr.3, 14

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z32__device_stub__bitonic_sort_stepPiS_ii
	.addrsig_sym _Z29__device_stub__inclusive_scanPiS_i
	.addrsig_sym _Z43__device_stub__work_inefficient_scan_kernelPiS_i
	.addrsig_sym _Z41__device_stub__work_efficient_scan_kernelPiS_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z17bitonic_sort_stepPiS_ii
	.addrsig_sym _Z14inclusive_scanPiS_i
	.addrsig_sym _Z28work_inefficient_scan_kernelPiS_i
	.addrsig_sym _Z26work_efficient_scan_kernelPiS_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z17bitonic_sort_stepPiS_ii ; -- Begin function _Z17bitonic_sort_stepPiS_ii
	.globl	_Z17bitonic_sort_stepPiS_ii
	.p2align	8
	.type	_Z17bitonic_sort_stepPiS_ii,@function
_Z17bitonic_sort_stepPiS_ii:            ; @_Z17bitonic_sort_stepPiS_ii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b64 s[4:5], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[8:9], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_xor_b32_e32 v2, s4, v8
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 v2, v8
	s_cbranch_execz .LBB0_7
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x0
	v_ashrrev_i32_e32 v9, 31, v8
	v_ashrrev_i32_e32 v3, 31, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[0:1], 2, v[8:9]
	v_lshlrev_b64 v[6:7], 2, v[2:3]
	v_and_b32_e32 v8, s5, v8
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v2, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v1, vcc_lo
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_u32 v4, vcc_lo, s0, v6
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v7, vcc_lo
	s_mov_b32 s0, 0
	s_clause 0x1
	global_load_b32 v9, v[2:3], off
	global_load_b32 v10, v[4:5], off
	s_mov_b32 s1, exec_lo
	v_cmpx_ne_u32_e32 0, v8
	s_xor_b32 s1, exec_lo, s1
	s_cbranch_execz .LBB0_3
; %bb.2:
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, v9, v10
	s_and_b32 s0, vcc_lo, exec_lo
.LBB0_3:                                ; %Flow
	s_and_not1_saveexec_b32 s1, s1
	s_cbranch_execz .LBB0_5
; %bb.4:
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, v9, v10
	s_and_not1_b32 s0, s0, exec_lo
	s_and_b32 s4, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s0, s0, s4
.LBB0_5:                                ; %Flow50
	s_or_b32 exec_lo, exec_lo, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 exec_lo, exec_lo, s0
	s_cbranch_execz .LBB0_7
; %bb.6:                                ; %.sink.split
	v_add_co_u32 v6, vcc_lo, s2, v6
	v_add_co_ci_u32_e32 v7, vcc_lo, s3, v7, vcc_lo
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	s_waitcnt vmcnt(0)
	s_clause 0x1
	global_store_b32 v[2:3], v10, off
	global_store_b32 v[4:5], v9, off
	s_clause 0x1
	global_load_b32 v2, v[6:7], off
	global_load_b32 v3, v[0:1], off
	s_waitcnt vmcnt(1)
	global_store_b32 v[0:1], v2, off
	s_waitcnt vmcnt(0)
	global_store_b32 v[6:7], v3, off
.LBB0_7:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z17bitonic_sort_stepPiS_ii
		.amdhsa_group_segment_fixed_size 0
		.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 11
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z17bitonic_sort_stepPiS_ii, .Lfunc_end0-_Z17bitonic_sort_stepPiS_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 348
; NumSgprs: 18
; NumVgprs: 11
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 11
; 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	_Z14inclusive_scanPiS_i ; -- Begin function _Z14inclusive_scanPiS_i
	.globl	_Z14inclusive_scanPiS_i
	.p2align	8
	.type	_Z14inclusive_scanPiS_i,@function
_Z14inclusive_scanPiS_i:                ; @_Z14inclusive_scanPiS_i
; %bb.0:
	s_clause 0x2
	s_load_b32 s4, s[0:1], 0x24
	s_load_b32 s5, s[0:1], 0x10
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_cmp_gt_i32_e32 vcc_lo, s5, v1
	v_ashrrev_i32_e32 v2, 31, v1
	s_and_saveexec_b32 s5, vcc_lo
	s_cbranch_execz .LBB1_2
; %bb.1:
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[1:2]
	v_add_co_u32 v3, vcc_lo, s0, v3
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo
	global_load_b32 v3, v[3:4], off
	v_lshl_add_u32 v4, v0, 2, 0
	s_waitcnt vmcnt(0)
	ds_store_b32 v4, v3
.LBB1_2:
	s_or_b32 exec_lo, exec_lo, s5
	s_mov_b32 s1, 0
	s_mov_b32 s0, exec_lo
                                        ; implicit-def: $vgpr3
	v_cmpx_ne_u32_e32 0, v0
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB1_6
; %bb.3:                                ; %.lr.ph
	v_lshl_add_u32 v4, v0, 2, 0
	s_mov_b32 s5, 1
.LBB1_4:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_subrev_nc_u32_e32 v3, s5, v0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_lshl_b32 s5, s5, 1
	v_lshl_add_u32 v3, v3, 2, 0
	v_cmp_gt_u32_e32 vcc_lo, s5, v0
	ds_load_b32 v3, v3
	ds_load_b32 v5, v4
	s_or_b32 s1, vcc_lo, s1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v3, v5, v3
	ds_store_b32 v4, v3
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB1_4
; %bb.5:                                ; %Flow33
	s_or_b32 exec_lo, exec_lo, s1
.LBB1_6:                                ; %Flow34
	s_and_not1_saveexec_b32 s0, s0
	s_cbranch_execz .LBB1_8
; %bb.7:                                ; %.._crit_edge_crit_edge
	v_mov_b32_e32 v3, 0
	ds_load_b32 v3, v3
.LBB1_8:                                ; %._crit_edge
	s_or_b32 exec_lo, exec_lo, s0
	v_lshlrev_b64 v[4:5], 2, v[1:2]
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v4, vcc_lo, s2, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s3, v5, vcc_lo
	s_waitcnt lgkmcnt(0)
	global_store_b32 v[4:5], v3, off
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e64 s15, v0
	s_cbranch_execz .LBB1_10
; %bb.9:
	v_mul_u32_u24_e32 v2, s4, v0
	v_lshl_add_u32 v0, v0, 2, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_lshlrev_b32_e32 v2, 2, v2
	global_load_b32 v2, v2, s[2:3] offset:1020
	s_waitcnt vmcnt(0)
	ds_store_b32 v0, v2
.LBB1_10:
	s_or_b32 exec_lo, exec_lo, s0
	s_cmp_eq_u32 s15, 0
	s_mov_b32 s0, 0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB1_13
; %bb.11:                               ; %.lr.ph21
	v_mov_b32_e32 v2, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_add_co_u32 v0, vcc_lo, s2, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
.LBB1_12:                               ; =>This Inner Loop Header: Depth=1
	global_load_b32 v2, v[0:1], off
	v_mov_b32_e32 v3, s0
	s_add_i32 s15, s15, -1
	s_add_i32 s0, s0, 4
	s_cmp_eq_u32 s15, 0
	ds_load_b32 v3, v3
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_add_nc_u32_e32 v2, v2, v3
	global_store_b32 v[0:1], v2, off
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB1_12
.LBB1_13:                               ; %._crit_edge22
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z14inclusive_scanPiS_i
		.amdhsa_group_segment_fixed_size 0
		.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 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z14inclusive_scanPiS_i, .Lfunc_end1-_Z14inclusive_scanPiS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 516
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z28work_inefficient_scan_kernelPiS_i ; -- Begin function _Z28work_inefficient_scan_kernelPiS_i
	.globl	_Z28work_inefficient_scan_kernelPiS_i
	.p2align	8
	.type	_Z28work_inefficient_scan_kernelPiS_i,@function
_Z28work_inefficient_scan_kernelPiS_i:  ; @_Z28work_inefficient_scan_kernelPiS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x24
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	v_add_co_u32 v3, vcc_lo, s0, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s1, v2, vcc_lo
	s_mov_b32 s1, 0
	s_mov_b32 s0, exec_lo
	global_load_b32 v4, v[3:4], off
	v_lshlrev_b32_e32 v3, 2, v0
	s_waitcnt vmcnt(0)
	ds_store_b32 v3, v4
	v_cmpx_ne_u32_e32 0, v0
	s_cbranch_execz .LBB2_4
; %bb.1:                                ; %.lr.ph.preheader
	s_mov_b32 s4, 1
.LBB2_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_subrev_nc_u32_e32 v4, s4, v0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_lshl_b32 s4, s4, 1
	v_lshlrev_b32_e32 v4, 2, v4
	v_cmp_gt_u32_e32 vcc_lo, s4, v0
	ds_load_b32 v4, v4
	ds_load_b32 v5, v3
	s_or_b32 s1, vcc_lo, s1
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v4, v5, v4
	ds_store_b32 v3, v4
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB2_2
; %bb.3:                                ; %Flow
	s_or_b32 exec_lo, exec_lo, s1
.LBB2_4:                                ; %Flow15
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s0
	v_add_co_u32 v0, vcc_lo, s2, v1
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v2, vcc_lo
	global_store_b32 v[0:1], v4, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z28work_inefficient_scan_kernelPiS_i
		.amdhsa_group_segment_fixed_size 1024
		.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 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z28work_inefficient_scan_kernelPiS_i, .Lfunc_end2-_Z28work_inefficient_scan_kernelPiS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 244
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 1024 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z26work_efficient_scan_kernelPiS_i ; -- Begin function _Z26work_efficient_scan_kernelPiS_i
	.globl	_Z26work_efficient_scan_kernelPiS_i
	.p2align	8
	.type	_Z26work_efficient_scan_kernelPiS_i,@function
_Z26work_efficient_scan_kernelPiS_i:    ; @_Z26work_efficient_scan_kernelPiS_i
; %bb.0:
	s_clause 0x2
	s_load_b32 s4, s[0:1], 0x24
	s_load_b32 s5, s[0:1], 0x10
	s_load_b128 s[0:3], s[0:1], 0x0
	v_lshlrev_b32_e32 v5, 2, v0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_cmp_gt_i32_e32 vcc_lo, s5, v1
	v_ashrrev_i32_e32 v2, 31, v1
	s_and_saveexec_b32 s5, vcc_lo
	s_cbranch_execz .LBB3_2
; %bb.1:
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[1:2]
	v_add_co_u32 v3, vcc_lo, s0, v3
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s1, v4, vcc_lo
	global_load_b32 v3, v[3:4], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v5, v3
.LBB3_2:
	s_or_b32 exec_lo, exec_lo, s5
	v_lshl_add_u32 v6, v0, 1, 2
	s_cmp_lt_u32 s4, 2
	s_mov_b32 s0, 1
	s_cbranch_scc1 .LBB3_6
.LBB3_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_mad_u64_u32 v[3:4], null, s0, v6, -1
	s_mov_b32 s1, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e64 s4, v3
	s_cbranch_execz .LBB3_5
; %bb.4:                                ;   in Loop: Header=BB3_3 Depth=1
	v_subrev_nc_u32_e32 v4, s0, v3
	v_lshlrev_b32_e32 v3, 2, v3
	s_delay_alu instid0(VALU_DEP_2)
	v_lshlrev_b32_e32 v4, 2, v4
	ds_load_b32 v4, v4
	ds_load_b32 v7, v3
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v4, v7, v4
	ds_store_b32 v3, v4
.LBB3_5:                                ;   in Loop: Header=BB3_3 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	s_lshl_b32 s0, s0, 1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_ge_u32 s0, s4
	s_cbranch_scc0 .LBB3_3
.LBB3_6:                                ; %.preheader.preheader
	s_mov_b32 s0, 64
.LBB3_7:                                ; %.preheader
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u32_u24 v3, v6, s0, -1
	s_mov_b32 s1, exec_lo
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_add_nc_u32_e32 v4, s0, v3
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e32 0x100, v4
	s_cbranch_execz .LBB3_9
; %bb.8:                                ;   in Loop: Header=BB3_7 Depth=1
	v_lshlrev_b32_e32 v3, 2, v3
	v_lshlrev_b32_e32 v4, 2, v4
	ds_load_b32 v3, v3
	ds_load_b32 v7, v4
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v3, v7, v3
	ds_store_b32 v4, v3
.LBB3_9:                                ;   in Loop: Header=BB3_7 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	s_lshr_b32 s1, s0, 1
	s_cmp_lt_u32 s0, 2
	s_mov_b32 s0, s1
	s_cbranch_scc0 .LBB3_7
; %bb.10:
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	ds_load_b32 v3, v5
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_mov_b32 s0, exec_lo
	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
	s_waitcnt lgkmcnt(0)
	global_store_b32 v[1:2], v3, off
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_u32_e64 s15, v0
	s_cbranch_execz .LBB3_12
; %bb.11:
	v_mul_u32_u24_e32 v0, s4, v0
	v_mov_b32_e32 v4, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add3_u32 v3, s4, -1, v0
	v_lshlrev_b64 v[3:4], 2, v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v3, vcc_lo, s2, v3
	v_add_co_ci_u32_e32 v4, vcc_lo, s3, v4, vcc_lo
	global_load_b32 v0, v[3:4], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v5, v0
.LBB3_12:
	s_or_b32 exec_lo, exec_lo, s0
	s_cmp_eq_u32 s15, 0
	s_mov_b32 s0, 0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB3_16
; %bb.13:                               ; %.lr.ph36
	global_load_b32 v0, v[1:2], off
.LBB3_14:                               ; =>This Inner Loop Header: Depth=1
	v_mov_b32_e32 v3, s0
	s_add_i32 s15, s15, -1
	s_add_i32 s0, s0, 4
	s_cmp_eq_u32 s15, 0
	ds_load_b32 v3, v3
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_add_nc_u32_e32 v0, v0, v3
	s_cbranch_scc0 .LBB3_14
; %bb.15:                               ; %._crit_edge
	global_store_b32 v[1:2], v0, off
.LBB3_16:
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z26work_efficient_scan_kernelPiS_i
		.amdhsa_group_segment_fixed_size 1024
		.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 8
		.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_end3:
	.size	_Z26work_efficient_scan_kernelPiS_i, .Lfunc_end3-_Z26work_efficient_scan_kernelPiS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 632
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 1024 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .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: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z17bitonic_sort_stepPiS_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z17bitonic_sort_stepPiS_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     11
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .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
      - .offset:         144
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z14inclusive_scanPiS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z14inclusive_scanPiS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .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: 1024
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z28work_inefficient_scan_kernelPiS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z28work_inefficient_scan_kernelPiS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .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: 1024
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z26work_efficient_scan_kernelPiS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z26work_efficient_scan_kernelPiS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
