//------------------------------------------------------------------------------
//
// Name:       gameoflife.cu
//
// Purpose:    CUDA implementation of Conway's game of life
//
// HISTORY:    Written by Tom Deakin and Simon McIntosh-Smith, August 2013
//
//------------------------------------------------------------------------------

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

#define FINALSTATEFILE "final_state.dat"

// Define the state of the cell
#define DEAD 0
#define ALIVE 1

/*************************************************************************************
 * Forward declarations of utility functions
 ************************************************************************************/
void die(const char* message, const int line, const char* file);
void load_board(char* board, const char* file, const unsigned int nx, const unsigned int ny);
void print_board(const char* board, const unsigned int nx, const unsigned int ny);
void save_board(const char* board, const unsigned int nx, const unsigned int ny);
void load_params(const char* file, unsigned int* nx, unsigned int* ny, unsigned int* iterations);
void errorCheck(cudaError_t error);

/*************************************************************************************
 * Game of Life worker method - CUDA kernel
 ************************************************************************************/

// Apply the rules of life to tick and save in tock
__global__ void accelerate_life(const char* tick, char* tock, const int nx, const int ny)
{
    // The cell we work on in the loop
    unsigned int idx = blockDim.x * blockIdx.x + threadIdx.x;
    unsigned int idy = blockDim.y * blockIdx.y + threadIdx.y;

    // Index with respect to global array
    unsigned int id = idy * nx + idx;
    unsigned int id_b = (threadIdx.y + 1) * (blockDim.x + 2) + threadIdx.x + 1;

    // Copy block to shared memory
    extern __shared__ char block[];
    block[id_b] = tick[id];

    // Copy the halo cells (those around the block) to shared memory
    const unsigned int block_r = (blockIdx.x + 1) % gridDim.x;
    const unsigned int block_l = (blockIdx.x == 0) ? gridDim.x - 1 : blockIdx.x - 1;
    const unsigned int block_u = (blockIdx.y + 1) % gridDim.y;
    const unsigned int block_d = (blockIdx.y == 0) ? gridDim.y - 1 : blockIdx.y - 1;

    // Select the first row of threads
    if (threadIdx.y == 0)
    {
        // Down row
        block[threadIdx.x + 1] = tick[(blockDim.y * block_d + blockDim.y - 1) * nx + idx];
    }
    // Select the last row of threads
    if (threadIdx.y == blockDim.y - 1)
    {
        // Up row
        block[id_b + blockDim.x + 2] = tick[(blockDim.y * block_u) * nx + idx];
    }

    // Select right column of threads
    if (threadIdx.x == blockDim.x - 1)
    {
        // Copy in right
        block[id_b + 1] = tick[nx * idy + (blockDim.x * block_r)];
    }

    // Select left column of threads
    if (threadIdx.x == 0)
    {
        // Copy in left
        block[id_b - 1] = tick[nx * idy + (blockDim.x * block_l + blockDim.x - 1)];
    }

    // Add the 4 corner halo cells
    block[0] = tick[nx * (blockDim.y * block_d + blockDim.y - 1) + (blockDim.x * block_l)
                    + blockDim.x - 1];
    block[blockDim.x + 1] = tick[nx * (blockDim.y * block_d + blockDim.y - 1) + (blockDim.x * block_r)];
    block[(blockDim.x + 2) * (blockDim.y + 1)] = tick[nx * (blockDim.y * block_u)
                                                      + (blockDim.x * block_l) + blockDim.x - 1];
    block[(blockDim.x + 2) * (blockDim.y + 2) - 1] = tick[nx * (blockDim.y * block_u)
                                                          + (blockDim.x * block_r)];

    __syncthreads();

    // Indexes of rows/columns next to id_b
    unsigned int x_l, x_r, y_u, y_d;

    // Calculate indexes
    x_r = threadIdx.x + 2;
    x_l = threadIdx.x;
    y_u = threadIdx.y + 2;
    y_d = threadIdx.y;

    // Count alive neighbours (out of eight)
    int neighbours = 0;
    if (block[(threadIdx.y + 1) * (blockDim.x + 2) + x_l] == ALIVE) neighbours++;
    if (block[y_u * (blockDim.x + 2) + x_l] == ALIVE) neighbours++;
    if (block[y_d * (blockDim.x + 2) + x_l] == ALIVE) neighbours++;

    if (block[(threadIdx.y + 1) * (blockDim.x + 2) + x_r] == ALIVE) neighbours++;
    if (block[y_u * (blockDim.x + 2) + x_r] == ALIVE) neighbours++;
    if (block[y_d * (blockDim.x + 2) + x_r] == ALIVE) neighbours++;

    if (block[y_u * (blockDim.x + 2) + threadIdx.x + 1] == ALIVE) neighbours++;
    if (block[y_d * (blockDim.x + 2) + threadIdx.x + 1] == ALIVE) neighbours++;

    // Apply game of life rules
    if (block[id_b] == ALIVE)
    {
        if (neighbours == 2 || neighbours == 3)
            // Cell lives on
            tock[id] = ALIVE;
        else
            // Cell dies by over/under population
            tock[id] = DEAD;
    }
    else
    {
        if (neighbours == 3)
            // Cell becomes alive through reproduction
            tock[id] = ALIVE;
        else
            // Remains dead
            tock[id] = DEAD;
    }
}

/*************************************************************************************
 * Main function
 ************************************************************************************/

int main(int argc, char** argv)
{
    // Check we have a starting state file
    if (argc != 5)
    {
        printf("Usage:\n./gameoflife input.dat input.params bx by\n");
        printf("\tinput.dat\tpattern file\n");
        printf("\tinput.params\tparameter file defining board size\n");
        printf("\tbx by\tsizes of thread blocks - must divide the board size equally\n");
        return EXIT_FAILURE;
    }

    // Board dimensions and iteration total
    unsigned int nx, ny;
    unsigned int iterations;
    unsigned int bx = atoi(argv[3]);
    unsigned int by = atoi(argv[4]);

    load_params(argv[2], &nx, &ny, &iterations);

    // Allocate memory for boards
    size_t size = nx * ny * sizeof(char);
    char* h_board = (char*)calloc(nx * ny, sizeof(char));
    char* d_board_tick;
    char* d_board_tock;

    errorCheck(cudaMalloc(&d_board_tick, size));
    errorCheck(cudaMalloc(&d_board_tock, size));

    // Load in the starting state to board_tick
    load_board(h_board, argv[1], nx, ny);

    // Display the starting state
    printf("Starting state\n");
    print_board(h_board, nx, ny);

    // Copy the host array to the device array
    errorCheck(cudaMemcpy(d_board_tick, h_board, size, cudaMemcpyHostToDevice));

    // Define our problem size for CUDA
    dim3 numBlocks(nx / bx, ny / by);
    dim3 numThreads(bx, by);
    size_t sharedMem = sizeof(char) * (bx + 2) * (by + 2);

    // Loop
    for (unsigned int i = 0; i < iterations; i++)
    {
        // Apply the rules of Life
        accelerate_life<<<numBlocks, numThreads, sharedMem>>>(d_board_tick, d_board_tock, nx, ny);
        errorCheck(cudaPeekAtLastError());

        // Swap the boards over
        char* tmp = d_board_tick;
        d_board_tick = d_board_tock;
        d_board_tock = tmp;
    }

    // Copy the device array back to the host
    errorCheck(cudaMemcpy(h_board, d_board_tick, size, cudaMemcpyDeviceToHost));

    // Display the final state
    printf("Finishing state\n");
    print_board(h_board, nx, ny);

    // Save the final state of the board
    save_board(h_board, nx, ny);

    return EXIT_SUCCESS;
}

/*************************************************************************************
 * Utility functions
 ************************************************************************************/

