#include <chrono>
#include <iostream>

#include <cuda.h>
using namespace std;


void gen_matrix(int *matrix, int rows, int cols) {
    for (int i = 0; i < rows * cols; ++i) {
        matrix[i] = rand() % 10;
    }
}

void print_matrix(double *matrix, int rows, int cols) {
    for (int i = 0; i < rows * cols; ++i) {
        cout << matrix[i] << " ";
        if ((i + 1) % cols == 0) {
            cout << endl;
        }
    }
}

#define BLOCK_SIZE 16
#define FILTER_SIZE 3
#define IDX(row, col, len) ((row)*(len)+(col))

__global__ void laplap(double *from, double *to, double *filter, double divisor, int X, int Y) {
    int row = blockIdx.y * blockDim.y + threadIdx.y;
    int col = blockIdx.x * blockDim.x + threadIdx.x;

    double sum = 0;

    if (col > 0 && row > 0 && col < X - 1 && row < Y - 1) {
        for (int i = -1; i < 2; ++i) {
            for (int j = -1; j < 2; ++j) {
                // assume that middle element in filter equals to 0
                sum += from[(row + i) * X + (col + j)] * filter[(i + 1) * FILTER_SIZE + j + 1];
            }
        }
        to[row * X + col] = sum / divisor;
    }
}


int main(int argc, char* argv[]) {
    int X = 128, Y = 128;

    double *from = new double[X * Y];

    for (int i = 0; i != X; ++i) {
        for (int j = 0; j != Y; ++j) {
            from[i * Y + j] = 0;
        }

    }

    for (int i = 0; i != X; ++i) {
        from[i * Y] = 1;
    }
    double *to = new double[X * Y];

    // 0 1 0
    // 1 0 1
    // 0 1 0
    double *filter = new double[FILTER_SIZE * FILTER_SIZE];
    for (int i = 0; i != FILTER_SIZE * FILTER_SIZE; ++i) {
        if (i % 2) {
            filter[i] = 1;
        } else {
            filter[i] = 0;
        }
    }



    print_matrix(filter, FILTER_SIZE, FILTER_SIZE);


    double *new_from, *new_to, *new_filter;
    cudaMalloc((void**) &new_from, sizeof(double) * X * Y);
    cudaMalloc((void**) &new_to, sizeof(double) * X * Y);
    cudaMalloc((void**) &new_filter, sizeof(double) * FILTER_SIZE * FILTER_SIZE);

    // copy matrix A and B from host to device memory
    cudaMemcpy(new_from, from, sizeof(double) * X * Y, cudaMemcpyHostToDevice);
    cudaMemcpy(new_filter, filter, sizeof(double) * FILTER_SIZE * FILTER_SIZE, cudaMemcpyHostToDevice);

    dim3 grid((X + BLOCK_SIZE - 1) / BLOCK_SIZE, (Y + BLOCK_SIZE - 1) / BLOCK_SIZE);
    dim3 block(BLOCK_SIZE, BLOCK_SIZE);

    int MAX_ITER = 8000;
    for (int it = 0; it != MAX_ITER; ++it) {
        laplap<<<grid, block>>>(new_from, new_to, new_filter, 4, X, Y);
        laplap<<<grid, block>>>(new_to, new_from, new_filter, 4, X, Y);
    }

    cudaMemcpy(to, new_from, sizeof(double) * X * Y, cudaMemcpyDeviceToHost);
    cudaThreadSynchronize();

    FILE *f_name;
    f_name = fopen("res.txt", "w");

    for (int i = 0; i < X; ++i)
    {
        for (int j = 0; j < Y; ++j)
        {
            fprintf(f_name, "%f\t", to[i * X + j]);
        }
         fprintf(f_name, "\n");
    }


    cudaFree(new_from);
    cudaFree(new_to);
    cudaFree(new_filter);


    delete from;
    delete to;
    delete filter;
}

	.file	"tmpxft_00309b35_00000000-6_laplas.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3739:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3739:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z10gen_matrixPiii
	.type	_Z10gen_matrixPiii, @function
_Z10gen_matrixPiii:
.LFB3734:
	.cfi_startproc
	endbr64
	imull	%edx, %esi
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$10, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%esi, %ebp
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
.L3:
	cmpl	%ebx, %ebp
	jle	.L7
	call	rand@PLT
	cltd
	idivl	%r13d
	movl	%edx, (%r12,%rbx,4)
	incq	%rbx
	jmp	.L3
