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

//Dimension of problem grid
#define NPROB 240     	 
#define GENERATION 100000	
//Size of threads should be multiple of warp's size(32)     
#define THREAD_NUMBER 64 	

//Standard inidat

void inidat(int nx, bool *u)
{
	int ix, iy;
	for (ix = 0; ix <= nx - 1; ix++)
	{
		for (iy = 0; iy <= nx - 1; iy++)
		{
			u[ix*NPROB+iy] = rand() % 2;
		}
	}
}

//Standard prtdat

void prtdat(int nx, bool* u, char *fnam)
{
	int ix, iy;
	FILE *fp;
	fp = fopen(fnam, "w");
	for (ix = 0; ix < nx; ix++)
	{
		for (iy = 0; iy < nx; iy++)
		{
			fprintf(fp, "%d", u[ix*NPROB+iy]);
			if (iy != nx - 1)
			{
				fprintf(fp, " ");
			}
			else
			{
				fprintf(fp, "\n");
			}
		}
	}
	fclose(fp);
}


__global__ void Update(bool *A, bool* B)
{
	//Take Indexes

	int i, j,temp,sum,down,up,left,right;
	temp = blockIdx.x * blockDim.x + threadIdx.x;
	i = temp / NPROB;
	j = temp % NPROB;


	//Check for errors and values of edges

	if (i < 0 || i > NPROB - 1 || j < 0 || j > NPROB - 1)
	{
		return;
	}

	down = (i != NPROB-1) ? i+1 : 0;
	up = (i != 0) ? i-1 : NPROB-1;
	left = (j != 0) ? j-1 : NPROB-1;
	right = (j != NPROB-1) ? j+1 : 0;

	sum = A[down*NPROB+j] + A[up*NPROB+j] + A[i*NPROB+left] + A[i*NPROB+right] + A[down*NPROB+left] + A[up*NPROB+left] + A[down*NPROB+right] + A[up*NPROB+right];
	
	//Calculate formula

	B[i*NPROB+j] = ((sum == 3) || (A[i*NPROB+j] == true && sum == 2));

	__syncthreads();
}

	


int main(int argc,char *argv[])
{
	bool *d_A,*d_B, *h_A;
	int it;
	
	//Creating two 1d arrays for cuda 

	cudaMalloc((void**)&d_A,(unsigned long)(NPROB*NPROB*sizeof(bool)));
	cudaMalloc((void**)&d_B,(unsigned long)(NPROB*NPROB*sizeof(bool)));

	//Creating h_A to initialiaze 

	h_A=(bool*)malloc(NPROB*NPROB*sizeof(bool));
	memset(h_A,0,NPROB*NPROB*sizeof(bool));
	
	//Transfering the h_A to device 

	printf("Grid size: %d Generations: %d\n", NPROB, GENERATION);
	printf("Initializing grid and writing in initial.dat  \n");

	inidat(NPROB,h_A);
	prtdat(NPROB, h_A, "initial.dat");
	cudaMemcpy(d_B,h_A,NPROB*NPROB*sizeof(bool),cudaMemcpyHostToDevice);
	cudaMemcpy(d_A,h_A,NPROB*NPROB*sizeof(bool),cudaMemcpyHostToDevice);	
	
	bool* handler;
	
	struct timeval  tv1, tv2;
	gettimeofday(&tv1, NULL);
	
	for (it = 1; it <= GENERATION; it++)
	{
		//Swapping between the two arrays
       	
		Update<<<NPROB*NPROB/THREAD_NUMBER+1,THREAD_NUMBER>>>(d_A,d_B);	

		cudaThreadSynchronize();

        handler = d_A;
		d_A = d_B;
		d_B = handler; 
   		
	}
			
	gettimeofday(&tv2, NULL);
	printf("Finished after %f seconds\n", (double) (tv2.tv_usec - tv1.tv_usec) / 1000000 + (double) (tv2.tv_sec - tv1.tv_sec));
	printf("Writing final.dat file \n");

	//Copy results back to host memory 

	cudaMemcpy(h_A,d_A, NPROB*NPROB*sizeof(bool), cudaMemcpyDeviceToHost) ;	

	//Print Results

	prtdat(NPROB, h_A, "final.dat");
	
	
	cudaFree(d_A);	
	cudaFree(d_B);
	
    free(h_A);
	
}

	.file	"tmpxft_0024f0d9_00000000-6_life_game_cuda.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z6inidatiPb
	.type	_Z6inidatiPb, @function
