/**
 * Multiply 2 matrices using CUDA.
 */
#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <iostream>
#include <string.h>

typedef struct {
    int width;
    int height;
    float* elements;
} Matrix;

/**
 * This macro checks return value of the CUDA runtime call and exits
 * the application if the call failed.
 */
#define CUDA_CHECK_RETURN( value ) { \
    cudaError_t err = value; \
    if( err != cudaSuccess ) { \
        fprintf( stderr, "Error %s at line %d in file %s\n", \
                        cudaGetErrorString(err), __LINE__, __FILE__ ); \
        exit( 1 ); \
    } }

#define BLOCK_SIZE (2u)
#define MATRIX_1_WIDTH (6u)
#define MATRIX_1_HEIGHT (4u)
#define MATRIX_2_WIDTH (4u)
#define MATRIX_2_HEIGHT (6u)

__global__ void matrix_fill( Matrix * data )
{
    int i = blockDim.x * blockIdx.x + threadIdx.x;
    if( i < data->width * data->height ) data->elements[i] = i + 1;
}

__global__ void matrix_mul( Matrix * matrix_1, Matrix * matrix_2, Matrix * matrix_result )
{
    float value = 0;
    int row = blockDim.y * blockIdx.y + threadIdx.y;
    int col = blockDim.x * blockIdx.x + threadIdx.x;
    for (int i = 0; i < matrix_1->width; ++i) {
        value += matrix_1->elements[row * matrix_1->width + i] * matrix_2->elements[i * matrix_2->width + col];
    }
    matrix_result->elements[row * matrix_result->width + col] = value;
}

/**
 * Host function that prepares data array and passes it to the CUDA kernel.
 */
