#include<stdio.h>
#include<stdlib.h>
#include<sys/time.h>
#include<pthread.h>
#include<math.h>

#define MAX_THREAD 1024

#define USAGE_EXIT(s) do{ \
                            printf("Usage: %s <# of elements> <random seed> \n %s\n", argv[0], s); \
                            exit(-1);\
                    }while(0);

#define CUDA_ERROR_EXIT(str) do{\
                                cudaError err = cudaGetLastError();\
                                if( err != cudaSuccess){\
                                         printf("Cuda Error: '%s' for %s\n", cudaGetErrorString(err), str);\
                                         exit(-1);\
                                }\
                             }while(0);

#define TDIFF(start, end) ((end.tv_sec - start.tv_sec) * 1000000UL + (end.tv_usec - start.tv_usec))

__global__ void calculate(long long int *da, const long long int max_in, const long long int in, const long long int prev, long long int *d_ans, const long long int ctr, const long long int u){
      long long int i = blockDim.x * blockIdx.x + threadIdx.x;
      long long int l =  i*in + prev;
      long long int r =  (i+1)*in-1 + prev;
      if(r > max_in)
           return;
      if(i%2==0){
        da[l]=da[l]^da[r];
      }
      else{
        da[r]=da[l]^da[r];
      }
      if(prev!=0 && ctr==u) da[0] = da[0]^da[prev];
      if(ctr==u)
        *d_ans = da[0];
}

int main(int argc, char **argv)
{
  struct timeval start, end;
  long long int *a, num_elements, ctr;
  long long int *ans;
  long long int *d_ans;

  if(argc !=3)
           USAGE_EXIT("not enough parameters");

  num_elements = atoi(argv[1]);
  if(num_elements <=0)
          USAGE_EXIT("invalid num elements");

  long long int SEED = atoi(argv[2]);
  long long int size = num_elements * sizeof(long long int);

  a = (long long int *)malloc(size);
  ans = (long long int *)malloc(sizeof(long long int));
  if(!a){
          USAGE_EXIT("invalid num elements, not enough memory");
  }

  srand(SEED);

  for(ctr=0; ctr<num_elements; ++ctr)
        a[ctr] = random();
  long long int * da;
  cudaMalloc(&da,  size);
  CUDA_ERROR_EXIT("cudaMalloc1");

  cudaMalloc(&d_ans, sizeof(long long int));
  CUDA_ERROR_EXIT("cudaMalloc2");

  cudaMemcpy(da, a, size, cudaMemcpyHostToDevice);
  CUDA_ERROR_EXIT("memcpy1");

  gettimeofday(&start, NULL);
  long long int prev = 0;
  long long int max_in = 0;
  long long int flag=0;
  long long int num = num_elements;
  for(;;){
    if(num_elements==1){
      flag=1;
      break;
    }
    if(num_elements<=0)
      break;
    long long int u = (long long int)log2((double)num_elements);
    long long int x = pow(2,u);
    max_in = prev + x -1;
    for(ctr=1; ctr<=u; ++ctr){
      long long int in = pow(2,ctr);
      long long int threads = num_elements/in;
      if(threads>MAX_THREAD)threads = MAX_THREAD;
      long long int blocks = num_elements/threads;
      calculate<<<blocks, threads>>>(da, max_in, in, prev, d_ans, ctr, u);
      CUDA_ERROR_EXIT("kernel invocation");
    }
    prev += pow(2,u);
    num_elements = num - prev;
  }

  cudaMemcpy(ans, d_ans, sizeof(long long int), cudaMemcpyDeviceToHost);
  CUDA_ERROR_EXIT("memcpy2");

  if(flag==1 && num==1){
    (*ans) = 0^a[num-1];
  }
  else if(flag==1){
    (*ans) = (*ans)^a[num-1];
  }
  printf("XOR = %lld\n", (*ans));

  gettimeofday(&end, NULL);
  printf("Time taken = %ld microsecs\n", TDIFF(start, end));
  free(a);
  cudaFree(da);
  free(ans);
  cudaFree(d_ans);
}

	.file	"tmpxft_00281c2f_00000000-6_qn2.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2039:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2039:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z35__device_stub__Z9calculatePxxxxS_xxPxxxxS_xx
	.type	_Z35__device_stub__Z9calculatePxxxxS_xxPxxxxS_xx, @function
