/* Metsai Aleksandros 7723
 * metsalex@ece.auth.gr
 * 
 *  Game of life using CUDA. Multiple cells per thread and use of shared memory
 */

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

#define THRESHOLD 0.4


#define CELLS_PER_THREAD 2
#define THREADS_PER_BLOCK (500/CELLS_PER_THREAD)


struct timeval startwtime, endwtime;
double seq_time;


__global__ void game_c (int *newer, int *old, int N)
{
	
  int lsize=THREADS_PER_BLOCK*CELLS_PER_THREAD;
  
  __shared__ int top[THREADS_PER_BLOCK*CELLS_PER_THREAD+2];		//Extended Tables
  __shared__ int mid[THREADS_PER_BLOCK*CELLS_PER_THREAD+2];
  __shared__ int bot[THREADS_PER_BLOCK*CELLS_PER_THREAD+2];
  
  int index = blockIdx.x*blockDim.x*CELLS_PER_THREAD + threadIdx.x*CELLS_PER_THREAD;
  int count;
  int sum=0;
  int i=(int) index/N;
  int j= index%N;
  int lindex = threadIdx.x*CELLS_PER_THREAD +1; //Local Index
  
  for(count=0; count<CELLS_PER_THREAD;count++){
	  
	  
	  if(i==0){
		  
		  //top
		  
		  if(j==0){
			  
			  top[0]= old[N*N-1];
			  mid[0]= old[N-1];
			  bot[0]= old[2*N -1];
			  
			  top[1]= old[N*(N-1)];
			  mid[1]= old[0];
			  bot[1]= old[N];
			  
		  }else if(j==(N-1)){
			  
			  top[lindex+1]= old[N*(N-1)];
			  mid[lindex+1]= old[0];
			  bot[lindex+1]= old[N];
			  
			  top[lindex]= old[N*N -1];
			  mid[lindex]= old[N-1];
			  bot[lindex]= old[2*N -1];
			  
		  }else{
			  if(lindex==1){
				  
				  top[lindex-1]= old[N*(N-1) +(j-1)];
				  mid[lindex-1]= old[j-1];
				  bot[lindex-1]= old[N+(j-1)];
				  
				  top[lindex]= old[N*(N-1) +j];
				  mid[lindex]= old[j];
				  bot[lindex]= old[N+j];
				  
			  }else if(lindex==(lsize)){
				  
				  top[lindex+1]= old[N*(N-1) +(j+1)];
				  mid[lindex+1]= old[j+1];
				  bot[lindex+1]= old[N+ (j+1)];
				  
				  top[lindex]= old[N*(N-1) +j];
				  mid[lindex]= old[j];
				  bot[lindex]= old[N +j];
				  
			  }else{
				  
				  top[lindex]= old[N*(N-1) +j];
				  mid[lindex]= old[j];
				  bot[lindex]= old[N+j];
				  
			  }
		  }
	  }else if(i==(N-1)){
		  
		  //bottom
		  
		  if(j==0){
			  
			  top[0]= old[N*(N-1) -1];
			  mid[0]= old[N*N -1];
			  bot[0]= old[N-1];
			  
			  top[1]= old[N*(N-2)];
			  mid[1]= old[N*(N-1)];
			  bot[1]= old[0];
			  
		  }else if(j==(N-1)){
			  
			  top[lindex+1]= old[N*(N-2)];
			  mid[lindex+1]= old[N*(N-1)];
			  bot[lindex+1]= old[0];
			  
			  top[lindex]= old[N*(N-1) -1];
			  mid[lindex]= old[N*N -1];
			  bot[lindex]= old[N-1];
			  
		  }else{
			  // !!
			  if(lindex==1){
			  
				top[lindex-1]= old[(i-1)*N +(j-1)];
				mid[lindex-1]= old[i*N +(j-1)];
				bot[lindex-1]= old[j-1];
			  
				top[lindex]= old[(i-1)*N +j];
				mid[lindex]= old[i*N +j];
				bot[lindex]= old[j];
			  
			  }else if(lindex==(lsize)){
			  
			   top[lindex+1]= old[(i-1)*N +(j+1)];
			   mid[lindex+1]= old[i*N +(j+1)];
			   bot[lindex+1]= old[(j+1)];
			  
			   top[lindex]= old[(i-1)*N +j];
			   mid[lindex]= old[i*N +j];
			   bot[lindex]= old[j];
			   
		    }else{
		  
				top[lindex]= old[(i-1)*N +j];
				mid[lindex]= old[i*N +j];
				bot[lindex]= old[j];
			}
			  
		 }
	  }else if(j==0){
		  
		  //left
		  
		  top[0]= old[(i-1)*N +(N-1)];
		  mid[0]= old[i*N +(N-1)];
		  bot[0]= old[(i+1)*N +(N-1)];
		  
		  top[1]= old[(i-1)*N];
		  mid[1]= old[i*N];
		  bot[1]= old[(i+1)*N];
		  
	  }else if(j==(N-1)){
		  
		  //right
		  
		  top[lindex+1]= old[(i-1)*N];
		  mid[lindex+1]= old[i*N];
		  bot[lindex+1]= old[(i+1)*N];
		  
		  top[lindex]= old[(i-1)*N +j];
		  mid[lindex]= old[i*N +j];
		  bot[lindex]= old[(i+1)*N +j];
		  
	  }else{
		  
		  //general case
		  
		  if(lindex==1){
			  
			  top[lindex-1]= old[(i-1)*N +(j-1)];
			  mid[lindex-1]= old[i*N +(j-1)];
			  bot[lindex-1]= old[(i+1)*N +(j-1)];
			  
			  top[lindex]= old[(i-1)*N +j];
			  mid[lindex]= old[i*N +j];
			  bot[lindex]= old[(i+1)*N +j];
			  
		  }else if(lindex==(lsize)){
			  
			  top[lindex+1]= old[(i-1)*N +(j+1)];
			  mid[lindex+1]= old[i*N +(j+1)];
			  bot[lindex+1]= old[(i+1)*N +(j+1)];
			  
			  top[lindex]= old[(i-1)*N +j];
			  mid[lindex]= old[i*N +j];
			  bot[lindex]= old[(i+1)*N +j];
		  }else{
		  
			top[lindex]= old[(i-1)*N +j];
			mid[lindex]= old[i*N +j];
			bot[lindex]= old[(i+1)*N +j];
			
		  }
	  }
	  
	  lindex++;
	  j++;
  }
  
  //Restore values
  j=index%N;
  lindex=threadIdx.x*CELLS_PER_THREAD +1;
  
  __syncthreads();
  
  for(count=0; count<CELLS_PER_THREAD; count++){
	  
	  sum= top[lindex-1] +top[lindex]+top[lindex+1]
	  +mid[lindex-1] +mid[lindex+1]
	  +bot[lindex-1] +bot[lindex] +bot[lindex+1];
	  
	  switch(sum){
		  
		  case 3:
		  newer[i*N + j] = 1;
		  break;
		  
		  case 2:
		  newer[i*N + j] = old[i*N + j];
		  break;
		  
		  default:
		  newer[i*N + j] = 0;
	  }
	  
	  lindex++;
	  j++;
  }

}


void read_from_file(int *X, char *filename, int N);
void save_table(int *X, int N);


int main(){
	

	int *table;
	int* newer;
	int* old;
	int *temp;
	
	int blocks, t, N, count;

	
	printf("Set the number of generations\n");
	scanf("%d", &t);
	printf("Set N (table size = NxN)\n");
	scanf("%d", &N);
	int size=N*N*sizeof(int);
	
	/*
	 Insert table here
	 */
	
	
	char filename[20];
	sprintf(filename, "table%dx%d.bin", N, N);
	printf("Reading %dx%d table from file %s\n", N, N, filename);
	table = (int *)malloc(N*N*sizeof(int));
	read_from_file(table, filename, N);  	
	

	printf("This is kernel c\n");
	
	printf("The game will be played for %d generations N=%d\n", t, N);
	
	//!!!Start Timer!!!
	gettimeofday (&startwtime, NULL);
	
	//Allocate space of new and old in device
	cudaMalloc(&newer, size);
	cudaMalloc(&old, size);
	
	//copy table
	cudaMemcpy(old, table, size, cudaMemcpyHostToDevice);
	
	blocks=(N*N)/(THREADS_PER_BLOCK*CELLS_PER_THREAD);
	
	//Play game for t generations
	for(count=0;count<t;count++){
		
		game_c<<<blocks, THREADS_PER_BLOCK>>>(newer, old, N);
		cudaThreadSynchronize();
		
		//swap pointers
		temp=old;
		old=newer;
		newer=temp;
	}
	
	//copy back table
	cudaMemcpy(table, old, size, cudaMemcpyDeviceToHost);
	
	//!!!End Timer!!!
	gettimeofday (&endwtime, NULL);
	  seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6
		      + endwtime.tv_sec - startwtime.tv_sec);
	  printf("Cuda clock time = %f\n", seq_time);
	
	save_table(table, N);
	
	cudaFree(newer);
	cudaFree(old);
	
	free(table);
	
	return(0);
}