// Function to load the params file and set up the X and Y dimensions
void load_params(const char* file, unsigned int* nx, unsigned int* ny, unsigned int* iterations)
{
    FILE* fp = fopen(file, "r");
    if (!fp) die("Could not open params file.", __LINE__, __FILE__);

    int retval;
    retval = fscanf(fp, "%d\n", nx);
    if (retval != 1) die("Could not read params file: nx.", __LINE__, __FILE__);
    retval = fscanf(fp, "%d\n", ny);
    if (retval != 1) die("Could not read params file: ny", __LINE__, __FILE__);
    retval = fscanf(fp, "%d\n", iterations);
    if (retval != 1) die("Could not read params file: iterations", __LINE__, __FILE__);

    fclose(fp);
}

// Function to load in a file which lists the alive cells
// Each line of the file is expected to be: x y 1
void load_board(char* board, const char* file, const unsigned int nx, const unsigned int ny)
{
    FILE* fp = fopen(file, "r");
    if (!fp) die("Could not open input file.", __LINE__, __FILE__);

    int retval;
    unsigned int x, y, s;
    while ((retval = fscanf(fp, "%d %d %d\n", &x, &y, &s)) != EOF)
    {
        if (retval != 3) die("Expected 3 values per line in input file.", __LINE__, __FILE__);
        if (x > nx - 1) die("Input x-coord out of range.", __LINE__, __FILE__);
        if (y > ny - 1) die("Input y-coord out of range.", __LINE__, __FILE__);
        if (s != ALIVE) die("Alive value should be 1.", __LINE__, __FILE__);

        board[x + y * nx] = ALIVE;
    }

    fclose(fp);
}

// Function to print out the board to stdout
// Alive cells are displayed as O
// Dead cells are displayed as .
void print_board(const char* board, const unsigned int nx, const unsigned int ny)
{
    for (unsigned int i = 0; i < ny; i++)
    {
        for (unsigned int j = 0; j < nx; j++)
        {
            if (board[i * nx + j] == DEAD)
                printf(".");
            else
                printf("O");
        }
        printf("\n");
    }
}

void save_board(const char* board, const unsigned int nx, const unsigned int ny)
{
    FILE* fp = fopen(FINALSTATEFILE, "w");
    if (!fp) die("Could not open final state file.", __LINE__, __FILE__);

    for (unsigned int i = 0; i < ny; i++)
    {
        for (unsigned int j = 0; j < nx; j++)
        {
            if (board[i * nx + j] == ALIVE) fprintf(fp, "%d %d %d\n", j, i, ALIVE);
        }
    }
}

void errorCheck(cudaError_t error)
{
    if (error != cudaSuccess) die(cudaGetErrorString(error), __LINE__, __FILE__);
}

// Function to display error and exit nicely
void die(const char* message, const int line, const char* file)
{
    fprintf(stderr, "Error at line %d of file %s:\n", line, file);
    fprintf(stderr, "%s\n", message);
    fflush(stderr);
    exit(EXIT_FAILURE);
}

	.file	"tmpxft_0025e721_00000000-6_gameoflife.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2036:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2036:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"."
.LC1:
	.string	"O"
.LC2:
	.string	"\n"
	.text
	.globl	_Z11print_boardPKcjj
	.type	_Z11print_boardPKcjj, @function
_Z11print_boardPKcjj:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%esi, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %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
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	pushq	%rcx
	.cfi_def_cfa_offset 64
.L3:
	cmpq	%rbp, %r12
	je	.L12
	movl	%r13d, %ebx
.L7:
	leal	(%r15,%r13), %eax
	cmpl	%eax, %ebx
	je	.L13
	movl	%ebx, %eax
	leaq	.LC0(%rip), %rsi
	cmpb	$0, (%r14,%rax)
	je	.L10
	leaq	.LC1(%rip), %rsi
.L10:
	movl	$2, %edi
	xorl	%eax, %eax
	incl	%ebx
	call	__printf_chk@PLT
	jmp	.L7
.L13:
	leaq	.LC2(%rip), %rsi
	xorl	%eax, %eax
	incq	%r12
	movl	%ebx, %r13d
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L3
.L12:
	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
.LFE2030:
	.size	_Z11print_boardPKcjj, .-_Z11print_boardPKcjj
	.section	.rodata.str1.1
.LC3:
	.string	"Error at line %d of file %s:\n"
.LC4:
	.string	"%s\n"
	.text
	.globl	_Z3diePKciS0_
	.type	_Z3diePKciS0_, @function