.L7:
	popq	%rax
	.cfi_def_cfa_offset 40
	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
	ret
	.cfi_endproc
.LFE3734:
	.size	_Z10gen_matrixPiii, .-_Z10gen_matrixPiii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	" "
	.text
	.globl	_Z12print_matrixPdii
	.type	_Z12print_matrixPdii, @function
_Z12print_matrixPdii:
.LFB3735:
	.cfi_startproc
	endbr64
	imull	%edx, %esi
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	_ZSt4cout(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%esi, %r12d
	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
	xorl	%ebx, %ebx
.L9:
	cmpl	%ebx, %r12d
	jle	.L13
	movsd	0(%r13,%rbx,8), %xmm0
	movq	%r14, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movl	$1, %edx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	call	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT
	leal	1(%rbx), %eax
	cltd
	idivl	%ebp
	testl	%edx, %edx
	jne	.L10
	movq	%r14, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
.L10:
	incq	%rbx
	jmp	.L9
.L13:
	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
.LFE3735:
	.size	_Z12print_matrixPdii, .-_Z12print_matrixPdii
	.globl	_Z32__device_stub__Z6laplapPdS_S_diiPdS_S_dii
	.type	_Z32__device_stub__Z6laplapPdS_S_diiPdS_S_dii, @function
_Z32__device_stub__Z6laplapPdS_S_diiPdS_S_dii:
.LFB3761:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 12(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 8(%rsp)
	movsd	%xmm0, 16(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L14
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z6laplapPdS_S_dii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L14:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3761:
	.size	_Z32__device_stub__Z6laplapPdS_S_diiPdS_S_dii, .-_Z32__device_stub__Z6laplapPdS_S_diiPdS_S_dii
	.globl	_Z6laplapPdS_S_dii
	.type	_Z6laplapPdS_S_dii, @function
_Z6laplapPdS_S_dii:
.LFB3762:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z6laplapPdS_S_diiPdS_S_dii
	.cfi_endproc
.LFE3762:
	.size	_Z6laplapPdS_S_dii, .-_Z6laplapPdS_S_dii
	.section	.rodata.str1.1
.LC4:
	.string	"w"
.LC5:
	.string	"res.txt"
.LC6:
	.string	"%f\t"
.LC7:
	.string	"\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3736:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$131072, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	call	_Znam@PLT
	movl	$32768, %ecx
	movq	%rax, %rbx
	xorl	%eax, %eax
	movq	%rbx, %rdi
	leaq	131072(%rbx), %rdx
	rep stosl
	movq	%rbx, %rax
.L20:
	movq	.LC1(%rip), %rcx
	addq	$1024, %rax
	movq	%rcx, -1024(%rax)
	cmpq	%rax, %rdx
	jne	.L20
	movl	$131072, %edi
	call	_Znam@PLT
	movl	$72, %edi
	movq	%rax, %r13
	call	_Znam@PLT
	movq	%rax, %rbp
	xorl	%eax, %eax
.L22:
	movsd	.LC1(%rip), %xmm0
	testb	$1, %al
	jne	.L21
	xorps	%xmm0, %xmm0
.L21:
	movsd	%xmm0, 0(%rbp,%rax,8)
	incq	%rax
	cmpq	$9, %rax
	jne	.L22
	movl	$3, %edx
	movl	$3, %esi
	movq	%rbp, %rdi
	movl	$8000, %r12d
	call	_Z12print_matrixPdii
	leaq	24(%rsp), %rdi
	movl	$131072, %esi
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movl	$131072, %esi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movl	$72, %esi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$131072, %edx
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$72, %edx
	call	cudaMemcpy@PLT
	movl	$1, 56(%rsp)
	movabsq	$34359738376, %rax
	movq	%rax, 48(%rsp)
	movabsq	$68719476752, %rax
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
.L25:
	movl	68(%rsp), %ecx
	movq	60(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movl	$128, %ecx
	movl	$128, %r8d
	movsd	.LC3(%rip), %xmm0
	movq	24(%rsp), %rdi
	call	_Z32__device_stub__Z6laplapPdS_S_diiPdS_S_dii
.L23:
	movl	68(%rsp), %ecx
	movq	60(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L24
	movq	40(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	$128, %ecx
	movl	$128, %r8d
	movsd	.LC3(%rip), %xmm0
	movq	32(%rsp), %rdi
	call	_Z32__device_stub__Z6laplapPdS_S_diiPdS_S_dii
.L24:
	decl	%r12d
	jne	.L25
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%r13, %rdi
	movq	%r13, %r15
	movl	$131072, %edx
	call	cudaMemcpy@PLT
	call	cudaThreadSynchronize@PLT
	leaq	.LC4(%rip), %rsi
	leaq	.LC5(%rip), %rdi
	call	fopen@PLT
	movq	%rax, 8(%rsp)
.L26:
	xorl	%r14d, %r14d
.L27:
	movsd	(%r15,%r14,8), %xmm0
	movq	8(%rsp), %rdi
	movb	$1, %al
	incq	%r14
	leaq	.LC6(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	cmpq	$128, %r14
	jne	.L27
	movq	8(%rsp), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	subl	$-128, %r12d
	leaq	.LC7(%rip), %rdx
	addq	$1024, %r15
	call	__fprintf_chk@PLT
	cmpl	$16384, %r12d
	jne	.L26
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movl	$8, %esi
	movq	%rbx, %rdi
	call	_ZdlPvm@PLT
	movl	$8, %esi
	movq	%r13, %rdi
	call	_ZdlPvm@PLT
	movl	$8, %esi
	movq	%rbp, %rdi
	call	_ZdlPvm@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3736:
	.size	main, .-main
	.section	.rodata.str1.1
.LC8:
	.string	"_Z6laplapPdS_S_dii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3764:
	.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	.LC8(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z6laplapPdS_S_dii(%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
.LFE3764:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1072693248
	.align 8
.LC3:
	.long	0
	.long	1074790400
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <chrono>
#include <iostream>

#include <hip/hip_runtime.h>
using namespace std;


void gen_matrix(int *matrix, int rows, int cols) {
    for (int i = 0; i < rows * cols; ++i) {
        matrix[i] = rand() % 10;
    }
}

void print_matrix(double *matrix, int rows, int cols) {
    for (int i = 0; i < rows * cols; ++i) {
        cout << matrix[i] << " ";
        if ((i + 1) % cols == 0) {
            cout << endl;
        }
    }
}

#define BLOCK_SIZE 16
#define FILTER_SIZE 3
#define IDX(row, col, len) ((row)*(len)+(col))

__global__ void laplap(double *from, double *to, double *filter, double divisor, int X, int Y) {
    int row = blockIdx.y * blockDim.y + threadIdx.y;
    int col = blockIdx.x * blockDim.x + threadIdx.x;

    double sum = 0;

    if (col > 0 && row > 0 && col < X - 1 && row < Y - 1) {
        for (int i = -1; i < 2; ++i) {
            for (int j = -1; j < 2; ++j) {
                // assume that middle element in filter equals to 0
                sum += from[(row + i) * X + (col + j)] * filter[(i + 1) * FILTER_SIZE + j + 1];
            }
        }
        to[row * X + col] = sum / divisor;
    }
}


int main(int argc, char* argv[]) {
    int X = 128, Y = 128;

    double *from = new double[X * Y];

    for (int i = 0; i != X; ++i) {
        for (int j = 0; j != Y; ++j) {
            from[i * Y + j] = 0;
        }

    }

    for (int i = 0; i != X; ++i) {
        from[i * Y] = 1;
    }
    double *to = new double[X * Y];

    // 0 1 0
    // 1 0 1
    // 0 1 0
    double *filter = new double[FILTER_SIZE * FILTER_SIZE];
    for (int i = 0; i != FILTER_SIZE * FILTER_SIZE; ++i) {
        if (i % 2) {
            filter[i] = 1;
        } else {
            filter[i] = 0;
        }
    }



    print_matrix(filter, FILTER_SIZE, FILTER_SIZE);


    double *new_from, *new_to, *new_filter;
    hipMalloc((void**) &new_from, sizeof(double) * X * Y);
    hipMalloc((void**) &new_to, sizeof(double) * X * Y);
    hipMalloc((void**) &new_filter, sizeof(double) * FILTER_SIZE * FILTER_SIZE);

    // copy matrix A and B from host to device memory
    hipMemcpy(new_from, from, sizeof(double) * X * Y, hipMemcpyHostToDevice);
    hipMemcpy(new_filter, filter, sizeof(double) * FILTER_SIZE * FILTER_SIZE, hipMemcpyHostToDevice);

    dim3 grid((X + BLOCK_SIZE - 1) / BLOCK_SIZE, (Y + BLOCK_SIZE - 1) / BLOCK_SIZE);
    dim3 block(BLOCK_SIZE, BLOCK_SIZE);

    int MAX_ITER = 8000;
    for (int it = 0; it != MAX_ITER; ++it) {
        laplap<<<grid, block>>>(new_from, new_to, new_filter, 4, X, Y);
        laplap<<<grid, block>>>(new_to, new_from, new_filter, 4, X, Y);
    }

    hipMemcpy(to, new_from, sizeof(double) * X * Y, hipMemcpyDeviceToHost);
    hipDeviceSynchronize();

    FILE *f_name;
    f_name = fopen("res.txt", "w");

    for (int i = 0; i < X; ++i)
    {
        for (int j = 0; j < Y; ++j)
        {
            fprintf(f_name, "%f\t", to[i * X + j]);
        }
         fprintf(f_name, "\n");
    }


    hipFree(new_from);
    hipFree(new_to);
    hipFree(new_filter);


    delete from;
    delete to;
    delete filter;
}

	.text
	.file	"laplas.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z10gen_matrixPiii              # -- Begin function _Z10gen_matrixPiii
	.type	_Z10gen_matrixPiii,@function
_Z10gen_matrixPiii:                     # @_Z10gen_matrixPiii
	.cfi_startproc
# %bb.0:
	imull	%edx, %esi
	testl	%esi, %esi
	jle	.LBB0_4
# %bb.1:                                # %.lr.ph.preheader
	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
	movq	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	callq	rand
	cltq
	imulq	$1717986919, %rax, %rcx         # imm = 0x66666667
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$34, %rcx
	addl	%edx, %ecx
	addl	%ecx, %ecx
	leal	(%rcx,%rcx,4), %ecx
	subl	%ecx, %eax
	movl	%eax, (%rbx,%r15,4)
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB0_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB0_4:                                # %._crit_edge
	retq
.Lfunc_end0:
	.size	_Z10gen_matrixPiii, .Lfunc_end0-_Z10gen_matrixPiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z12print_matrixPdii            # -- Begin function _Z12print_matrixPdii
	.type	_Z12print_matrixPdii,@function
_Z12print_matrixPdii:                   # @_Z12print_matrixPdii
	.cfi_startproc
# %bb.0:
	imull	%edx, %esi
	testl	%esi, %esi
	jle	.LBB1_6
# %bb.1:                                # %.lr.ph.preheader
	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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%edx, %ebx
	movq	%rdi, %r14
	movl	%esi, %r12d
	xorl	%r15d, %r15d
	movl	$_ZSt4cout, %r13d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movsd	(%r14,%r15,8), %xmm0            # xmm0 = mem[0],zero
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	incq	%r15
	movl	%r15d, %eax
	cltd
	idivl	%ebx
	testl	%edx, %edx
	jne	.LBB1_4
# %bb.3:                                #   in Loop: Header=BB1_2 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB1_4:                                #   in Loop: Header=BB1_2 Depth=1
	cmpq	%r15, %r12
	jne	.LBB1_2
# %bb.5:
	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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r13
	.cfi_restore %r14
	.cfi_restore %r15
.LBB1_6:                                # %._crit_edge
	retq
.Lfunc_end1:
	.size	_Z12print_matrixPdii, .Lfunc_end1-_Z12print_matrixPdii
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__laplapPdS_S_dii # -- Begin function _Z21__device_stub__laplapPdS_S_dii
	.type	_Z21__device_stub__laplapPdS_S_dii,@function
_Z21__device_stub__laplapPdS_S_dii:     # @_Z21__device_stub__laplapPdS_S_dii
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movsd	%xmm0, (%rdx)
	leaq	12(%rsp), %r9
	movl	%ecx, (%r9)
	leaq	8(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%r9, 32(%rbx)
	movq	%rcx, 40(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z6laplapPdS_S_dii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z21__device_stub__laplapPdS_S_dii, .Lfunc_end2-_Z21__device_stub__laplapPdS_S_dii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x3ff0000000000000              # double 1
.LCPI3_1:
	.quad	0x4010000000000000              # double 4
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:                                # %.preheader96.preheader
	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
	movl	$131072, %edi                   # imm = 0x20000
	callq	_Znam
	movq	%rax, %rbx
	xorl	%r14d, %r14d
	movl	$131072, %edx                   # imm = 0x20000
	movq	%rax, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movabsq	$4607182418800017408, %rax      # imm = 0x3FF0000000000000
.LBB3_1:                                # %.preheader96
                                        # =>This Inner Loop Header: Depth=1
	movq	%rax, (%rbx,%r14)
	addq	$1024, %r14                     # imm = 0x400
	cmpq	$131072, %r14                   # imm = 0x20000
	jne	.LBB3_1
# %bb.2:
	movl	$131072, %edi                   # imm = 0x20000
	callq	_Znam
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movl	$72, %edi
	callq	_Znam
	movq	%rax, %r15
	xorl	%eax, %eax
	movsd	.LCPI3_0(%rip), %xmm0           # xmm0 = mem[0],zero
.LBB3_3:                                # =>This Inner Loop Header: Depth=1
	xorps	%xmm1, %xmm1
	testb	$1, %al
	je	.LBB3_5
# %bb.4:                                #   in Loop: Header=BB3_3 Depth=1
	movaps	%xmm0, %xmm1
.LBB3_5:                                #   in Loop: Header=BB3_3 Depth=1
	movsd	%xmm1, (%r15,%rax,8)
	incq	%rax
	cmpq	$9, %rax
	jne	.LBB3_3
# %bb.6:
	movabsq	$68719476752, %r12              # imm = 0x1000000010
	movabsq	$34359738376, %r13              # imm = 0x800000008
	movq	%r15, %rdi
	movl	$3, %esi
	movl	$3, %edx
	callq	_Z12print_matrixPdii
	leaq	8(%rsp), %rbp
	movl	$131072, %esi                   # imm = 0x20000
	movq	%rbp, %rdi
	callq	hipMalloc
	leaq	24(%rsp), %rdi
	movl	$131072, %esi                   # imm = 0x20000
	callq	hipMalloc
	leaq	16(%rsp), %r14
	movl	$72, %esi
	movq	%r14, %rdi
	callq	hipMalloc
	movq	(%rbp), %rdi
	movl	$131072, %edx                   # imm = 0x20000
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r14), %rdi
	movl	$72, %edx
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$8000, %ebp                     # imm = 0x1F40
.LBB3_7:                                # =>This Inner Loop Header: Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_9
# %bb.8:                                #   in Loop: Header=BB3_7 Depth=1
	movq	8(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdx
	movsd	.LCPI3_1(%rip), %xmm0           # xmm0 = mem[0],zero
	movl	$128, %ecx
	movl	$128, %r8d
	callq	_Z21__device_stub__laplapPdS_S_dii
.LBB3_9:                                #   in Loop: Header=BB3_7 Depth=1
	movq	%r13, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_11
# %bb.10:                               #   in Loop: Header=BB3_7 Depth=1
	movq	24(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdx
	movsd	.LCPI3_1(%rip), %xmm0           # xmm0 = mem[0],zero
	movl	$128, %ecx
	movl	$128, %r8d
	callq	_Z21__device_stub__laplapPdS_S_dii
.LBB3_11:                               #   in Loop: Header=BB3_7 Depth=1
	decl	%ebp
	jne	.LBB3_7
# %bb.12:
	movq	8(%rsp), %rsi
	movl	$131072, %edx                   # imm = 0x20000
	movq	32(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	movl	$.L.str.1, %edi
	movl	$.L.str.2, %esi
	callq	fopen
	movq	%rax, %r12
	xorl	%r14d, %r14d
.LBB3_13:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_14 Depth 2
	xorl	%ebp, %ebp
.LBB3_14:                               #   Parent Loop BB3_13 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%r13,%rbp,8), %xmm0            # xmm0 = mem[0],zero
	movl	$.L.str.3, %esi
	movq	%r12, %rdi
	movb	$1, %al
	callq	fprintf
	incq	%rbp
	cmpq	$128, %rbp
	jne	.LBB3_14
# %bb.15:                               #   in Loop: Header=BB3_13 Depth=1
	movl	$10, %edi
	movq	%r12, %rsi
	callq	fputc@PLT
	incq	%r14
	addq	$1024, %r13                     # imm = 0x400
	cmpq	$128, %r14
	jne	.LBB3_13
# %bb.16:
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	%rbx, %rdi
	callq	_ZdlPv
	movq	32(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdlPv
	movq	%r15, %rdi
	callq	_ZdlPv
	xorl	%eax, %eax
	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_end3:
	.size	main, .Lfunc_end3-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6laplapPdS_S_dii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB5_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	" "
	.size	.L.str, 2

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"res.txt"
	.size	.L.str.1, 8

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"%f\t"
	.size	.L.str.3, 4

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6laplapPdS_S_dii"
	.size	.L__unnamed_1, 19

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

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

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z6laplapPdS_S_dii      ; -- Begin function _Z6laplapPdS_S_dii
	.globl	_Z6laplapPdS_S_dii
	.p2align	8
	.type	_Z6laplapPdS_S_dii,@function
_Z6laplapPdS_S_dii:                     ; @_Z6laplapPdS_S_dii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b64 s[8:9], s[0:1], 0x20
	v_bfe_u32 v3, v0, 10, 10
	v_and_b32_e32 v2, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	v_mad_u64_u32 v[0:1], null, s15, s3, v[3:4]
	s_mul_i32 s14, s14, s2
	s_add_i32 s2, s8, -1
	v_add_nc_u32_e32 v1, s14, v2
	s_add_i32 s3, s9, -1
	s_mov_b32 s9, -1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cmp_gt_i32_e32 vcc_lo, s2, v1
	v_min_i32_e32 v3, v0, v1
	v_cmp_gt_i32_e64 s2, s3, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_lt_i32_e64 s3, 0, v3
	s_and_b32 s2, vcc_lo, s2
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_6
; %bb.1:                                ; %.preheader38
	s_load_b256 s[0:7], s[0:1], 0x0
	v_add_nc_u32_e32 v3, -1, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_mad_u64_u32 v[4:5], null, s8, v3, v[2:3]
	v_mov_b32_e32 v2, 0
	v_mov_b32_e32 v3, 0
	v_add3_u32 v4, v4, s14, -1
.LBB0_2:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_3 Depth 2
	s_mov_b32 s12, 0
	s_waitcnt lgkmcnt(0)
	s_mov_b64 s[10:11], s[4:5]
.LBB0_3:                                ;   Parent Loop BB0_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(VALU_DEP_1)
	v_add_nc_u32_e32 v5, s12, v4
	s_load_b64 s[14:15], s[10:11], 0x0
	s_add_u32 s10, s10, 8
	s_addc_u32 s11, s11, 0
	s_add_i32 s12, s12, 1
	v_ashrrev_i32_e32 v6, 31, v5
	s_cmp_eq_u32 s12, 3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[5:6], 3, v[5:6]
	v_add_co_u32 v5, vcc_lo, s0, v5
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v6, vcc_lo, s1, v6, vcc_lo
	global_load_b64 v[5:6], v[5:6], off
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_fma_f64 v[2:3], v[5:6], s[14:15], v[2:3]
	s_cbranch_scc0 .LBB0_3
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_add_i32 s9, s9, 1
	v_add_nc_u32_e32 v4, s8, v4
	s_add_u32 s4, s4, 24
	s_addc_u32 s5, s5, 0
	s_cmp_eq_u32 s9, 2
	s_cbranch_scc0 .LBB0_2
; %bb.5:
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_scale_f64 v[4:5], null, s[6:7], s[6:7], v[2:3]
	v_rcp_f64_e32 v[6:7], v[4:5]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[8:9], -v[4:5], v[6:7], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[6:7], v[6:7], v[8:9], v[6:7]
	v_fma_f64 v[8:9], -v[4:5], v[6:7], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_fma_f64 v[6:7], v[6:7], v[8:9], v[6:7]
	v_div_scale_f64 v[8:9], vcc_lo, v[2:3], s[6:7], v[2:3]
	v_mul_f64 v[10:11], v[8:9], v[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[4:5], -v[4:5], v[10:11], v[8:9]
	v_div_fmas_f64 v[4:5], v[4:5], v[6:7], v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_div_fixup_f64 v[2:3], v[4:5], s[6:7], v[2:3]
	v_mad_u64_u32 v[4:5], null, v0, s8, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v5, 31, v4
	v_lshlrev_b64 v[0:1], 3, v[4:5]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b64 v[0:1], v[2:3], off
.LBB0_6:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6laplapPdS_S_dii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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 12
		.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	_Z6laplapPdS_S_dii, .Lfunc_end0-_Z6laplapPdS_S_dii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 468
; NumSgprs: 18
; NumVgprs: 12
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 12
; 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
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           8
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         36
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6laplapPdS_S_dii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z6laplapPdS_S_dii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     12
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