_Z35__device_stub__Z9calculatePxxxxS_xxPxxxxS_xx:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%r9, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 144(%rsp)
	movq	%rsp, %rax
	movq	%rax, 152(%rsp)
	leaq	192(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z9calculatePxxxxS_xx(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L2:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z35__device_stub__Z9calculatePxxxxS_xxPxxxxS_xx, .-_Z35__device_stub__Z9calculatePxxxxS_xxPxxxxS_xx
	.globl	_Z9calculatePxxxxS_xx
	.type	_Z9calculatePxxxxS_xx, @function
_Z9calculatePxxxxS_xx:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z9calculatePxxxxS_xxPxxxxS_xx
	.cfi_endproc
.LFE2062:
	.size	_Z9calculatePxxxxS_xx, .-_Z9calculatePxxxxS_xx
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"not enough parameters"
.LC1:
	.string	"Usage: %s <# of elements> <random seed> \n %s\n"
.LC2:
	.string	"invalid num elements"
.LC3:
	.string	"invalid num elements, not enough memory"
.LC4:
	.string	"cudaMalloc1"
.LC5:
	.string	"Cuda Error: '%s' for %s\n"
.LC6:
	.string	"cudaMalloc2"
.LC7:
	.string	"memcpy1"
.LC9:
	.string	"kernel invocation"
.LC10:
	.string	"memcpy2"
.LC11:
	.string	"XOR = %lld\n"
.LC12:
	.string	"Time taken = %ld microsecs\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2036:
	.cfi_startproc
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	je	.L9
	movq	(%rsi), %rdx
	leaq	.LC0(%rip), %rcx
	movl	$2, %edi
	leaq	.LC1(%rip), %rsi
	jmp	.L38
.L9:
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movslq	%eax, %r13
	testq	%r13, %r13
	jg	.L10
	leaq	.LC2(%rip), %rcx
.L39:
	movq	(%rbx), %rdx
	leaq	.LC1(%rip), %rsi
.L40:
	movl	$2, %edi
	xorl	%eax, %eax
.L38:
	call	__printf_chk@PLT
	orl	$-1, %edi
	call	exit@PLT
.L10:
	movq	16(%rbx), %rdi
	call	atoi@PLT
	movl	%eax, %r14d
	leaq	0(,%r13,8), %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movl	$8, %edi
	movq	%rax, %r12
	call	malloc@PLT
	leaq	.LC3(%rip), %rcx
	movq	%rax, %rbp
	testq	%r12, %r12
	je	.L39
	movl	%r14d, %edi
	xorl	%ebx, %ebx
	call	srand@PLT
.L12:
	call	random@PLT
	movq	%rax, (%r12,%rbx,8)
	incq	%rbx
	cmpq	%rbx, %r13
	jg	.L12
	movq	8(%rsp), %rsi
	leaq	64(%rsp), %rdi
	call	cudaMalloc@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L13
	call	cudaGetErrorString@PLT
	leaq	.LC4(%rip), %rcx
	movq	%rax, %rdx
	jmp	.L41
.L13:
	leaq	56(%rsp), %rdi
	movl	$8, %esi
	call	cudaMalloc@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L14
	call	cudaGetErrorString@PLT
	leaq	.LC6(%rip), %rcx
	movq	%rax, %rdx
	jmp	.L41
.L14:
	movq	64(%rsp), %rdi
	movq	8(%rsp), %rdx
	movl	$1, %ecx
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L15
	call	cudaGetErrorString@PLT
	leaq	.LC7(%rip), %rcx
	movq	%rax, %rdx
	jmp	.L41
.L15:
	leaq	88(%rsp), %rdi
	xorl	%esi, %esi
	movq	%r13, %rbx
	xorl	%r14d, %r14d
	call	gettimeofday@PLT
.L21:
	cmpq	$1, %rbx
	je	.L16
	testq	%rbx, %rbx
	jle	.L26
	cvtsi2sdq	%rbx, %xmm0
	call	log2@PLT
	cvttsd2siq	%xmm0, %r15
	movsd	.LC8(%rip), %xmm0
	cvtsi2sdq	%r15, %xmm2
	movaps	%xmm2, %xmm1
	movsd	%xmm2, 40(%rsp)
	call	pow@PLT
	movq	$1, 16(%rsp)
	cvttsd2siq	%xmm0, %rax
	leaq	-1(%r14,%rax), %rax
	movq	%rax, 32(%rsp)
.L17:
	cmpq	%r15, 16(%rsp)
	jg	.L42
	cvtsi2sdq	16(%rsp), %xmm1
	movsd	.LC8(%rip), %xmm0
	call	pow@PLT
	movabsq	$4294967297, %rsi
	cvttsd2siq	%xmm0, %rax
	movq	%rsi, 108(%rsp)
	movq	%rsi, 80(%rsp)
	movl	84(%rsp), %esi
	movq	%rax, 24(%rsp)
	movq	%rbx, %rax
	cqto
	idivq	24(%rsp)
	movl	$1024, %edx
	movq	%rdx, %rcx
	cmpq	%rdx, %rax
	cmovle	%rax, %rcx
	movq	%rbx, %rax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	cqto
	idivq	%rcx
	movl	%ecx, 104(%rsp)
	movl	112(%rsp), %ecx
	movq	104(%rsp), %rdx
	movl	%eax, 76(%rsp)
	movq	76(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	pushq	%rax
	.cfi_def_cfa_offset 200
	movq	%r14, %rcx
	pushq	%r15
	.cfi_def_cfa_offset 208
	movq	32(%rsp), %r9
	movq	72(%rsp), %r8
	movq	40(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	80(%rsp), %rdi
	call	_Z35__device_stub__Z9calculatePxxxxS_xxPxxxxS_xx
	popq	%rdx
	.cfi_def_cfa_offset 200
	popq	%rcx
	.cfi_def_cfa_offset 192
.L18:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L19
	call	cudaGetErrorString@PLT
	leaq	.LC9(%rip), %rcx
	movq	%rax, %rdx
	jmp	.L41
.L19:
	incq	16(%rsp)
	jmp	.L17
.L42:
	movsd	40(%rsp), %xmm1
	movsd	.LC8(%rip), %xmm0
	movq	%r13, %rbx
	call	pow@PLT
	movaps	%xmm0, %xmm1
	cvtsi2sdq	%r14, %xmm0
	addsd	%xmm1, %xmm0
	cvttsd2siq	%xmm0, %r14
	subq	%r14, %rbx
	jmp	.L21
.L26:
	xorl	%ebx, %ebx
.L16:
	movq	56(%rsp), %rsi
	movq	%rbp, %rdi
	movl	$2, %ecx
	movl	$8, %edx
	call	cudaMemcpy@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L22
	call	cudaGetErrorString@PLT
	leaq	.LC10(%rip), %rcx
	movq	%rax, %rdx
.L41:
	leaq	.LC5(%rip), %rsi
	jmp	.L40
.L22:
	decq	%r13
	jne	.L23
	testb	$1, %bl
	je	.L23
	movq	8(%rsp), %rax
	movq	-8(%r12,%rax), %rax
	movq	%rax, 0(%rbp)
	jmp	.L24
.L23:
	decq	%rbx
	jne	.L24
	movq	8(%rsp), %rax
	movq	-8(%r12,%rax), %rax
	xorq	%rax, 0(%rbp)
.L24:
	movq	0(%rbp), %rdx
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%esi, %esi
	leaq	104(%rsp), %rdi
	call	gettimeofday@PLT
	movq	104(%rsp), %rdx
	subq	88(%rsp), %rdx
	xorl	%eax, %eax
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	imulq	$1000000, %rdx, %rdx
	addq	112(%rsp), %rdx
	subq	96(%rsp), %rdx
	call	__printf_chk@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$136, %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
.LFE2036:
	.size	main, .-main
	.section	.rodata.str1.1
.LC13:
	.string	"_Z9calculatePxxxxS_xx"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2064:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC13(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z9calculatePxxxxS_xx(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2064:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC8:
	.long	0
	.long	1073741824
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


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

#define MAX_THREAD 1024

#define USAGE_EXIT(s) do{ \
                            printf("Usage: %s <# of elements> <random seed> \n %s\n", argv[0], s); \
                            exit(-1);\
                    }while(0);

#define CUDA_ERROR_EXIT(str) do{\
                                hipError_t err = hipGetLastError();\
                                if( err != hipSuccess){\
                                         printf("Cuda Error: '%s' for %s\n", hipGetErrorString(err), str);\
                                         exit(-1);\
                                }\
                             }while(0);

#define TDIFF(start, end) ((end.tv_sec - start.tv_sec) * 1000000UL + (end.tv_usec - start.tv_usec))

__global__ void calculate(long long int *da, const long long int max_in, const long long int in, const long long int prev, long long int *d_ans, const long long int ctr, const long long int u){
      long long int i = blockDim.x * blockIdx.x + threadIdx.x;
      long long int l =  i*in + prev;
      long long int r =  (i+1)*in-1 + prev;
      if(r > max_in)
           return;
      if(i%2==0){
        da[l]=da[l]^da[r];
      }
      else{
        da[r]=da[l]^da[r];
      }
      if(prev!=0 && ctr==u) da[0] = da[0]^da[prev];
      if(ctr==u)
        *d_ans = da[0];
}

int main(int argc, char **argv)
{
  struct timeval start, end;
  long long int *a, num_elements, ctr;
  long long int *ans;
  long long int *d_ans;

  if(argc !=3)
           USAGE_EXIT("not enough parameters");

  num_elements = atoi(argv[1]);
  if(num_elements <=0)
          USAGE_EXIT("invalid num elements");

  long long int SEED = atoi(argv[2]);
  long long int size = num_elements * sizeof(long long int);

  a = (long long int *)malloc(size);
  ans = (long long int *)malloc(sizeof(long long int));
  if(!a){
          USAGE_EXIT("invalid num elements, not enough memory");
  }

  srand(SEED);

  for(ctr=0; ctr<num_elements; ++ctr)
        a[ctr] = random();
  long long int * da;
  hipMalloc(&da,  size);
  CUDA_ERROR_EXIT("cudaMalloc1");

  hipMalloc(&d_ans, sizeof(long long int));
  CUDA_ERROR_EXIT("cudaMalloc2");

  hipMemcpy(da, a, size, hipMemcpyHostToDevice);
  CUDA_ERROR_EXIT("memcpy1");

  gettimeofday(&start, NULL);
  long long int prev = 0;
  long long int max_in = 0;
  long long int flag=0;
  long long int num = num_elements;
  for(;;){
    if(num_elements==1){
      flag=1;
      break;
    }
    if(num_elements<=0)
      break;
    long long int u = (long long int)log2((double)num_elements);
    long long int x = pow(2,u);
    max_in = prev + x -1;
    for(ctr=1; ctr<=u; ++ctr){
      long long int in = pow(2,ctr);
      long long int threads = num_elements/in;
      if(threads>MAX_THREAD)threads = MAX_THREAD;
      long long int blocks = num_elements/threads;
      calculate<<<blocks, threads>>>(da, max_in, in, prev, d_ans, ctr, u);
      CUDA_ERROR_EXIT("kernel invocation");
    }
    prev += pow(2,u);
    num_elements = num - prev;
  }

  hipMemcpy(ans, d_ans, sizeof(long long int), hipMemcpyDeviceToHost);
  CUDA_ERROR_EXIT("memcpy2");

  if(flag==1 && num==1){
    (*ans) = 0^a[num-1];
  }
  else if(flag==1){
    (*ans) = (*ans)^a[num-1];
  }
  printf("XOR = %lld\n", (*ans));

  gettimeofday(&end, NULL);
  printf("Time taken = %ld microsecs\n", TDIFF(start, end));
  free(a);
  hipFree(da);
  free(ans);
  hipFree(d_ans);
}

	.text
	.file	"qn2.hip"
	.globl	_Z24__device_stub__calculatePxxxxS_xx # -- Begin function _Z24__device_stub__calculatePxxxxS_xx
	.type	_Z24__device_stub__calculatePxxxxS_xx,@function
_Z24__device_stub__calculatePxxxxS_xx:  # @_Z24__device_stub__calculatePxxxxS_xx
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	16(%rsp), %r8
	movq	%r9, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z9calculatePxxxxS_xx, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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	_Z24__device_stub__calculatePxxxxS_xx, .Lfunc_end0-_Z24__device_stub__calculatePxxxxS_xx
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	$120, %rsp
	.cfi_def_cfa_offset 176
	.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, %r15
	cmpl	$3, %edi
	jne	.LBB1_1
# %bb.2:
	movq	8(%r15), %rdi
	callq	atoi
	testl	%eax, %eax
	jle	.LBB1_3
# %bb.4:
	movl	%eax, 20(%rsp)                  # 4-byte Spill
	movslq	%eax, %rbx
	movq	16(%r15), %rdi
	callq	atoi
	movl	%eax, %ebp
	movq	%rbx, 48(%rsp)                  # 8-byte Spill
	leaq	(,%rbx,8), %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, %r13
	movl	$8, %edi
	callq	malloc
	testq	%r13, %r13
	je	.LBB1_5
# %bb.6:                                # %.lr.ph.preheader
	movq	%rax, %r12
	movl	%ebp, %edi
	callq	srand
	xorl	%r14d, %r14d
	movq	48(%rsp), %r15                  # 8-byte Reload
.LBB1_7:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	random
	movq	%rax, (%r13,%r14,8)
	incq	%r14
	cmpq	%r14, %r15
	jne	.LBB1_7
# %bb.8:                                # %._crit_edge
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB1_9
# %bb.12:
	leaq	40(%rsp), %rdi
	movl	$8, %esi
	callq	hipMalloc
	callq	hipGetLastError
	testl	%eax, %eax
	movl	20(%rsp), %ebp                  # 4-byte Reload
	jne	.LBB1_13
# %bb.14:
	movq	32(%rsp), %rdi
	movq	%r13, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB1_15
# %bb.16:
	leaq	88(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movb	$1, %bl
	cmpl	$1, %ebp
	je	.LBB1_29
# %bb.17:                               # %.lr.ph111.preheader
	movq	%r13, 56(%rsp)                  # 8-byte Spill
	movq	%r12, 64(%rsp)                  # 8-byte Spill
	movabsq	$4294967296, %r14               # imm = 0x100000000
	xorl	%eax, %eax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movq	%r15, %r12
.LBB1_18:                               # %.lr.ph111
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_21 Depth 2
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r12, %xmm0
	callq	log2
	cvttsd2si	%xmm0, %r15
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r15, %xmm0
	movsd	%xmm0, 72(%rsp)                 # 8-byte Spill
	callq	exp2@PLT
	testq	%r15, %r15
	jle	.LBB1_27
# %bb.19:                               # %.lr.ph105.preheader
                                        #   in Loop: Header=BB1_18 Depth=1
	cvttsd2si	%xmm0, %rax
	movq	24(%rsp), %rcx                  # 8-byte Reload
	addq	%rcx, %rax
	decq	%rax
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movq	%r15, %r13
	negq	%r13
	movl	$1, %ebx
.LBB1_21:                               # %.lr.ph105
                                        #   Parent Loop BB1_18 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rbx, %xmm0
	callq	exp2@PLT
	cvttsd2si	%xmm0, %rbp
	movq	%r12, %rax
	cqto
	idivq	%rbp
	movq	%rax, %rcx
	movl	$1024, %eax                     # imm = 0x400
	cmpq	%rax, %rcx
	jl	.LBB1_23
# %bb.22:                               # %.lr.ph105
                                        #   in Loop: Header=BB1_21 Depth=2
	movl	$1024, %ecx                     # imm = 0x400
.LBB1_23:                               # %.lr.ph105
                                        #   in Loop: Header=BB1_21 Depth=2
	movq	%r12, %rax
	cqto
	idivq	%rcx
	movl	%eax, %edi
	orq	%r14, %rdi
	movl	%ecx, %edx
	orq	%r14, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_25
# %bb.24:                               #   in Loop: Header=BB1_21 Depth=2
	movq	32(%rsp), %rdi
	movq	40(%rsp), %r8
	movq	%r15, (%rsp)
	movq	80(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movq	24(%rsp), %rcx                  # 8-byte Reload
	movq	%rbx, %r9
	callq	_Z24__device_stub__calculatePxxxxS_xx
.LBB1_25:                               #   in Loop: Header=BB1_21 Depth=2
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB1_26
# %bb.20:                               #   in Loop: Header=BB1_21 Depth=2
	leaq	(%rbx,%r13), %rax
	incq	%rax
	incq	%rbx
	cmpq	$1, %rax
	jne	.LBB1_21
.LBB1_27:                               # %._crit_edge106
                                        #   in Loop: Header=BB1_18 Depth=1
	movsd	72(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	exp2@PLT
	xorps	%xmm1, %xmm1
	cvtsi2sdq	24(%rsp), %xmm1         # 8-byte Folded Reload
	addsd	%xmm0, %xmm1
	cvttsd2si	%xmm1, %rcx
	movq	48(%rsp), %r15                  # 8-byte Reload
	movq	%r15, %r12
	movq	%rcx, %rax
	movq	%rcx, 24(%rsp)                  # 8-byte Spill
	subq	%rcx, %r12
	cmpq	$1, %r12
	jg	.LBB1_18
# %bb.28:                               # %._crit_edge112.loopexit
	sete	%bl
	movq	64(%rsp), %r12                  # 8-byte Reload
	movq	56(%rsp), %r13                  # 8-byte Reload
	movl	20(%rsp), %ebp                  # 4-byte Reload
.LBB1_29:                               # %._crit_edge112
	movq	40(%rsp), %rsi
	movl	$8, %edx
	movq	%r12, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB1_30
# %bb.31:
	cmpl	$1, %ebp
	setne	%al
	movl	%ebx, %ecx
	xorb	$1, %cl
	orb	%al, %cl
	jne	.LBB1_33
# %bb.32:
	movq	(%r13), %rsi
	jmp	.LBB1_35
.LBB1_33:
	movq	(%r12), %rsi
	testb	%bl, %bl
	je	.LBB1_36
# %bb.34:
	xorq	-8(%r13,%r15,8), %rsi
.LBB1_35:                               # %.sink.split
	movq	%rsi, (%r12)
.LBB1_36:
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	leaq	104(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%rbx), %rax
	movq	8(%rbx), %rsi
	subq	88(%rsp), %rax
	imulq	$1000000, %rax, %rax            # imm = 0xF4240
	subq	96(%rsp), %rsi
	addq	%rax, %rsi
	movl	$.L.str.11, %edi
	xorl	%eax, %eax
	callq	printf
	movq	%r13, %rdi
	callq	free
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	%r12, %rdi
	callq	free
	movq	40(%rsp), %rdi
	callq	hipFree
	xorl	%eax, %eax
	addq	$120, %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
.LBB1_26:
	.cfi_def_cfa_offset 176
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	movl	$.L.str.8, %edx
.LBB1_10:
	movq	%rax, %rsi
.LBB1_11:
	xorl	%eax, %eax
	callq	printf
	movl	$-1, %edi
	callq	exit
.LBB1_1:
	movq	(%r15), %rsi
	movl	$.L.str, %edi
	movl	$.L.str.1, %edx
	jmp	.LBB1_11
.LBB1_3:
	movq	(%r15), %rsi
	movl	$.L.str, %edi
	movl	$.L.str.2, %edx
	jmp	.LBB1_11
.LBB1_5:
	movq	(%r15), %rsi
	movl	$.L.str, %edi
	movl	$.L.str.3, %edx
	jmp	.LBB1_11
.LBB1_9:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	movl	$.L.str.5, %edx
	jmp	.LBB1_10
.LBB1_13:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	movl	$.L.str.6, %edx
	jmp	.LBB1_10
.LBB1_15:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	movl	$.L.str.7, %edx
	jmp	.LBB1_10
.LBB1_30:
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.4, %edi
	movl	$.L.str.9, %edx
	jmp	.LBB1_10
.Lfunc_end1:
	.size	main, .Lfunc_end1-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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9calculatePxxxxS_xx, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z9calculatePxxxxS_xx,@object   # @_Z9calculatePxxxxS_xx
	.section	.rodata,"a",@progbits
	.globl	_Z9calculatePxxxxS_xx
	.p2align	3, 0x0
_Z9calculatePxxxxS_xx:
	.quad	_Z24__device_stub__calculatePxxxxS_xx
	.size	_Z9calculatePxxxxS_xx, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Usage: %s <# of elements> <random seed> \n %s\n"
	.size	.L.str, 46

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"not enough parameters"
	.size	.L.str.1, 22

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"invalid num elements"
	.size	.L.str.2, 21

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"invalid num elements, not enough memory"
	.size	.L.str.3, 40

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Cuda Error: '%s' for %s\n"
	.size	.L.str.4, 25

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

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

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"memcpy1"
	.size	.L.str.7, 8

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"kernel invocation"
	.size	.L.str.8, 18

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

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"XOR = %lld\n"
	.size	.L.str.10, 12

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Time taken = %ld microsecs\n"
	.size	.L.str.11, 28

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9calculatePxxxxS_xx"
	.size	.L__unnamed_1, 22

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

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

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9calculatePxxxxS_xx   ; -- Begin function _Z9calculatePxxxxS_xx
	.globl	_Z9calculatePxxxxS_xx
	.p2align	8
	.type	_Z9calculatePxxxxS_xx,@function
_Z9calculatePxxxxS_xx:                  ; @_Z9calculatePxxxxS_xx
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x44
	s_load_b256 s[4:11], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_add_u32 s2, s10, -1
	s_addc_u32 s3, s11, -1
	v_mad_u64_u32 v[2:3], null, s8, v1, s[8:9]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mov_b32_e32 v0, v3
	v_mad_u64_u32 v[3:4], null, s9, v1, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_mov_b32_e32 v0, v3
	v_add_co_u32 v3, vcc_lo, s2, v2
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v4, vcc_lo, s3, v0, vcc_lo
	v_cmpx_ge_i64_e64 s[6:7], v[3:4]
	s_cbranch_execz .LBB0_5
; %bb.1:
	v_mad_u64_u32 v[3:4], null, v1, s8, 0
	s_lshl_b64 s[2:3], s[10:11], 3
	s_load_b256 s[12:19], s[0:1], 0x20
	s_add_u32 s6, s2, s4
	s_addc_u32 s7, s3, s5
	s_cmp_eq_u64 s[10:11], 0
	s_cselect_b32 s1, -1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[5:6], null, v1, s9, v[4:5]
	v_dual_mov_b32 v4, v5 :: v_dual_and_b32 v1, 1, v1
	v_add_co_u32 v5, vcc_lo, s10, v2
	v_add_co_ci_u32_e32 v6, vcc_lo, s11, v0, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[2:3], 3, v[3:4]
	s_waitcnt lgkmcnt(0)
	s_cmp_eq_u64 s[14:15], s[16:17]
	v_lshlrev_b64 v[4:5], 3, v[5:6]
	s_cselect_b32 s0, -1, 0
	s_cmp_lg_u64 s[14:15], s[16:17]
	v_add_co_u32 v6, vcc_lo, s6, v2
	v_add_co_ci_u32_e32 v7, vcc_lo, s7, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_u32 v3, vcc_lo, s4, v4
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v5, vcc_lo
	s_clause 0x1
	global_load_b64 v[8:9], v[6:7], off
	global_load_b64 v[10:11], v[3:4], off offset:-8
	v_add_co_u32 v0, vcc_lo, v3, -8
	v_add_co_ci_u32_e32 v3, vcc_lo, -1, v4, vcc_lo
	v_mov_b32_e32 v2, 0
	s_cselect_b32 s6, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_or_b32 s1, s1, s6
	v_cmp_eq_u64_e32 vcc_lo, 0, v[1:2]
	v_dual_cndmask_b32 v1, v3, v7 :: v_dual_cndmask_b32 v0, v0, v6
	s_and_b32 vcc_lo, exec_lo, s1
	s_waitcnt vmcnt(0)
	v_xor_b32_e32 v4, v11, v9
	v_xor_b32_e32 v3, v10, v8
	global_store_b64 v[0:1], v[3:4], off
	s_cbranch_vccnz .LBB0_3
; %bb.2:
	s_add_u32 s2, s4, s2
	s_addc_u32 s3, s5, s3
	s_clause 0x1
	global_load_b64 v[0:1], v2, s[4:5]
	global_load_b64 v[3:4], v2, s[2:3]
	s_waitcnt vmcnt(0)
	v_xor_b32_e32 v0, v3, v0
	v_xor_b32_e32 v1, v4, v1
	global_store_b64 v2, v[0:1], s[4:5]
.LBB0_3:
	s_and_not1_b32 vcc_lo, exec_lo, s0
	s_cbranch_vccnz .LBB0_5
; %bb.4:
	v_mov_b32_e32 v2, 0
	global_load_b64 v[0:1], v2, s[4:5]
	s_waitcnt vmcnt(0)
	global_store_b64 v2, v[0:1], s[12:13]
.LBB0_5:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9calculatePxxxxS_xx
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 312
		.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 12
		.amdhsa_next_free_sgpr 20
		.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	_Z9calculatePxxxxS_xx, .Lfunc_end0-_Z9calculatePxxxxS_xx
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 428
; NumSgprs: 22
; NumVgprs: 12
; ScratchSize: 0
; MemoryBound: 1
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 22
; NumVGPRsForWavesPerEU: 12
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           8
        .value_kind:     by_value
      - .offset:         16
        .size:           8
        .value_kind:     by_value
      - .offset:         24
        .size:           8
        .value_kind:     by_value
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           8
        .value_kind:     by_value
      - .offset:         48
        .size:           8
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         60
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         68
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         70
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         72
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         74
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         76
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         78
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         120
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 312
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9calculatePxxxxS_xx
    .private_segment_fixed_size: 0
    .sgpr_count:     22
    .sgpr_spill_count: 0
    .symbol:         _Z9calculatePxxxxS_xx.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     12
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