_Z3diePKciS0_:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	movq	stderr(%rip), %rdi
	movq	%rdx, %r8
	movl	%esi, %ecx
	leaq	.LC3(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	%rbx, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC4(%rip), %rdx
	call	__fprintf_chk@PLT
	movq	stderr(%rip), %rdi
	call	fflush@PLT
	movl	$1, %edi
	call	exit@PLT
	.cfi_endproc
.LFE2033:
	.size	_Z3diePKciS0_, .-_Z3diePKciS0_
	.section	.rodata.str1.1
.LC5:
	.string	"r"
.LC6:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/dbeurle/gpu-tutorial/master/Exercises/Exercise13/CUDA/gameoflife.cu"
.LC7:
	.string	"Could not open params file."
.LC8:
	.string	"%d\n"
.LC9:
	.string	"Could not read params file: nx."
.LC10:
	.string	"Could not read params file: ny"
.LC11:
	.string	"Could not read params file: iterations"
	.text
	.globl	_Z11load_paramsPKcPjS1_S1_
	.type	_Z11load_paramsPKcPjS1_S1_, @function
_Z11load_paramsPKcPjS1_S1_:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rsi, %rbp
	leaq	.LC5(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%r8
	.cfi_def_cfa_offset 48
	call	fopen@PLT
	leaq	.LC6(%rip), %rdx
	movl	$219, %esi
	leaq	.LC7(%rip), %rdi
	testq	%rax, %rax
	je	.L22
	movq	%rbp, %rdx
	leaq	.LC8(%rip), %rbp
	movq	%rax, %rdi
	movq	%rax, %rbx
	movq	%rbp, %rsi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	decl	%eax
	je	.L18
	leaq	.LC6(%rip), %rdx
	movl	$223, %esi
	leaq	.LC9(%rip), %rdi
.L22:
	call	_Z3diePKciS0_
.L18:
	movq	%r13, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	leaq	.LC6(%rip), %rdx
	movl	$225, %esi
	leaq	.LC10(%rip), %rdi
	decl	%eax
	jne	.L22
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc23_fscanf@PLT
	leaq	.LC6(%rip), %rdx
	movl	$227, %esi
	leaq	.LC11(%rip), %rdi
	decl	%eax
	jne	.L22
	popq	%rax
	.cfi_def_cfa_offset 40
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z11load_paramsPKcPjS1_S1_, .-_Z11load_paramsPKcPjS1_S1_
	.section	.rodata.str1.1
.LC12:
	.string	"Could not open input file."
.LC13:
	.string	"Expected 3 values per line in input file."
.LC14:
	.string	"Input x-coord out of range."
.LC15:
	.string	"Input y-coord out of range."
.LC16:
	.string	"Alive value should be 1."
.LC17:
	.string	"%d %d %d\n"
	.text
	.globl	_Z10load_boardPcPKcjj
	.type	_Z10load_boardPcPKcjj, @function
_Z10load_boardPcPKcjj:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC17(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%ecx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rdi, %r12
	movq	%rsi, %rdi
	leaq	.LC5(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	fopen@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	jne	.L24
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	leaq	.LC6(%rip), %rdx
	movl	$237, %esi
	leaq	.LC12(%rip), %rdi
	je	.L40
	jmp	.L41
.L26:
	movl	12(%rsp), %edx
	leal	-1(%rbp), %eax
	cmpl	%edx, %eax
	jb	.L42
	movl	16(%rsp), %eax
	leal	-1(%r13), %ecx
	cmpl	%eax, %ecx
	jb	.L43
	cmpl	$1, 20(%rsp)
	jne	.L44
	imull	%ebp, %eax
	addl	%edx, %eax
	movl	%eax, %eax
	movb	$1, (%r12,%rax)
.L24:
	xorl	%eax, %eax
	leaq	16(%rsp), %rcx
	leaq	12(%rsp), %rdx
	movq	%r14, %rsi
	leaq	20(%rsp), %r8
	movq	%rbx, %rdi
	call	__isoc23_fscanf@PLT
	cmpl	$-1, %eax
	je	.L45
	cmpl	$3, %eax
	je	.L26
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	leaq	.LC6(%rip), %rdx
	movl	$243, %esi
	leaq	.LC13(%rip), %rdi
	jne	.L41
.L40:
	call	_Z3diePKciS0_
.L42:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	leaq	.LC6(%rip), %rdx
	movl	$244, %esi
	leaq	.LC14(%rip), %rdi
	je	.L40
	jmp	.L41
.L43:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	leaq	.LC6(%rip), %rdx
	movl	$245, %esi
	leaq	.LC15(%rip), %rdi
	je	.L40
	jmp	.L41
.L44:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	leaq	.LC6(%rip), %rdx
	movl	$246, %esi
	leaq	.LC16(%rip), %rdi
	je	.L40
	jmp	.L41
.L45:
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L35
.L41:
	call	__stack_chk_fail@PLT
.L35:
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z10load_boardPcPKcjj, .-_Z10load_boardPcPKcjj
	.section	.rodata.str1.1
.LC18:
	.string	"w"
.LC19:
	.string	"final_state.dat"
.LC20:
	.string	"Could not open final state file."
	.text
	.globl	_Z10save_boardPKcjj
	.type	_Z10save_boardPKcjj, @function
_Z10save_boardPKcjj:
.LFB2031:
	.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
	movq	%rdi, %r14
	leaq	.LC19(%rip), %rdi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%esi, %r12d
	leaq	.LC18(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	call	fopen@PLT
	testq	%rax, %rax
	je	.L47
	movq	%rax, %rdi
	xorl	%r10d, %r10d
	xorl	%r13d, %r13d
	jmp	.L48
.L47:
	leaq	.LC6(%rip), %rdx
	movl	$275, %esi
	leaq	.LC20(%rip), %rdi
	call	_Z3diePKciS0_
.L50:
	leal	(%r10,%rbx), %eax
	cmpb	$1, (%r14,%rax)
	jne	.L49
	movl	$1, %r9d
	leaq	.LC17(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movl	%r10d, 12(%rsp)
	movl	%r8d, 8(%rsp)
	movq	%rdi, (%rsp)
	call	__fprintf_chk@PLT
	movl	12(%rsp), %r10d
	movl	8(%rsp), %r8d
	movq	(%rsp), %rdi
.L49:
	incq	%rbx
.L52:
	movl	%ebx, %ecx
	cmpq	%r15, %rbx
	jne	.L50
	incq	%r13
	addl	%r12d, %r10d
.L48:
	movl	%r13d, %r8d
	cmpq	%rbp, %r13
	je	.L46
	movl	%r12d, %r15d
	xorl	%ebx, %ebx
	jmp	.L52
.L46:
	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
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z10save_boardPKcjj, .-_Z10save_boardPKcjj
	.globl	_Z10errorCheck9cudaError
	.type	_Z10errorCheck9cudaError, @function
_Z10errorCheck9cudaError:
.LFB2032:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L54
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	cudaGetErrorString@PLT
	leaq	.LC6(%rip), %rdx
	movl	$288, %esi
	movq	%rax, %rdi
	call	_Z3diePKciS0_
.L54:
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z10errorCheck9cudaError, .-_Z10errorCheck9cudaError
	.globl	_Z40__device_stub__Z15accelerate_lifePKcPciiPKcPcii
	.type	_Z40__device_stub__Z15accelerate_lifePKcPciiPKcPcii, @function
_Z40__device_stub__Z15accelerate_lifePKcPciiPKcPcii:
.LFB2058:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L59
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z15accelerate_lifePKcPcii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L59:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L61
	call	__stack_chk_fail@PLT
.L61:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z40__device_stub__Z15accelerate_lifePKcPciiPKcPcii, .-_Z40__device_stub__Z15accelerate_lifePKcPciiPKcPcii
	.globl	_Z15accelerate_lifePKcPcii
	.type	_Z15accelerate_lifePKcPcii, @function
_Z15accelerate_lifePKcPcii:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z40__device_stub__Z15accelerate_lifePKcPciiPKcPcii
	.cfi_endproc
.LFE2059:
	.size	_Z15accelerate_lifePKcPcii, .-_Z15accelerate_lifePKcPcii
	.section	.rodata.str1.1
.LC21:
	.string	"Usage:\n./gameoflife input.dat input.params bx by\n"
.LC22:
	.string	"\tinput.dat\tpattern file\n"
.LC23:
	.string	"\tinput.params\tparameter file defining board size\n"
.LC24:
	.string	"\tbx by\tsizes of thread blocks - must divide the board size equally\n"
.LC25:
	.string	"Starting state\n"
.LC26:
	.string	"Finishing state\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
	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
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	cmpl	$5, %edi
	je	.L65
	leaq	.LC21(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC22(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC23(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC24(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %eax
	jmp	.L64
.L65:
	movq	24(%rsi), %rdi
	movq	%rsi, %r14
	call	atoi@PLT
	movq	32(%r14), %rdi
	movl	%eax, %r13d
	call	atoi@PLT
	movq	16(%r14), %rdi
	leaq	12(%rsp), %rcx
	leaq	8(%rsp), %rdx
	leaq	4(%rsp), %rsi
	movl	%eax, %r12d
	call	_Z11load_paramsPKcPjS1_S1_
	movl	4(%rsp), %ebp
	imull	8(%rsp), %ebp
	movl	$1, %esi
	movq	%rbp, %rdi
	call	calloc@PLT
	movq	%rbp, %rsi
	leaq	16(%rsp), %rdi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z10errorCheck9cudaError
	movq	%rbp, %rsi
	leaq	24(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	call	_Z10errorCheck9cudaError
	movl	8(%rsp), %ecx
	movl	4(%rsp), %edx
	movq	%rbx, %rdi
	movq	8(%r14), %rsi
	call	_Z10load_boardPcPKcjj
	leaq	.LC25(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	8(%rsp), %edx
	movl	4(%rsp), %esi
	movq	%rbx, %rdi
	call	_Z11print_boardPKcjj
	movq	16(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%rbx, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	_Z10errorCheck9cudaError
	movl	8(%rsp), %eax
	xorl	%edx, %edx
	movl	%r13d, 44(%rsp)
	movl	$1, 40(%rsp)
	divl	%r12d
	movl	$1, 52(%rsp)
	movl	%r12d, 48(%rsp)
	xorl	%edx, %edx
	movl	%eax, %ecx
	movl	4(%rsp), %eax
	movl	%ecx, 36(%rsp)
	divl	%r13d
	addl	$2, %r13d
	movl	%eax, 32(%rsp)
	leal	2(%r12), %eax
	xorl	%r12d, %r12d
	imulq	%rax, %r13
.L67:
	cmpl	12(%rsp), %r12d
	jnb	.L72
	movl	52(%rsp), %ecx
	movq	44(%rsp), %rdx
	xorl	%r9d, %r9d
	movq	%r13, %r8
	movq	32(%rsp), %rdi
	movl	40(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L68
	movl	8(%rsp), %ecx
	movl	4(%rsp), %edx
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	call	_Z40__device_stub__Z15accelerate_lifePKcPciiPKcPcii
.L68:
	call	cudaPeekAtLastError@PLT
	incl	%r12d
	movl	%eax, %edi
	call	_Z10errorCheck9cudaError
	movq	16(%rsp), %rax
	movq	24(%rsp), %rdx
	movq	%rax, 24(%rsp)
	movq	%rdx, 16(%rsp)
	jmp	.L67
.L72:
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbp, %rdx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	call	_Z10errorCheck9cudaError
	leaq	.LC26(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	8(%rsp), %edx
	movl	4(%rsp), %esi
	movq	%rbx, %rdi
	call	_Z11print_boardPKcjj
	movl	8(%rsp), %edx
	movl	4(%rsp), %esi
	movq	%rbx, %rdi
	call	_Z10save_boardPKcjj
	xorl	%eax, %eax
.L64:
	movq	56(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L70
	call	__stack_chk_fail@PLT
.L70:
	addq	$64, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC27:
	.string	"_Z15accelerate_lifePKcPcii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2061:
	.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	.LC27(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z15accelerate_lifePKcPcii(%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
.LFE2061:
	.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
	.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:

//------------------------------------------------------------------------------
//
// Name:       gameoflife.cu
//
// Purpose:    CUDA implementation of Conway's game of life
//
// HISTORY:    Written by Tom Deakin and Simon McIntosh-Smith, August 2013
//
//------------------------------------------------------------------------------

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

#define FINALSTATEFILE "final_state.dat"

// Define the state of the cell
#define DEAD 0
#define ALIVE 1

/*************************************************************************************
 * Forward declarations of utility functions
 ************************************************************************************/
void die(const char* message, const int line, const char* file);
void load_board(char* board, const char* file, const unsigned int nx, const unsigned int ny);
void print_board(const char* board, const unsigned int nx, const unsigned int ny);
void save_board(const char* board, const unsigned int nx, const unsigned int ny);
void load_params(const char* file, unsigned int* nx, unsigned int* ny, unsigned int* iterations);
void errorCheck(hipError_t error);

/*************************************************************************************
 * Game of Life worker method - CUDA kernel
 ************************************************************************************/

// Apply the rules of life to tick and save in tock
__global__ void accelerate_life(const char* tick, char* tock, const int nx, const int ny)
{
    // The cell we work on in the loop
    unsigned int idx = blockDim.x * blockIdx.x + threadIdx.x;
    unsigned int idy = blockDim.y * blockIdx.y + threadIdx.y;

    // Index with respect to global array
    unsigned int id = idy * nx + idx;
    unsigned int id_b = (threadIdx.y + 1) * (blockDim.x + 2) + threadIdx.x + 1;

    // Copy block to shared memory
    extern __shared__ char block[];
    block[id_b] = tick[id];

    // Copy the halo cells (those around the block) to shared memory
    const unsigned int block_r = (blockIdx.x + 1) % gridDim.x;
    const unsigned int block_l = (blockIdx.x == 0) ? gridDim.x - 1 : blockIdx.x - 1;
    const unsigned int block_u = (blockIdx.y + 1) % gridDim.y;
    const unsigned int block_d = (blockIdx.y == 0) ? gridDim.y - 1 : blockIdx.y - 1;

    // Select the first row of threads
    if (threadIdx.y == 0)
    {
        // Down row
        block[threadIdx.x + 1] = tick[(blockDim.y * block_d + blockDim.y - 1) * nx + idx];
    }
    // Select the last row of threads
    if (threadIdx.y == blockDim.y - 1)
    {
        // Up row
        block[id_b + blockDim.x + 2] = tick[(blockDim.y * block_u) * nx + idx];
    }

    // Select right column of threads
    if (threadIdx.x == blockDim.x - 1)
    {
        // Copy in right
        block[id_b + 1] = tick[nx * idy + (blockDim.x * block_r)];
    }

    // Select left column of threads
    if (threadIdx.x == 0)
    {
        // Copy in left
        block[id_b - 1] = tick[nx * idy + (blockDim.x * block_l + blockDim.x - 1)];
    }

    // Add the 4 corner halo cells
    block[0] = tick[nx * (blockDim.y * block_d + blockDim.y - 1) + (blockDim.x * block_l)
                    + blockDim.x - 1];
    block[blockDim.x + 1] = tick[nx * (blockDim.y * block_d + blockDim.y - 1) + (blockDim.x * block_r)];
    block[(blockDim.x + 2) * (blockDim.y + 1)] = tick[nx * (blockDim.y * block_u)
                                                      + (blockDim.x * block_l) + blockDim.x - 1];
    block[(blockDim.x + 2) * (blockDim.y + 2) - 1] = tick[nx * (blockDim.y * block_u)
                                                          + (blockDim.x * block_r)];

    __syncthreads();

    // Indexes of rows/columns next to id_b
    unsigned int x_l, x_r, y_u, y_d;

    // Calculate indexes
    x_r = threadIdx.x + 2;
    x_l = threadIdx.x;
    y_u = threadIdx.y + 2;
    y_d = threadIdx.y;

    // Count alive neighbours (out of eight)
    int neighbours = 0;
    if (block[(threadIdx.y + 1) * (blockDim.x + 2) + x_l] == ALIVE) neighbours++;
    if (block[y_u * (blockDim.x + 2) + x_l] == ALIVE) neighbours++;
    if (block[y_d * (blockDim.x + 2) + x_l] == ALIVE) neighbours++;

    if (block[(threadIdx.y + 1) * (blockDim.x + 2) + x_r] == ALIVE) neighbours++;
    if (block[y_u * (blockDim.x + 2) + x_r] == ALIVE) neighbours++;
    if (block[y_d * (blockDim.x + 2) + x_r] == ALIVE) neighbours++;

    if (block[y_u * (blockDim.x + 2) + threadIdx.x + 1] == ALIVE) neighbours++;
    if (block[y_d * (blockDim.x + 2) + threadIdx.x + 1] == ALIVE) neighbours++;

    // Apply game of life rules
    if (block[id_b] == ALIVE)
    {
        if (neighbours == 2 || neighbours == 3)
            // Cell lives on
            tock[id] = ALIVE;
        else
            // Cell dies by over/under population
            tock[id] = DEAD;
    }
    else
    {
        if (neighbours == 3)
            // Cell becomes alive through reproduction
            tock[id] = ALIVE;
        else
            // Remains dead
            tock[id] = DEAD;
    }
}

/*************************************************************************************
 * Main function
 ************************************************************************************/

int main(int argc, char** argv)
{
    // Check we have a starting state file
    if (argc != 5)
    {
        printf("Usage:\n./gameoflife input.dat input.params bx by\n");
        printf("\tinput.dat\tpattern file\n");
        printf("\tinput.params\tparameter file defining board size\n");
        printf("\tbx by\tsizes of thread blocks - must divide the board size equally\n");
        return EXIT_FAILURE;
    }

    // Board dimensions and iteration total
    unsigned int nx, ny;
    unsigned int iterations;
    unsigned int bx = atoi(argv[3]);
    unsigned int by = atoi(argv[4]);

    load_params(argv[2], &nx, &ny, &iterations);

    // Allocate memory for boards
    size_t size = nx * ny * sizeof(char);
    char* h_board = (char*)calloc(nx * ny, sizeof(char));
    char* d_board_tick;
    char* d_board_tock;

    errorCheck(hipMalloc(&d_board_tick, size));
    errorCheck(hipMalloc(&d_board_tock, size));

    // Load in the starting state to board_tick
    load_board(h_board, argv[1], nx, ny);

    // Display the starting state
    printf("Starting state\n");
    print_board(h_board, nx, ny);

    // Copy the host array to the device array
    errorCheck(hipMemcpy(d_board_tick, h_board, size, hipMemcpyHostToDevice));

    // Define our problem size for CUDA
    dim3 numBlocks(nx / bx, ny / by);
    dim3 numThreads(bx, by);
    size_t sharedMem = sizeof(char) * (bx + 2) * (by + 2);

    // Loop
    for (unsigned int i = 0; i < iterations; i++)
    {
        // Apply the rules of Life
        accelerate_life<<<numBlocks, numThreads, sharedMem>>>(d_board_tick, d_board_tock, nx, ny);
        errorCheck(hipPeekAtLastError());

        // Swap the boards over
        char* tmp = d_board_tick;
        d_board_tick = d_board_tock;
        d_board_tock = tmp;
    }

    // Copy the device array back to the host
    errorCheck(hipMemcpy(h_board, d_board_tick, size, hipMemcpyDeviceToHost));

    // Display the final state
    printf("Finishing state\n");
    print_board(h_board, nx, ny);

    // Save the final state of the board
    save_board(h_board, nx, ny);

    return EXIT_SUCCESS;
}

/*************************************************************************************
 * Utility functions
 ************************************************************************************/

// Function to load the params file and set up the X and Y dimensions
void load_params(const char* file, unsigned int* nx, unsigned int* ny, unsigned int* iterations)
{
    FILE* fp = fopen(file, "r");
    if (!fp) die("Could not open params file.", __LINE__, __FILE__);

    int retval;
    retval = fscanf(fp, "%d\n", nx);
    if (retval != 1) die("Could not read params file: nx.", __LINE__, __FILE__);
    retval = fscanf(fp, "%d\n", ny);
    if (retval != 1) die("Could not read params file: ny", __LINE__, __FILE__);
    retval = fscanf(fp, "%d\n", iterations);
    if (retval != 1) die("Could not read params file: iterations", __LINE__, __FILE__);

    fclose(fp);
}

// Function to load in a file which lists the alive cells
// Each line of the file is expected to be: x y 1
void load_board(char* board, const char* file, const unsigned int nx, const unsigned int ny)
{
    FILE* fp = fopen(file, "r");
    if (!fp) die("Could not open input file.", __LINE__, __FILE__);

    int retval;
    unsigned int x, y, s;
    while ((retval = fscanf(fp, "%d %d %d\n", &x, &y, &s)) != EOF)
    {
        if (retval != 3) die("Expected 3 values per line in input file.", __LINE__, __FILE__);
        if (x > nx - 1) die("Input x-coord out of range.", __LINE__, __FILE__);
        if (y > ny - 1) die("Input y-coord out of range.", __LINE__, __FILE__);
        if (s != ALIVE) die("Alive value should be 1.", __LINE__, __FILE__);

        board[x + y * nx] = ALIVE;
    }

    fclose(fp);
}

// Function to print out the board to stdout
// Alive cells are displayed as O
// Dead cells are displayed as .
void print_board(const char* board, const unsigned int nx, const unsigned int ny)
{
    for (unsigned int i = 0; i < ny; i++)
    {
        for (unsigned int j = 0; j < nx; j++)
        {
            if (board[i * nx + j] == DEAD)
                printf(".");
            else
                printf("O");
        }
        printf("\n");
    }
}

void save_board(const char* board, const unsigned int nx, const unsigned int ny)
{
    FILE* fp = fopen(FINALSTATEFILE, "w");
    if (!fp) die("Could not open final state file.", __LINE__, __FILE__);

    for (unsigned int i = 0; i < ny; i++)
    {
        for (unsigned int j = 0; j < nx; j++)
        {
            if (board[i * nx + j] == ALIVE) fprintf(fp, "%d %d %d\n", j, i, ALIVE);
        }
    }
}

void errorCheck(hipError_t error)
{
    if (error != hipSuccess) die(hipGetErrorString(error), __LINE__, __FILE__);
}

// Function to display error and exit nicely
void die(const char* message, const int line, const char* file)
{
    fprintf(stderr, "Error at line %d of file %s:\n", line, file);
    fprintf(stderr, "%s\n", message);
    fflush(stderr);
    exit(EXIT_FAILURE);
}

	.text
	.file	"gameoflife.hip"
	.globl	_Z30__device_stub__accelerate_lifePKcPcii # -- Begin function _Z30__device_stub__accelerate_lifePKcPcii
	.type	_Z30__device_stub__accelerate_lifePKcPcii,@function
_Z30__device_stub__accelerate_lifePKcPcii: # @_Z30__device_stub__accelerate_lifePKcPcii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z15accelerate_lifePKcPcii, %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	_Z30__device_stub__accelerate_lifePKcPcii, .Lfunc_end0-_Z30__device_stub__accelerate_lifePKcPcii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$5, %edi
	jne	.LBB1_1
# %bb.2:
	movq	%rsi, %rbp
	movq	24(%rsi), %rdi
	callq	atoi
	movl	%eax, %r12d
	movq	32(%rbp), %rdi
	callq	atoi
	movl	%eax, %r14d
	movq	16(%rbp), %rdi
	leaq	12(%rsp), %r13
	leaq	8(%rsp), %rbx
	leaq	28(%rsp), %rcx
	movq	%r13, %rsi
	movq	%rbx, %rdx
	callq	_Z11load_paramsPKcPjS1_S1_
	movl	(%rbx), %r15d
	imull	(%r13), %r15d
	movl	$1, %esi
	movq	%r15, %rdi
	callq	calloc
	movq	%rax, %rbx
	leaq	16(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z10errorCheck10hipError_t
	leaq	32(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movl	%eax, %edi
	callq	_Z10errorCheck10hipError_t
	movq	8(%rbp), %rsi
	movl	(%r13), %edx
	leaq	8(%rsp), %rbp
	movl	(%rbp), %ecx
	movq	%rbx, %rdi
	callq	_Z10load_boardPcPKcjj
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	(%r13), %esi
	movl	(%rbp), %edx
	movq	%rbx, %rdi
	callq	_Z11print_boardPKcjj
	leaq	16(%rsp), %rax
	movq	(%rax), %rdi
	movq	%rbx, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	_Z10errorCheck10hipError_t
	movq	%r12, %rsi
	movl	(%r13), %eax
	xorl	%r12d, %r12d
	xorl	%edx, %edx
	divl	%esi
	movl	%eax, %ecx
	movl	(%rbp), %eax
	xorl	%edx, %edx
	divl	%r14d
	movl	%eax, %r13d
	leaq	28(%rsp), %rax
	cmpl	$0, (%rax)
	je	.LBB1_7
# %bb.3:                                # %.lr.ph.preheader
	shlq	$32, %r13
	orq	%rcx, %r13
	movl	%esi, %eax
	movq	%r14, %rbp
	shlq	$32, %rbp
	orq	%rax, %rbp
	addl	$2, %esi
	addl	$2, %r14d
	imulq	%rsi, %r14
.LBB1_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%rbp, %rdx
	movl	$1, %ecx
	movq	%r14, %r8
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_6
# %bb.5:                                #   in Loop: Header=BB1_4 Depth=1
	movq	16(%rsp), %rdi
	movq	32(%rsp), %rsi
	movl	12(%rsp), %edx
	movl	8(%rsp), %ecx
	callq	_Z30__device_stub__accelerate_lifePKcPcii
.LBB1_6:                                #   in Loop: Header=BB1_4 Depth=1
	callq	hipPeekAtLastError
	movl	%eax, %edi
	callq	_Z10errorCheck10hipError_t
	movq	16(%rsp), %rax
	movq	32(%rsp), %rsi
	movq	%rsi, 16(%rsp)
	movq	%rax, 32(%rsp)
	incl	%r12d
	cmpl	28(%rsp), %r12d
	jb	.LBB1_4
	jmp	.LBB1_8
.LBB1_1:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	movl	$1, %eax
	jmp	.LBB1_9
.LBB1_7:                                # %.._crit_edge_crit_edge
	movq	16(%rsp), %rsi
.LBB1_8:                                # %._crit_edge
	movq	%rbx, %rdi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	%eax, %edi
	callq	_Z10errorCheck10hipError_t
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	12(%rsp), %esi
	movl	8(%rsp), %edx
	movq	%rbx, %rdi
	callq	_Z11print_boardPKcjj
	movl	12(%rsp), %esi
	movl	8(%rsp), %edx
	movq	%rbx, %rdi
	callq	_Z10save_boardPKcjj
	xorl	%eax, %eax
.LBB1_9:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z11load_paramsPKcPjS1_S1_      # -- Begin function _Z11load_paramsPKcPjS1_S1_
	.type	_Z11load_paramsPKcPjS1_S1_,@function
_Z11load_paramsPKcPjS1_S1_:             # @_Z11load_paramsPKcPjS1_S1_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rcx, %rbx
	movq	%rdx, %r15
	movq	%rsi, %r12
	movl	$.L.str.6, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB2_5
# %bb.1:
	movq	%rax, %r14
	movl	$.L.str.9, %esi
	movq	%rax, %rdi
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$1, %eax
	jne	.LBB2_6
# %bb.2:
	movl	$.L.str.9, %esi
	movq	%r14, %rdi
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$1, %eax
	jne	.LBB2_7
# %bb.3:
	movl	$.L.str.9, %esi
	movq	%r14, %rdi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$1, %eax
	jne	.LBB2_8
# %bb.4:
	movq	%r14, %rdi
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.LBB2_5:
	.cfi_def_cfa_offset 48
	movl	$.L.str.7, %edi
	movl	$.L.str.8, %edx
	movl	$219, %esi
	callq	_Z3diePKciS0_
.LBB2_6:
	movl	$.L.str.10, %edi
	movl	$.L.str.8, %edx
	movl	$223, %esi
	callq	_Z3diePKciS0_
.LBB2_7:
	movl	$.L.str.11, %edi
	movl	$.L.str.8, %edx
	movl	$225, %esi
	callq	_Z3diePKciS0_
.LBB2_8:
	movl	$.L.str.12, %edi
	movl	$.L.str.8, %edx
	movl	$227, %esi
	callq	_Z3diePKciS0_
.Lfunc_end2:
	.size	_Z11load_paramsPKcPjS1_S1_, .Lfunc_end2-_Z11load_paramsPKcPjS1_S1_
	.cfi_endproc
                                        # -- End function
	.globl	_Z10errorCheck10hipError_t      # -- Begin function _Z10errorCheck10hipError_t
	.type	_Z10errorCheck10hipError_t,@function
_Z10errorCheck10hipError_t:             # @_Z10errorCheck10hipError_t
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB3_2
# %bb.1:
	retq
.LBB3_2:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	hipGetErrorString
	movl	$.L.str.8, %edx
	movq	%rax, %rdi
	movl	$288, %esi                      # imm = 0x120
	callq	_Z3diePKciS0_
.Lfunc_end3:
	.size	_Z10errorCheck10hipError_t, .Lfunc_end3-_Z10errorCheck10hipError_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z10load_boardPcPKcjj           # -- Begin function _Z10load_boardPcPKcjj
	.type	_Z10load_boardPcPKcjj,@function
_Z10load_boardPcPKcjj:                  # @_Z10load_boardPcPKcjj
	.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
	movl	%ecx, %ebx
	movl	%edx, %r14d
	movq	%rsi, %rax
	movq	%rdi, %r15
	movl	$.L.str.6, %esi
	movq	%rax, %rdi
	callq	fopen
	testq	%rax, %rax
	je	.LBB4_10
# %bb.1:
	movq	%rax, %r12
	leal	-1(%r14), %ebp
	decl	%ebx
	leaq	12(%rsp), %r13
.LBB4_2:                                # =>This Inner Loop Header: Depth=1
	movl	$.L.str.14, %esi
	movq	%r12, %rdi
	leaq	20(%rsp), %rdx
	leaq	16(%rsp), %rcx
	movq	%r13, %r8
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$3, %eax
	jne	.LBB4_3
# %bb.5:                                #   in Loop: Header=BB4_2 Depth=1
	movl	20(%rsp), %eax
	cmpl	%ebp, %eax
	ja	.LBB4_11
# %bb.6:                                #   in Loop: Header=BB4_2 Depth=1
	movl	16(%rsp), %ecx
	cmpl	%ebx, %ecx
	ja	.LBB4_12
# %bb.7:                                #   in Loop: Header=BB4_2 Depth=1
	cmpl	$1, 12(%rsp)
	jne	.LBB4_13
# %bb.8:                                #   in Loop: Header=BB4_2 Depth=1
	imull	%r14d, %ecx
	addl	%eax, %ecx
	movb	$1, (%r15,%rcx)
	jmp	.LBB4_2
.LBB4_3:
	cmpl	$-1, %eax
	jne	.LBB4_4
# %bb.9:
	movq	%r12, %rdi
	callq	fclose
	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
	retq
.LBB4_13:
	.cfi_def_cfa_offset 80
	movl	$.L.str.18, %edi
	movl	$.L.str.8, %edx
	movl	$246, %esi
	callq	_Z3diePKciS0_
.LBB4_11:
	movl	$.L.str.16, %edi
	movl	$.L.str.8, %edx
	movl	$244, %esi
	callq	_Z3diePKciS0_
.LBB4_12:
	movl	$.L.str.17, %edi
	movl	$.L.str.8, %edx
	movl	$245, %esi
	callq	_Z3diePKciS0_
.LBB4_4:
	movl	$.L.str.15, %edi
	movl	$.L.str.8, %edx
	movl	$243, %esi
	callq	_Z3diePKciS0_
.LBB4_10:
	movl	$.L.str.13, %edi
	movl	$.L.str.8, %edx
	movl	$237, %esi
	callq	_Z3diePKciS0_
.Lfunc_end4:
	.size	_Z10load_boardPcPKcjj, .Lfunc_end4-_Z10load_boardPcPKcjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z11print_boardPKcjj            # -- Begin function _Z11print_boardPKcjj
	.type	_Z11print_boardPKcjj,@function
_Z11print_boardPKcjj:                   # @_Z11print_boardPKcjj
	.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
	movl	%edx, 12(%rsp)                  # 4-byte Spill
	testl	%edx, %edx
	je	.LBB5_4
# %bb.1:                                # %.preheader.lr.ph
	movl	%esi, %ebp
	movq	%rdi, %r14
	movl	%esi, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	xorl	%ebx, %ebx
	xorl	%r13d, %r13d
.LBB5_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_5 Depth 2
	movq	16(%rsp), %r15                  # 8-byte Reload
	movl	%ebx, %r12d
	testl	%ebp, %ebp
	je	.LBB5_3
.LBB5_5:                                #   Parent Loop BB5_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%r12d, %eax
	cmpb	$0, (%r14,%rax)
	movl	$46, %edi
	je	.LBB5_7
# %bb.6:                                #   in Loop: Header=BB5_5 Depth=2
	movl	$79, %edi
.LBB5_7:                                #   in Loop: Header=BB5_5 Depth=2
	callq	putchar@PLT
	incl	%r12d
	decq	%r15
	jne	.LBB5_5
.LBB5_3:                                # %._crit_edge
                                        #   in Loop: Header=BB5_2 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	incl	%r13d
	addl	%ebp, %ebx
	cmpl	12(%rsp), %r13d                 # 4-byte Folded Reload
	jne	.LBB5_2
.LBB5_4:                                # %._crit_edge15
	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
	retq
.Lfunc_end5:
	.size	_Z11print_boardPKcjj, .Lfunc_end5-_Z11print_boardPKcjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z10save_boardPKcjj             # -- Begin function _Z10save_boardPKcjj
	.type	_Z10save_boardPKcjj,@function
_Z10save_boardPKcjj:                    # @_Z10save_boardPKcjj
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %r13d
	movl	%esi, (%rsp)                    # 4-byte Spill
	movq	%rdi, %r14
	movl	$.L.str.22, %edi
	movl	$.L.str.23, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB6_10
# %bb.1:                                # %.preheader15
	testl	%r13d, %r13d
	je	.LBB6_9
# %bb.2:                                # %.preheader.lr.ph
	movq	%rax, %r15
	movl	(%rsp), %ebp                    # 4-byte Reload
	xorl	%ebx, %ebx
	xorl	%r12d, %r12d
	movl	%r13d, 4(%rsp)                  # 4-byte Spill
.LBB6_3:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB6_5 Depth 2
	cmpl	$0, (%rsp)                      # 4-byte Folded Reload
	je	.LBB6_8
# %bb.4:                                # %.lr.ph
                                        #   in Loop: Header=BB6_3 Depth=1
	xorl	%r13d, %r13d
.LBB6_5:                                #   Parent Loop BB6_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rbx,%r13), %eax
	cmpb	$1, (%r14,%rax)
	jne	.LBB6_7
# %bb.6:                                #   in Loop: Header=BB6_5 Depth=2
	movl	$.L.str.14, %esi
	movq	%r15, %rdi
	movl	%r13d, %edx
	movl	%r12d, %ecx
	movl	$1, %r8d
	xorl	%eax, %eax
	callq	fprintf
.LBB6_7:                                #   in Loop: Header=BB6_5 Depth=2
	incq	%r13
	cmpq	%r13, %rbp
	jne	.LBB6_5
.LBB6_8:                                # %._crit_edge
                                        #   in Loop: Header=BB6_3 Depth=1
	incl	%r12d
	addq	%rbp, %rbx
	movl	4(%rsp), %r13d                  # 4-byte Reload
	cmpl	%r13d, %r12d
	jne	.LBB6_3
.LBB6_9:                                # %._crit_edge18
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB6_10:
	.cfi_def_cfa_offset 64
	movl	$.L.str.24, %edi
	movl	$.L.str.8, %edx
	movl	$275, %esi                      # imm = 0x113
	callq	_Z3diePKciS0_
.Lfunc_end6:
	.size	_Z10save_boardPKcjj, .Lfunc_end6-_Z10save_boardPKcjj
	.cfi_endproc
                                        # -- End function
	.globl	_Z3diePKciS0_                   # -- Begin function _Z3diePKciS0_
	.type	_Z3diePKciS0_,@function
_Z3diePKciS0_:                          # @_Z3diePKciS0_
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdx, %rcx
	movl	%esi, %edx
	movq	%rdi, %rbx
	movq	stderr(%rip), %rdi
	movl	$.L.str.25, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.26, %esi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	callq	fflush
	movl	$1, %edi
	callq	exit
.Lfunc_end7:
	.size	_Z3diePKciS0_, .Lfunc_end7-_Z3diePKciS0_
	.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	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15accelerate_lifePKcPcii, %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_end8:
	.size	__hip_module_ctor, .Lfunc_end8-__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	.LBB9_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
.LBB9_2:
	retq
.Lfunc_end9:
	.size	__hip_module_dtor, .Lfunc_end9-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z15accelerate_lifePKcPcii,@object # @_Z15accelerate_lifePKcPcii
	.section	.rodata,"a",@progbits
	.globl	_Z15accelerate_lifePKcPcii
	.p2align	3, 0x0
_Z15accelerate_lifePKcPcii:
	.quad	_Z30__device_stub__accelerate_lifePKcPcii
	.size	_Z15accelerate_lifePKcPcii, 8

	.type	.L.str.6,@object                # @.str.6
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.6:
	.asciz	"r"
	.size	.L.str.6, 2

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Could not open params file."
	.size	.L.str.7, 28

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/dbeurle/gpu-tutorial/master/Exercises/Exercise13/CUDA/gameoflife.hip"
	.size	.L.str.8, 131

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

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Could not read params file: nx."
	.size	.L.str.10, 32

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Could not read params file: ny"
	.size	.L.str.11, 31

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Could not read params file: iterations"
	.size	.L.str.12, 39

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Could not open input file."
	.size	.L.str.13, 27

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

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Expected 3 values per line in input file."
	.size	.L.str.15, 42

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Input x-coord out of range."
	.size	.L.str.16, 28

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Input y-coord out of range."
	.size	.L.str.17, 28

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Alive value should be 1."
	.size	.L.str.18, 25

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"final_state.dat"
	.size	.L.str.22, 16

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

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"Could not open final state file."
	.size	.L.str.24, 33

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"Error at line %d of file %s:\n"
	.size	.L.str.25, 30

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"%s\n"
	.size	.L.str.26, 4

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z15accelerate_lifePKcPcii"
	.size	.L__unnamed_1, 27

	.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	"Starting state"
	.size	.Lstr, 15

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Finishing state"
	.size	.Lstr.1, 16

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Usage:\n./gameoflife input.dat input.params bx by"
	.size	.Lstr.2, 49

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\tinput.dat\tpattern file"
	.size	.Lstr.3, 24

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"\tinput.params\tparameter file defining board size"
	.size	.Lstr.4, 49

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"\tbx by\tsizes of thread blocks - must divide the board size equally"
	.size	.Lstr.5, 67

	.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 _Z30__device_stub__accelerate_lifePKcPcii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z15accelerate_lifePKcPcii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z15accelerate_lifePKcPcii ; -- Begin function _Z15accelerate_lifePKcPcii
	.globl	_Z15accelerate_lifePKcPcii
	.p2align	8
	.type	_Z15accelerate_lifePKcPcii,@function
_Z15accelerate_lifePKcPcii:             ; @_Z15accelerate_lifePKcPcii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b32 s9, s[0:1], 0x10
	v_bfe_u32 v1, v0, 10, 10
	s_load_b128 s[4:7], s[0:1], 0x0
	v_and_b32_e32 v0, 0x3ff, v0
	s_load_b64 s[0:1], s[0:1], 0x18
	s_mov_b32 s11, exec_lo
	v_add_nc_u32_e32 v5, 1, v1
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s8, s2, 0xffff
	v_mad_u64_u32 v[2:3], null, s15, s3, v[1:2]
	v_mad_u64_u32 v[3:4], null, s14, s8, v[0:1]
	s_add_i32 s2, s8, 2
	s_cmp_eq_u32 s15, 0
	v_mul_u32_u24_e32 v5, s2, v5
	s_cselect_b32 s10, s1, s15
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v2, v2, s9
	s_mul_i32 s10, s10, s3
	v_add3_u32 v5, v5, v0, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_nc_u32_e32 v4, v2, v3
	global_load_u8 v6, v4, s[4:5]
	s_waitcnt vmcnt(0)
	ds_store_b8 v5, v6 offset:1
	v_cmpx_eq_u32_e32 0, v1
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_add_i32 s12, s10, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[6:7], null, s12, s9, v[3:4]
	v_add_nc_u32_e32 v7, 0, v0
	global_load_u8 v6, v6, s[4:5]
	s_waitcnt vmcnt(0)
	ds_store_b8 v7, v6 offset:1
.LBB0_2:
	s_or_b32 exec_lo, exec_lo, s11
	v_cvt_f32_u32_e32 v6, s1
	s_sub_i32 s12, 0, s1
	s_add_i32 s15, s15, 1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v6, v6
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v6, 0x4f7ffffe, v6
	v_cvt_u32_f32_e32 v6, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_readfirstlane_b32 s11, v6
	s_mul_i32 s12, s12, s11
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s12, s11, s12
	s_add_i32 s11, s11, s12
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s11, s15, s11
	s_mul_i32 s11, s11, s1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_sub_i32 s11, s15, s11
	s_sub_i32 s12, s11, s1
	s_cmp_ge_u32 s11, s1
	s_cselect_b32 s11, s12, s11
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	s_sub_i32 s12, s11, s1
	s_cmp_ge_u32 s11, s1
	s_cselect_b32 s1, s12, s11
	s_add_i32 s11, s3, -1
	v_cmp_eq_u32_e32 vcc_lo, s11, v1
	s_mul_i32 s11, s3, s9
	s_and_saveexec_b32 s12, vcc_lo
	s_cbranch_execz .LBB0_4
; %bb.3:
	v_mad_u64_u32 v[6:7], null, s11, s1, v[3:4]
	global_load_u8 v3, v6, s[4:5]
	v_add_nc_u32_e32 v6, 1, v5
	s_delay_alu instid0(VALU_DEP_1)
	v_add_nc_u32_e32 v6, s8, v6
	s_waitcnt vmcnt(0)
	ds_store_b8 v6, v3 offset:2
.LBB0_4:
	s_or_b32 exec_lo, exec_lo, s12
	v_cvt_f32_u32_e32 v3, s0
	s_sub_i32 s13, 0, s0
	s_add_i32 s15, s14, 1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_iflag_f32_e32 v3, v3
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v3, 0x4f7ffffe, v3
	v_cvt_u32_f32_e32 v3, v3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_readfirstlane_b32 s12, v3
	s_mul_i32 s13, s13, s12
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s13, s12, s13
	s_add_i32 s12, s12, s13
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s12, s15, s12
	s_mul_i32 s12, s12, s0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	s_sub_i32 s12, s15, s12
	s_mov_b32 s15, exec_lo
	s_sub_i32 s13, s12, s0
	s_cmp_ge_u32 s12, s0
	s_cselect_b32 s12, s13, s12
	s_sub_i32 s13, s12, s0
	s_cmp_ge_u32 s12, s0
	s_cselect_b32 s12, s13, s12
	s_add_i32 s13, s8, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_cmpx_eq_u32_e64 s13, v0
	s_cbranch_execz .LBB0_6
; %bb.5:
	v_mad_u64_u32 v[6:7], null, s12, s8, v[2:3]
	global_load_u8 v3, v6, s[4:5]
	s_waitcnt vmcnt(0)
	ds_store_b8 v5, v3 offset:2
.LBB0_6:
	s_or_b32 exec_lo, exec_lo, s15
	s_cmp_eq_u32 s14, 0
	s_cselect_b32 s0, s0, s14
	s_mov_b32 s14, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_8
; %bb.7:
	s_mul_i32 s15, s0, s8
	s_delay_alu instid0(SALU_CYCLE_1)
	v_add3_u32 v2, s15, -1, v2
	global_load_u8 v2, v2, s[4:5]
	s_waitcnt vmcnt(0)
	ds_store_b8 v5, v2
.LBB0_8:
	s_or_b32 exec_lo, exec_lo, s14
	s_add_i32 s0, s0, -1
	s_add_i32 s10, s10, -1
	s_mul_i32 s0, s0, s8
	s_mul_i32 s9, s10, s9
	s_add_i32 s0, s13, s0
	s_mul_i32 s12, s12, s8
	s_add_i32 s10, s0, s9
	s_mul_i32 s1, s11, s1
	s_add_i32 s9, s9, s12
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_dual_mov_b32 v2, s10 :: v_dual_mov_b32 v3, s9
	s_add_i32 s0, s0, s1
	s_add_i32 s1, s1, s12
	v_dual_mov_b32 v6, s0 :: v_dual_mov_b32 v7, s1
	s_clause 0x3
	global_load_u8 v2, v2, s[4:5]
	global_load_u8 v3, v3, s[4:5]
	global_load_u8 v6, v6, s[4:5]
	global_load_u8 v7, v7, s[4:5]
	s_add_i32 s1, s3, 1
	s_add_i32 s0, s8, 0
	s_mul_i32 s1, s1, s2
	v_dual_mov_b32 v8, 0 :: v_dual_add_nc_u32 v9, 2, v1
	s_add_i32 s3, s1, s2
	s_add_i32 s1, s1, 0
	s_delay_alu instid0(SALU_CYCLE_1)
	v_dual_mov_b32 v10, s0 :: v_dual_mov_b32 v11, s1
	s_add_i32 s0, s3, 0
	v_mul_u32_u24_e32 v1, s2, v1
	s_add_i32 s0, s0, -1
	v_mul_u32_u24_e32 v9, s2, v9
	v_mov_b32_e32 v12, s0
	s_mov_b32 s0, exec_lo
	v_add3_u32 v1, v1, v0, 0
	s_waitcnt vmcnt(3)
	ds_store_b8 v8, v2
	s_waitcnt vmcnt(2)
	ds_store_b8 v10, v3 offset:1
	s_waitcnt vmcnt(1)
	ds_store_b8 v11, v6
	s_waitcnt vmcnt(0)
	ds_store_b8 v12, v7
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	ds_load_u8 v2, v5
	v_add3_u32 v0, v9, v0, 0
	ds_load_u8 v3, v1
	ds_load_u8 v6, v0
	ds_load_u8 v7, v0 offset:2
	ds_load_u8 v8, v5 offset:2
	ds_load_u8 v0, v0 offset:1
	ds_load_u8 v5, v5 offset:1
	ds_load_u8 v9, v1 offset:2
	ds_load_u8 v1, v1 offset:1
	s_waitcnt lgkmcnt(8)
	v_cmp_eq_u16_e32 vcc_lo, 1, v2
	v_cndmask_b32_e64 v2, 0, 1, vcc_lo
	v_cndmask_b32_e64 v10, 1, 2, vcc_lo
	s_waitcnt lgkmcnt(7)
	v_cmp_eq_u16_e32 vcc_lo, 1, v3
	v_cndmask_b32_e64 v3, 0, 1, vcc_lo
	s_waitcnt lgkmcnt(6)
	v_cmp_eq_u16_e32 vcc_lo, 1, v6
	v_cndmask_b32_e32 v2, v2, v10, vcc_lo
	s_waitcnt lgkmcnt(5)
	v_cmp_eq_u16_e32 vcc_lo, 1, v7
	v_cndmask_b32_e64 v6, 0, 1, vcc_lo
	s_waitcnt lgkmcnt(4)
	v_cmp_eq_u16_e32 vcc_lo, 1, v8
	v_add_co_ci_u32_e32 v2, vcc_lo, v2, v3, vcc_lo
	s_waitcnt lgkmcnt(3)
	v_cmp_eq_u16_e32 vcc_lo, 1, v0
	v_cndmask_b32_e64 v0, 0, 1, vcc_lo
	s_waitcnt lgkmcnt(1)
	v_cmp_eq_u16_e32 vcc_lo, 1, v9
	v_add_co_ci_u32_e32 v2, vcc_lo, v2, v6, vcc_lo
	s_waitcnt lgkmcnt(0)
	v_cmp_eq_u16_e32 vcc_lo, 1, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v0, vcc_lo, v2, v0, vcc_lo
	v_cmpx_ne_u16_e32 1, v5
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_14
; %bb.9:
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_ne_u32_e32 vcc_lo, 3, v0
	v_add_co_u32 v0, s1, s6, v4
	v_add_co_ci_u32_e64 v1, null, s7, 0, s1
	s_and_saveexec_b32 s1, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s1, exec_lo, s1
	s_cbranch_execz .LBB0_11
; %bb.10:
	v_mov_b32_e32 v2, 0
	global_store_b8 v[0:1], v2, off
                                        ; implicit-def: $vgpr0_vgpr1
.LBB0_11:                               ; %Flow
	s_and_not1_saveexec_b32 s1, s1
	s_cbranch_execz .LBB0_13
; %bb.12:
	v_mov_b32_e32 v2, 1
	global_store_b8 v[0:1], v2, off
.LBB0_13:                               ; %Flow127
	s_or_b32 exec_lo, exec_lo, s1
                                        ; implicit-def: $vgpr0
                                        ; implicit-def: $vgpr4
.LBB0_14:                               ; %Flow130
	s_and_not1_saveexec_b32 s0, s0
	s_cbranch_execz .LBB0_19
; %bb.15:
	v_and_b32_e32 v0, 30, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cmp_ne_u32_e32 vcc_lo, 2, v0
	v_add_co_u32 v0, s0, s6, v4
	v_add_co_ci_u32_e64 v1, null, s7, 0, s0
	s_and_saveexec_b32 s0, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_17
; %bb.16:
	v_mov_b32_e32 v2, 0
	global_store_b8 v[0:1], v2, off
                                        ; implicit-def: $vgpr0_vgpr1
.LBB0_17:                               ; %Flow128
	s_and_not1_saveexec_b32 s0, s0
	s_cbranch_execz .LBB0_19
; %bb.18:
	v_mov_b32_e32 v2, 1
	global_store_b8 v[0:1], v2, off
.LBB0_19:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15accelerate_lifePKcPcii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 13
		.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	_Z15accelerate_lifePKcPcii, .Lfunc_end0-_Z15accelerate_lifePKcPcii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1228
; NumSgprs: 18
; NumVgprs: 13
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 13
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