int main(int argc, char **argv) {
        
    /* Allocate data buffer in host memory for result matrix */
    Matrix *h_matrix_result = (Matrix*) malloc( sizeof(Matrix) );
    h_matrix_result->width = MATRIX_2_WIDTH;
    h_matrix_result->height = MATRIX_1_HEIGHT;
    h_matrix_result->elements = (float*) malloc( MATRIX_2_WIDTH * MATRIX_1_HEIGHT * sizeof(float) );
    memset( h_matrix_result->elements, 0, MATRIX_2_WIDTH * MATRIX_1_HEIGHT * sizeof(float) );
    
    /* Allocate data buffer in device memory for 3 matrices */
    Matrix *d_matrix_1, *d_matrix_2, *d_matrix_result = NULL;
    float *d_matrix_1_elements, *d_matrix_2_elements, *d_matrix_result_elements;
    int w, h;

    CUDA_CHECK_RETURN( cudaMalloc( &d_matrix_1, sizeof(Matrix) ) );
    // Cannot allocate in struct in device directly, allocate separately and than link
    CUDA_CHECK_RETURN( cudaMalloc( &d_matrix_1_elements, MATRIX_1_WIDTH * MATRIX_1_HEIGHT * sizeof(float) ) );
    CUDA_CHECK_RETURN( cudaMemcpy( &(d_matrix_1->elements), &d_matrix_1_elements, sizeof(float *), cudaMemcpyHostToDevice) );
    w = MATRIX_1_WIDTH;
    h = MATRIX_1_HEIGHT;
    CUDA_CHECK_RETURN( cudaMemcpy( &(d_matrix_1->width), &w, sizeof(int), cudaMemcpyHostToDevice ) );
    CUDA_CHECK_RETURN( cudaMemcpy( &(d_matrix_1->height), &h, sizeof(int), cudaMemcpyHostToDevice ) );

    CUDA_CHECK_RETURN( cudaMalloc( &d_matrix_2, sizeof(Matrix) ) );
    // Cannot allocate in struct in device directly, allocate separately and than link
    CUDA_CHECK_RETURN( cudaMalloc( &d_matrix_2_elements, MATRIX_2_WIDTH * MATRIX_2_HEIGHT * sizeof(float) ) );
    CUDA_CHECK_RETURN( cudaMemcpy( &(d_matrix_2->elements), &d_matrix_2_elements, sizeof(float *), cudaMemcpyHostToDevice) );
    w = MATRIX_2_WIDTH;
    h = MATRIX_2_HEIGHT;
    CUDA_CHECK_RETURN( cudaMemcpy( &(d_matrix_2->width), &w, sizeof(int), cudaMemcpyHostToDevice ) );
    CUDA_CHECK_RETURN( cudaMemcpy( &(d_matrix_2->height), &h, sizeof(int), cudaMemcpyHostToDevice ) );

    CUDA_CHECK_RETURN( cudaMalloc( &d_matrix_result, sizeof(Matrix) ) );
    // Cannot allocate in struct in device directly, allocate separately and than link
    CUDA_CHECK_RETURN( cudaMalloc( &d_matrix_result_elements, MATRIX_2_WIDTH * MATRIX_1_HEIGHT * sizeof(float) ) );
    CUDA_CHECK_RETURN( cudaMemcpy( &(d_matrix_result->elements), &d_matrix_result_elements, sizeof(float *), cudaMemcpyHostToDevice) );
    w = MATRIX_2_WIDTH;
    h = MATRIX_1_HEIGHT;
    CUDA_CHECK_RETURN( cudaMemcpy( &(d_matrix_result->width), &w, sizeof(int), cudaMemcpyHostToDevice ) );
    CUDA_CHECK_RETURN( cudaMemcpy( &(d_matrix_result->height), &h, sizeof(int), cudaMemcpyHostToDevice ) );
        
    /* Configure kernel */
    int blockSize = BLOCK_SIZE;
    int gridSizeMatrix1 = (MATRIX_1_WIDTH * MATRIX_1_HEIGHT + BLOCK_SIZE - 1) / BLOCK_SIZE;
    int gridSizeMatrix2 = (MATRIX_2_WIDTH * MATRIX_2_HEIGHT + BLOCK_SIZE - 1) / BLOCK_SIZE;
    
    /* Run kernels to fill 2 matrices */
    matrix_fill<<< gridSizeMatrix1, blockSize >>>( d_matrix_1 );
    matrix_fill<<< gridSizeMatrix2, blockSize >>>( d_matrix_2 );
    /* Wait until the kernel finishes its work */
    CUDA_CHECK_RETURN( cudaDeviceSynchronize() );

    /* Configure kernel */
    dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);
    dim3 dimGrid(h_matrix_result->width/dimBlock.x, h_matrix_result->height/dimBlock.y);
    /* Multiply 2 matrices */
    matrix_mul<<< dimGrid, dimBlock >>>( d_matrix_1, d_matrix_2, d_matrix_result );
    /* Wait until the kernel finishes its work */
    CUDA_CHECK_RETURN( cudaDeviceSynchronize() );
        
    /* Copy back to host and print result matrix */
    CUDA_CHECK_RETURN( cudaMemcpy( h_matrix_result->elements, d_matrix_result_elements, MATRIX_2_WIDTH * MATRIX_1_HEIGHT * sizeof(float), cudaMemcpyDeviceToHost) );
    for( int i = 0; i < h_matrix_result->width * h_matrix_result->height; ++i ) {
        std::cout << h_matrix_result->elements[i] << " ";
        
        if ((i+1) % (h_matrix_result->width) == 0) {
            std::cout << std::endl;
        }
    }

    CUDA_CHECK_RETURN( cudaFree(d_matrix_1_elements) );
    CUDA_CHECK_RETURN( cudaFree(d_matrix_1) );
    CUDA_CHECK_RETURN( cudaFree(d_matrix_2_elements) );
    CUDA_CHECK_RETURN( cudaFree(d_matrix_2) );
    CUDA_CHECK_RETURN( cudaFree(d_matrix_result_elements) );
    CUDA_CHECK_RETURN( cudaFree(d_matrix_result) );
        
    free( h_matrix_result->elements );
    free( h_matrix_result );
    
    return 0;
}

	.file	"tmpxft_0038b9b2_00000000-6_main.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3638:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3638:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z37__device_stub__Z11matrix_fillP6MatrixP6Matrix
	.type	_Z37__device_stub__Z11matrix_fillP6MatrixP6Matrix, @function
