#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cuda.h>
#include <cuda_runtime.h>
#define CHECK(call) {   const cudaError_t error = call; if (error != cudaSuccess) { printf("Error: %s:%d, ", __FILE__, __LINE__); printf("code:%d, reason: %s\n", error, cudaGetErrorString(error)); exit(1); }}


__global__ void compute_displacement (int *reso_map,float *projection_mat,float *projection_dis,float *eigenvec,int frame_min,int frame_max,int total_points){

        int k=threadIdx.x + blockDim.x * blockIdx.x;
	int kk,reso_count,bin_num;

	reso_count=0;
	if(k>=frame_min && k<frame_max){
		for(kk=0;kk<total_points;kk++){
			if(reso_map[kk]==1){
				bin_num=k+(frame_max*reso_count);
				projection_dis[k]+=(projection_mat[bin_num]*eigenvec[reso_count]);
            			reso_count+=1;
			}
		}
	}

} // End of Global



int main ()
{
  int devCount,blocks,threads,i,ii,iii,line_num,frame_number,counter_cov,max_frame,min_frame,reso_count,reso_sum,bin_number,frame_dimension,total_points,projection_value;
  float variance_value;
  int *reso;
  float *eigenvector,*projection_matrix,*projection_displacement;
  int *dev_reso;
  float *dev_eigenvector,*dev_projection_matrix,*dev_projection_displacement;
  char buf[256];
  FILE* file0=fopen("map_density.dat","r");
  FILE* file=fopen("reso_map.dat","r");
  FILE* file2=fopen("eigenvector.dat","r");
  FILE* file3=fopen("hb_count_matrix.dat","r");
  FILE *ofp;
  char outputFilename[] = "displacement.dat";

CHECK (cudaSetDevice ( 0 ) );

reso_sum=0;
//Read Resolution Map
while (fgets(buf, sizeof (buf), file0)) {
        sscanf (buf, "%i\t%i\t%i",&i,&ii,&iii);
        reso_sum+=1;
}
fclose(file0);
printf("Total Points=%i\n",reso_sum);

//Allocate Resolution Map
reso=(int *)malloc(reso_sum*sizeof(int));
if(reso == NULL){
   printf("Error: %s:%d, ", __FILE__, __LINE__);
   exit(1);}
memset(reso,0,reso_sum*sizeof(int));

total_points=reso_sum;

reso_sum=0;
//Read Resolution Map
while (fgets(buf, sizeof (buf), file)) {
        sscanf (buf, "%i\t%i\t%i\t%i",&i,&ii,&iii,&line_num);
        reso_sum+=1;
}
rewind(file);
printf("Resolution Points=%i\n",reso_sum);

//Read Resolution Map
while (fgets(buf, sizeof (buf), file)) {
        sscanf (buf, "%i\t%i\t%i\t%i",&i,&ii,&iii,&line_num);
	reso[line_num]=1;
}
fclose (file);


//Allocate Eigenvector Array
eigenvector=(float *)malloc(reso_sum*sizeof(float));
if(eigenvector == NULL){
   printf("Error: %s:%d, ", __FILE__, __LINE__);
   exit(1);}
memset(eigenvector,0,reso_sum*sizeof(float));

counter_cov=0;

printf("Reading Input...\n");
//Fill Eigenvector Array
while (fgets(buf, sizeof (buf), file2)) {
        sscanf (buf, "%f",&variance_value);
	eigenvector[counter_cov]=variance_value;
	counter_cov+=1;
}
fclose (file2);

//Determine Max Frame
counter_cov=0;
reso_count=0;
min_frame=99999999;
counter_cov=0;
max_frame=-1;
frame_dimension=0;
while (fgets(buf, sizeof (buf), file3)) {
        sscanf (buf, "%i\t%i",&frame_number,&projection_value);
	max_frame=frame_number;}
rewind(file3);

frame_dimension=max_frame;

//Allocate Projection Matrix
projection_matrix=(float *)malloc(frame_dimension*reso_sum*sizeof(float));
if(projection_matrix == NULL){
   printf("Error: %s:%d, ", __FILE__, __LINE__);
   exit(1);}
memset(projection_matrix,0,frame_dimension*reso_sum*sizeof(float));

//Fill Projection Matrix
max_frame=-1;
min_frame=99999999;
while (fgets(buf, sizeof (buf), file3)) {
        sscanf (buf, "%i\t%i",&frame_number,&projection_value);
	if(max_frame!=frame_number){
		counter_cov=0;
		reso_count=0;}

	if(reso[counter_cov]==1){
		bin_number=(frame_number)+(frame_dimension*reso_count);
		projection_matrix[bin_number]=float(projection_value);
		reso_count+=1;}

        if(frame_number < min_frame){
		min_frame=frame_number;}

	max_frame=frame_number;
	counter_cov+=1;
}
fclose (file3);

counter_cov=counter_cov-1;

//Allocate Projection Displacement Array
projection_displacement=(float *)malloc(frame_dimension*sizeof(float));
if(projection_displacement == NULL){
   printf("Error: %s:%d, ", __FILE__, __LINE__);
   exit(1);}
memset(projection_displacement,0,frame_dimension*sizeof(float));


//Prepare Device Parameters
cudaGetDeviceCount(&devCount);
for (int i = 0; i < devCount; ++i){
	cudaDeviceProp devProp;
	cudaGetDeviceProperties(&devProp, i);
	threads=devProp.maxThreadsPerBlock;
}

blocks=ceil(float(frame_dimension)/float(threads))+1;
printf("Threads=%i\n",threads);
printf("Blocks=%i\n",blocks);

//Allocate Device Arrays
CHECK (cudaMalloc((void **) &dev_reso, total_points*sizeof(int)) );
CHECK (cudaMalloc((void **) &dev_projection_matrix, frame_dimension*reso_sum*sizeof(float)) );
CHECK (cudaMalloc((void **) &dev_projection_displacement, frame_dimension*sizeof(float)) );
CHECK (cudaMalloc((void **) &dev_eigenvector, reso_sum*sizeof(float)) );

CHECK (cudaMemcpy(dev_reso, reso, total_points*sizeof(int), cudaMemcpyHostToDevice) );
CHECK (cudaMemcpy(dev_projection_matrix, projection_matrix, frame_dimension*reso_sum*sizeof(float), cudaMemcpyHostToDevice) );

CHECK (cudaMemcpy(dev_eigenvector,eigenvector, reso_sum*sizeof(float), cudaMemcpyHostToDevice) );

CHECK (cudaMemcpy(dev_projection_displacement, projection_displacement, frame_dimension*sizeof(float), cudaMemcpyHostToDevice) );

compute_displacement<<<blocks,threads>>>(dev_reso,dev_projection_matrix,dev_projection_displacement,dev_eigenvector,min_frame,frame_dimension,total_points);

CHECK (cudaMemcpy(projection_displacement, dev_projection_displacement, (frame_dimension)*sizeof(float), cudaMemcpyDeviceToHost) );

CHECK (cudaFree(dev_reso) );
CHECK (cudaFree(dev_projection_matrix) );
CHECK (cudaFree(dev_projection_displacement) );
CHECK (cudaFree(dev_eigenvector) );
cudaDeviceReset();

//Write a File
ofp=fopen(outputFilename, "w");
for (i=min_frame;i<frame_dimension;i++){
        fprintf(ofp,"%i\t%f\n",i,projection_displacement[i]);
}
fclose(ofp);

//Free Allocated Arrays
free(reso);
free(projection_matrix);
free(projection_displacement);
free(eigenvector);


printf("Complete!\n");
  return 0;
}

	.file	"tmpxft_00373839_00000000-6_projection.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z51__device_stub__Z20compute_displacementPiPfS0_S0_iiiPiPfS0_S0_iii
	.type	_Z51__device_stub__Z20compute_displacementPiPfS0_S0_iiiPiPfS0_S0_iii, @function
