// Código Matrix multiplication: C = A * B. Super simplificado.

#include <stdio.h>
#include <cuda_runtime.h>
#include <chrono>

#define BLOCK_SIZE 32
#ifndef VECTOR_SIZE
    #define VECTOR_SIZE 128
#endif

void MatrixMulCpuSeq(float* M, float* N, float* P, int size) {
    for (int i = 0; i < size; i++) {
        for (int j = 0; j < size; j++) {
            for (int k = 0; k < size; k++) {
                P[i*size+j] += M[i*size+k] * N[k*size+j];
            }
        }
    }
}

int main(int argc, char **argv)
{

    const int size = VECTOR_SIZE;
    // const int nIter = 100000;

    float *h_A = (float *)malloc(sizeof(float) * size * size);
    float *h_B = (float *)malloc(sizeof(float) * size * size);
    float *h_C = (float *)malloc(sizeof(float) * size * size);
    for (int i = 0; i < size * size; ++i) { h_A[i] =  1.0f; h_B[i] =  1.0f; }

    // Nao precisa alocar GPU
    // float *d_A, *d_B, *d_C;
    // cudaMalloc((void **) &d_A, sizeof(float) * size * size);
    // cudaMalloc((void **) &d_B, sizeof(float) * size * size);
    // cudaMalloc((void **) &d_C, sizeof(float) * size * size);

    // cudaMemcpy(d_A, h_A, sizeof(float) * size * size, cudaMemcpyHostToDevice);
    // cudaMemcpy(d_B, h_B, sizeof(float) * size * size, cudaMemcpyHostToDevice);

    // dim3 threads(BLOCK_SIZE, BLOCK_SIZE);
    // dim3 grid(size / threads.x, size / threads.y);

    // SEQUENCIAL
    cudaEvent_t start, stop;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    cudaEventRecord(start, NULL);
    // for (int j = 0; j < nIter; j++) {
        MatrixMulCpuSeq(h_A, h_B, h_C, size);
    // }
    cudaEventRecord(stop, NULL);
    cudaEventSynchronize(stop);
    float msecTotal = 0.0f;
    cudaEventElapsedTime(&msecTotal, start, stop);
    float msecPerMatrixMul = msecTotal;
    printf("Time= %f\n", msecPerMatrixMul);

    // Copy result from device to host
    // cudaMemcpy(h_C, d_C, sizeof(float) * size * size, cudaMemcpyDeviceToHost);

    // test relative error by the formula
    //     |<x, y>_cpu - <x,y>_gpu|/<|x|, |y|>  < eps
    double eps = 1.e-6 ; // machine zero

    for (int i = 0; i < (int)(size * size); i++)
    {
        double abs_err = fabs(h_C[i] - (size * 1.0f));
        double abs_val = fabs(h_C[i]);
        double rel_err = abs_err/abs_val/size ;
        if (rel_err > eps)
            printf("Error! Matrix[%05d]=%.8f, ref=%.8f error term is > %E\n", i, h_C[i], size*1.0f, eps);
    }

    free(h_A); free(h_B); free(h_C);
    // cudaFree(d_A); cudaFree(d_B); cudaFree(d_C);

    return(0);
}

	.file	"tmpxft_003218e5_00000000-6_seq.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2130:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2130:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z15MatrixMulCpuSeqPfS_S_i
	.type	_Z15MatrixMulCpuSeqPfS_S_i, @function
_Z15MatrixMulCpuSeqPfS_S_i:
.LFB2126:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdx, %r10
	movq	%rdi, %r8
	xorl	%edx, %edx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rsi, %rbx
	movslq	%ecx, %rsi
	movq	%rsi, %rax
	salq	$2, %rsi
.L3:
	cmpl	%eax, %ebp
	jge	.L2
	movq	%rbx, %r11
	leaq	(%r10,%rdx), %rcx
	leaq	(%r8,%rdx), %r13
	xorl	%r9d, %r9d
.L7:
	movq	%r11, %r12
	xorl	%edi, %edi
.L4:
	movss	0(%r13,%rdi,4), %xmm0
	mulss	(%r12), %xmm0
	incq	%rdi
	addq	%rsi, %r12
	addss	(%rcx), %xmm0
	movss	%xmm0, (%rcx)
	cmpl	%edi, %eax
	jg	.L4
	incl	%r9d
	addq	$4, %r11
	addq	$4, %rcx
	cmpl	%r9d, %eax
	jne	.L7
	incl	%ebp
	addq	%rsi, %rdx
	jmp	.L3
.L2:
	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