_Z37__device_stub__Z11matrix_fillP6MatrixP6Matrix:
.LFB3660:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z11matrix_fillP6Matrix(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L2:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3660:
	.size	_Z37__device_stub__Z11matrix_fillP6MatrixP6Matrix, .-_Z37__device_stub__Z11matrix_fillP6MatrixP6Matrix
	.globl	_Z11matrix_fillP6Matrix
	.type	_Z11matrix_fillP6Matrix, @function
_Z11matrix_fillP6Matrix:
.LFB3661:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z11matrix_fillP6MatrixP6Matrix
	.cfi_endproc
.LFE3661:
	.size	_Z11matrix_fillP6Matrix, .-_Z11matrix_fillP6Matrix
	.globl	_Z42__device_stub__Z10matrix_mulP6MatrixS0_S0_P6MatrixS0_S0_
	.type	_Z42__device_stub__Z10matrix_mulP6MatrixS0_S0_P6MatrixS0_S0_, @function
_Z42__device_stub__Z10matrix_mulP6MatrixS0_S0_P6MatrixS0_S0_:
.LFB3662:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z10matrix_mulP6MatrixS0_S0_(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L8:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3662:
	.size	_Z42__device_stub__Z10matrix_mulP6MatrixS0_S0_P6MatrixS0_S0_, .-_Z42__device_stub__Z10matrix_mulP6MatrixS0_S0_P6MatrixS0_S0_
	.globl	_Z10matrix_mulP6MatrixS0_S0_
	.type	_Z10matrix_mulP6MatrixS0_S0_, @function
_Z10matrix_mulP6MatrixS0_S0_:
.LFB3663:
	.cfi_startproc
	endbr64
	jmp	_Z42__device_stub__Z10matrix_mulP6MatrixS0_S0_P6MatrixS0_S0_
	.cfi_endproc
.LFE3663:
	.size	_Z10matrix_mulP6MatrixS0_S0_, .-_Z10matrix_mulP6MatrixS0_S0_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/jdobes/apvg/master/project2/main.cu"
.LC1:
	.string	"Error %s at line %d in file %s\n"
.LC2:
	.string	" "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$16, %edi
	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	$96, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movl	$64, %edi
	movq	%rax, %rbp
	movabsq	$17179869188, %rax
	movq	%rax, 0(%rbp)
	call	malloc@PLT
	movl	$16, %ecx
	movl	$16, %esi
	movq	%rax, %rbx
	movq	%rax, 8(%rbp)
	xorl	%eax, %eax
	movq	%rbx, %rdi
	rep stosl
	xorl	%eax, %eax
	leaq	16(%rsp), %rdi
	movq	%rax, 32(%rsp)
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L14
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$69, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L14:
	leaq	40(%rsp), %r12
	movl	$96, %esi
	movq	%r12, %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L15
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$71, %r8d
	movq	%rax, %rcx
.L47:
	movq	stderr(%rip), %rdi
	leaq	.LC1(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L15:
	movq	16(%rsp), %rax
	movl	$1, %ecx
	movl	$8, %edx
	movq	%r12, %rsi
	leaq	8(%rax), %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L16
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$72, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L16:
	movq	16(%rsp), %rdi
	leaq	8(%rsp), %r13
	movl	$1, %ecx
	movl	$4, %edx
	movq	%r13, %rsi
	movl	$6, 8(%rsp)
	movl	$4, 12(%rsp)
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L17
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$75, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L17:
	movq	16(%rsp), %rax
	leaq	12(%rsp), %r12
	movl	$1, %ecx
	movl	$4, %edx
	movq	%r12, %rsi
	leaq	4(%rax), %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L18
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$76, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L18:
	leaq	24(%rsp), %rdi
	movl	$16, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L19
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$78, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L19:
	leaq	48(%rsp), %r14
	movl	$96, %esi
	movq	%r14, %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L20
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$80, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L20:
	movq	24(%rsp), %rax
	movl	$1, %ecx
	movl	$8, %edx
	movq	%r14, %rsi
	leaq	8(%rax), %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L21
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$81, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L21:
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movl	$4, %edx
	movq	%r13, %rsi
	movl	$4, 8(%rsp)
	movl	$6, 12(%rsp)
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L22
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$84, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L22:
	movq	24(%rsp), %rax
	movl	$1, %ecx
	movl	$4, %edx
	movq	%r12, %rsi
	leaq	4(%rax), %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L23
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$85, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L23:
	leaq	32(%rsp), %rdi
	movl	$16, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L24
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$87, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L24:
	leaq	56(%rsp), %r14
	movl	$64, %esi
	movq	%r14, %rdi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L25
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$89, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L25:
	movq	32(%rsp), %rax
	movl	$1, %ecx
	movl	$8, %edx
	movq	%r14, %rsi
	leaq	8(%rax), %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L26
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$90, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L26:
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movl	$4, %edx
	movq	%r13, %rsi
	movl	$4, 8(%rsp)
	movl	$4, 12(%rsp)
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L27
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$93, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L27:
	movq	32(%rsp), %rax
	movl	$1, %ecx
	movl	$4, %edx
	movq	%r12, %rsi
	leaq	4(%rax), %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L28
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$94, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L28:
	movl	$2147483649, %edx
	movl	$1073741827, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	addq	%rdx, %rdx
	salq	$2, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%rdx, 76(%rsp)
	movl	$1, 84(%rsp)
	movq	%rdi, 64(%rsp)
	movl	$1, 72(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	movq	16(%rsp), %rdi
	call	_Z37__device_stub__Z11matrix_fillP6MatrixP6Matrix
.L29:
	movl	$2147483649, %edx
	movl	$1073741827, %edi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	addq	%rdx, %rdx
	salq	$2, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%rdx, 76(%rsp)
	movl	$1, 84(%rsp)
	movq	%rdi, 64(%rsp)
	movl	$1, 72(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L30
	movq	24(%rsp), %rdi
	call	_Z37__device_stub__Z11matrix_fillP6MatrixP6Matrix
.L30:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L31
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$105, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L31:
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$8589934594, %rdi
	movl	$1, 84(%rsp)
	movq	%rdi, %rdx
	movq	%rdi, 76(%rsp)
	movq	%rdi, 64(%rsp)
	movl	$1, 72(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L32
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	call	_Z42__device_stub__Z10matrix_mulP6MatrixS0_S0_P6MatrixS0_S0_
.L32:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L33
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$113, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L33:
	movq	56(%rsp), %rsi
	movq	%rbx, %rdi
	movl	$2, %ecx
	movl	$64, %edx
	movl	$1, %r12d
	leaq	_ZSt4cout(%rip), %r13
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L34
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$116, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L35:
	incq	%r12
	cmpq	$17, %r12
	je	.L48
.L34:
	movq	%r13, %rdi
	cvtss2sd	-4(%rbx,%r12,4), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movl	$1, %edx
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT
	testl	$3, %r12d
	jne	.L35
	movq	%r13, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	jmp	.L35
.L48:
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L36
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$125, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L36:
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L37
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$126, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L37:
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L38
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$127, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L38:
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L39
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$128, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L39:
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L40
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$129, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L40:
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L41
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %r9
	movl	$130, %r8d
	movq	%rax, %rcx
	jmp	.L47
.L41:
	movq	%rbx, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	addq	$96, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	main, .-main
	.section	.rodata.str1.1
.LC3:
	.string	"_Z10matrix_mulP6MatrixS0_S0_"
.LC4:
	.string	"_Z11matrix_fillP6Matrix"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3665:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -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	.LC3(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z10matrix_mulP6MatrixS0_S0_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC4(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z11matrix_fillP6Matrix(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	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	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3665:
	.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:

/**
 * Multiply 2 matrices using CUDA.
 */
#include <stdio.h>
#include <stdlib.h>
#include <hip/hip_runtime.h>

#include <iostream>
#include <string.h>

typedef struct {
    int width;
    int height;
    float* elements;
} Matrix;

/**
 * This macro checks return value of the CUDA runtime call and exits
 * the application if the call failed.
 */
#define CUDA_CHECK_RETURN( value ) { \
    hipError_t err = value; \
    if( err != hipSuccess ) { \
        fprintf( stderr, "Error %s at line %d in file %s\n", \
                        hipGetErrorString(err), __LINE__, __FILE__ ); \
        exit( 1 ); \
    } }

#define BLOCK_SIZE (2u)
#define MATRIX_1_WIDTH (6u)
#define MATRIX_1_HEIGHT (4u)
#define MATRIX_2_WIDTH (4u)
#define MATRIX_2_HEIGHT (6u)

__global__ void matrix_fill( Matrix * data )
{
    int i = blockDim.x * blockIdx.x + threadIdx.x;
    if( i < data->width * data->height ) data->elements[i] = i + 1;
}

__global__ void matrix_mul( Matrix * matrix_1, Matrix * matrix_2, Matrix * matrix_result )
{
    float value = 0;
    int row = blockDim.y * blockIdx.y + threadIdx.y;
    int col = blockDim.x * blockIdx.x + threadIdx.x;
    for (int i = 0; i < matrix_1->width; ++i) {
        value += matrix_1->elements[row * matrix_1->width + i] * matrix_2->elements[i * matrix_2->width + col];
    }
    matrix_result->elements[row * matrix_result->width + col] = value;
}

/**
 * Host function that prepares data array and passes it to the CUDA kernel.
 */
int main(int argc, char **argv) {
        
    /* Allocate data buffer in host memory for result matrix */
    Matrix *h_matrix_result = (Matrix*) malloc( sizeof(Matrix) );
    h_matrix_result->width = MATRIX_2_WIDTH;
    h_matrix_result->height = MATRIX_1_HEIGHT;
    h_matrix_result->elements = (float*) malloc( MATRIX_2_WIDTH * MATRIX_1_HEIGHT * sizeof(float) );
    memset( h_matrix_result->elements, 0, MATRIX_2_WIDTH * MATRIX_1_HEIGHT * sizeof(float) );
    
    /* Allocate data buffer in device memory for 3 matrices */
    Matrix *d_matrix_1, *d_matrix_2, *d_matrix_result = NULL;
    float *d_matrix_1_elements, *d_matrix_2_elements, *d_matrix_result_elements;
    int w, h;

    CUDA_CHECK_RETURN( hipMalloc( &d_matrix_1, sizeof(Matrix) ) );
    // Cannot allocate in struct in device directly, allocate separately and than link
    CUDA_CHECK_RETURN( hipMalloc( &d_matrix_1_elements, MATRIX_1_WIDTH * MATRIX_1_HEIGHT * sizeof(float) ) );
    CUDA_CHECK_RETURN( hipMemcpy( &(d_matrix_1->elements), &d_matrix_1_elements, sizeof(float *), hipMemcpyHostToDevice) );
    w = MATRIX_1_WIDTH;
    h = MATRIX_1_HEIGHT;
    CUDA_CHECK_RETURN( hipMemcpy( &(d_matrix_1->width), &w, sizeof(int), hipMemcpyHostToDevice ) );
    CUDA_CHECK_RETURN( hipMemcpy( &(d_matrix_1->height), &h, sizeof(int), hipMemcpyHostToDevice ) );

    CUDA_CHECK_RETURN( hipMalloc( &d_matrix_2, sizeof(Matrix) ) );
    // Cannot allocate in struct in device directly, allocate separately and than link
    CUDA_CHECK_RETURN( hipMalloc( &d_matrix_2_elements, MATRIX_2_WIDTH * MATRIX_2_HEIGHT * sizeof(float) ) );
    CUDA_CHECK_RETURN( hipMemcpy( &(d_matrix_2->elements), &d_matrix_2_elements, sizeof(float *), hipMemcpyHostToDevice) );
    w = MATRIX_2_WIDTH;
    h = MATRIX_2_HEIGHT;
    CUDA_CHECK_RETURN( hipMemcpy( &(d_matrix_2->width), &w, sizeof(int), hipMemcpyHostToDevice ) );
    CUDA_CHECK_RETURN( hipMemcpy( &(d_matrix_2->height), &h, sizeof(int), hipMemcpyHostToDevice ) );

    CUDA_CHECK_RETURN( hipMalloc( &d_matrix_result, sizeof(Matrix) ) );
    // Cannot allocate in struct in device directly, allocate separately and than link
    CUDA_CHECK_RETURN( hipMalloc( &d_matrix_result_elements, MATRIX_2_WIDTH * MATRIX_1_HEIGHT * sizeof(float) ) );
    CUDA_CHECK_RETURN( hipMemcpy( &(d_matrix_result->elements), &d_matrix_result_elements, sizeof(float *), hipMemcpyHostToDevice) );
    w = MATRIX_2_WIDTH;
    h = MATRIX_1_HEIGHT;
    CUDA_CHECK_RETURN( hipMemcpy( &(d_matrix_result->width), &w, sizeof(int), hipMemcpyHostToDevice ) );
    CUDA_CHECK_RETURN( hipMemcpy( &(d_matrix_result->height), &h, sizeof(int), hipMemcpyHostToDevice ) );
        
    /* Configure kernel */
    int blockSize = BLOCK_SIZE;
    int gridSizeMatrix1 = (MATRIX_1_WIDTH * MATRIX_1_HEIGHT + BLOCK_SIZE - 1) / BLOCK_SIZE;
    int gridSizeMatrix2 = (MATRIX_2_WIDTH * MATRIX_2_HEIGHT + BLOCK_SIZE - 1) / BLOCK_SIZE;
    
    /* Run kernels to fill 2 matrices */
    matrix_fill<<< gridSizeMatrix1, blockSize >>>( d_matrix_1 );
    matrix_fill<<< gridSizeMatrix2, blockSize >>>( d_matrix_2 );
    /* Wait until the kernel finishes its work */
    CUDA_CHECK_RETURN( hipDeviceSynchronize() );

    /* Configure kernel */
    dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE);
    dim3 dimGrid(h_matrix_result->width/dimBlock.x, h_matrix_result->height/dimBlock.y);
    /* Multiply 2 matrices */
    matrix_mul<<< dimGrid, dimBlock >>>( d_matrix_1, d_matrix_2, d_matrix_result );
    /* Wait until the kernel finishes its work */
    CUDA_CHECK_RETURN( hipDeviceSynchronize() );
        
    /* Copy back to host and print result matrix */
    CUDA_CHECK_RETURN( hipMemcpy( h_matrix_result->elements, d_matrix_result_elements, MATRIX_2_WIDTH * MATRIX_1_HEIGHT * sizeof(float), hipMemcpyDeviceToHost) );
    for( int i = 0; i < h_matrix_result->width * h_matrix_result->height; ++i ) {
        std::cout << h_matrix_result->elements[i] << " ";
        
        if ((i+1) % (h_matrix_result->width) == 0) {
            std::cout << std::endl;
        }
    }

    CUDA_CHECK_RETURN( hipFree(d_matrix_1_elements) );
    CUDA_CHECK_RETURN( hipFree(d_matrix_1) );
    CUDA_CHECK_RETURN( hipFree(d_matrix_2_elements) );
    CUDA_CHECK_RETURN( hipFree(d_matrix_2) );
    CUDA_CHECK_RETURN( hipFree(d_matrix_result_elements) );
    CUDA_CHECK_RETURN( hipFree(d_matrix_result) );
        
    free( h_matrix_result->elements );
    free( h_matrix_result );
    
    return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z26__device_stub__matrix_fillP6Matrix # -- Begin function _Z26__device_stub__matrix_fillP6Matrix
	.type	_Z26__device_stub__matrix_fillP6Matrix,@function
_Z26__device_stub__matrix_fillP6Matrix: # @_Z26__device_stub__matrix_fillP6Matrix
	.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	$64, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%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	$_Z11matrix_fillP6Matrix, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	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	_Z26__device_stub__matrix_fillP6Matrix, .Lfunc_end0-_Z26__device_stub__matrix_fillP6Matrix
	.cfi_endproc
                                        # -- End function
	.globl	_Z25__device_stub__matrix_mulP6MatrixS0_S0_ # -- Begin function _Z25__device_stub__matrix_mulP6MatrixS0_S0_
	.type	_Z25__device_stub__matrix_mulP6MatrixS0_S0_,@function
_Z25__device_stub__matrix_mulP6MatrixS0_S0_: # @_Z25__device_stub__matrix_mulP6MatrixS0_S0_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%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	$_Z10matrix_mulP6MatrixS0_S0_, %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_end1:
	.size	_Z25__device_stub__matrix_mulP6MatrixS0_S0_, .Lfunc_end1-_Z25__device_stub__matrix_mulP6MatrixS0_S0_
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	%rbx
	.cfi_def_cfa_offset 32
	subq	$64, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	$1, %edi
	movl	$64, %esi
	callq	calloc@PLT
	movq	%rax, %rbx
	movq	$0, 8(%rsp)
	leaq	24(%rsp), %rdi
	movl	$16, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_1
# %bb.3:
	leaq	56(%rsp), %rdi
	movl	$96, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_4
# %bb.5:
	movq	24(%rsp), %rdi
	addq	$8, %rdi
	leaq	56(%rsp), %rsi
	movl	$8, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_6
# %bb.7:
	leaq	36(%rsp), %rsi
	movl	$6, (%rsi)
	movl	$4, 4(%rsp)
	movq	24(%rsp), %rdi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_8
# %bb.9:
	movq	24(%rsp), %rdi
	addq	$4, %rdi
	leaq	4(%rsp), %rsi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_10
# %bb.11:
	leaq	16(%rsp), %rdi
	movl	$16, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_12
# %bb.13:
	leaq	48(%rsp), %rdi
	movl	$96, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_14
# %bb.15:
	movq	16(%rsp), %rdi
	addq	$8, %rdi
	leaq	48(%rsp), %rsi
	movl	$8, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_16
# %bb.17:
	leaq	36(%rsp), %rsi
	movl	$4, (%rsi)
	movl	$6, 4(%rsp)
	movq	16(%rsp), %rdi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_18
# %bb.19:
	movq	16(%rsp), %rdi
	addq	$4, %rdi
	leaq	4(%rsp), %rsi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_20
# %bb.21:
	leaq	8(%rsp), %rdi
	movl	$16, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_22
# %bb.23:
	leaq	40(%rsp), %rdi
	movl	$64, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_24
# %bb.25:
	movq	8(%rsp), %rdi
	addq	$8, %rdi
	leaq	40(%rsp), %rsi
	movl	$8, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_26
# %bb.27:
	movl	$4, %eax
	leaq	36(%rsp), %rsi
	movl	%eax, (%rsi)
	movl	%eax, 4(%rsp)
	movq	8(%rsp), %rdi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_28
# %bb.29:
	movq	8(%rsp), %rdi
	addq	$4, %rdi
	leaq	4(%rsp), %rsi
	movl	$4, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_30
# %bb.31:
	movabsq	$4294967298, %r14               # imm = 0x100000002
	leaq	10(%r14), %r15
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_33
# %bb.32:
	movq	24(%rsp), %rdi
	callq	_Z26__device_stub__matrix_fillP6Matrix
.LBB2_33:
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_35
# %bb.34:
	movq	16(%rsp), %rdi
	callq	_Z26__device_stub__matrix_fillP6Matrix
.LBB2_35:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB2_36
# %bb.37:
	movabsq	$8589934594, %rdi               # imm = 0x200000002
	movl	$1, %esi
	movq	%rdi, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_39
# %bb.38:
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	callq	_Z25__device_stub__matrix_mulP6MatrixS0_S0_
.LBB2_39:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB2_40
# %bb.41:
	movq	40(%rsp), %rsi
	movl	$64, %edx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_59
# %bb.42:                               # %.preheader.preheader
	movl	$1, %r14d
	movl	$_ZSt4cout, %r15d
.LBB2_43:                               # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	-4(%rbx,%r14,4), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str.2, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	testb	$3, %r14b
	jne	.LBB2_45
# %bb.44:                               #   in Loop: Header=BB2_43 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB2_45:                               #   in Loop: Header=BB2_43 Depth=1
	incq	%r14
	cmpq	$17, %r14
	jne	.LBB2_43
# %bb.46:
	movq	56(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_47
# %bb.48:
	movq	24(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_49
# %bb.50:
	movq	48(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_51
# %bb.52:
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_53
# %bb.54:
	movq	40(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_55
# %bb.56:
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_57
# %bb.58:
	movq	%rbx, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$64, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB2_1:
	.cfi_def_cfa_offset 96
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$69, %ecx
	jmp	.LBB2_2
.LBB2_4:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$71, %ecx
	jmp	.LBB2_2
.LBB2_6:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$72, %ecx
	jmp	.LBB2_2
.LBB2_8:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$75, %ecx
	jmp	.LBB2_2
.LBB2_10:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$76, %ecx
	jmp	.LBB2_2
.LBB2_12:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$78, %ecx
	jmp	.LBB2_2
.LBB2_14:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$80, %ecx
	jmp	.LBB2_2
.LBB2_16:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$81, %ecx
	jmp	.LBB2_2
.LBB2_18:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$84, %ecx
	jmp	.LBB2_2
.LBB2_20:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$85, %ecx
	jmp	.LBB2_2
.LBB2_22:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$87, %ecx
	jmp	.LBB2_2
.LBB2_24:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$89, %ecx
	jmp	.LBB2_2
.LBB2_26:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$90, %ecx
	jmp	.LBB2_2
.LBB2_28:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$93, %ecx
	jmp	.LBB2_2
.LBB2_30:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$94, %ecx
	jmp	.LBB2_2
.LBB2_36:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$105, %ecx
	jmp	.LBB2_2
.LBB2_40:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$113, %ecx
	jmp	.LBB2_2
.LBB2_59:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$116, %ecx
	jmp	.LBB2_2
.LBB2_47:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$125, %ecx
	jmp	.LBB2_2
.LBB2_49:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$126, %ecx
	jmp	.LBB2_2
.LBB2_51:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$127, %ecx
	jmp	.LBB2_2
.LBB2_53:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$128, %ecx
	jmp	.LBB2_2
.LBB2_55:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$129, %ecx
	jmp	.LBB2_2
.LBB2_57:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str, %esi
	movl	$.L.str.1, %r8d
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$130, %ecx
.LBB2_2:
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end2:
	.size	main, .Lfunc_end2-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:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11matrix_fillP6Matrix, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z10matrix_mulP6MatrixS0_S0_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__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	.LBB4_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
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z11matrix_fillP6Matrix,@object # @_Z11matrix_fillP6Matrix
	.section	.rodata,"a",@progbits
	.globl	_Z11matrix_fillP6Matrix
	.p2align	3, 0x0
_Z11matrix_fillP6Matrix:
	.quad	_Z26__device_stub__matrix_fillP6Matrix
	.size	_Z11matrix_fillP6Matrix, 8

	.type	_Z10matrix_mulP6MatrixS0_S0_,@object # @_Z10matrix_mulP6MatrixS0_S0_
	.globl	_Z10matrix_mulP6MatrixS0_S0_
	.p2align	3, 0x0
_Z10matrix_mulP6MatrixS0_S0_:
	.quad	_Z25__device_stub__matrix_mulP6MatrixS0_S0_
	.size	_Z10matrix_mulP6MatrixS0_S0_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Error %s at line %d in file %s\n"
	.size	.L.str, 32

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/jdobes/apvg/master/project2/main.hip"
	.size	.L.str.1, 99

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z11matrix_fillP6Matrix"
	.size	.L__unnamed_1, 24

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z10matrix_mulP6MatrixS0_S0_"
	.size	.L__unnamed_2, 29

	.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 _Z26__device_stub__matrix_fillP6Matrix
	.addrsig_sym _Z25__device_stub__matrix_mulP6MatrixS0_S0_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z11matrix_fillP6Matrix
	.addrsig_sym _Z10matrix_mulP6MatrixS0_S0_
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z11matrix_fillP6Matrix ; -- Begin function _Z11matrix_fillP6Matrix
	.globl	_Z11matrix_fillP6Matrix
	.p2align	8
	.type	_Z11matrix_fillP6Matrix,@function
_Z11matrix_fillP6Matrix:                ; @_Z11matrix_fillP6Matrix
; %bb.0:
	s_clause 0x1
	s_load_b64 s[2:3], s[0:1], 0x0
	s_load_b32 s4, s[0:1], 0x14
	s_waitcnt lgkmcnt(0)
	s_load_b64 s[0:1], s[2:3], 0x0
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s0, s1, s0
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_i32_e32 vcc_lo, s0, v1
	s_and_saveexec_b32 s0, vcc_lo
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b64 s[0:1], s[2:3], 0x8
	v_ashrrev_i32_e32 v2, 31, v1
	v_add_nc_u32_e32 v3, 1, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_cvt_f32_i32_e32 v2, v3
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11matrix_fillP6Matrix
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 264
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 4
		.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	_Z11matrix_fillP6Matrix, .Lfunc_end0-_Z11matrix_fillP6Matrix
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 148
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; Occupancy: 16
; WaveLimiterHint : 1
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z10matrix_mulP6MatrixS0_S0_ ; -- Begin function _Z10matrix_mulP6MatrixS0_S0_
	.globl	_Z10matrix_mulP6MatrixS0_S0_
	.p2align	8
	.type	_Z10matrix_mulP6MatrixS0_S0_,@function
_Z10matrix_mulP6MatrixS0_S0_:           ; @_Z10matrix_mulP6MatrixS0_S0_
; %bb.0:
	s_clause 0x2
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b32 s2, s[0:1], 0x24
	s_load_b64 s[0:1], s[0:1], 0x10
	v_bfe_u32 v2, v0, 10, 10
	v_and_b32_e32 v3, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_load_b32 s8, s[4:5], 0x0
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	v_mad_u64_u32 v[0:1], null, s15, s3, v[2:3]
	v_mad_u64_u32 v[1:2], null, s14, s2, v[3:4]
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s8, 1
	s_cbranch_scc1 .LBB1_3
; %bb.1:                                ; %.lr.ph
	s_load_b64 s[10:11], s[4:5], 0x8
	s_delay_alu instid0(VALU_DEP_2)
	v_mul_lo_u32 v2, s8, v0
	s_clause 0x1
	s_load_b32 s4, s[6:7], 0x0
	s_load_b64 s[2:3], s[6:7], 0x8
	v_mov_b32_e32 v6, 0
	v_mov_b32_e32 v4, v1
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s10, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s11, v3, vcc_lo
.LBB1_2:                                ; =>This Inner Loop Header: Depth=1
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s8, s8, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s8, 0
	v_lshlrev_b64 v[7:8], 2, v[4:5]
	v_add_nc_u32_e32 v4, s4, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v7, vcc_lo, s2, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v8, vcc_lo
	global_load_b32 v5, v[2:3], off
	global_load_b32 v7, v[7:8], off
	v_add_co_u32 v2, vcc_lo, v2, 4
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_waitcnt vmcnt(0)
	v_fmac_f32_e32 v6, v5, v7
	s_cbranch_scc0 .LBB1_2
	s_branch .LBB1_4
.LBB1_3:
	v_mov_b32_e32 v6, 0
.LBB1_4:                                ; %Flow42
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	v_mad_u64_u32 v[2:3], null, s2, v0, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	global_store_b32 v[0:1], v6, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z10matrix_mulP6MatrixS0_S0_
		.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 9
		.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_end1:
	.size	_Z10matrix_mulP6MatrixS0_S0_, .Lfunc_end1-_Z10matrix_mulP6MatrixS0_S0_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 356
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; Occupancy: 16
; WaveLimiterHint : 1
; 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
      - .offset:         8
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         12
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         20
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         22
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         24
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         26
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         28
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         30
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         48
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         72
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 264
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11matrix_fillP6Matrix
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z11matrix_fillP6Matrix.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .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:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z10matrix_mulP6MatrixS0_S0_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z10matrix_mulP6MatrixS0_S0_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