_Z51__device_stub__Z20compute_displacementPiPfS0_S0_iiiPiPfS0_S0_iii:
.LFB2052:
	.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
	movl	%r8d, 12(%rsp)
	movl	%r9d, 8(%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	12(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	8(%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	_Z20compute_displacementPiPfS0_S0_iii(%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
.LFE2052:
	.size	_Z51__device_stub__Z20compute_displacementPiPfS0_S0_iiiPiPfS0_S0_iii, .-_Z51__device_stub__Z20compute_displacementPiPfS0_S0_iiiPiPfS0_S0_iii
	.globl	_Z20compute_displacementPiPfS0_S0_iii
	.type	_Z20compute_displacementPiPfS0_S0_iii, @function
_Z20compute_displacementPiPfS0_S0_iii:
.LFB2053:
	.cfi_startproc
	endbr64
	jmp	_Z51__device_stub__Z20compute_displacementPiPfS0_S0_iiiPiPfS0_S0_iii
	.cfi_endproc
.LFE2053:
	.size	_Z20compute_displacementPiPfS0_S0_iii, .-_Z20compute_displacementPiPfS0_S0_iii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"map_density.dat"
.LC2:
	.string	"reso_map.dat"
.LC3:
	.string	"eigenvector.dat"
.LC4:
	.string	"hb_count_matrix.dat"
.LC5:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/slaustin/gpu_sources/master/projection.cu"
.LC6:
	.string	"Error: %s:%d, "
.LC7:
	.string	"code:%d, reason: %s\n"
.LC8:
	.string	"%i\t%i\t%i"
.LC9:
	.string	"Total Points=%i\n"
.LC10:
	.string	"%i\t%i\t%i\t%i"
.LC11:
	.string	"Resolution Points=%i\n"
.LC12:
	.string	"Reading Input...\n"
.LC13:
	.string	"%f"
.LC14:
	.string	"%i\t%i"
.LC16:
	.string	"Threads=%i\n"
.LC17:
	.string	"Blocks=%i\n"
.LC18:
	.string	"w"
.LC19:
	.string	"%i\t%f\n"
.LC20:
	.string	"Complete!\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %rdi
	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
	leaq	.LC8(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC0(%rip), %rbx
	movq	%rbx, %rsi
	subq	$1480, %rsp
	.cfi_def_cfa_offset 1536
	movq	%fs:40, %rax
	movq	%rax, 1464(%rsp)
	xorl	%eax, %eax
	call	fopen@PLT
	movq	%rbx, %rsi
	leaq	.LC2(%rip), %rdi
	movq	%rax, %rbp
	call	fopen@PLT
	movq	%rbx, %rsi
	leaq	.LC3(%rip), %rdi
	movq	%rax, %r13
	call	fopen@PLT
	movq	%rbx, %rsi
	leaq	.LC4(%rip), %rdi
	movq	%rax, %r14
	call	fopen@PLT
	xorl	%edi, %edi
	movb	$0, 1207(%rsp)
	movabsq	$8386094131825239405, %rdx
	movq	%rax, (%rsp)
	movabsq	$7305790138896050532, %rax
	movq	%rax, 1191(%rsp)
	movq	%rdx, 1199(%rsp)
	call	cudaSetDevice@PLT
	xorl	%esi, %esi
	movl	%esi, 48(%rsp)
	testl	%eax, %eax
	je	.L9
	movl	%eax, %ebx
	movl	$45, %ecx
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC5(%rip), %rdx
	leaq	.LC6(%rip), %rsi
	call	__printf_chk@PLT
	movl	%ebx, %edi
	call	cudaGetErrorString@PLT
	movl	%ebx, %edx
	movq	%rax, %rcx
	jmp	.L55
.L9:
	leaq	1208(%rsp), %rbx
	movq	%rbp, %rcx
	movl	$256, %edx
	movl	$256, %esi
	movq	%rbx, %rdi
	call	__fgets_chk@PLT
	testq	%rax, %rax
	je	.L57
	leaq	72(%rsp), %rcx
	leaq	68(%rsp), %rdx
	movq	%r12, %rsi
	movq	%rbx, %rdi
	leaq	76(%rsp), %r8
	xorl	%eax, %eax
	call	__isoc23_sscanf@PLT
	incl	48(%rsp)
	jmp	.L9
.L57:
	movq	%rbp, %rdi
	call	fclose@PLT
	movl	48(%rsp), %edx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC9(%rip), %rsi
	call	__printf_chk@PLT
	movslq	48(%rsp), %rax
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	malloc@PLT
	movq	%rax, %r12
	testq	%rax, %rax
	jne	.L11
	movl	$59, %ecx
.L53:
	leaq	.LC5(%rip), %rdx
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
.L52:
	call	__printf_chk@PLT
.L51:
	movl	$1, %edi
	call	exit@PLT
.L11:
	movq	8(%rsp), %rcx
	xorl	%esi, %esi
	movq	%rax, %rdi
	xorl	%ebp, %ebp
	leaq	.LC10(%rip), %r15
	movq	%rcx, %rdx
	call	__memset_chk@PLT
.L12:
	movq	%r13, %rcx
	movl	$256, %edx
	movl	$256, %esi
	movq	%rbx, %rdi
	call	__fgets_chk@PLT
	testq	%rax, %rax
	je	.L58
	leaq	72(%rsp), %rcx
	leaq	68(%rsp), %rdx
	movq	%r15, %rsi
	movq	%rbx, %rdi
	leaq	80(%rsp), %r9
	leaq	76(%rsp), %r8
	xorl	%eax, %eax
	incl	%ebp
	call	__isoc23_sscanf@PLT
	jmp	.L12
.L58:
	movq	%r13, %rdi
	leaq	.LC10(%rip), %r15
	call	rewind@PLT
	movl	%ebp, %edx
	leaq	.LC11(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
.L14:
	movq	%r13, %rcx
	movl	$256, %edx
	movl	$256, %esi
	movq	%rbx, %rdi
	call	__fgets_chk@PLT
	testq	%rax, %rax
	je	.L59
	leaq	72(%rsp), %rcx
	leaq	68(%rsp), %rdx
	movq	%r15, %rsi
	movq	%rbx, %rdi
	leaq	80(%rsp), %r9
	leaq	76(%rsp), %r8
	xorl	%eax, %eax
	call	__isoc23_sscanf@PLT
	movslq	80(%rsp), %rax
	movl	$1, (%r12,%rax,4)
	jmp	.L14
.L59:
	movq	%r13, %rdi
	call	fclose@PLT
	movslq	%ebp, %rax
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	movl	$85, %ecx
	movq	%rax, 32(%rsp)
	testq	%rax, %rax
	je	.L54
	movq	16(%rsp), %rcx
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	leaq	.LC13(%rip), %r15
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	32(%rsp), %r13
.L17:
	movq	%r14, %rcx
	movl	$256, %edx
	movl	$256, %esi
	movq	%rbx, %rdi
	call	__fgets_chk@PLT
	testq	%rax, %rax
	je	.L60
	leaq	92(%rsp), %rdx
	movq	%r15, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc23_sscanf@PLT
	movss	92(%rsp), %xmm0
	addq	$4, %r13
	movss	%xmm0, -4(%r13)
	jmp	.L17
.L60:
	movq	%r14, %rdi
	orl	$-1, %r13d
	leaq	.LC14(%rip), %r14
	call	fclose@PLT
.L19:
	movq	(%rsp), %rcx
	movl	$256, %edx
	movl	$256, %esi
	movq	%rbx, %rdi
	call	__fgets_chk@PLT
	testq	%rax, %rax
	je	.L61
	leaq	88(%rsp), %rcx
	leaq	84(%rsp), %rdx
	movq	%r14, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc23_sscanf@PLT
	movl	84(%rsp), %r13d
	jmp	.L19
.L61:
	imull	%r13d, %ebp
	movq	(%rsp), %rdi
	call	rewind@PLT
	movslq	%ebp, %rbp
	leaq	0(,%rbp,4), %rax
	movq	%rax, %rdi
	movq	%rax, 24(%rsp)
	call	malloc@PLT
	movq	%rax, 40(%rsp)
	testq	%rax, %rax
	jne	.L21
	movl	$117, %ecx
.L54:
	leaq	.LC5(%rip), %rdx
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	jmp	.L52
.L21:
	movq	24(%rsp), %rcx
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	xorl	%r14d, %r14d
	movl	$99999999, %ebx
	orl	$-1, %ebp
	xorl	%r15d, %r15d
	movq	%rcx, %rdx
	call	__memset_chk@PLT
.L22:
	movq	(%rsp), %rcx
	movl	$256, %edx
	movl	$256, %esi
	leaq	1208(%rsp), %rdi
	movq	%rdi, 56(%rsp)
	call	__fgets_chk@PLT
	movq	56(%rsp), %rdi
	testq	%rax, %rax
	je	.L62
	leaq	84(%rsp), %rdx
	xorl	%eax, %eax
	leaq	88(%rsp), %rcx
	leaq	.LC14(%rip), %rsi
	call	__isoc23_sscanf@PLT
	movl	84(%rsp), %eax
	xorl	%edx, %edx
	cmpl	%ebp, %eax
	cmovne	%edx, %r15d
	cmovne	%edx, %r14d
	movslq	%r15d, %rdx
	cmpl	$1, (%r12,%rdx,4)
	jne	.L24
	movl	%r13d, %edx
	cvtsi2ssl	88(%rsp), %xmm0
	movq	40(%rsp), %rcx
	imull	%r14d, %edx
	incl	%r14d
	addl	%eax, %edx
	movslq	%edx, %rdx
	movss	%xmm0, (%rcx,%rdx,4)
.L24:
	cmpl	%eax, %ebx
	movl	%eax, %ebp
	cmovg	%eax, %ebx
	incl	%r15d
	jmp	.L22
.L62:
	movq	(%rsp), %rdi
	call	fclose@PLT
	movslq	%r13d, %rax
	salq	$2, %rax
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movl	$148, %ecx
	movq	%rax, %rbp
	testq	%rax, %rax
	je	.L53
	movq	(%rsp), %rcx
	xorl	%esi, %esi
	movq	%rax, %rdi
	xorl	%r15d, %r15d
	leaq	152(%rsp), %r14
	movq	%rcx, %rdx
	call	__memset_chk@PLT
	leaq	64(%rsp), %rdi
	call	cudaGetDeviceCount@PLT
.L27:
	cmpl	%r15d, 64(%rsp)
	jle	.L63
	movl	%r15d, %esi
	movq	%r14, %rdi
	incl	%r15d
	call	cudaGetDeviceProperties_v2@PLT
	movl	472(%rsp), %eax
	movl	%eax, 52(%rsp)
	jmp	.L27
.L63:
	cvtsi2ssl	52(%rsp), %xmm1
	cvtsi2ssl	%r13d, %xmm0
	divss	%xmm1, %xmm0
	call	ceilf@PLT
	movl	52(%rsp), %edx
	movl	$2, %edi
	xorl	%eax, %eax
	addss	.LC15(%rip), %xmm0
	leaq	.LC16(%rip), %rsi
	cvttss2sil	%xmm0, %r15d
	call	__printf_chk@PLT
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movl	%r15d, %edx
	call	__printf_chk@PLT
	movq	8(%rsp), %rsi
	leaq	96(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$166, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	24(%rsp), %rsi
	leaq	112(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$167, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	(%rsp), %rsi
	leaq	120(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$168, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	16(%rsp), %rsi
	leaq	104(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$169, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	8(%rsp), %rdx
	movq	96(%rsp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	call	cudaMemcpy@PLT
	movl	$171, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	24(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	$1, %ecx
	movq	112(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$172, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	16(%rsp), %rdx
	movq	32(%rsp), %rsi
	movl	$1, %ecx
	movq	104(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$174, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	(%rsp), %rdx
	movq	120(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	call	cudaMemcpy@PLT
	movl	$176, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movl	52(%rsp), %eax
	movl	%r15d, 128(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%eax, 140(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 144(%rsp)
	movl	148(%rsp), %ecx
	movq	%rax, 132(%rsp)
	movq	140(%rsp), %rdx
	movq	128(%rsp), %rdi
	movl	136(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L37
	pushq	%rax
	.cfi_def_cfa_offset 1544
	movl	56(%rsp), %eax
	movl	%r13d, %r9d
	movl	%ebx, %r8d
	pushq	%rax
	.cfi_def_cfa_offset 1552
	movq	120(%rsp), %rcx
	movq	136(%rsp), %rdx
	movq	128(%rsp), %rsi
	movq	112(%rsp), %rdi
	call	_Z51__device_stub__Z20compute_displacementPiPfS0_S0_iiiPiPfS0_S0_iii
	popq	%rdx
	.cfi_def_cfa_offset 1544
	popq	%rcx
	.cfi_def_cfa_offset 1536
.L37:
	movq	(%rsp), %rdx
	movq	120(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	movl	$180, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	96(%rsp), %rdi
	call	cudaFree@PLT
	movl	$182, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	112(%rsp), %rdi
	call	cudaFree@PLT
	movl	$183, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	120(%rsp), %rdi
	call	cudaFree@PLT
	movl	$184, %ecx
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	.L56
	movq	104(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %r14d
	testl	%eax, %eax
	je	.L42
	movl	$185, %ecx
.L56:
	leaq	.LC5(%rip), %rdx
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%r14d, %edi
	call	cudaGetErrorString@PLT
	movl	%r14d, %edx
	movq	%rax, %rcx
.L55:
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L51
.L42:
	call	cudaDeviceReset@PLT
	leaq	1191(%rsp), %rdi
	leaq	.LC18(%rip), %rsi
	call	fopen@PLT
	leaq	.LC19(%rip), %r14
	movq	%rax, %r15
.L43:
	movl	%ebx, 68(%rsp)
	cmpl	%ebx, %r13d
	jle	.L64
	movslq	%ebx, %rax
	movl	%ebx, %ecx
	movq	%r14, %rdx
	movl	$2, %esi
	cvtss2sd	0(%rbp,%rax,4), %xmm0
	movq	%r15, %rdi
	movb	$1, %al
	call	__fprintf_chk@PLT
	movl	68(%rsp), %eax
	leal	1(%rax), %ebx
	jmp	.L43
.L64:
	movq	%r15, %rdi
	call	fclose@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	40(%rsp), %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	32(%rsp), %rdi
	call	free@PLT
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC20(%rip), %rsi
	call	__printf_chk@PLT
	movq	1464(%rsp), %rax
	subq	%fs:40, %rax
	je	.L45
	call	__stack_chk_fail@PLT
.L45:
	addq	$1480, %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
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC21:
	.string	"_Z20compute_displacementPiPfS0_S0_iii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2055:
	.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	.LC21(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z20compute_displacementPiPfS0_S0_iii(%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
.LFE2055:
	.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.cst4,"aM",@progbits,4
	.align 4
.LC15:
	.long	1065353216
	.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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hip/hip_runtime.h>

#define CHECK(call) {   const hipError_t error = call; if (error != hipSuccess) { printf("Error: %s:%d, ", __FILE__, __LINE__); printf("code:%d, reason: %s\n", error, hipGetErrorString(error)); exit(1); }}


__global__ void compute_displacement (int *reso_map,float *projection_mat,float *projection_dis,float *eigenvec,int frame_min,int frame_max,int total_points){

        int k=threadIdx.x + blockDim.x * blockIdx.x;
	int kk,reso_count,bin_num;

	reso_count=0;
	if(k>=frame_min && k<frame_max){
		for(kk=0;kk<total_points;kk++){
			if(reso_map[kk]==1){
				bin_num=k+(frame_max*reso_count);
				projection_dis[k]+=(projection_mat[bin_num]*eigenvec[reso_count]);
            			reso_count+=1;
			}
		}
	}

} // End of Global



int main ()
{
  int devCount,blocks,threads,i,ii,iii,line_num,frame_number,counter_cov,max_frame,min_frame,reso_count,reso_sum,bin_number,frame_dimension,total_points,projection_value;
  float variance_value;
  int *reso;
  float *eigenvector,*projection_matrix,*projection_displacement;
  int *dev_reso;
  float *dev_eigenvector,*dev_projection_matrix,*dev_projection_displacement;
  char buf[256];
  FILE* file0=fopen("map_density.dat","r");
  FILE* file=fopen("reso_map.dat","r");
  FILE* file2=fopen("eigenvector.dat","r");
  FILE* file3=fopen("hb_count_matrix.dat","r");
  FILE *ofp;
  char outputFilename[] = "displacement.dat";

CHECK (hipSetDevice ( 0 ) );

reso_sum=0;
//Read Resolution Map
while (fgets(buf, sizeof (buf), file0)) {
        sscanf (buf, "%i\t%i\t%i",&i,&ii,&iii);
        reso_sum+=1;
}
fclose(file0);
printf("Total Points=%i\n",reso_sum);

//Allocate Resolution Map
reso=(int *)malloc(reso_sum*sizeof(int));
if(reso == NULL){
   printf("Error: %s:%d, ", __FILE__, __LINE__);
   exit(1);}
memset(reso,0,reso_sum*sizeof(int));

total_points=reso_sum;

reso_sum=0;
//Read Resolution Map
while (fgets(buf, sizeof (buf), file)) {
        sscanf (buf, "%i\t%i\t%i\t%i",&i,&ii,&iii,&line_num);
        reso_sum+=1;
}
rewind(file);
printf("Resolution Points=%i\n",reso_sum);

//Read Resolution Map
while (fgets(buf, sizeof (buf), file)) {
        sscanf (buf, "%i\t%i\t%i\t%i",&i,&ii,&iii,&line_num);
	reso[line_num]=1;
}
fclose (file);


//Allocate Eigenvector Array
eigenvector=(float *)malloc(reso_sum*sizeof(float));
if(eigenvector == NULL){
   printf("Error: %s:%d, ", __FILE__, __LINE__);
   exit(1);}
memset(eigenvector,0,reso_sum*sizeof(float));

counter_cov=0;

printf("Reading Input...\n");
//Fill Eigenvector Array
while (fgets(buf, sizeof (buf), file2)) {
        sscanf (buf, "%f",&variance_value);
	eigenvector[counter_cov]=variance_value;
	counter_cov+=1;
}
fclose (file2);

//Determine Max Frame
counter_cov=0;
reso_count=0;
min_frame=99999999;
counter_cov=0;
max_frame=-1;
frame_dimension=0;
while (fgets(buf, sizeof (buf), file3)) {
        sscanf (buf, "%i\t%i",&frame_number,&projection_value);
	max_frame=frame_number;}
rewind(file3);

frame_dimension=max_frame;

//Allocate Projection Matrix
projection_matrix=(float *)malloc(frame_dimension*reso_sum*sizeof(float));
if(projection_matrix == NULL){
   printf("Error: %s:%d, ", __FILE__, __LINE__);
   exit(1);}
memset(projection_matrix,0,frame_dimension*reso_sum*sizeof(float));

//Fill Projection Matrix
max_frame=-1;
min_frame=99999999;
while (fgets(buf, sizeof (buf), file3)) {
        sscanf (buf, "%i\t%i",&frame_number,&projection_value);
	if(max_frame!=frame_number){
		counter_cov=0;
		reso_count=0;}

	if(reso[counter_cov]==1){
		bin_number=(frame_number)+(frame_dimension*reso_count);
		projection_matrix[bin_number]=float(projection_value);
		reso_count+=1;}

        if(frame_number < min_frame){
		min_frame=frame_number;}

	max_frame=frame_number;
	counter_cov+=1;
}
fclose (file3);

counter_cov=counter_cov-1;

//Allocate Projection Displacement Array
projection_displacement=(float *)malloc(frame_dimension*sizeof(float));
if(projection_displacement == NULL){
   printf("Error: %s:%d, ", __FILE__, __LINE__);
   exit(1);}
memset(projection_displacement,0,frame_dimension*sizeof(float));


//Prepare Device Parameters
hipGetDeviceCount(&devCount);
for (int i = 0; i < devCount; ++i){
	hipDeviceProp_t devProp;
	hipGetDeviceProperties(&devProp, i);
	threads=devProp.maxThreadsPerBlock;
}

blocks=ceil(float(frame_dimension)/float(threads))+1;
printf("Threads=%i\n",threads);
printf("Blocks=%i\n",blocks);

//Allocate Device Arrays
CHECK (hipMalloc((void **) &dev_reso, total_points*sizeof(int)) );
CHECK (hipMalloc((void **) &dev_projection_matrix, frame_dimension*reso_sum*sizeof(float)) );
CHECK (hipMalloc((void **) &dev_projection_displacement, frame_dimension*sizeof(float)) );
CHECK (hipMalloc((void **) &dev_eigenvector, reso_sum*sizeof(float)) );

CHECK (hipMemcpy(dev_reso, reso, total_points*sizeof(int), hipMemcpyHostToDevice) );
CHECK (hipMemcpy(dev_projection_matrix, projection_matrix, frame_dimension*reso_sum*sizeof(float), hipMemcpyHostToDevice) );

CHECK (hipMemcpy(dev_eigenvector,eigenvector, reso_sum*sizeof(float), hipMemcpyHostToDevice) );

CHECK (hipMemcpy(dev_projection_displacement, projection_displacement, frame_dimension*sizeof(float), hipMemcpyHostToDevice) );

compute_displacement<<<blocks,threads>>>(dev_reso,dev_projection_matrix,dev_projection_displacement,dev_eigenvector,min_frame,frame_dimension,total_points);

CHECK (hipMemcpy(projection_displacement, dev_projection_displacement, (frame_dimension)*sizeof(float), hipMemcpyDeviceToHost) );

CHECK (hipFree(dev_reso) );
CHECK (hipFree(dev_projection_matrix) );
CHECK (hipFree(dev_projection_displacement) );
CHECK (hipFree(dev_eigenvector) );
hipDeviceReset();

//Write a File
ofp=fopen(outputFilename, "w");
for (i=min_frame;i<frame_dimension;i++){
        fprintf(ofp,"%i\t%f\n",i,projection_displacement[i]);
}
fclose(ofp);

//Free Allocated Arrays
free(reso);
free(projection_matrix);
free(projection_displacement);
free(eigenvector);


printf("Complete!\n");
  return 0;
}

	.text
	.file	"projection.hip"
	.globl	_Z35__device_stub__compute_displacementPiPfS0_S0_iii # -- Begin function _Z35__device_stub__compute_displacementPiPfS0_S0_iii
	.type	_Z35__device_stub__compute_displacementPiPfS0_S0_iii,@function
_Z35__device_stub__compute_displacementPiPfS0_S0_iii: # @_Z35__device_stub__compute_displacementPiPfS0_S0_iii
	.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	12(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	8(%rsp), %r8
	movl	%r9d, (%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	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	$_Z20compute_displacementPiPfS0_S0_iii, %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	_Z35__device_stub__compute_displacementPiPfS0_S0_iii, .Lfunc_end0-_Z35__device_stub__compute_displacementPiPfS0_S0_iii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI1_0:
	.byte	100                             # 0x64
	.byte	105                             # 0x69
	.byte	115                             # 0x73
	.byte	112                             # 0x70
	.byte	108                             # 0x6c
	.byte	97                              # 0x61
	.byte	99                              # 0x63
	.byte	101                             # 0x65
	.byte	109                             # 0x6d
	.byte	101                             # 0x65
	.byte	110                             # 0x6e
	.byte	116                             # 0x74
	.byte	46                              # 0x2e
	.byte	100                             # 0x64
	.byte	97                              # 0x61
	.byte	116                             # 0x74
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI1_1:
	.quad	0x3ff0000000000000              # double 1
	.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	$1912, %rsp                     # imm = 0x778
	.cfi_def_cfa_offset 1968
	.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	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %rbx
	movl	$.L.str.2, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movl	$.L.str.3, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movl	$.L.str.4, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movaps	.LCPI1_0(%rip), %xmm0           # xmm0 = [100,105,115,112,108,97,99,101,109,101,110,116,46,100,97,116]
	movaps	%xmm0, 144(%rsp)
	movb	$0, 160(%rsp)
	xorl	%r12d, %r12d
	xorl	%edi, %edi
	callq	hipSetDevice
	testl	%eax, %eax
	jne	.LBB1_50
# %bb.1:                                # %.preheader
	leaq	176(%rsp), %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	%rbx, %rdx
	callq	fgets
	testq	%rax, %rax
	je	.LBB1_4
# %bb.2:                                # %.lr.ph.preheader
	leaq	176(%rsp), %r15
	leaq	12(%rsp), %rbp
	leaq	60(%rsp), %r14
	leaq	56(%rsp), %r13
	xorl	%r12d, %r12d
.LBB1_3:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.8, %esi
	movq	%r15, %rdi
	movq	%rbp, %rdx
	movq	%r14, %rcx
	movq	%r13, %r8
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	incl	%r12d
	movq	%r15, %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	%rbx, %rdx
	callq	fgets
	testq	%rax, %rax
	jne	.LBB1_3
.LBB1_4:                                # %._crit_edge
	movq	%rbx, %rdi
	callq	fclose
	xorl	%r15d, %r15d
	movl	$.L.str.9, %edi
	movl	%r12d, %esi
	xorl	%eax, %eax
	callq	printf
	movl	%r12d, %esi
	shlq	$2, %rsi
	movl	$1, %edi
	movq	%rsi, 136(%rsp)                 # 8-byte Spill
	callq	calloc@PLT
	testq	%rax, %rax
	je	.LBB1_51
# %bb.5:
	movl	%r12d, 100(%rsp)                # 4-byte Spill
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	leaq	176(%rsp), %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	32(%rsp), %r12                  # 8-byte Reload
	movq	%r12, %rdx
	callq	fgets
	testq	%rax, %rax
	je	.LBB1_8
# %bb.6:                                # %.lr.ph194.preheader
	leaq	176(%rsp), %rbx
	leaq	12(%rsp), %rbp
	leaq	56(%rsp), %r13
	leaq	52(%rsp), %r14
	xorl	%r15d, %r15d
.LBB1_7:                                # %.lr.ph194
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.10, %esi
	movq	%rbx, %rdi
	movq	%rbp, %rdx
	leaq	60(%rsp), %rcx
	movq	%r13, %r8
	movq	%r14, %r9
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	incl	%r15d
	movq	%rbx, %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	%r12, %rdx
	callq	fgets
	testq	%rax, %rax
	jne	.LBB1_7
.LBB1_8:                                # %._crit_edge195
	movq	%r12, %rdi
	callq	rewind
	movl	$.L.str.11, %edi
	movl	%r15d, %esi
	xorl	%eax, %eax
	callq	printf
	leaq	176(%rsp), %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	%r12, %rdx
	callq	fgets
	testq	%rax, %rax
	movq	64(%rsp), %r14                  # 8-byte Reload
	je	.LBB1_11
# %bb.9:                                # %.lr.ph199.preheader
	leaq	176(%rsp), %rbx
	leaq	56(%rsp), %r13
	leaq	52(%rsp), %rbp
.LBB1_10:                               # %.lr.ph199
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.10, %esi
	movq	%rbx, %rdi
	leaq	12(%rsp), %rdx
	leaq	60(%rsp), %rcx
	movq	%r13, %r8
	movq	%rbp, %r9
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movslq	52(%rsp), %rax
	movl	$1, (%r14,%rax,4)
	movq	%rbx, %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	%r12, %rdx
	callq	fgets
	testq	%rax, %rax
	jne	.LBB1_10
.LBB1_11:                               # %._crit_edge200
	movq	%r12, %rdi
	callq	fclose
	movl	%r15d, %esi
	shlq	$2, %rsi
	movl	$1, %edi
	movq	%rsi, 120(%rsp)                 # 8-byte Spill
	callq	calloc@PLT
	testq	%rax, %rax
	je	.LBB1_52
# %bb.12:
	movq	%rax, %rbp
	movl	$.Lstr, %edi
	callq	puts@PLT
	leaq	176(%rsp), %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	40(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %rdx
	callq	fgets
	testq	%rax, %rax
	je	.LBB1_15
# %bb.13:                               # %.lr.ph204.preheader
	leaq	176(%rsp), %rbx
	leaq	104(%rsp), %r14
	movq	%rbp, %r12
.LBB1_14:                               # %.lr.ph204
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.13, %esi
	movq	%rbx, %rdi
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movss	104(%rsp), %xmm0                # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r12)
	movq	%rbx, %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	%r13, %rdx
	callq	fgets
	addq	$4, %r12
	testq	%rax, %rax
	jne	.LBB1_14
.LBB1_15:                               # %._crit_edge205
	movq	%rbp, 112(%rsp)                 # 8-byte Spill
	movq	%r13, %rdi
	callq	fclose
	leaq	176(%rsp), %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	16(%rsp), %rdx                  # 8-byte Reload
	callq	fgets
	testq	%rax, %rax
	je	.LBB1_18
# %bb.16:                               # %.lr.ph208.preheader
	leaq	176(%rsp), %rbx
	leaq	28(%rsp), %r14
	leaq	48(%rsp), %r13
	movq	16(%rsp), %rbp                  # 8-byte Reload
.LBB1_17:                               # %.lr.ph208
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.14, %esi
	movq	%rbx, %rdi
	movq	%r14, %rdx
	movq	%r13, %rcx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movl	28(%rsp), %r12d
	movq	%rbx, %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	%rbp, %rdx
	callq	fgets
	testq	%rax, %rax
	jne	.LBB1_17
	jmp	.LBB1_19
.LBB1_18:
	movl	$-1, %r12d
	movq	16(%rsp), %rbp                  # 8-byte Reload
.LBB1_19:                               # %._crit_edge209
	movq	%rbp, %rdi
	callq	rewind
	imull	%r12d, %r15d
	movslq	%r15d, %rsi
	shlq	$2, %rsi
	movl	$1, %edi
	movq	%rsi, 128(%rsp)                 # 8-byte Spill
	callq	calloc@PLT
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	testq	%rax, %rax
	je	.LBB1_53
# %bb.20:
	movl	%r12d, 32(%rsp)                 # 4-byte Spill
	leaq	176(%rsp), %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	%rbp, %rdx
	callq	fgets
	movl	$99999999, %r15d                # imm = 0x5F5E0FF
	testq	%rax, %rax
	je	.LBB1_25
# %bb.21:                               # %.lr.ph217.preheader
	movl	$-1, %r13d
	leaq	176(%rsp), %r14
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
.LBB1_22:                               # %.lr.ph217
                                        # =>This Inner Loop Header: Depth=1
	movl	%r13d, %ebp
	movl	$.L.str.14, %esi
	movq	%r14, %rdi
	leaq	28(%rsp), %rdx
	leaq	48(%rsp), %rcx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movl	28(%rsp), %r13d
	cmpl	%r13d, %ebp
	movl	$0, %eax
	cmovnel	%eax, %r12d
	cmovnel	%eax, %ebx
	movslq	%ebx, %rax
	movq	64(%rsp), %rcx                  # 8-byte Reload
	cmpl	$1, (%rcx,%rax,4)
	jne	.LBB1_24
# %bb.23:                               #   in Loop: Header=BB1_22 Depth=1
	movl	%r12d, %eax
	imull	32(%rsp), %eax                  # 4-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsi2ssl	48(%rsp), %xmm0
	addl	%r13d, %eax
	cltq
	movq	40(%rsp), %rcx                  # 8-byte Reload
	movss	%xmm0, (%rcx,%rax,4)
	incl	%r12d
.LBB1_24:                               #   in Loop: Header=BB1_22 Depth=1
	cmpl	%r15d, %r13d
	cmovll	%r13d, %r15d
	incl	%ebx
	movq	%r14, %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	16(%rsp), %rdx                  # 8-byte Reload
	callq	fgets
	testq	%rax, %rax
	jne	.LBB1_22
.LBB1_25:                               # %._crit_edge218
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	fclose
	movl	32(%rsp), %r14d                 # 4-byte Reload
	movslq	%r14d, %rsi
	shlq	$2, %rsi
	movl	$1, %edi
	movq	%rsi, %rbp
	callq	calloc@PLT
	testq	%rax, %rax
	je	.LBB1_54
# %bb.26:
	movq	%rax, %r13
	leaq	108(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipGetDeviceCount
	cmpl	$0, (%rbx)
	jle	.LBB1_30
# %bb.27:                               # %.lr.ph222
	xorl	%ebx, %ebx
	leaq	440(%rsp), %r14
.LBB1_28:                               # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	hipGetDevicePropertiesR0600
	incl	%ebx
	cmpl	108(%rsp), %ebx
	jl	.LBB1_28
# %bb.29:
	movl	760(%rsp), %ebx
	movl	32(%rsp), %r14d                 # 4-byte Reload
	jmp	.LBB1_31
.LBB1_30:
                                        # implicit-def: $ebx
.LBB1_31:                               # %._crit_edge223
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r14d, %xmm0
	cvtsi2ss	%ebx, %xmm1
	divss	%xmm1, %xmm0
	callq	ceilf@PLT
	cvtss2sd	%xmm0, %xmm0
	addsd	.LCPI1_1(%rip), %xmm0
	cvttsd2si	%xmm0, %r14d
	movl	$.L.str.15, %edi
	movl	%ebx, 16(%rsp)                  # 4-byte Spill
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.16, %edi
	movl	%r14d, %r12d
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
	leaq	440(%rsp), %rdi
	movq	136(%rsp), %r14                 # 8-byte Reload
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_57
# %bb.32:
	leaq	80(%rsp), %rdi
	movq	128(%rsp), %rsi                 # 8-byte Reload
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_58
# %bb.33:
	leaq	72(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_59
# %bb.34:
	leaq	88(%rsp), %rdi
	movq	120(%rsp), %rsi                 # 8-byte Reload
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB1_60
# %bb.35:
	movq	440(%rsp), %rdi
	movq	64(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_61
# %bb.36:
	movq	80(%rsp), %rdi
	movq	40(%rsp), %rsi                  # 8-byte Reload
	movq	128(%rsp), %rdx                 # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	movl	32(%rsp), %r14d                 # 4-byte Reload
	jne	.LBB1_62
# %bb.37:
	movq	88(%rsp), %rdi
	movq	112(%rsp), %rsi                 # 8-byte Reload
	movq	120(%rsp), %rdx                 # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_63
# %bb.38:
	movq	72(%rsp), %rdi
	movq	%r13, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_64
# %bb.39:
	movl	%r12d, %edi
	btsq	$32, %rdi
	movl	16(%rsp), %edx                  # 4-byte Reload
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_41
# %bb.40:
	movq	440(%rsp), %rdi
	movq	80(%rsp), %rsi
	movq	72(%rsp), %rdx
	movq	88(%rsp), %rcx
	movl	100(%rsp), %eax                 # 4-byte Reload
	movl	%eax, (%rsp)
	movl	%r15d, %r8d
	movl	%r14d, %r9d
	callq	_Z35__device_stub__compute_displacementPiPfS0_S0_iii
.LBB1_41:
	movq	72(%rsp), %rsi
	movq	%r13, %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_65
# %bb.42:
	movq	440(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB1_66
# %bb.43:
	movq	80(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB1_67
# %bb.44:
	movq	72(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB1_68
# %bb.45:
	movq	88(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB1_69
# %bb.46:
	callq	hipDeviceReset
	leaq	144(%rsp), %rdi
	movl	$.L.str.17, %esi
	callq	fopen
	movq	%rax, %rbx
.LBB1_47:                               # %.lr.ph227
                                        # =>This Inner Loop Header: Depth=1
	movl	%r15d, 12(%rsp)
	cmpl	%r14d, %r15d
	jge	.LBB1_49
# %bb.48:                               # %.lr.ph227
                                        #   in Loop: Header=BB1_47 Depth=1
	movslq	%r15d, %rdx
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13,%rdx,4), %xmm0
	movl	$.L.str.18, %esi
	movq	%rbx, %rdi
                                        # kill: def $edx killed $edx killed $rdx
	movb	$1, %al
	callq	fprintf
	movl	12(%rsp), %r15d
	incl	%r15d
	jmp	.LBB1_47
.LBB1_49:                               # %._crit_edge228
	movq	%rbx, %rdi
	callq	fclose
	movq	64(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	40(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r13, %rdi
	callq	free
	movq	112(%rsp), %rdi                 # 8-byte Reload
	callq	free
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	xorl	%eax, %eax
	addq	$1912, %rsp                     # imm = 0x778
	.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_50:
	.cfi_def_cfa_offset 1968
	movl	%eax, %ebp
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$45, %edx
	xorl	%eax, %eax
	callq	printf
	movl	%ebp, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %edi
	movl	%ebp, %esi
	jmp	.LBB1_71
.LBB1_51:
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$59, %edx
	jmp	.LBB1_55
.LBB1_52:
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$85, %edx
	jmp	.LBB1_55
.LBB1_53:
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$117, %edx
	jmp	.LBB1_55
.LBB1_54:
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$148, %edx
.LBB1_55:
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB1_56
.LBB1_57:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$166, %edx
	jmp	.LBB1_70
.LBB1_58:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$167, %edx
	jmp	.LBB1_70
.LBB1_59:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$168, %edx
	jmp	.LBB1_70
.LBB1_60:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$169, %edx
	jmp	.LBB1_70
.LBB1_61:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$171, %edx
	jmp	.LBB1_70
.LBB1_62:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$172, %edx
	jmp	.LBB1_70
.LBB1_63:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$174, %edx
	jmp	.LBB1_70
.LBB1_64:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$176, %edx
	jmp	.LBB1_70
.LBB1_65:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$180, %edx
	jmp	.LBB1_70
.LBB1_66:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$182, %edx
	jmp	.LBB1_70
.LBB1_67:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$183, %edx
	jmp	.LBB1_70
.LBB1_68:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$184, %edx
	jmp	.LBB1_70
.LBB1_69:
	movl	%eax, %ebx
	movl	$.L.str.5, %edi
	movl	$.L.str.6, %esi
	movl	$185, %edx
.LBB1_70:
	xorl	%eax, %eax
	callq	printf
	movl	%ebx, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %edi
	movl	%ebx, %esi
.LBB1_71:
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	printf
.LBB1_56:
	movl	$1, %edi
	callq	exit
.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	$_Z20compute_displacementPiPfS0_S0_iii, %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	_Z20compute_displacementPiPfS0_S0_iii,@object # @_Z20compute_displacementPiPfS0_S0_iii
	.section	.rodata,"a",@progbits
	.globl	_Z20compute_displacementPiPfS0_S0_iii
	.p2align	3, 0x0
_Z20compute_displacementPiPfS0_S0_iii:
	.quad	_Z35__device_stub__compute_displacementPiPfS0_S0_iii
	.size	_Z20compute_displacementPiPfS0_S0_iii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"map_density.dat"
	.size	.L.str, 16

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"r"
	.size	.L.str.1, 2

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"reso_map.dat"
	.size	.L.str.2, 13

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"eigenvector.dat"
	.size	.L.str.3, 16

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"hb_count_matrix.dat"
	.size	.L.str.4, 20

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Error: %s:%d, "
	.size	.L.str.5, 15

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/slaustin/gpu_sources/master/projection.hip"
	.size	.L.str.6, 105

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"code:%d, reason: %s\n"
	.size	.L.str.7, 21

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"%i\t%i\t%i"
	.size	.L.str.8, 9

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Total Points=%i\n"
	.size	.L.str.9, 17

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"%i\t%i\t%i\t%i"
	.size	.L.str.10, 12

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Resolution Points=%i\n"
	.size	.L.str.11, 22

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"%f"
	.size	.L.str.13, 3

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"%i\t%i"
	.size	.L.str.14, 6

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Threads=%i\n"
	.size	.L.str.15, 12

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Blocks=%i\n"
	.size	.L.str.16, 11

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"w"
	.size	.L.str.17, 2

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"%i\t%f\n"
	.size	.L.str.18, 7

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z20compute_displacementPiPfS0_S0_iii"
	.size	.L__unnamed_1, 38

	.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	"Reading Input..."
	.size	.Lstr, 17

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Complete!"
	.size	.Lstr.1, 10

	.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 _Z35__device_stub__compute_displacementPiPfS0_S0_iii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z20compute_displacementPiPfS0_S0_iii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z20compute_displacementPiPfS0_S0_iii ; -- Begin function _Z20compute_displacementPiPfS0_S0_iii
	.globl	_Z20compute_displacementPiPfS0_S0_iii
	.p2align	8
	.type	_Z20compute_displacementPiPfS0_S0_iii,@function
_Z20compute_displacementPiPfS0_S0_iii:  ; @_Z20compute_displacementPiPfS0_S0_iii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x3c
	s_load_b128 s[8:11], s[0:1], 0x20
	s_mov_b32 s12, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	v_cmp_le_i32_e32 vcc_lo, s8, v1
	v_cmp_gt_i32_e64 s2, s9, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_cmp_gt_i32 s10, 0
	s_cselect_b32 s3, -1, 0
	s_and_b32 s2, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_5
; %bb.1:                                ; %.lr.ph
	s_load_b256 s[0:7], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	v_mov_b32_e32 v0, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s4, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_load_b32 s4, s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_cmp_lg_u32 s4, 1
	s_cbranch_scc1 .LBB0_4
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	v_mad_u64_u32 v[4:5], null, s12, s9, v[1:2]
	s_ashr_i32 s13, s12, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[4:5], s[12:13], 2
	s_add_u32 s4, s6, s4
	s_addc_u32 s5, s7, s5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s12, s12, 1
	v_lshlrev_b64 v[4:5], 2, v[4:5]
	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
	global_load_b32 v6, v0, s[4:5]
	global_load_b32 v4, v[4:5], off
	global_load_b32 v5, v[2:3], off
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v5, v4, v6
	global_store_b32 v[2:3], v5, off
.LBB0_4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_add_i32 s10, s10, -1
	s_add_u32 s0, s0, 4
	s_addc_u32 s1, s1, 0
	s_cmp_lg_u32 s10, 0
	s_cbranch_scc1 .LBB0_2
.LBB0_5:                                ; %.loopexit
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z20compute_displacementPiPfS0_S0_iii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 304
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 7
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z20compute_displacementPiPfS0_S0_iii, .Lfunc_end0-_Z20compute_displacementPiPfS0_S0_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 296
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