.LFE2126:
	.size	_Z15MatrixMulCpuSeqPfS_S_i, .-_Z15MatrixMulCpuSeqPfS_S_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"Time= %f\n"
.LC8:
	.string	"Error! Matrix[%05d]=%.8f, ref=%.8f error term is > %E\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2127:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$65536, %edi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movl	$65536, %edi
	movq	%rax, %r12
	call	malloc@PLT
	movl	$65536, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movss	.LC0(%rip), %xmm0
	movq	%rax, %rbx
	xorl	%eax, %eax
.L12:
	movss	%xmm0, (%r12,%rax)
	movss	%xmm0, 0(%rbp,%rax)
	addq	$4, %rax
	cmpq	$65536, %rax
	jne	.L12
	leaq	8(%rsp), %rdi
	xorl	%r13d, %r13d
	call	cudaEventCreate@PLT
	leaq	16(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	$128, %ecx
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	movq	%r12, %rdi
	call	_Z15MatrixMulCpuSeqPfS_S_i
	movq	16(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	16(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	leaq	4(%rsp), %rdi
	movl	$0x00000000, 4(%rsp)
	call	cudaEventElapsedTime@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	4(%rsp), %xmm0
	call	__printf_chk@PLT
	movss	.LC4(%rip), %xmm3
.L15:
	movss	(%rbx,%r13,4), %xmm0
	movaps	%xmm0, %xmm1
	subss	.LC3(%rip), %xmm1
	movaps	%xmm0, %xmm2
	andps	%xmm3, %xmm2
	cvtss2sd	%xmm2, %xmm2
	andps	%xmm3, %xmm1
	cvtss2sd	%xmm1, %xmm1
	divsd	%xmm2, %xmm1
	movsd	.LC6(%rip), %xmm2
	mulsd	.LC5(%rip), %xmm1
	comisd	%xmm2, %xmm1
	jbe	.L13
	movl	%r13d, %edx
	movl	$2, %edi
	leaq	.LC8(%rip), %rsi
	movb	$3, %al
	movsd	.LC7(%rip), %xmm1
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	movss	.LC4(%rip), %xmm3
.L13:
	incq	%r13
	cmpq	$16384, %r13
	jne	.L15
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	addq	$40, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
.LFE2127:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2153:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2153:
	.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
	.set	.LC0,.LC5+4
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC3:
	.long	1124073472
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC4:
	.long	2147483647
	.long	0
	.long	0
	.long	0
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC5:
	.long	0
	.long	1065353216
	.align 8
.LC6:
	.long	-1598689907
	.long	1051772663
	.align 8
.LC7:
	.long	0
	.long	1080033280
	.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:

// Código Matrix multiplication: C = A * B. Super simplificado.

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

#define BLOCK_SIZE 32
#ifndef VECTOR_SIZE
    #define VECTOR_SIZE 128
#endif

void MatrixMulCpuSeq(float* M, float* N, float* P, int size) {
    for (int i = 0; i < size; i++) {
        for (int j = 0; j < size; j++) {
            for (int k = 0; k < size; k++) {
                P[i*size+j] += M[i*size+k] * N[k*size+j];
            }
        }
    }
}

int main(int argc, char **argv)
{

    const int size = VECTOR_SIZE;
    // const int nIter = 100000;

    float *h_A = (float *)malloc(sizeof(float) * size * size);
    float *h_B = (float *)malloc(sizeof(float) * size * size);
    float *h_C = (float *)malloc(sizeof(float) * size * size);
    for (int i = 0; i < size * size; ++i) { h_A[i] =  1.0f; h_B[i] =  1.0f; }

    // Nao precisa alocar GPU
    // float *d_A, *d_B, *d_C;
    // cudaMalloc((void **) &d_A, sizeof(float) * size * size);
    // cudaMalloc((void **) &d_B, sizeof(float) * size * size);
    // cudaMalloc((void **) &d_C, sizeof(float) * size * size);

    // cudaMemcpy(d_A, h_A, sizeof(float) * size * size, cudaMemcpyHostToDevice);
    // cudaMemcpy(d_B, h_B, sizeof(float) * size * size, cudaMemcpyHostToDevice);

    // dim3 threads(BLOCK_SIZE, BLOCK_SIZE);
    // dim3 grid(size / threads.x, size / threads.y);

    // SEQUENCIAL
    hipEvent_t start, stop;
    hipEventCreate(&start);
    hipEventCreate(&stop);
    hipEventRecord(start, NULL);
    // for (int j = 0; j < nIter; j++) {
        MatrixMulCpuSeq(h_A, h_B, h_C, size);
    // }
    hipEventRecord(stop, NULL);
    hipEventSynchronize(stop);
    float msecTotal = 0.0f;
    hipEventElapsedTime(&msecTotal, start, stop);
    float msecPerMatrixMul = msecTotal;
    printf("Time= %f\n", msecPerMatrixMul);

    // Copy result from device to host
    // cudaMemcpy(h_C, d_C, sizeof(float) * size * size, cudaMemcpyDeviceToHost);

    // test relative error by the formula
    //     |<x, y>_cpu - <x,y>_gpu|/<|x|, |y|>  < eps
    double eps = 1.e-6 ; // machine zero

    for (int i = 0; i < (int)(size * size); i++)
    {
        double abs_err = fabs(h_C[i] - (size * 1.0f));
        double abs_val = fabs(h_C[i]);
        double rel_err = abs_err/abs_val/size ;
        if (rel_err > eps)
            printf("Error! Matrix[%05d]=%.8f, ref=%.8f error term is > %E\n", i, h_C[i], size*1.0f, eps);
    }

    free(h_A); free(h_B); free(h_C);
    // cudaFree(d_A); cudaFree(d_B); cudaFree(d_C);

    return(0);
}

	.text
	.file	"seq.hip"
	.globl	_Z15MatrixMulCpuSeqPfS_S_i      # -- Begin function _Z15MatrixMulCpuSeqPfS_S_i
	.type	_Z15MatrixMulCpuSeqPfS_S_i,@function
_Z15MatrixMulCpuSeqPfS_S_i:             # @_Z15MatrixMulCpuSeqPfS_S_i
	.cfi_startproc
# %bb.0:
	testl	%ecx, %ecx
	jle	.LBB0_8
# %bb.1:                                # %.preheader23.lr.ph
	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	%ecx, %eax
	leaq	(,%rax,4), %r8
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
.LBB0_2:                                # %.preheader.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_3 Depth 2
                                        #       Child Loop BB0_4 Depth 3
	movl	%r9d, %r11d
	leaq	(%rdi,%r11,4), %r11
	movq	%r10, %rbx
	imulq	%rax, %rbx
	leaq	(%rdx,%rbx,4), %rbx
	movq	%rsi, %r14
	xorl	%r15d, %r15d
.LBB0_3:                                # %.preheader
                                        #   Parent Loop BB0_2 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB0_4 Depth 3
	movss	(%rbx,%r15,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	%r14, %r12
	xorl	%r13d, %r13d
.LBB0_4:                                #   Parent Loop BB0_2 Depth=1
                                        #     Parent Loop BB0_3 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%r11,%r13,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	mulss	(%r12), %xmm1
	addss	%xmm1, %xmm0
	movss	%xmm0, (%rbx,%r15,4)
	incq	%r13
	addq	%r8, %r12
	cmpq	%r13, %rax
	jne	.LBB0_4
# %bb.5:                                # %._crit_edge
                                        #   in Loop: Header=BB0_3 Depth=2
	incq	%r15
	addq	$4, %r14
	cmpq	%rax, %r15
	jne	.LBB0_3
# %bb.6:                                # %._crit_edge26
                                        #   in Loop: Header=BB0_2 Depth=1
	incq	%r10
	addl	%ecx, %r9d
	cmpq	%rax, %r10
	jne	.LBB0_2
# %bb.7:
	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
.LBB0_8:                                # %._crit_edge28
	retq
.Lfunc_end0:
	.size	_Z15MatrixMulCpuSeqPfS_S_i, .Lfunc_end0-_Z15MatrixMulCpuSeqPfS_S_i
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI1_0:
	.long	0xc3000000                      # float -128
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0
.LCPI1_1:
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
	.long	0x7fffffff                      # float NaN
.LCPI1_2:
	.quad	0x7fffffffffffffff              # double NaN
	.quad	0x7fffffffffffffff              # double NaN
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI1_3:
	.quad	0x3f80000000000000              # double 0.0078125
.LCPI1_4:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
.LCPI1_5:
	.quad	0x4060000000000000              # double 128
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$32, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$65536, %edi                    # imm = 0x10000
	callq	malloc
	movq	%rax, %rbx
	movl	$65536, %edi                    # imm = 0x10000
	callq	malloc
	movq	%rax, %r14
	movl	$65536, %edi                    # imm = 0x10000
	callq	malloc
	movq	%rax, %r15
	xorl	%eax, %eax
	movl	$1065353216, %ecx               # imm = 0x3F800000
.LBB1_1:                                # =>This Inner Loop Header: Depth=1
	movl	%ecx, (%rbx,%rax,4)
	movl	%ecx, (%r14,%rax,4)
	incq	%rax
	cmpq	$16384, %rax                    # imm = 0x4000
	jne	.LBB1_1
# %bb.2:
	leaq	16(%rsp), %r12
	movq	%r12, %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r12), %rdi
	xorl	%r12d, %r12d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%rbx, %rax
.LBB1_3:                                # %.preheader.lr.ph.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_4 Depth 2
                                        #       Child Loop BB1_5 Depth 3
	movq	%r12, %rcx
	shlq	$9, %rcx
	addq	%r15, %rcx
	movq	%r14, %rdx
	xorl	%esi, %esi
.LBB1_4:                                # %.preheader.i
                                        #   Parent Loop BB1_3 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB1_5 Depth 3
	movss	(%rcx,%rsi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movq	%rdx, %rdi
	xorl	%r8d, %r8d
.LBB1_5:                                #   Parent Loop BB1_3 Depth=1
                                        #     Parent Loop BB1_4 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movss	(%rax,%r8,4), %xmm1             # xmm1 = mem[0],zero,zero,zero
	mulss	(%rdi), %xmm1
	addss	%xmm1, %xmm0
	incq	%r8
	addq	$512, %rdi                      # imm = 0x200
	cmpq	$128, %r8
	jne	.LBB1_5
# %bb.6:                                # %._crit_edge.i
                                        #   in Loop: Header=BB1_4 Depth=2
	movss	%xmm0, (%rcx,%rsi,4)
	incq	%rsi
	addq	$4, %rdx
	cmpq	$128, %rsi
	jne	.LBB1_4
# %bb.7:                                # %._crit_edge26.i
                                        #   in Loop: Header=BB1_3 Depth=1
	incq	%r12
	addq	$512, %rax                      # imm = 0x200
	cmpq	$128, %r12
	jne	.LBB1_3
# %bb.8:                                # %_Z15MatrixMulCpuSeqPfS_S_i.exit
	movq	8(%rsp), %rdi
	xorl	%r12d, %r12d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	leaq	28(%rsp), %r13
	movl	$0, (%r13)
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13), %xmm0
	movl	$.L.str, %edi
	movb	$1, %al
	callq	printf
	movss	.LCPI1_0(%rip), %xmm3           # xmm3 = mem[0],zero,zero,zero
	movaps	.LCPI1_1(%rip), %xmm4           # xmm4 = [NaN,NaN,NaN,NaN]
	movaps	.LCPI1_2(%rip), %xmm5           # xmm5 = [NaN,NaN]
	movsd	.LCPI1_3(%rip), %xmm6           # xmm6 = mem[0],zero
	movsd	.LCPI1_4(%rip), %xmm2           # xmm2 = mem[0],zero
.LBB1_9:                                # =>This Inner Loop Header: Depth=1
	movss	(%r15,%r12,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm0
	addss	%xmm3, %xmm1
	andps	%xmm4, %xmm1
	cvtss2sd	%xmm1, %xmm1
	movaps	%xmm0, %xmm7
	andps	%xmm5, %xmm7
	divsd	%xmm7, %xmm1
	mulsd	%xmm6, %xmm1
	ucomisd	%xmm2, %xmm1
	jbe	.LBB1_11
# %bb.10:                               #   in Loop: Header=BB1_9 Depth=1
	movl	$.L.str.1, %edi
	movl	%r12d, %esi
	movsd	.LCPI1_5(%rip), %xmm1           # xmm1 = mem[0],zero
	movb	$3, %al
	callq	printf
	movsd	.LCPI1_4(%rip), %xmm2           # xmm2 = mem[0],zero
	movsd	.LCPI1_3(%rip), %xmm6           # xmm6 = mem[0],zero
	movaps	.LCPI1_2(%rip), %xmm5           # xmm5 = [NaN,NaN]
	movaps	.LCPI1_1(%rip), %xmm4           # xmm4 = [NaN,NaN,NaN,NaN]
	movss	.LCPI1_0(%rip), %xmm3           # xmm3 = mem[0],zero,zero,zero
.LBB1_11:                               #   in Loop: Header=BB1_9 Depth=1
	incq	%r12
	cmpq	$16384, %r12                    # imm = 0x4000
	jne	.LBB1_9
# %bb.12:
	movq	%rbx, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%r15, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	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_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Time= %f\n"
	.size	.L.str, 10

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Error! Matrix[%05d]=%.8f, ref=%.8f error term is > %E\n"
	.size	.L.str.1, 55

	.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 __hip_cuid_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