_Z6inidatiPb:
.LFB2027:
	.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
	movslq	%edi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r14, %r12
	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
	pushq	%rdx
	.cfi_def_cfa_offset 64
.L3:
	cmpl	%r12d, %r13d
	jge	.L9
	movq	%rbx, %rbp
	leaq	(%r14,%rbx), %r15
.L4:
	call	rand@PLT
	movb	%al, 0(%rbp)
	andb	$1, 0(%rbp)
	incq	%rbp
	cmpq	%r15, %rbp
	jne	.L4
	incl	%r13d
	addq	$240, %rbx
	jmp	.L3
.L9:
	popq	%rax
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z6inidatiPb, .-_Z6inidatiPb
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"w"
.LC1:
	.string	"%d"
.LC2:
	.string	" "
.LC3:
	.string	"\n"
	.text
	.globl	_Z6prtdatiPbPc
	.type	_Z6prtdatiPbPc, @function
_Z6prtdatiPbPc:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %r15
	movq	%rdx, %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	leaq	.LC0(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%r15, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	movq	%rax, 8(%rsp)
.L11:
	cmpl	%r12d, %ebx
	jle	.L19
	imulq	$240, %r12, %r14
	xorl	%ebp, %ebp
	addq	%r13, %r14
.L14:
	movzbl	(%r14,%rbp), %ecx
	movq	8(%rsp), %rdi
	leaq	.LC1(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	leal	-1(%rbx), %eax
	leaq	.LC2(%rip), %rdx
	cmpl	%ebp, %eax
	jne	.L18
	leaq	.LC3(%rip), %rdx
.L18:
	movq	8(%rsp), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	incq	%rbp
	call	__fprintf_chk@PLT
	cmpq	%r15, %rbp
	jne	.L14
	incq	%r12
	jmp	.L11
.L19:
	movq	8(%rsp), %rdi
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z6prtdatiPbPc, .-_Z6prtdatiPbPc
	.globl	_Z27__device_stub__Z6UpdatePbS_PbS_
	.type	_Z27__device_stub__Z6UpdatePbS_PbS_, @function
_Z27__device_stub__Z6UpdatePbS_PbS_:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L20
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z6UpdatePbS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L20:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z27__device_stub__Z6UpdatePbS_PbS_, .-_Z27__device_stub__Z6UpdatePbS_PbS_
	.globl	_Z6UpdatePbS_
	.type	_Z6UpdatePbS_, @function
_Z6UpdatePbS_:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z27__device_stub__Z6UpdatePbS_PbS_
	.cfi_endproc
.LFE2055:
	.size	_Z6UpdatePbS_, .-_Z6UpdatePbS_
	.section	.rodata.str1.1
.LC4:
	.string	"Grid size: %d Generations: %d\n"
.LC5:
	.string	"Initializing grid and writing in initial.dat  \n"
.LC6:
	.string	"initial.dat"
.LC8:
	.string	"Finished after %f seconds\n"
.LC9:
	.string	"Writing final.dat file \n"
.LC10:
	.string	"final.dat"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$57600, %esi
	movabsq	$4294967360, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	$100000, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$80, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$57600, %esi
	leaq	16(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$57600, %edi
	call	malloc@PLT
	movl	$14400, %ecx
	movl	$240, %edx
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rbx
	xorl	%eax, %eax
	movq	%rbx, %rdi
	rep stosl
	movl	$100000, %ecx
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbx, %rsi
	movl	$240, %edi
	call	_Z6inidatiPb
	leaq	.LC6(%rip), %rdx
	movq	%rbx, %rsi
	movl	$240, %edi
	call	_Z6prtdatiPbPc
	movq	16(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$57600, %edx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$57600, %edx
	call	cudaMemcpy@PLT
	leaq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	gettimeofday@PLT
.L27:
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	movl	$1, %ecx
	movabsq	$4294968197, %rdi
	movl	$1, %esi
	movq	%r12, 56(%rsp)
	movl	$1, 64(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L26
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdi
	call	_Z27__device_stub__Z6UpdatePbS_PbS_
.L26:
	call	cudaThreadSynchronize@PLT
	movq	8(%rsp), %rax
	movq	16(%rsp), %rdx
	movq	%rax, 16(%rsp)
	movq	%rdx, 8(%rsp)
	decl	%ebp
	jne	.L27
	xorl	%esi, %esi
	leaq	56(%rsp), %rdi
	call	gettimeofday@PLT
	movq	64(%rsp), %rax
	subq	48(%rsp), %rax
	leaq	.LC8(%rip), %rsi
	cvtsi2sdq	%rax, %xmm0
	movq	56(%rsp), %rax
	subq	40(%rsp), %rax
	divsd	.LC7(%rip), %xmm0
	cvtsi2sdq	%rax, %xmm1
	movl	$2, %edi
	movb	$1, %al
	addsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$57600, %edx
	call	cudaMemcpy@PLT
	leaq	.LC10(%rip), %rdx
	movq	%rbx, %rsi
	movl	$240, %edi
	call	_Z6prtdatiPbPc
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$80, %rsp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	main, .-main
	.section	.rodata.str1.1
.LC11:
	.string	"_Z6UpdatePbS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2057:
	.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	.LC11(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z6UpdatePbS_(%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
.LFE2057:
	.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
.LC7:
	.long	0
	.long	1093567616
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


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

//Dimension of problem grid
#define NPROB 240     	 
#define GENERATION 100000	
//Size of threads should be multiple of warp's size(32)     
#define THREAD_NUMBER 64 	

//Standard inidat

void inidat(int nx, bool *u)
{
	int ix, iy;
	for (ix = 0; ix <= nx - 1; ix++)
	{
		for (iy = 0; iy <= nx - 1; iy++)
		{
			u[ix*NPROB+iy] = rand() % 2;
		}
	}
}

//Standard prtdat

void prtdat(int nx, bool* u, char *fnam)
{
	int ix, iy;
	FILE *fp;
	fp = fopen(fnam, "w");
	for (ix = 0; ix < nx; ix++)
	{
		for (iy = 0; iy < nx; iy++)
		{
			fprintf(fp, "%d", u[ix*NPROB+iy]);
			if (iy != nx - 1)
			{
				fprintf(fp, " ");
			}
			else
			{
				fprintf(fp, "\n");
			}
		}
	}
	fclose(fp);
}


__global__ void Update(bool *A, bool* B)
{
	//Take Indexes

	int i, j,temp,sum,down,up,left,right;
	temp = blockIdx.x * blockDim.x + threadIdx.x;
	i = temp / NPROB;
	j = temp % NPROB;


	//Check for errors and values of edges

	if (i < 0 || i > NPROB - 1 || j < 0 || j > NPROB - 1)
	{
		return;
	}

	down = (i != NPROB-1) ? i+1 : 0;
	up = (i != 0) ? i-1 : NPROB-1;
	left = (j != 0) ? j-1 : NPROB-1;
	right = (j != NPROB-1) ? j+1 : 0;

	sum = A[down*NPROB+j] + A[up*NPROB+j] + A[i*NPROB+left] + A[i*NPROB+right] + A[down*NPROB+left] + A[up*NPROB+left] + A[down*NPROB+right] + A[up*NPROB+right];
	
	//Calculate formula

	B[i*NPROB+j] = ((sum == 3) || (A[i*NPROB+j] == true && sum == 2));

	__syncthreads();
}

	


int main(int argc,char *argv[])
{
	bool *d_A,*d_B, *h_A;
	int it;
	
	//Creating two 1d arrays for cuda 

	hipMalloc((void**)&d_A,(unsigned long)(NPROB*NPROB*sizeof(bool)));
	hipMalloc((void**)&d_B,(unsigned long)(NPROB*NPROB*sizeof(bool)));

	//Creating h_A to initialiaze 

	h_A=(bool*)malloc(NPROB*NPROB*sizeof(bool));
	memset(h_A,0,NPROB*NPROB*sizeof(bool));
	
	//Transfering the h_A to device 

	printf("Grid size: %d Generations: %d\n", NPROB, GENERATION);
	printf("Initializing grid and writing in initial.dat  \n");

	inidat(NPROB,h_A);
	prtdat(NPROB, h_A, "initial.dat");
	hipMemcpy(d_B,h_A,NPROB*NPROB*sizeof(bool),hipMemcpyHostToDevice);
	hipMemcpy(d_A,h_A,NPROB*NPROB*sizeof(bool),hipMemcpyHostToDevice);	
	
	bool* handler;
	
	struct timeval  tv1, tv2;
	gettimeofday(&tv1, NULL);
	
	for (it = 1; it <= GENERATION; it++)
	{
		//Swapping between the two arrays
       	
		Update<<<NPROB*NPROB/THREAD_NUMBER+1,THREAD_NUMBER>>>(d_A,d_B);	

		hipDeviceSynchronize();

        handler = d_A;
		d_A = d_B;
		d_B = handler; 
   		
	}
			
	gettimeofday(&tv2, NULL);
	printf("Finished after %f seconds\n", (double) (tv2.tv_usec - tv1.tv_usec) / 1000000 + (double) (tv2.tv_sec - tv1.tv_sec));
	printf("Writing final.dat file \n");

	//Copy results back to host memory 

	hipMemcpy(h_A,d_A, NPROB*NPROB*sizeof(bool), hipMemcpyDeviceToHost) ;	

	//Print Results

	prtdat(NPROB, h_A, "final.dat");
	
	
	hipFree(d_A);	
	hipFree(d_B);
	
    free(h_A);
	
}

	.text
	.file	"life_game_cuda.hip"
	.globl	_Z6inidatiPb                    # -- Begin function _Z6inidatiPb
	.type	_Z6inidatiPb,@function
_Z6inidatiPb:                           # @_Z6inidatiPb
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jle	.LBB0_6
# %bb.1:                                # %.preheader.lr.ph
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %r14d
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
.LBB0_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_3 Depth 2
	movl	%r15d, %r13d
	shll	$4, %r13d
	addq	%rbx, %r13
	xorl	%ebp, %ebp
.LBB0_3:                                #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	andb	$1, %al
	movb	%al, (%r13,%rbp)
	incq	%rbp
	cmpq	%rbp, %r14
	jne	.LBB0_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB0_2 Depth=1
	incq	%r12
	addl	$15, %r15d
	cmpq	%r14, %r12
	jne	.LBB0_2
# %bb.5:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB0_6:                                # %._crit_edge15
	retq
.Lfunc_end0:
	.size	_Z6inidatiPb, .Lfunc_end0-_Z6inidatiPb
	.cfi_endproc
                                        # -- End function
	.globl	_Z6prtdatiPbPc                  # -- Begin function _Z6prtdatiPbPc
	.type	_Z6prtdatiPbPc,@function
_Z6prtdatiPbPc:                         # @_Z6prtdatiPbPc
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, 8(%rsp)                   # 8-byte Spill
	movl	%edi, %r15d
	movl	$.L.str, %esi
	movq	%rdx, %rdi
	callq	fopen
	movq	%rax, %r14
	testl	%r15d, %r15d
	jle	.LBB1_5
# %bb.1:                                # %.preheader.lr.ph
	leal	-1(%r15), %r12d
	movl	%r15d, %r15d
	movl	$10, %ebp
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB1_2:                                # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_3 Depth 2
	movq	%rcx, 16(%rsp)                  # 8-byte Spill
	movl	%eax, 4(%rsp)                   # 4-byte Spill
	movl	%eax, %r13d
	shll	$4, %r13d
	addq	8(%rsp), %r13                   # 8-byte Folded Reload
	xorl	%ebx, %ebx
.LBB1_3:                                #   Parent Loop BB1_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	(%r13,%rbx), %edx
	movl	$.L.str.1, %esi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	fprintf
	cmpq	%rbx, %r12
	movl	$32, %edi
	cmovel	%ebp, %edi
	movq	%r14, %rsi
	callq	fputc@PLT
	incq	%rbx
	cmpq	%rbx, %r15
	jne	.LBB1_3
# %bb.4:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	movq	16(%rsp), %rcx                  # 8-byte Reload
	incq	%rcx
	movl	4(%rsp), %eax                   # 4-byte Reload
	addl	$15, %eax
	cmpq	%r15, %rcx
	jne	.LBB1_2
.LBB1_5:                                # %._crit_edge20
	movq	%r14, %rdi
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.Lfunc_end1:
	.size	_Z6prtdatiPbPc, .Lfunc_end1-_Z6prtdatiPbPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__UpdatePbS_   # -- Begin function _Z21__device_stub__UpdatePbS_
	.type	_Z21__device_stub__UpdatePbS_,@function
_Z21__device_stub__UpdatePbS_:          # @_Z21__device_stub__UpdatePbS_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	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	$_Z6UpdatePbS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z21__device_stub__UpdatePbS_, .Lfunc_end2-_Z21__device_stub__UpdatePbS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	8(%rsp), %rdi
	movl	$57600, %esi                    # imm = 0xE100
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movl	$57600, %esi                    # imm = 0xE100
	callq	hipMalloc
	movl	$1, %edi
	movl	$57600, %esi                    # imm = 0xE100
	callq	calloc@PLT
	movq	%rax, %rbx
	xorl	%r14d, %r14d
	movl	$.L.str.4, %edi
	movl	$240, %esi
	movl	$100000, %edx                   # imm = 0x186A0
	xorl	%eax, %eax
	callq	printf
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$240, %r15d
	movq	%rbx, %r12
.LBB3_1:                                # %.lr.ph.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_2 Depth 2
	xorl	%r13d, %r13d
.LBB3_2:                                #   Parent Loop BB3_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	callq	rand
	andb	$1, %al
	movb	%al, (%r12,%r13)
	incq	%r13
	cmpq	$240, %r13
	jne	.LBB3_2
# %bb.3:                                # %._crit_edge.i
                                        #   in Loop: Header=BB3_1 Depth=1
	incq	%r14
	addq	%r15, %r12
	cmpq	%r15, %r14
	jne	.LBB3_1
# %bb.4:                                # %_Z6inidatiPb.exit
	movabsq	$4294967360, %r14               # imm = 0x100000040
	movl	$.L.str.6, %edx
	movl	$240, %edi
	movq	%rbx, %rsi
	callq	_Z6prtdatiPbPc
	movq	16(%rsp), %rdi
	movl	$57600, %edx                    # imm = 0xE100
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	8(%rsp), %rdi
	movl	$57600, %edx                    # imm = 0xE100
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movl	$100000, %ebp                   # imm = 0x186A0
	leaq	837(%r14), %r15
.LBB3_5:                                # =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_7
# %bb.6:                                #   in Loop: Header=BB3_5 Depth=1
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi
	callq	_Z21__device_stub__UpdatePbS_
.LBB3_7:                                #   in Loop: Header=BB3_5 Depth=1
	callq	hipDeviceSynchronize
	movq	8(%rsp), %rax
	movq	16(%rsp), %rcx
	movq	%rcx, 8(%rsp)
	movq	%rax, 16(%rsp)
	decl	%ebp
	jne	.LBB3_5
# %bb.8:
	leaq	40(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r14), %rax
	movq	8(%r14), %rcx
	subq	32(%rsp), %rcx
	cvtsi2sd	%rcx, %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	subq	24(%rsp), %rax
	cvtsi2sd	%rax, %xmm0
	addsd	%xmm1, %xmm0
	movl	$.L.str.7, %edi
	movb	$1, %al
	callq	printf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movq	8(%rsp), %rsi
	movl	$57600, %edx                    # imm = 0xE100
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.9, %edx
	movl	$240, %edi
	movq	%rbx, %rsi
	callq	_Z6prtdatiPbPc
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	%rbx, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	main, .Lfunc_end3-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	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6UpdatePbS_, %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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"w"
	.size	.L.str, 2

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"%d"
	.size	.L.str.1, 3

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

	.type	.L.str.4,@object                # @.str.4
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.4:
	.asciz	"Grid size: %d Generations: %d\n"
	.size	.L.str.4, 31

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

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Finished after %f seconds\n"
	.size	.L.str.7, 27

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"final.dat"
	.size	.L.str.9, 10

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6UpdatePbS_"
	.size	.L__unnamed_1, 14

	.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	"Initializing grid and writing in initial.dat  "
	.size	.Lstr, 47

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Writing final.dat file "
	.size	.Lstr.1, 24

	.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 _Z21__device_stub__UpdatePbS_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z6UpdatePbS_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z6UpdatePbS_           ; -- Begin function _Z6UpdatePbS_
	.globl	_Z6UpdatePbS_
	.p2align	8
	.type	_Z6UpdatePbS_,@function
_Z6UpdatePbS_:                          ; @_Z6UpdatePbS_
; %bb.0:
	s_load_b32 s2, s[0:1], 0x1c
	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_mul_hi_i32 v0, 0x88888889, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v0, v0, v1
	v_lshrrev_b32_e32 v2, 31, v0
	v_ashrrev_i32_e32 v0, 7, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v0, v0, v2
	v_add_nc_u32_e32 v2, 0xffff1f00, v1
	v_mul_lo_u32 v0, 0xf0, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_lt_u32_e32 vcc_lo, 0xffff1e10, v2
	v_sub_nc_u32_e32 v0, v1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_lt_i32_e64 s2, -1, v0
	s_and_b32 s2, vcc_lo, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_6
; %bb.1:
	v_sub_nc_u32_e32 v6, v1, v0
	s_load_b128 s[0:3], s[0:1], 0x0
	v_add_nc_u32_e32 v4, 0xffff1ff0, v1
	s_mov_b32 s5, exec_lo
                                        ; implicit-def: $sgpr4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_add_nc_u32_e32 v7, 0xf0, v6
	v_add_nc_u32_e32 v2, 0xef, v1
	v_add_nc_u32_e32 v3, 0xffffff10, v6
	v_cmp_lt_u32_e32 vcc_lo, 0x1de, v2
	v_add_nc_u32_e32 v5, -1, v0
	v_add_nc_u32_e32 v2, 1, v0
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_cndmask_b32_e32 v8, 0xe010, v3, vcc_lo
	v_cmp_ne_u32_e32 vcc_lo, 0, v0
	v_cndmask_b32_e32 v9, 0xef, v5, vcc_lo
	v_cmp_lt_u32_e32 vcc_lo, 0xef, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_dual_cndmask_b32 v7, 0, v7 :: v_dual_add_nc_u32 v4, v9, v6
	v_cmp_ne_u32_e32 vcc_lo, 0xef, v0
	v_add_nc_u32_e32 v3, v8, v0
	v_ashrrev_i32_e32 v11, 31, v4
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_add_nc_u32_e32 v0, v7, v0
	v_cndmask_b32_e32 v10, 0, v2, vcc_lo
	v_ashrrev_i32_e32 v5, 31, v3
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s0, v3
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_nc_u32_e32 v6, v10, v6
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v5, vcc_lo
	v_add_co_u32 v4, vcc_lo, s0, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v11, vcc_lo
	v_add_nc_u32_e32 v11, v7, v9
	s_clause 0x1
	global_load_u8 v0, v0, s[0:1]
	global_load_u8 v12, v[2:3], off
	v_add_nc_u32_e32 v9, v8, v9
	s_clause 0x1
	global_load_u8 v13, v[4:5], off
	global_load_u8 v6, v6, s[0:1]
	v_ashrrev_i32_e32 v3, 31, v11
	v_add_co_u32 v2, vcc_lo, s0, v11
	v_ashrrev_i32_e32 v5, 31, v9
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	v_add_co_u32 v4, vcc_lo, s0, v9
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	global_load_u8 v9, v[2:3], off
	v_add_nc_u32_e32 v2, v7, v10
	v_add_nc_u32_e32 v3, v8, v10
	s_clause 0x1
	global_load_u8 v4, v[4:5], off
	global_load_u8 v5, v2, s[0:1]
	v_ashrrev_i32_e32 v7, 31, v3
	v_add_co_u32 v2, vcc_lo, s0, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v7, vcc_lo
	global_load_u8 v2, v[2:3], off
	s_waitcnt vmcnt(6)
	v_add_nc_u16 v0, v12, v0
	s_waitcnt vmcnt(5)
	v_add_nc_u16 v0, v0, v13
	s_waitcnt vmcnt(4)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_nc_u16 v0, v0, v6
	s_waitcnt vmcnt(3)
	v_add_nc_u16 v0, v0, v9
	s_waitcnt vmcnt(2)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_nc_u16 v0, v0, v4
	s_waitcnt vmcnt(1)
	v_add_nc_u16 v0, v0, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_and_b32_e32 v0, 0xff, v0
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v0, v0, v2
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_ne_u32_e32 3, v0
	s_xor_b32 s5, exec_lo, s5
                                        ; implicit-def: $vgpr1_vgpr2
	s_cbranch_execz .LBB0_3
; %bb.2:
	global_load_u8 v2, v1, s[0:1]
	v_cmp_eq_u32_e32 vcc_lo, 2, v0
	s_waitcnt vmcnt(0)
	v_cmp_ne_u16_e64 s0, 0, v2
	v_mov_b32_e32 v2, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, vcc_lo, s0
	s_and_b32 s4, s0, exec_lo
.LBB0_3:                                ; %Flow
	s_and_not1_saveexec_b32 s0, s5
; %bb.4:                                ; %._crit_edge
	v_mov_b32_e32 v2, 0
	s_or_b32 s4, s4, exec_lo
; %bb.5:
	s_or_b32 exec_lo, exec_lo, s0
	v_add_co_u32 v0, vcc_lo, s2, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v2, vcc_lo
	v_cndmask_b32_e64 v2, 0, 1, s4
	global_store_b8 v[0:1], v2, off
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
.LBB0_6:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6UpdatePbS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 14
		.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	_Z6UpdatePbS_, .Lfunc_end0-_Z6UpdatePbS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 684
; NumSgprs: 18
; NumVgprs: 14
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 14
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6UpdatePbS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z6UpdatePbS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     14
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