void read_from_file(int *X, char *filename, int N){

  FILE *fp = fopen(filename, "r+");

  int size = fread(X, sizeof(int), N*N, fp);

  printf("elements: %d\n", size);

  fclose(fp);

}

void save_table(int *X, int N){

  FILE *fp;

  char filename[20];

  sprintf(filename, "cuda_c_table%dx%d.bin", N, N);

  printf("Saving table in file %s\n", filename);

  fp = fopen(filename, "w+");

  fwrite(X, sizeof(int), N*N, fp);

  fclose(fp);

}








	.file	"tmpxft_002b6f9c_00000000-6_CUDA_gameoflife_impl3.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r+"
.LC1:
	.string	"elements: %d\n"
	.text
	.globl	_Z14read_from_filePiPci
	.type	_Z14read_from_filePiPci, @function
_Z14read_from_filePiPci:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	movq	%rsi, %rdi
	leaq	.LC0(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edx, %ebx
	imull	%ebx, %ebx
	call	fopen@PLT
	movq	%r12, %rdi
	movl	$4, %edx
	orq	$-1, %rsi
	movslq	%ebx, %rcx
	movq	%rax, %r8
	movq	%rax, %rbp
	call	__fread_chk@PLT
	movl	$2, %edi
	leaq	.LC1(%rip), %rsi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	movq	%rbp, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z14read_from_filePiPci, .-_Z14read_from_filePiPci
	.section	.rodata.str1.1
.LC2:
	.string	"cuda_c_table%dx%d.bin"
.LC3:
	.string	"Saving table in file %s\n"
.LC4:
	.string	"w+"
	.text
	.globl	_Z10save_tablePii
	.type	_Z10save_tablePii, @function
_Z10save_tablePii:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%esi, %r9d
	movl	%esi, %r8d
	leaq	.LC2(%rip), %rcx
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %r12
	movl	$20, %edx
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%esi, %ebx
	movl	$2, %esi
	imull	%ebx, %ebx
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rbp
	movq	%rbp, %rdi
	call	__sprintf_chk@PLT
	movq	%rbp, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	leaq	.LC4(%rip), %rsi
	call	fopen@PLT
	movq	%r12, %rdi
	movslq	%ebx, %rdx
	movl	$4, %esi
	movq	%rax, %rbp
	movq	%rax, %rcx
	call	fwrite@PLT
	movq	%rbp, %rdi
	call	fclose@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z10save_tablePii, .-_Z10save_tablePii
	.globl	_Z28__device_stub__Z6game_cPiS_iPiS_i
	.type	_Z28__device_stub__Z6game_cPiS_iPiS_i, @function
_Z28__device_stub__Z6game_cPiS_iPiS_i:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z6game_cPiS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L8:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z28__device_stub__Z6game_cPiS_iPiS_i, .-_Z28__device_stub__Z6game_cPiS_iPiS_i
	.globl	_Z6game_cPiS_i
	.type	_Z6game_cPiS_i, @function
_Z6game_cPiS_i:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z6game_cPiS_iPiS_i
	.cfi_endproc
.LFE2055:
	.size	_Z6game_cPiS_i, .-_Z6game_cPiS_i
	.section	.rodata.str1.1
.LC5:
	.string	"Set the number of generations\n"
.LC6:
	.string	"%d"
.LC7:
	.string	"Set N (table size = NxN)\n"
.LC8:
	.string	"table%dx%d.bin"
.LC9:
	.string	"Reading %dx%d table from file %s\n"
.LC10:
	.string	"This is kernel c\n"
.LC11:
	.string	"The game will be played for %d generations N=%d\n"
.LC13:
	.string	"Cuda clock time = %f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movabsq	$4294967546, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC6(%rip), %rbx
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	52(%rsp), %r12
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	movq	%rsp, %rsi
	xorl	%eax, %eax
	call	__isoc23_scanf@PLT
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbx, %rdi
	leaq	4(%rsp), %rsi
	xorl	%eax, %eax
	call	__isoc23_scanf@PLT
	movl	4(%rsp), %ebx
	movq	%r12, %rdi
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rcx
	movl	$20, %edx
	movl	$2, %esi
	movl	%ebx, %r9d
	movl	%ebx, %r8d
	call	__sprintf_chk@PLT
	movl	4(%rsp), %edx
	movq	%r12, %r8
	xorl	%eax, %eax
	movl	$2, %edi
	imull	%ebx, %ebx
	leaq	.LC9(%rip), %rsi
	movl	%edx, %ecx
	call	__printf_chk@PLT
	movl	4(%rsp), %r13d
	sall	$2, %ebx
	movl	%r13d, %edi
	movslq	%ebx, %rbx
	imull	%r13d, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movl	%r13d, %edx
	movq	%r12, %rsi
	xorl	%r13d, %r13d
	movq	%rax, %rdi
	movq	%rax, %rbp
	call	_Z14read_from_filePiPci
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	4(%rsp), %ecx
	movl	(%rsp), %edx
	xorl	%eax, %eax
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	xorl	%esi, %esi
	leaq	startwtime(%rip), %rdi
	call	gettimeofday@PLT
	leaq	8(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	16(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	4(%rsp), %eax
	movl	$500, %ecx
	imull	%eax, %eax
	cltd
	idivl	%ecx
	movl	%eax, %r12d
.L14:
	cmpl	%r13d, (%rsp)
	jle	.L19
	movl	%r12d, 28(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	%r14, %rdx
	movabsq	$4294967297, %rax
	movl	$1, %ecx
	movq	%rax, 32(%rsp)
	movq	28(%rsp), %rdi
	movl	36(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	movl	4(%rsp), %edx
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdi
	call	_Z28__device_stub__Z6game_cPiS_iPiS_i
.L15:
	call	cudaThreadSynchronize@PLT
	movq	16(%rsp), %rax
	movq	8(%rsp), %rdx
	incl	%r13d
	movq	%rdx, 16(%rsp)
	movq	%rax, 8(%rsp)
	jmp	.L14
.L19:
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	movq	%rbp, %rdi
	call	cudaMemcpy@PLT
	xorl	%esi, %esi
	leaq	endwtime(%rip), %rdi
	call	gettimeofday@PLT
	movq	8+endwtime(%rip), %rax
	movl	$2, %edi
	cvtsi2sdq	endwtime(%rip), %xmm1
	subq	8+startwtime(%rip), %rax
	leaq	.LC13(%rip), %rsi
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC12(%rip), %xmm0
	movb	$1, %al
	addsd	%xmm1, %xmm0
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	movsd	%xmm0, seq_time(%rip)
	call	__printf_chk@PLT
	movl	4(%rsp), %esi
	movq	%rbp, %rdi
	call	_Z10save_tablePii
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$80, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z6game_cPiS_i"
	.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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z6game_cPiS_i(%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
	.globl	seq_time
	.bss
	.align 8
	.type	seq_time, @object
	.size	seq_time, 8
seq_time:
	.zero	8
	.globl	endwtime
	.align 16
	.type	endwtime, @object
	.size	endwtime, 16
endwtime:
	.zero	16
	.globl	startwtime
	.align 16
	.type	startwtime, @object
	.size	startwtime, 16
startwtime:
	.zero	16
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC12:
	.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:

/* Metsai Aleksandros 7723
 * metsalex@ece.auth.gr
 * 
 *  Game of life using CUDA. Multiple cells per thread and use of shared memory
 */


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

#define THRESHOLD 0.4


#define CELLS_PER_THREAD 2
#define THREADS_PER_BLOCK (500/CELLS_PER_THREAD)


struct timeval startwtime, endwtime;
double seq_time;


__global__ void game_c (int *newer, int *old, int N)
{
	
  int lsize=THREADS_PER_BLOCK*CELLS_PER_THREAD;
  
  __shared__ int top[THREADS_PER_BLOCK*CELLS_PER_THREAD+2];		//Extended Tables
  __shared__ int mid[THREADS_PER_BLOCK*CELLS_PER_THREAD+2];
  __shared__ int bot[THREADS_PER_BLOCK*CELLS_PER_THREAD+2];
  
  int index = blockIdx.x*blockDim.x*CELLS_PER_THREAD + threadIdx.x*CELLS_PER_THREAD;
  int count;
  int sum=0;
  int i=(int) index/N;
  int j= index%N;
  int lindex = threadIdx.x*CELLS_PER_THREAD +1; //Local Index
  
  for(count=0; count<CELLS_PER_THREAD;count++){
	  
	  
	  if(i==0){
		  
		  //top
		  
		  if(j==0){
			  
			  top[0]= old[N*N-1];
			  mid[0]= old[N-1];
			  bot[0]= old[2*N -1];
			  
			  top[1]= old[N*(N-1)];
			  mid[1]= old[0];
			  bot[1]= old[N];
			  
		  }else if(j==(N-1)){
			  
			  top[lindex+1]= old[N*(N-1)];
			  mid[lindex+1]= old[0];
			  bot[lindex+1]= old[N];
			  
			  top[lindex]= old[N*N -1];
			  mid[lindex]= old[N-1];
			  bot[lindex]= old[2*N -1];
			  
		  }else{
			  if(lindex==1){
				  
				  top[lindex-1]= old[N*(N-1) +(j-1)];
				  mid[lindex-1]= old[j-1];
				  bot[lindex-1]= old[N+(j-1)];
				  
				  top[lindex]= old[N*(N-1) +j];
				  mid[lindex]= old[j];
				  bot[lindex]= old[N+j];
				  
			  }else if(lindex==(lsize)){
				  
				  top[lindex+1]= old[N*(N-1) +(j+1)];
				  mid[lindex+1]= old[j+1];
				  bot[lindex+1]= old[N+ (j+1)];
				  
				  top[lindex]= old[N*(N-1) +j];
				  mid[lindex]= old[j];
				  bot[lindex]= old[N +j];
				  
			  }else{
				  
				  top[lindex]= old[N*(N-1) +j];
				  mid[lindex]= old[j];
				  bot[lindex]= old[N+j];
				  
			  }
		  }
	  }else if(i==(N-1)){
		  
		  //bottom
		  
		  if(j==0){
			  
			  top[0]= old[N*(N-1) -1];
			  mid[0]= old[N*N -1];
			  bot[0]= old[N-1];
			  
			  top[1]= old[N*(N-2)];
			  mid[1]= old[N*(N-1)];
			  bot[1]= old[0];
			  
		  }else if(j==(N-1)){
			  
			  top[lindex+1]= old[N*(N-2)];
			  mid[lindex+1]= old[N*(N-1)];
			  bot[lindex+1]= old[0];
			  
			  top[lindex]= old[N*(N-1) -1];
			  mid[lindex]= old[N*N -1];
			  bot[lindex]= old[N-1];
			  
		  }else{
			  // !!
			  if(lindex==1){
			  
				top[lindex-1]= old[(i-1)*N +(j-1)];
				mid[lindex-1]= old[i*N +(j-1)];
				bot[lindex-1]= old[j-1];
			  
				top[lindex]= old[(i-1)*N +j];
				mid[lindex]= old[i*N +j];
				bot[lindex]= old[j];
			  
			  }else if(lindex==(lsize)){
			  
			   top[lindex+1]= old[(i-1)*N +(j+1)];
			   mid[lindex+1]= old[i*N +(j+1)];
			   bot[lindex+1]= old[(j+1)];
			  
			   top[lindex]= old[(i-1)*N +j];
			   mid[lindex]= old[i*N +j];
			   bot[lindex]= old[j];
			   
		    }else{
		  
				top[lindex]= old[(i-1)*N +j];
				mid[lindex]= old[i*N +j];
				bot[lindex]= old[j];
			}
			  
		 }
	  }else if(j==0){
		  
		  //left
		  
		  top[0]= old[(i-1)*N +(N-1)];
		  mid[0]= old[i*N +(N-1)];
		  bot[0]= old[(i+1)*N +(N-1)];
		  
		  top[1]= old[(i-1)*N];
		  mid[1]= old[i*N];
		  bot[1]= old[(i+1)*N];
		  
	  }else if(j==(N-1)){
		  
		  //right
		  
		  top[lindex+1]= old[(i-1)*N];
		  mid[lindex+1]= old[i*N];
		  bot[lindex+1]= old[(i+1)*N];
		  
		  top[lindex]= old[(i-1)*N +j];
		  mid[lindex]= old[i*N +j];
		  bot[lindex]= old[(i+1)*N +j];
		  
	  }else{
		  
		  //general case
		  
		  if(lindex==1){
			  
			  top[lindex-1]= old[(i-1)*N +(j-1)];
			  mid[lindex-1]= old[i*N +(j-1)];
			  bot[lindex-1]= old[(i+1)*N +(j-1)];
			  
			  top[lindex]= old[(i-1)*N +j];
			  mid[lindex]= old[i*N +j];
			  bot[lindex]= old[(i+1)*N +j];
			  
		  }else if(lindex==(lsize)){
			  
			  top[lindex+1]= old[(i-1)*N +(j+1)];
			  mid[lindex+1]= old[i*N +(j+1)];
			  bot[lindex+1]= old[(i+1)*N +(j+1)];
			  
			  top[lindex]= old[(i-1)*N +j];
			  mid[lindex]= old[i*N +j];
			  bot[lindex]= old[(i+1)*N +j];
		  }else{
		  
			top[lindex]= old[(i-1)*N +j];
			mid[lindex]= old[i*N +j];
			bot[lindex]= old[(i+1)*N +j];
			
		  }
	  }
	  
	  lindex++;
	  j++;
  }
  
  //Restore values
  j=index%N;
  lindex=threadIdx.x*CELLS_PER_THREAD +1;
  
  __syncthreads();
  
  for(count=0; count<CELLS_PER_THREAD; count++){
	  
	  sum= top[lindex-1] +top[lindex]+top[lindex+1]
	  +mid[lindex-1] +mid[lindex+1]
	  +bot[lindex-1] +bot[lindex] +bot[lindex+1];
	  
	  switch(sum){
		  
		  case 3:
		  newer[i*N + j] = 1;
		  break;
		  
		  case 2:
		  newer[i*N + j] = old[i*N + j];
		  break;
		  
		  default:
		  newer[i*N + j] = 0;
	  }
	  
	  lindex++;
	  j++;
  }

}


void read_from_file(int *X, char *filename, int N);
void save_table(int *X, int N);


int main(){
	

	int *table;
	int* newer;
	int* old;
	int *temp;
	
	int blocks, t, N, count;

	
	printf("Set the number of generations\n");
	scanf("%d", &t);
	printf("Set N (table size = NxN)\n");
	scanf("%d", &N);
	int size=N*N*sizeof(int);
	
	/*
	 Insert table here
	 */
	
	
	char filename[20];
	sprintf(filename, "table%dx%d.bin", N, N);
	printf("Reading %dx%d table from file %s\n", N, N, filename);
	table = (int *)malloc(N*N*sizeof(int));
	read_from_file(table, filename, N);  	
	

	printf("This is kernel c\n");
	
	printf("The game will be played for %d generations N=%d\n", t, N);
	
	//!!!Start Timer!!!
	gettimeofday (&startwtime, NULL);
	
	//Allocate space of new and old in device
	hipMalloc(&newer, size);
	hipMalloc(&old, size);
	
	//copy table
	hipMemcpy(old, table, size, hipMemcpyHostToDevice);
	
	blocks=(N*N)/(THREADS_PER_BLOCK*CELLS_PER_THREAD);
	
	//Play game for t generations
	for(count=0;count<t;count++){
		
		game_c<<<blocks, THREADS_PER_BLOCK>>>(newer, old, N);
		hipDeviceSynchronize();
		
		//swap pointers
		temp=old;
		old=newer;
		newer=temp;
	}
	
	//copy back table
	hipMemcpy(table, old, size, hipMemcpyDeviceToHost);
	
	//!!!End Timer!!!
	gettimeofday (&endwtime, NULL);
	  seq_time = (double)((endwtime.tv_usec - startwtime.tv_usec)/1.0e6
		      + endwtime.tv_sec - startwtime.tv_sec);
	  printf("Cuda clock time = %f\n", seq_time);
	
	save_table(table, N);
	
	hipFree(newer);
	hipFree(old);
	
	free(table);
	
	return(0);
}


void read_from_file(int *X, char *filename, int N){

  FILE *fp = fopen(filename, "r+");

  int size = fread(X, sizeof(int), N*N, fp);

  printf("elements: %d\n", size);

  fclose(fp);

}

void save_table(int *X, int N){

  FILE *fp;

  char filename[20];

  sprintf(filename, "cuda_c_table%dx%d.bin", N, N);

  printf("Saving table in file %s\n", filename);

  fp = fopen(filename, "w+");

  fwrite(X, sizeof(int), N*N, fp);

  fclose(fp);

}








	.text
	.file	"CUDA_gameoflife_impl3.hip"
	.globl	_Z21__device_stub__game_cPiS_i  # -- Begin function _Z21__device_stub__game_cPiS_i
	.type	_Z21__device_stub__game_cPiS_i,@function
_Z21__device_stub__game_cPiS_i:         # @_Z21__device_stub__game_cPiS_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z6game_cPiS_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z21__device_stub__game_cPiS_i, .Lfunc_end0-_Z21__device_stub__game_cPiS_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI1_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
	movl	$.Lstr, %edi
	callq	puts@PLT
	xorl	%r13d, %r13d
	leaq	20(%rsp), %rsi
	movl	$.L.str.1, %edi
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	leaq	4(%rsp), %r15
	movl	$.L.str.1, %edi
	movq	%r15, %rsi
	xorl	%eax, %eax
	callq	__isoc23_scanf
	movl	(%r15), %ecx
	movl	%ecx, %r14d
	imull	%ecx, %r14d
	shll	$2, %r14d
	leaq	32(%rsp), %r12
	movl	$.L.str.3, %esi
	movq	%r12, %rdi
	movl	%ecx, %edx
	xorl	%eax, %eax
	callq	sprintf
	movl	(%r15), %edx
	movl	$.L.str.4, %edi
	movl	%edx, %esi
	movq	%r12, %rcx
	xorl	%eax, %eax
	callq	printf
	movl	(%r15), %ebp
	movl	%ebp, %edi
	imull	%edi, %edi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %rbx
	movq	%rax, %rdi
	movq	%r12, %rsi
	movl	%ebp, %edx
	callq	_Z14read_from_filePiPci
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	leaq	20(%rsp), %rbp
	movl	(%rbp), %esi
	movl	(%r15), %edx
	movl	$.L.str.6, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$startwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movslq	%r14d, %r15
	leaq	24(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	8(%rsp), %r12
	movq	%r12, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movq	(%r12), %rdi
	movq	%rbx, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	cmpl	$0, (%rbp)
	jle	.LBB1_1
# %bb.2:                                # %.lr.ph
	movabsq	$4294967296, %r14               # imm = 0x100000000
	movl	4(%rsp), %eax
	imull	%eax, %eax
	imulq	$274877907, %rax, %r12          # imm = 0x10624DD3
	shrq	$37, %r12
	btsq	$32, %r12
	addq	$250, %r14
.LBB1_3:                                # =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_5
# %bb.4:                                #   in Loop: Header=BB1_3 Depth=1
	movq	24(%rsp), %rdi
	movq	8(%rsp), %rsi
	movl	4(%rsp), %edx
	callq	_Z21__device_stub__game_cPiS_i
.LBB1_5:                                #   in Loop: Header=BB1_3 Depth=1
	callq	hipDeviceSynchronize
	movq	8(%rsp), %rax
	movq	24(%rsp), %rsi
	movq	%rsi, 8(%rsp)
	movq	%rax, 24(%rsp)
	incl	%r13d
	cmpl	20(%rsp), %r13d
	jl	.LBB1_3
	jmp	.LBB1_6
.LBB1_1:                                # %.._crit_edge_crit_edge
	movq	8(%rsp), %rsi
.LBB1_6:                                # %._crit_edge
	movq	%rbx, %rdi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$endwtime, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	endwtime+8(%rip), %rax
	subq	startwtime+8(%rip), %rax
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI1_0(%rip), %xmm1
	cvtsi2sdq	endwtime(%rip), %xmm0
	addsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	startwtime(%rip), %xmm1
	subsd	%xmm1, %xmm0
	movsd	%xmm0, seq_time(%rip)
	movl	$.L.str.7, %edi
	movb	$1, %al
	callq	printf
	movl	4(%rsp), %esi
	movq	%rbx, %rdi
	callq	_Z10save_tablePii
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	8(%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_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z14read_from_filePiPci         # -- Begin function _Z14read_from_filePiPci
	.type	_Z14read_from_filePiPci,@function
_Z14read_from_filePiPci:                # @_Z14read_from_filePiPci
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%edx, %ebx
	movq	%rsi, %rax
	movq	%rdi, %r14
	movl	$.L.str.8, %esi
	movq	%rax, %rdi
	callq	fopen
	movq	%rax, %r15
	imull	%ebx, %ebx
	movl	$4, %esi
	movq	%r14, %rdi
	movq	%rbx, %rdx
	movq	%rax, %rcx
	callq	fread
	movl	$.L.str.9, %edi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	printf
	movq	%r15, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.Lfunc_end2:
	.size	_Z14read_from_filePiPci, .Lfunc_end2-_Z14read_from_filePiPci
	.cfi_endproc
                                        # -- End function
	.globl	_Z10save_tablePii               # -- Begin function _Z10save_tablePii
	.type	_Z10save_tablePii,@function
_Z10save_tablePii:                      # @_Z10save_tablePii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	subq	$32, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%esi, %ebx
	movq	%rdi, %r14
	movq	%rsp, %r15
	movl	$.L.str.10, %esi
	movq	%r15, %rdi
	movl	%ebx, %edx
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	sprintf
	movl	$.L.str.11, %edi
	movq	%r15, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.12, %esi
	movq	%r15, %rdi
	callq	fopen
	movq	%rax, %r15
	imull	%ebx, %ebx
	movl	$4, %esi
	movq	%r14, %rdi
	movq	%rbx, %rdx
	movq	%rax, %rcx
	callq	fwrite
	movq	%r15, %rdi
	callq	fclose
	addq	$32, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z10save_tablePii, .Lfunc_end3-_Z10save_tablePii
	.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	$_Z6game_cPiS_i, %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	startwtime,@object              # @startwtime
	.bss
	.globl	startwtime
	.p2align	3, 0x0
startwtime:
	.zero	16
	.size	startwtime, 16

	.type	endwtime,@object                # @endwtime
	.globl	endwtime
	.p2align	3, 0x0
endwtime:
	.zero	16
	.size	endwtime, 16

	.type	seq_time,@object                # @seq_time
	.globl	seq_time
	.p2align	3, 0x0
seq_time:
	.quad	0x0000000000000000              # double 0
	.size	seq_time, 8

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

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"table%dx%d.bin"
	.size	.L.str.3, 15

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Reading %dx%d table from file %s\n"
	.size	.L.str.4, 34

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"The game will be played for %d generations N=%d\n"
	.size	.L.str.6, 49

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Cuda clock time = %f\n"
	.size	.L.str.7, 22

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"r+"
	.size	.L.str.8, 3

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"elements: %d\n"
	.size	.L.str.9, 14

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"cuda_c_table%dx%d.bin"
	.size	.L.str.10, 22

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Saving table in file %s\n"
	.size	.L.str.11, 25

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"w+"
	.size	.L.str.12, 3

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6game_cPiS_i"
	.size	.L__unnamed_1, 15

	.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	"Set the number of generations"
	.size	.Lstr, 30

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Set N (table size = NxN)"
	.size	.Lstr.1, 25

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"This is kernel c"
	.size	.Lstr.2, 17

	.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__game_cPiS_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym startwtime
	.addrsig_sym endwtime
	.addrsig_sym _Z6game_cPiS_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z6game_cPiS_i          ; -- Begin function _Z6game_cPiS_i
	.globl	_Z6game_cPiS_i
	.p2align	8
	.type	_Z6game_cPiS_i,@function
_Z6game_cPiS_i:                         ; @_Z6game_cPiS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x10
	s_load_b32 s4, s[0:1], 0x24
	s_mov_b32 s14, -1
	v_lshlrev_b32_e32 v14, 1, v0
	v_mov_b32_e32 v34, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_or_b32_e32 v15, 1, v14
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s3, s2, 31
	s_and_b32 s4, s4, 0xffff
	s_add_i32 s5, s2, s3
	s_add_i32 s17, s2, -1
	s_xor_b32 s12, s5, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f32_u32_e32 v1, s12
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	v_cvt_u32_f32_e32 v4, v1
	v_mad_u64_u32 v[2:3], null, s15, s4, v[0:1]
	s_sub_i32 s4, 0, s12
	v_lshlrev_b32_e32 v0, 3, v0
	v_mul_lo_u32 v3, s4, v4
	s_load_b128 s[4:7], s[0:1], 0x0
	s_add_i32 s0, s2, -2
	s_mov_b32 s1, 0
	s_delay_alu instid0(VALU_DEP_3)
	v_lshlrev_b32_e32 v1, 1, v2
	v_bfe_i32 v2, v2, 30, 1
	s_mul_i32 s10, s0, s2
	s_mul_i32 s0, s2, s2
	v_mul_hi_u32 v3, v4, v3
	s_ashr_i32 s11, s10, 31
	v_add_nc_u32_e32 v5, v1, v2
	s_lshl_b64 s[8:9], s[10:11], 2
	v_or_b32_e32 v16, 4, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_xor_b32_e32 v5, v5, v2
	v_add_nc_u32_e32 v3, v4, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v3, v5, v3
	v_mul_lo_u32 v4, v3, s12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v4, v5, v4
	v_subrev_nc_u32_e32 v6, s12, v4
	v_cmp_le_u32_e32 vcc_lo, s12, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_cndmask_b32 v4, v4, v6 :: v_dual_add_nc_u32 v5, 1, v3
	v_cndmask_b32_e32 v3, v3, v5, vcc_lo
	v_xor_b32_e32 v6, s3, v2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cmp_le_u32_e32 vcc_lo, s12, v4
	v_add_nc_u32_e32 v5, 1, v3
	s_lshl_b64 s[12:13], s[2:3], 2
	s_waitcnt lgkmcnt(0)
	s_add_u32 s8, s6, s8
	s_addc_u32 s9, s7, s9
	s_add_i32 s10, s10, s2
	v_cndmask_b32_e32 v2, v3, v5, vcc_lo
	s_ashr_i32 s11, s10, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_lshl_b64 s[18:19], s[10:11], 2
	v_xor_b32_e32 v3, v2, v6
	s_add_u32 s10, s6, s18
	s_addc_u32 s11, s7, s19
	s_lshl_b64 s[0:1], s[0:1], 2
	s_delay_alu instid0(VALU_DEP_1)
	v_sub_nc_u32_e32 v4, v3, v6
	s_add_u32 s3, s6, s0
	s_addc_u32 s15, s7, s1
	v_sub_nc_u32_e32 v17, v6, v3
	s_add_u32 s16, s6, s12
	v_mul_lo_u32 v2, v4, s2
	v_cmp_ne_u32_e64 s0, 0, v4
	v_cmp_ne_u32_e64 s1, s17, v4
	s_addc_u32 s17, s7, s13
	s_delay_alu instid0(VALU_DEP_3)
	v_subrev_nc_u32_e32 v4, s2, v2
	v_ashrrev_i32_e32 v3, 31, v2
	v_add_nc_u32_e32 v6, s2, v2
	v_sub_nc_u32_e32 v8, v1, v2
	v_sub_nc_u32_e32 v18, v2, v1
	v_ashrrev_i32_e32 v5, 31, v4
	v_lshlrev_b64 v[10:11], 2, v[2:3]
	v_ashrrev_i32_e32 v7, 31, v6
	v_ashrrev_i32_e32 v9, 31, v8
	v_xad_u32 v19, v1, -1, v6
	v_lshlrev_b64 v[32:33], 2, v[4:5]
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_2) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[28:29], 2, v[6:7]
	v_add_co_u32 v2, vcc_lo, s6, v10
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v11, vcc_lo
	v_add_co_u32 v4, vcc_lo, s6, v32
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v33, vcc_lo
	v_lshlrev_b64 v[12:13], 2, v[8:9]
	v_add_co_u32 v6, vcc_lo, s6, v28
	v_add_co_ci_u32_e32 v7, vcc_lo, s7, v29, vcc_lo
	v_add_co_u32 v8, vcc_lo, v2, s12
	v_add_co_ci_u32_e32 v9, vcc_lo, s13, v3, vcc_lo
	v_add_co_u32 v20, vcc_lo, v12, 4
	v_add_co_ci_u32_e32 v23, vcc_lo, 0, v13, vcc_lo
	v_add_co_u32 v21, vcc_lo, v10, v12
	v_add_co_ci_u32_e32 v22, vcc_lo, v11, v13, vcc_lo
	v_add_co_u32 v10, vcc_lo, v4, s12
	v_add_co_ci_u32_e32 v11, vcc_lo, s13, v5, vcc_lo
	v_add_co_u32 v12, vcc_lo, v6, s12
	v_add_co_ci_u32_e32 v13, vcc_lo, s13, v7, vcc_lo
	v_add_co_u32 v24, vcc_lo, v20, s12
	v_add_co_ci_u32_e32 v25, vcc_lo, s13, v23, vcc_lo
	v_add_co_u32 v26, vcc_lo, v20, s18
	v_add_co_ci_u32_e32 v27, vcc_lo, s19, v23, vcc_lo
	v_add_co_u32 v28, vcc_lo, v20, v28
	v_add_co_ci_u32_e32 v29, vcc_lo, v23, v29, vcc_lo
	v_add_co_u32 v30, vcc_lo, v21, 4
	v_add_co_ci_u32_e32 v31, vcc_lo, 0, v22, vcc_lo
	v_add_co_u32 v32, vcc_lo, v20, v32
	v_add_co_ci_u32_e32 v33, vcc_lo, v23, v33, vcc_lo
	s_add_u32 s12, s16, s12
	s_addc_u32 s13, s17, s13
.LBB0_1:                                ; =>This Inner Loop Header: Depth=1
	v_cmp_ne_u32_e32 vcc_lo, 0, v18
	s_and_saveexec_b32 s2, s0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s18, exec_lo, s2
	s_cbranch_execz .LBB0_43
; %bb.2:                                ;   in Loop: Header=BB0_1 Depth=1
	s_and_saveexec_b32 s2, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s19, exec_lo, s2
	s_cbranch_execz .LBB0_22
; %bb.3:                                ;   in Loop: Header=BB0_1 Depth=1
	s_and_saveexec_b32 s2, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s20, exec_lo, s2
	s_cbranch_execz .LBB0_19
; %bb.4:                                ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s21, exec_lo
	v_cmpx_ne_u32_e32 0, v19
	s_xor_b32 s21, exec_lo, s21
	s_cbranch_execz .LBB0_16
; %bb.5:                                ; %NodeBlock586
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s22, 0
	s_mov_b32 s24, 0
	s_mov_b32 s23, exec_lo
	v_cmpx_lt_i32_e32 0x1f3, v15
	s_xor_b32 s23, exec_lo, s23
	s_cbranch_execz .LBB0_9
; %bb.6:                                ; %LeafBlock584
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s25, -1
	s_mov_b32 s24, exec_lo
	v_cmpx_eq_u32_e32 0x1f4, v15
	s_cbranch_execz .LBB0_8
; %bb.7:                                ;   in Loop: Header=BB0_1 Depth=1
	v_add_co_u32 v35, s2, s6, v32
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v36, s2, s7, v33, s2
	v_add_co_u32 v37, s2, s6, v30
	v_add_co_ci_u32_e64 v38, s2, s7, v31, s2
	v_add_co_u32 v39, s2, s6, v28
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v40, s2, s7, v29, s2
	s_clause 0x2
	global_load_b64 v[35:36], v[35:36], off offset:-4
	global_load_b64 v[37:38], v[37:38], off offset:-4
	global_load_b64 v[39:40], v[39:40], off offset:-4
	v_add_nc_u32_e64 v41, 0x7c0, 0
	s_xor_b32 s25, exec_lo, -1
	s_waitcnt vmcnt(2)
	ds_store_b64 v34, v[35:36] offset:6032
	s_waitcnt vmcnt(0)
	ds_store_2addr_b64 v41, v[39:40], v[37:38] offset0:2 offset1:254
.LBB0_8:                                ; %Flow597
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s24
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 s24, s25, exec_lo
.LBB0_9:                                ; %Flow596
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s23, s23
; %bb.10:                               ; %LeafBlock582
                                        ;   in Loop: Header=BB0_1 Depth=1
	v_cmp_ne_u32_e64 s2, 1, v15
	s_and_not1_b32 s24, s24, exec_lo
	s_mov_b32 s22, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, s2, exec_lo
	s_or_b32 s24, s24, s2
; %bb.11:                               ; %Flow598
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s23
	s_and_saveexec_b32 s2, s24
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s23, exec_lo, s2
	s_cbranch_execz .LBB0_13
; %bb.12:                               ;   in Loop: Header=BB0_1 Depth=1
	v_add_co_u32 v35, s2, s6, v32
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v36, s2, s7, v33, s2
	v_add_co_u32 v37, s2, s6, v30
	v_add_co_ci_u32_e64 v38, s2, s7, v31, s2
	v_add_co_u32 v39, s2, s6, v28
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v40, s2, s7, v29, s2
	s_clause 0x2
	global_load_b32 v35, v[35:36], off offset:-4
	global_load_b32 v36, v[37:38], off offset:-4
	global_load_b32 v37, v[39:40], off offset:-4
	s_and_not1_b32 s22, s22, exec_lo
	s_waitcnt vmcnt(2)
	ds_store_b32 v16, v35 offset:4032
	s_waitcnt vmcnt(1)
	ds_store_b32 v16, v36 offset:2016
	s_waitcnt vmcnt(0)
	ds_store_b32 v16, v37
.LBB0_13:                               ; %Flow599
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s23
	s_and_saveexec_b32 s23, s22
	s_cbranch_execz .LBB0_15
; %bb.14:                               ;   in Loop: Header=BB0_1 Depth=1
	v_add_co_u32 v35, s2, s6, v32
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v36, s2, s7, v33, s2
	v_add_co_u32 v37, s2, s6, v30
	v_add_co_ci_u32_e64 v38, s2, s7, v31, s2
	v_add_co_u32 v39, s2, s6, v28
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v40, s2, s7, v29, s2
	s_clause 0x2
	global_load_b64 v[35:36], v[35:36], off offset:-8
	global_load_b64 v[37:38], v[37:38], off offset:-8
	global_load_b64 v[39:40], v[39:40], off offset:-8
	s_waitcnt vmcnt(2)
	ds_store_b64 v34, v[35:36] offset:4032
	s_waitcnt vmcnt(0)
	ds_store_2addr_b64 v34, v[39:40], v[37:38] offset1:252
.LBB0_15:                               ; %Flow600
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s23
.LBB0_16:                               ; %Flow602
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s2, s21
	s_cbranch_execz .LBB0_18
; %bb.17:                               ;   in Loop: Header=BB0_1 Depth=1
	s_clause 0x5
	global_load_b32 v35, v[4:5], off
	global_load_b32 v36, v[2:3], off
	global_load_b32 v37, v[6:7], off
	global_load_b32 v38, v[10:11], off offset:-4
	global_load_b32 v39, v[8:9], off offset:-4
	global_load_b32 v40, v[12:13], off offset:-4
	v_add_nc_u32_e32 v41, 0xfc0, v16
	v_add_nc_u32_e32 v42, 0x7e0, v16
	s_waitcnt vmcnt(2)
	ds_store_2addr_b32 v41, v38, v35 offset1:1
	s_waitcnt vmcnt(1)
	ds_store_2addr_b32 v42, v39, v36 offset1:1
	s_waitcnt vmcnt(0)
	ds_store_2addr_b32 v16, v40, v37 offset1:1
.LBB0_18:                               ; %Flow603
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
.LBB0_19:                               ; %Flow605
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s2, s20
	s_cbranch_execz .LBB0_21
; %bb.20:                               ;   in Loop: Header=BB0_1 Depth=1
	s_clause 0x5
	global_load_b32 v35, v[8:9], off offset:-4
	global_load_b32 v37, v[12:13], off offset:-4
	global_load_b32 v40, v[4:5], off
	global_load_b32 v36, v[2:3], off
	global_load_b32 v39, v[10:11], off offset:-4
	global_load_b32 v38, v[6:7], off
	s_waitcnt vmcnt(1)
	ds_store_b64 v34, v[39:40] offset:4032
	s_waitcnt vmcnt(0)
	ds_store_2addr_b64 v34, v[37:38], v[35:36] offset1:252
.LBB0_21:                               ; %Flow606
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
.LBB0_22:                               ; %Flow618
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s19, s19
	s_cbranch_execz .LBB0_42
; %bb.23:                               ;   in Loop: Header=BB0_1 Depth=1
	s_and_saveexec_b32 s2, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s20, exec_lo, s2
	s_cbranch_execz .LBB0_39
; %bb.24:                               ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s21, exec_lo
	v_cmpx_ne_u32_e64 v17, v18
	s_xor_b32 s21, exec_lo, s21
	s_cbranch_execz .LBB0_36
; %bb.25:                               ; %NodeBlock580
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s22, 0
	s_mov_b32 s24, 0
	s_mov_b32 s23, exec_lo
	v_cmpx_lt_i32_e32 0x1f3, v15
	s_xor_b32 s23, exec_lo, s23
	s_cbranch_execz .LBB0_29
; %bb.26:                               ; %LeafBlock578
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s25, -1
	s_mov_b32 s24, exec_lo
	v_cmpx_eq_u32_e32 0x1f4, v15
	s_cbranch_execz .LBB0_28
; %bb.27:                               ;   in Loop: Header=BB0_1 Depth=1
	v_add_co_u32 v35, s2, s6, v32
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v36, s2, s7, v33, s2
	v_add_co_u32 v37, s2, s6, v30
	v_add_co_ci_u32_e64 v38, s2, s7, v31, s2
	v_add_co_u32 v39, s2, s6, v20
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v40, s2, s7, v23, s2
	s_clause 0x2
	global_load_b64 v[35:36], v[35:36], off offset:-4
	global_load_b64 v[37:38], v[37:38], off offset:-4
	global_load_b64 v[39:40], v[39:40], off offset:-4
	v_add_nc_u32_e64 v41, 0x7c0, 0
	s_xor_b32 s25, exec_lo, -1
	s_waitcnt vmcnt(2)
	ds_store_b64 v34, v[35:36] offset:6032
	s_waitcnt vmcnt(0)
	ds_store_2addr_b64 v41, v[39:40], v[37:38] offset0:2 offset1:254
.LBB0_28:                               ; %Flow608
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s24
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 s24, s25, exec_lo
.LBB0_29:                               ; %Flow607
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s23, s23
; %bb.30:                               ; %LeafBlock576
                                        ;   in Loop: Header=BB0_1 Depth=1
	v_cmp_ne_u32_e64 s2, 1, v15
	s_and_not1_b32 s24, s24, exec_lo
	s_mov_b32 s22, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, s2, exec_lo
	s_or_b32 s24, s24, s2
; %bb.31:                               ; %Flow609
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s23
	s_and_saveexec_b32 s2, s24
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s23, exec_lo, s2
	s_cbranch_execz .LBB0_33
; %bb.32:                               ;   in Loop: Header=BB0_1 Depth=1
	v_add_co_u32 v35, s2, s6, v32
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v36, s2, s7, v33, s2
	v_add_co_u32 v37, s2, s6, v30
	v_add_co_ci_u32_e64 v38, s2, s7, v31, s2
	v_add_co_u32 v39, s2, s6, v20
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v40, s2, s7, v23, s2
	s_clause 0x2
	global_load_b32 v35, v[35:36], off offset:-4
	global_load_b32 v36, v[37:38], off offset:-4
	global_load_b32 v37, v[39:40], off offset:-4
	s_and_not1_b32 s22, s22, exec_lo
	s_waitcnt vmcnt(2)
	ds_store_b32 v16, v35 offset:4032
	s_waitcnt vmcnt(1)
	ds_store_b32 v16, v36 offset:2016
	s_waitcnt vmcnt(0)
	ds_store_b32 v16, v37
.LBB0_33:                               ; %Flow610
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s23
	s_and_saveexec_b32 s23, s22
	s_cbranch_execz .LBB0_35
; %bb.34:                               ;   in Loop: Header=BB0_1 Depth=1
	v_add_co_u32 v35, s2, s6, v32
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v36, s2, s7, v33, s2
	v_add_co_u32 v37, s2, s6, v30
	v_add_co_ci_u32_e64 v38, s2, s7, v31, s2
	v_add_co_u32 v39, s2, s6, v20
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v40, s2, s7, v23, s2
	s_clause 0x2
	global_load_b64 v[35:36], v[35:36], off offset:-8
	global_load_b64 v[37:38], v[37:38], off offset:-8
	global_load_b64 v[39:40], v[39:40], off offset:-8
	s_waitcnt vmcnt(2)
	ds_store_b64 v34, v[35:36] offset:4032
	s_waitcnt vmcnt(0)
	ds_store_2addr_b64 v34, v[39:40], v[37:38] offset1:252
.LBB0_35:                               ; %Flow611
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s23
.LBB0_36:                               ; %Flow613
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s2, s21
	s_cbranch_execz .LBB0_38
; %bb.37:                               ;   in Loop: Header=BB0_1 Depth=1
	s_add_u32 s22, s10, -4
	s_addc_u32 s23, s11, -1
	s_add_u32 s24, s3, -4
	s_addc_u32 s25, s15, -1
	s_add_u32 s26, s16, -4
	s_clause 0x1
	s_load_b32 s21, s[8:9], 0x0
	s_load_b64 s[22:23], s[22:23], 0x0
	s_addc_u32 s27, s17, -1
	s_clause 0x2
	s_load_b32 s24, s[24:25], 0x0
	s_load_b32 s25, s[26:27], 0x0
	s_load_b32 s26, s[6:7], 0x0
	v_add_nc_u32_e32 v35, 0xfc0, v16
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v37, s21 :: v_dual_add_nc_u32 v36, 0x7e0, v16
	v_dual_mov_b32 v38, s22 :: v_dual_mov_b32 v39, s23
	v_dual_mov_b32 v40, s24 :: v_dual_mov_b32 v41, s25
	v_mov_b32_e32 v42, s26
	ds_store_2addr_b32 v35, v38, v37 offset1:1
	ds_store_2addr_b32 v36, v40, v39 offset1:1
	ds_store_2addr_b32 v16, v41, v42 offset1:1
.LBB0_38:                               ; %Flow614
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
.LBB0_39:                               ; %Flow615
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s2, s20
	s_cbranch_execz .LBB0_41
; %bb.40:                               ;   in Loop: Header=BB0_1 Depth=1
	s_add_u32 s20, s10, -4
	s_addc_u32 s21, s11, -1
	s_add_u32 s22, s3, -4
	s_addc_u32 s23, s15, -1
	s_add_u32 s24, s16, -4
	s_addc_u32 s25, s17, -1
	s_clause 0x4
	s_load_b64 s[20:21], s[20:21], 0x0
	s_load_b32 s22, s[22:23], 0x0
	s_load_b32 s23, s[24:25], 0x0
	s_load_b32 s24, s[8:9], 0x0
	s_load_b32 s25, s[6:7], 0x0
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v35, s20 :: v_dual_mov_b32 v38, s21
	v_dual_mov_b32 v37, s22 :: v_dual_mov_b32 v36, s24
	v_dual_mov_b32 v39, s23 :: v_dual_mov_b32 v40, s25
	ds_store_b64 v34, v[35:36] offset:4032
	ds_store_2addr_b64 v34, v[39:40], v[37:38] offset1:252
.LBB0_41:                               ; %Flow616
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
.LBB0_42:                               ; %Flow619
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s19
.LBB0_43:                               ; %Flow631
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s2, s18
	s_cbranch_execz .LBB0_63
; %bb.44:                               ;   in Loop: Header=BB0_1 Depth=1
	s_and_saveexec_b32 s18, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s18, exec_lo, s18
	s_cbranch_execz .LBB0_60
; %bb.45:                               ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s19, exec_lo
	v_cmpx_ne_u32_e32 0, v19
	s_xor_b32 s19, exec_lo, s19
	s_cbranch_execz .LBB0_57
; %bb.46:                               ; %NodeBlock
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s20, 0
	s_mov_b32 s22, 0
	s_mov_b32 s21, exec_lo
	v_cmpx_lt_i32_e32 0x1f3, v15
	s_xor_b32 s21, exec_lo, s21
	s_cbranch_execz .LBB0_50
; %bb.47:                               ; %LeafBlock574
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_mov_b32 s23, -1
	s_mov_b32 s22, exec_lo
	v_cmpx_eq_u32_e32 0x1f4, v15
	s_cbranch_execz .LBB0_49
; %bb.48:                               ;   in Loop: Header=BB0_1 Depth=1
	v_add_co_u32 v35, vcc_lo, s6, v26
	v_add_co_ci_u32_e32 v36, vcc_lo, s7, v27, vcc_lo
	v_add_co_u32 v37, vcc_lo, s6, v20
	v_add_co_ci_u32_e32 v38, vcc_lo, s7, v23, vcc_lo
	v_add_co_u32 v39, vcc_lo, s6, v24
	v_add_co_ci_u32_e32 v40, vcc_lo, s7, v25, vcc_lo
	s_clause 0x2
	global_load_b64 v[35:36], v[35:36], off offset:-4
	global_load_b64 v[37:38], v[37:38], off offset:-4
	global_load_b64 v[39:40], v[39:40], off offset:-4
	v_add_nc_u32_e64 v41, 0x7c0, 0
	s_xor_b32 s23, exec_lo, -1
	s_waitcnt vmcnt(2)
	ds_store_b64 v34, v[35:36] offset:6032
	s_waitcnt vmcnt(0)
	ds_store_2addr_b64 v41, v[39:40], v[37:38] offset0:2 offset1:254
.LBB0_49:                               ; %Flow621
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s22
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 s22, s23, exec_lo
.LBB0_50:                               ; %Flow620
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s21, s21
; %bb.51:                               ; %LeafBlock
                                        ;   in Loop: Header=BB0_1 Depth=1
	v_cmp_ne_u32_e32 vcc_lo, 1, v15
	s_and_not1_b32 s22, s22, exec_lo
	s_mov_b32 s20, exec_lo
	s_and_b32 s23, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s22, s22, s23
; %bb.52:                               ; %Flow622
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s21
	s_and_saveexec_b32 s21, s22
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s21, exec_lo, s21
	s_cbranch_execz .LBB0_54
; %bb.53:                               ;   in Loop: Header=BB0_1 Depth=1
	v_add_co_u32 v35, vcc_lo, s6, v26
	v_add_co_ci_u32_e32 v36, vcc_lo, s7, v27, vcc_lo
	v_add_co_u32 v37, vcc_lo, s6, v20
	v_add_co_ci_u32_e32 v38, vcc_lo, s7, v23, vcc_lo
	v_add_co_u32 v39, vcc_lo, s6, v24
	v_add_co_ci_u32_e32 v40, vcc_lo, s7, v25, vcc_lo
	s_clause 0x2
	global_load_b32 v35, v[35:36], off offset:-4
	global_load_b32 v36, v[37:38], off offset:-4
	global_load_b32 v37, v[39:40], off offset:-4
	s_and_not1_b32 s20, s20, exec_lo
	s_waitcnt vmcnt(2)
	ds_store_b32 v16, v35 offset:4032
	s_waitcnt vmcnt(1)
	ds_store_b32 v16, v36 offset:2016
	s_waitcnt vmcnt(0)
	ds_store_b32 v16, v37
.LBB0_54:                               ; %Flow623
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s21
	s_and_saveexec_b32 s21, s20
	s_cbranch_execz .LBB0_56
; %bb.55:                               ;   in Loop: Header=BB0_1 Depth=1
	v_add_co_u32 v35, vcc_lo, s6, v26
	v_add_co_ci_u32_e32 v36, vcc_lo, s7, v27, vcc_lo
	v_add_co_u32 v37, vcc_lo, s6, v20
	v_add_co_ci_u32_e32 v38, vcc_lo, s7, v23, vcc_lo
	v_add_co_u32 v39, vcc_lo, s6, v24
	v_add_co_ci_u32_e32 v40, vcc_lo, s7, v25, vcc_lo
	s_clause 0x2
	global_load_b64 v[35:36], v[35:36], off offset:-8
	global_load_b64 v[37:38], v[37:38], off offset:-8
	global_load_b64 v[39:40], v[39:40], off offset:-8
	s_waitcnt vmcnt(2)
	ds_store_b64 v34, v[35:36] offset:4032
	s_waitcnt vmcnt(0)
	ds_store_2addr_b64 v34, v[39:40], v[37:38] offset1:252
.LBB0_56:                               ; %Flow624
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s21
.LBB0_57:                               ; %Flow626
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s19, s19
	s_cbranch_execz .LBB0_59
; %bb.58:                               ;   in Loop: Header=BB0_1 Depth=1
	s_add_u32 s20, s16, -4
	s_addc_u32 s21, s17, -1
	s_add_u32 s22, s3, -4
	s_addc_u32 s23, s15, -1
	s_add_u32 s24, s12, -4
	s_addc_u32 s25, s13, -1
	s_clause 0x4
	s_load_b32 s26, s[10:11], 0x0
	s_load_b64 s[20:21], s[20:21], 0x0
	s_load_b32 s22, s[22:23], 0x0
	s_load_b32 s23, s[24:25], 0x0
	s_load_b32 s24, s[6:7], 0x0
	v_add_nc_u32_e32 v35, 0xfc0, v16
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v37, s26 :: v_dual_add_nc_u32 v36, 0x7e0, v16
	v_dual_mov_b32 v39, s21 :: v_dual_mov_b32 v40, s22
	v_dual_mov_b32 v38, s20 :: v_dual_mov_b32 v41, s24
	v_mov_b32_e32 v42, s23
	ds_store_2addr_b32 v35, v40, v37 offset1:1
	ds_store_2addr_b32 v36, v38, v41 offset1:1
	ds_store_2addr_b32 v16, v42, v39 offset1:1
.LBB0_59:                               ; %Flow627
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s19
.LBB0_60:                               ; %Flow628
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_saveexec_b32 s18, s18
	s_cbranch_execz .LBB0_62
; %bb.61:                               ;   in Loop: Header=BB0_1 Depth=1
	s_add_u32 s20, s3, -4
	s_addc_u32 s21, s15, -1
	s_add_u32 s22, s16, -4
	s_addc_u32 s23, s17, -1
	s_add_u32 s24, s12, -4
	s_addc_u32 s25, s13, -1
	s_clause 0x4
	s_load_b32 s19, s[20:21], 0x0
	s_load_b64 s[20:21], s[22:23], 0x0
	s_load_b32 s22, s[24:25], 0x0
	s_load_b32 s23, s[10:11], 0x0
	s_load_b32 s24, s[6:7], 0x0
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v35, s19 :: v_dual_mov_b32 v40, s21
	v_dual_mov_b32 v37, s20 :: v_dual_mov_b32 v36, s23
	v_dual_mov_b32 v38, s24 :: v_dual_mov_b32 v39, s22
	ds_store_b64 v34, v[35:36] offset:4032
	ds_store_2addr_b64 v34, v[39:40], v[37:38] offset1:252
.LBB0_62:                               ; %Flow629
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s18
.LBB0_63:                               ;   in Loop: Header=BB0_1 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s2
	v_add_co_u32 v24, vcc_lo, v24, 4
	v_add_co_ci_u32_e32 v25, vcc_lo, 0, v25, vcc_lo
	v_add_co_u32 v26, vcc_lo, v26, 4
	v_add_co_ci_u32_e32 v27, vcc_lo, 0, v27, vcc_lo
	v_add_co_u32 v28, vcc_lo, v28, 4
	v_add_co_ci_u32_e32 v29, vcc_lo, 0, v29, vcc_lo
	v_add_co_u32 v30, vcc_lo, v30, 4
	v_add_co_ci_u32_e32 v31, vcc_lo, 0, v31, vcc_lo
	v_add_co_u32 v32, vcc_lo, v32, 4
	v_add_co_ci_u32_e32 v33, vcc_lo, 0, v33, vcc_lo
	v_add_co_u32 v20, vcc_lo, v20, 4
	v_add_nc_u32_e32 v15, 1, v15
	v_add_nc_u32_e32 v16, 4, v16
	v_add_nc_u32_e32 v18, -1, v18
	v_add_nc_u32_e32 v19, -1, v19
	v_add_co_ci_u32_e32 v23, vcc_lo, 0, v23, vcc_lo
	s_xor_b32 s2, s14, -1
	s_mov_b32 s14, 0
	s_and_not1_b32 vcc_lo, exec_lo, s2
	s_cbranch_vccnz .LBB0_1
; %bb.64:
	v_lshlrev_b32_e32 v2, 2, v14
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	v_add_co_u32 v3, vcc_lo, s6, v21
	ds_load_b32 v6, v2 offset:4036
	ds_load_b32 v8, v2 offset:4
	v_add_co_ci_u32_e32 v4, vcc_lo, s7, v22, vcc_lo
	s_mov_b32 s0, -1
.LBB0_65:                               ; =>This Inner Loop Header: Depth=1
	v_add_nc_u32_e32 v5, 0xc00, v0
	s_waitcnt lgkmcnt(0)
	v_dual_mov_b32 v9, v6 :: v_dual_mov_b32 v2, v8
	v_add_nc_u32_e32 v7, 0x400, v0
	s_xor_b32 s0, s0, -1
	ds_load_2addr_b32 v[5:6], v5 offset0:240 offset1:242
	ds_load_2addr_b32 v[10:11], v7 offset0:248 offset1:250
	ds_load_2addr_b32 v[7:8], v0 offset1:2
	s_mov_b32 s1, 0
	s_mov_b32 s2, 0
	s_mov_b32 s6, exec_lo
                                        ; implicit-def: $sgpr3
	s_waitcnt lgkmcnt(2)
	v_add_nc_u32_e32 v5, v9, v5
	s_waitcnt lgkmcnt(1)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add3_u32 v5, v5, v6, v10
	s_waitcnt lgkmcnt(0)
	v_add3_u32 v5, v5, v11, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add3_u32 v2, v5, v2, v8
	v_cmpx_lt_i32_e32 2, v2
	s_xor_b32 s6, exec_lo, s6
; %bb.66:                               ; %LeafBlock590
                                        ;   in Loop: Header=BB0_65 Depth=1
	v_cmp_ne_u32_e32 vcc_lo, 3, v2
	s_mov_b32 s3, 1
                                        ; implicit-def: $vgpr2
	s_and_b32 s2, vcc_lo, exec_lo
; %bb.67:                               ; %Flow
                                        ;   in Loop: Header=BB0_65 Depth=1
	s_and_not1_saveexec_b32 s6, s6
; %bb.68:                               ; %LeafBlock588
                                        ;   in Loop: Header=BB0_65 Depth=1
	v_cmp_ne_u32_e32 vcc_lo, 2, v2
	s_and_not1_b32 s2, s2, exec_lo
	s_mov_b32 s1, exec_lo
	s_and_b32 s7, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s2, s2, s7
; %bb.69:                               ; %Flow594
                                        ;   in Loop: Header=BB0_65 Depth=1
	s_or_b32 exec_lo, exec_lo, s6
	v_mov_b32_e32 v5, s3
	s_and_saveexec_b32 s3, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s2, exec_lo, s3
; %bb.70:                               ;   in Loop: Header=BB0_65 Depth=1
	v_mov_b32_e32 v5, 0
	s_and_not1_b32 s1, s1, exec_lo
; %bb.71:                               ; %Flow595
                                        ;   in Loop: Header=BB0_65 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
	s_and_saveexec_b32 s2, s1
	s_cbranch_execz .LBB0_73
; %bb.72:                               ;   in Loop: Header=BB0_65 Depth=1
	global_load_b32 v5, v[3:4], off
.LBB0_73:                               ;   in Loop: Header=BB0_65 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
	v_ashrrev_i32_e32 v2, 31, v1
	v_add_nc_u32_e32 v0, 4, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[9:10], 2, v[1:2]
	v_add_nc_u32_e32 v1, 1, v1
	v_add_co_u32 v9, vcc_lo, s4, v9
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v10, vcc_lo, s5, v10, vcc_lo
	v_add_co_u32 v3, vcc_lo, v3, 4
	v_add_co_ci_u32_e32 v4, vcc_lo, 0, v4, vcc_lo
	s_and_not1_b32 vcc_lo, exec_lo, s0
	s_mov_b32 s0, 0
	s_waitcnt vmcnt(0)
	global_store_b32 v[9:10], v5, off
	s_cbranch_vccnz .LBB0_65
; %bb.74:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6game_cPiS_i
		.amdhsa_group_segment_fixed_size 6040
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 43
		.amdhsa_next_free_sgpr 28
		.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	_Z6game_cPiS_i, .Lfunc_end0-_Z6game_cPiS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 3384
; NumSgprs: 30
; NumVgprs: 43
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 6040 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 5
; NumSGPRsForWavesPerEU: 30
; NumVGPRsForWavesPerEU: 43
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
