/*
 *                         Tiled Matrix Multiplication
 *             (MP2, Fall 2014, GPU Programming/Auburn University)
 *
 *   Compile with -DTILE_WIDTH=16 (for example) to change the tile size.
 *   Compile with -DSEED=12 (for example) to seed the random number generator.
 */

 #include <assert.h>
 #include <cuda.h>
 #include <stdio.h>
 #include <math.h>
 #include <iostream>
 #include <fstream>
 /* Usage message displayed when invalid command line arguments are supplied */
 #define USAGE \
     "MP2 generates a random (m x k) matrix M and (k x n) matrix N\n" \
     "and multiplies M by N using tiled matrix multiplication.\n" \
     "The values of m, k, and n must be >= 1.\n" \
     "\n" \
     "Usage: mp2 m k n\n"
 
 /* Tile size -- define here if not defined using the -D compiler flag */
 #ifndef TILE_WIDTH
 #  define TILE_WIDTH 16
 #endif
 
 /* Seed for the random number generator -- define here if not using -D */
 #ifndef SEED
 #  define SEED 1
 #endif
 
 /* Maximum difference allowed between the GPU and CPU result matrices */
 #define EPSILON 1e-2
 
 /* If a CUDA call fails, display an error message and exit */
 #define CUDA_CHECK(e) { \
     cudaError_t err = (e); \
     if (err != cudaSuccess) \
     { \
         fprintf(stderr, "CUDA error: %s, line %d, %s: %s\n", \
             __FILE__, __LINE__, #e, cudaGetErrorString(err)); \
         exit(EXIT_FAILURE); \
     } \
 }
 
 /* assert() is only supported on devices of compute capability >= 2.0 */
 #if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 200)
 #  undef  assert
 #  define assert(arg)
 #endif

void getDistance(float *h_M, float *h_P, int m, int k, int col, int row){
    float expected = 0.0;
    for (int i = 0; i < k; i++)
    {
        expected += pow(h_M[row*k+i] - h_M[col*k+i], 2);
    }
    expected = sqrt(expected);
    h_P[row*m+col] = expected;

 }
void argMin(float* h_M, int* result, int m, int k, int row){
    float minimum = 1e5;
    int pos = -1;
    for(int col = 0; col < m; col++){
        if (h_M[row*m+col] < minimum){
            pos = col;
            minimum = h_M[row*m+col];
        }
    }
    result[row] = pos;
}
 __global__ static void argMin_gpu(float* h_M, int* result, int m, int k){
    assert(blockDim.x == TILE_WIDTH && blockDim.y == TILE_WIDTH);

    int row = blockIdx.y * TILE_WIDTH + threadIdx.y;
    if(row >= m)
        return;
    float minimum = 1e5;
    int pos = -1;
    for(int col = 0; col < m; col++){
        if (h_M[row*m+col] < minimum){
            pos = col;
            minimum = h_M[row*m+col];
        }
    }
    result[row] = pos;
 }
 __global__ static void getDistance_gpu(float *d_M, float *d_P, int m, int k) {
    assert(blockDim.x == TILE_WIDTH && blockDim.y == TILE_WIDTH);

    int row = blockIdx.y * TILE_WIDTH + threadIdx.y;
    int col= blockIdx.x  * TILE_WIDTH + threadIdx.x;
    if(row >= m || col >= m)
        return;
    if(row == col){
        d_P[row*m+col] = 100;
        return;
    }

    float expected = 0.0;
    for (int i = 0; i < k; i++)
    {
        expected += pow(d_M[row*k+i] - d_M[col*k+i], 2);
    }
    expected = sqrt(expected);
    d_P[row*m+col] = expected;
}

 /* Displays one row of the given matrix */
 static void printRow(int row, float *matrix, int cols)
 {
     printf("[");
     if (cols >= 1) printf(" %3.3f", matrix[row*cols+0]);
     if (cols >= 2) printf(" %3.3f", matrix[row*cols+1]);
     if (cols >= 3) printf(" %3.3f", matrix[row*cols+2]);
     if (cols >= 6) printf(" ...");
     if (cols >= 5) printf(" %3.3f", matrix[row*cols+(cols-2)]);
     if (cols >= 4) printf(" %3.3f", matrix[row*cols+(cols-1)]);
     printf(" ]\n");
 }
 
 /* Displays the given matrix */
 static void printMatrix(float *matrix, int rows, int cols)
 {
     if (rows >= 1) printRow(0, matrix, cols);
     if (rows >= 2) printRow(1, matrix, cols);
     if (rows >= 3) printRow(2, matrix, cols);
     if (rows >= 6) printf("  ...\n");
     if (rows >= 5) printRow(rows-2, matrix, cols);
     if (rows >= 4) printRow(rows-1, matrix, cols);
 }
 
 /* Program entrypoint.  Invoke with three command line arguments: m k n */
 int main()
 {

    printf("%d, %d, %d, %d\n", sizeof(long), sizeof(long long), sizeof(bool), sizeof(char));
     /* Get command line arguments; save as m, k, and n */
     int m = 100;
     int k = 128;

     if (m < 1 || k < 1)
     {
         fprintf(stderr, USAGE);
         fprintf(stderr, "Invalid value for m or k (%d, %d)\n",
             m, k);
         return EXIT_FAILURE;
     }
     printf("using (%d x %d) tiles.\n", TILE_WIDTH, TILE_WIDTH);
 
     /********************************************/
     /* M is (m x k), P is (m x m) */
     /********************************************/
 
     /* Compute number of bytes needed to stores matrices M and P */
     size_t bytesForM = m * k * sizeof(float);
     size_t bytesForP = m * m * sizeof(float);
 
     /* Allocate host memory for matrices */
     float *h_M, *h_P;
     float *result = new float[m*m];
     int *index = new int[m];

     h_M = (float *)malloc(bytesForM);
     h_P = (float *)malloc(bytesForP);

     if (h_M == NULL || h_P == NULL)
     {
         fprintf(stderr, "Unable to allocate host memory\n");
         return EXIT_FAILURE;
     }
 
     /* Allocate device memory for matrices */
     float *d_M, *d_P;
     int *d_index;
     CUDA_CHECK(cudaMalloc((void **)&d_M, bytesForM));
     CUDA_CHECK(cudaMalloc((void **)&d_P, bytesForP));
     CUDA_CHECK(cudaMalloc((void **)&d_index, m*sizeof(int)));
 
     /* Fill M (on host) */
 
     


     std::cout << "Loading matrices...\n";
     std::ifstream in1, in2;
	in1.open("descriptor.txt");
	for (int i = 0; i < m*k; ++i)
		in1 >> h_M[i];
    in1.close();

    printf("M =\n"); printMatrix(h_M, m, k);

     /* Copy M to device global memory */
     CUDA_CHECK(cudaMemcpy(d_M, h_M, bytesForM, cudaMemcpyHostToDevice));
 
     /* Launch the CUDA kernel */
     dim3 dimGrid((m+TILE_WIDTH-1)/TILE_WIDTH, (m+TILE_WIDTH-1)/TILE_WIDTH);
     dim3 dimBlock(TILE_WIDTH, TILE_WIDTH);
 
    printf("matMul called from host\n");
     
     getDistance_gpu<<<dimGrid, dimBlock>>>(d_M, d_P, m, k);
     argMin_gpu<<<dimGrid, dimBlock>>>(d_P, d_index, m, k);
     CUDA_CHECK(cudaDeviceSynchronize());
 
     /* Copy result matrix from device global memory back to host memory */
     CUDA_CHECK(cudaMemcpy(h_P, d_P, bytesForP, cudaMemcpyDeviceToHost));
     CUDA_CHECK(cudaMemcpy(index, d_index, m*sizeof(int), cudaMemcpyDeviceToHost));
           
    printf(" product received from host\n");

    printf("P =\n"); printMatrix(h_P, m, m);

     std::ofstream out, out2;
     out2.open("matrix.txt");
     for (int i = 0; i < 100; i++){
        for (int j = 0; j < m; j++){
            if (h_P[i*m+j] < 0.3)
                out2 << j+1 << " ";
        }
        out2 << std::endl;
        
     }
     out2.close();

    /*
     
     for (int row = 0; row < m; row++)
     {
         for (int col = 0; col < m; col++)
         {
            getDistance(h_M, result, m, k, col, row);
         }
    }
     
     printf("\nExpected matrix:\n");
     printMatrix(result, m, m);

     printf("\n");
     for (int i = 0; i < m; i++){
        printf("%d ", index[i]);
    }
    printf("\n");
    */
     /* Free device global memory */
     CUDA_CHECK(cudaFree(d_M));
     CUDA_CHECK(cudaFree(d_P));
     CUDA_CHECK(cudaFree(d_index));

 
     /* Free host memory */
     free(h_M);
     free(h_P);
     free(index);
     free(result);
 
     /* Reset the device (unnecessary if not profiling, but good practice) */
     CUDA_CHECK(cudaDeviceReset());
 
     printf("Done\n");
     system("Pause");
     return EXIT_SUCCESS;
 }
 
	.file	"tmpxft_0034b554_00000000-6_mp3.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"["
.LC1:
	.string	" %3.3f"
.LC2:
	.string	" ..."
.LC3:
	.string	" ]\n"
#NO_APP
	.text
	.type	_ZL8printRowiPfi, @function
_ZL8printRowiPfi:
.LFB3768:
	.cfi_startproc
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%eax, %eax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rsi, %rbp
	leaq	.LC0(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	%edi, %ebx
	movl	$2, %edi
	imull	%r13d, %ebx
	call	__printf_chk@PLT
	movq	%r12, %rsi
	movl	$2, %edi
	movslq	%ebx, %rax
	cvtss2sd	0(%rbp,%rax,4), %xmm0
	leaq	0(,%rax,4), %r14
	movb	$1, %al
	call	__printf_chk@PLT
	movq	%r12, %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	4(%rbp,%r14), %xmm0
	call	__printf_chk@PLT
	leal	2(%rbx), %eax
	movq	%r12, %rsi
	cltq
	movl	$2, %edi
	cvtss2sd	0(%rbp,%rax,4), %xmm0
	movb	$1, %al
	call	__printf_chk@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leal	-2(%rbx,%r13), %eax
	movq	%r12, %rsi
	movl	$2, %edi
	cltq
	cvtss2sd	0(%rbp,%rax,4), %xmm0
	movb	$1, %al
	call	__printf_chk@PLT
	leal	-1(%rbx,%r13), %eax
	movq	%r12, %rsi
	movl	$2, %edi
	cltq
	cvtss2sd	0(%rbp,%rax,4), %xmm0
	movb	$1, %al
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 40
	leaq	.LC3(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%r12
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE3768:
	.size	_ZL8printRowiPfi, .-_ZL8printRowiPfi
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3773:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3773:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1
.LC4:
	.string	"  ...\n"
	.text
	.type	_ZL11printMatrixPfii.constprop.0, @function
_ZL11printMatrixPfii.constprop.0:
.LFB4500:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%esi, %ebp
	movl	%esi, %edx
	movq	%rdi, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	xorl	%edi, %edi
	pushq	%rax
	.cfi_def_cfa_offset 32
	call	_ZL8printRowiPfi
	movl	%ebp, %edx
	movq	%rbx, %rsi
	movl	$1, %edi
	call	_ZL8printRowiPfi
	movl	%ebp, %edx
	movq	%rbx, %rsi
	movl	$2, %edi
	call	_ZL8printRowiPfi
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	%ebp, %edx
	movq	%rbx, %rsi
	movl	$98, %edi
	call	_ZL8printRowiPfi
	popq	%rcx
	.cfi_def_cfa_offset 24
	movl	%ebp, %edx
	movq	%rbx, %rsi
	movl	$99, %edi
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_ZL8printRowiPfi
	.cfi_endproc
.LFE4500:
	.size	_ZL11printMatrixPfii.constprop.0, .-_ZL11printMatrixPfii.constprop.0
	.type	_ZL39__device_stub__Z15getDistance_gpuPfS_iiPfS_ii, @function
_ZL39__device_stub__Z15getDistance_gpuPfS_iiPfS_ii:
.LFB3797:
	.cfi_startproc
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L6
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_ZL15getDistance_gpuPfS_ii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L6:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3797:
	.size	_ZL39__device_stub__Z15getDistance_gpuPfS_iiPfS_ii, .-_ZL39__device_stub__Z15getDistance_gpuPfS_iiPfS_ii
	.type	_ZL15getDistance_gpuPfS_ii, @function
_ZL15getDistance_gpuPfS_ii:
.LFB3798:
	.cfi_startproc
	endbr64
	jmp	_ZL39__device_stub__Z15getDistance_gpuPfS_iiPfS_ii
	.cfi_endproc
.LFE3798:
	.size	_ZL15getDistance_gpuPfS_ii, .-_ZL15getDistance_gpuPfS_ii
	.type	_ZL34__device_stub__Z10argMin_gpuPfPiiiPfPiii, @function
_ZL34__device_stub__Z10argMin_gpuPfPiiiPfPiii:
.LFB3795:
	.cfi_startproc
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L12
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_ZL10argMin_gpuPfPiii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L12:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3795:
	.size	_ZL34__device_stub__Z10argMin_gpuPfPiiiPfPiii, .-_ZL34__device_stub__Z10argMin_gpuPfPiiiPfPiii
	.type	_ZL10argMin_gpuPfPiii, @function
_ZL10argMin_gpuPfPiii:
.LFB3796:
	.cfi_startproc
	endbr64
	jmp	_ZL34__device_stub__Z10argMin_gpuPfPiiiPfPiii
	.cfi_endproc
.LFE3796:
	.size	_ZL10argMin_gpuPfPiii, .-_ZL10argMin_gpuPfPiii
	.globl	_Z11getDistancePfS_iiii
	.type	_Z11getDistancePfS_iiii, @function
_Z11getDistancePfS_iiii:
.LFB3766:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edx, %r13d
	movl	%ecx, %edx
	movl	%r9d, %ecx
	imull	%edx, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rsi, %r12
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	xorps	%xmm0, %xmm0
	movl	%r8d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%r9d, %ebx
	movslq	%ecx, %rcx
	pushq	%r10
	.cfi_def_cfa_offset 48
	leaq	(%rdi,%rcx,4), %rsi
	movl	%r8d, %ecx
	imull	%edx, %ecx
	movslq	%ecx, %rcx
	leaq	(%rdi,%rcx,4), %rcx
.L18:
	cmpl	%eax, %edx
	jle	.L21
	movss	(%rsi,%rax,4), %xmm1
	subss	(%rcx,%rax,4), %xmm1
	cvtss2sd	%xmm0, %xmm0
	incq	%rax
	cvtss2sd	%xmm1, %xmm1
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	jmp	.L18
.L21:
	call	sqrtf@PLT
	imull	%r13d, %ebx
	addl	%ebp, %ebx
	movslq	%ebx, %rbx
	movss	%xmm0, (%r12,%rbx,4)
	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
.LFE3766:
	.size	_Z11getDistancePfS_iiii, .-_Z11getDistancePfS_iiii
	.globl	_Z6argMinPfPiiii
	.type	_Z6argMinPfPiiii, @function
_Z6argMinPfPiiii:
.LFB3767:
	.cfi_startproc
	endbr64
	movl	%edx, %eax
	movss	.LC6(%rip), %xmm0
	orl	$-1, %ecx
	imull	%r8d, %eax
	cltq
	leaq	(%rdi,%rax,4), %rdi
	xorl	%eax, %eax
.L23:
	cmpl	%eax, %edx
	jle	.L28
	movss	(%rdi,%rax,4), %xmm1
	comiss	%xmm1, %xmm0
	minss	%xmm0, %xmm1
	cmova	%eax, %ecx
	movaps	%xmm1, %xmm0
	incq	%rax
	jmp	.L23
.L28:
	movslq	%r8d, %r8
	movl	%ecx, (%rsi,%r8,4)
	ret
	.cfi_endproc
.LFE3767:
	.size	_Z6argMinPfPiiii, .-_Z6argMinPfPiiii
	.section	.rodata.str1.1
.LC7:
	.string	"_Z15getDistance_gpuPfS_ii"
.LC8:
	.string	"_Z10argMin_gpuPfPiii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3800:
	.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	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_ZL15getDistance_gpuPfS_ii(%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	.LC8(%rip), %rdx
	orl	$-1, %r8d
	leaq	_ZL10argMin_gpuPfPiii(%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
.LFE3800:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1
.LC9:
	.string	"%d, %d, %d, %d\n"
.LC10:
	.string	"using (%d x %d) tiles.\n"
.LC11:
	.string	"Unable to allocate host memory\n"
.LC12:
	.string	"cudaMalloc((void **)&d_M, bytesForM)"
.LC13:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/goldenpartner/Face-recognition/master/mp3.cu"
.LC14:
	.string	"CUDA error: %s, line %d, %s: %s\n"
.LC15:
	.string	"cudaMalloc((void **)&d_P, bytesForP)"
.LC16:
	.string	"cudaMalloc((void **)&d_index, m*sizeof(int))"
.LC17:
	.string	"Loading matrices...\n"
.LC18:
	.string	"descriptor.txt"
.LC19:
	.string	"M =\n"
.LC20:
	.string	"cudaMemcpy(d_M, h_M, bytesForM, cudaMemcpyHostToDevice)"
.LC21:
	.string	"matMul called from host\n"
.LC22:
	.string	"cudaDeviceSynchronize()"
.LC23:
	.string	"cudaMemcpy(h_P, d_P, bytesForP, cudaMemcpyDeviceToHost)"
.LC24:
	.string	"cudaMemcpy(index, d_index, m*sizeof(int), cudaMemcpyDeviceToHost)"
.LC25:
	.string	" product received from host\n"
.LC26:
	.string	"P =\n"
.LC27:
	.string	"matrix.txt"
.LC29:
	.string	" "
.LC30:
	.string	"cudaFree(d_M)"
.LC31:
	.string	"cudaFree(d_P)"
.LC32:
	.string	"cudaFree(d_index)"
.LC33:
	.string	"cudaDeviceReset()"
.LC34:
	.string	"Done\n"
.LC35:
	.string	"Pause"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3770:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3770
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	$8, %ecx
	movl	$8, %edx
	movl	$2, %edi
	movl	$1, %r9d
	movl	$1, %r8d
	leaq	.LC9(%rip), %rsi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$2184, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
.LEHB0:
	call	__printf_chk@PLT
	movl	$16, %ecx
	movl	$16, %edx
	xorl	%eax, %eax
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$400, %edi
	call	_Znam@PLT
	movl	$51200, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movl	$40000, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movq	%rax, -2192(%rbp)
	testq	%rbx, %rbx
	je	.L66
	testq	%rax, %rax
	jne	.L32
.L66:
	movq	stderr(%rip), %rdi
	leaq	.LC11(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %eax
	jmp	.L31
.L32:
	leaq	-2168(%rbp), %rdi
	movl	$51200, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L35
	call	cudaGetErrorString@PLT
	leaq	.LC12(%rip), %r9
	pushq	%r15
	movl	$178, %r8d
	pushq	%rax
	jmp	.L73
.L35:
	leaq	-2160(%rbp), %rdi
	movl	$40000, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L36
	call	cudaGetErrorString@PLT
	pushq	%r14
	leaq	.LC15(%rip), %r9
	movl	$179, %r8d
	pushq	%rax
.L73:
	movq	stderr(%rip), %rdi
	leaq	.LC13(%rip), %rcx
	leaq	.LC14(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L36:
	leaq	-2152(%rbp), %rdi
	movl	$400, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L37
	call	cudaGetErrorString@PLT
	leaq	.LC16(%rip), %r9
	pushq	%r13
	movl	$180, %r8d
	pushq	%rax
	jmp	.L73
.L37:
	movl	$20, %edx
	leaq	.LC17(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT
	leaq	-1096(%rbp), %rax
	movq	%rax, %rdi
	movq	%rax, -2200(%rbp)
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE0:
	leaq	-576(%rbp), %rax
	movq	%rax, %rdi
	movq	%rax, -2216(%rbp)
.LEHB1:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE1:
	movq	-2200(%rbp), %rdi
	movl	$8, %edx
	leaq	.LC18(%rip), %rsi
.LEHB2:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	movq	%rbx, %r12
	leaq	51200(%rbx), %r14
.L38:
	movq	-2200(%rbp), %rdi
	movq	%r12, %rsi
	call	_ZNSi10_M_extractIfEERSiRT_@PLT
	addq	$4, %r12
	cmpq	%r14, %r12
	jne	.L38
	movq	-2200(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv@PLT
	leaq	.LC19(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$128, %esi
	movq	%rbx, %rdi
	call	_ZL11printMatrixPfii.constprop.0
	movq	-2168(%rbp), %rdi
	movl	$1, %ecx
	movl	$51200, %edx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L39
	call	cudaGetErrorString@PLT
	pushq	%r12
	leaq	.LC20(%rip), %r9
	movl	$197, %r8d
	pushq	%rax
.L80:
	movq	stderr(%rip), %rdi
	leaq	.LC13(%rip), %rcx
	leaq	.LC14(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	.cfi_escape 0x2e,0x10
	call	__fprintf_chk@PLT
.L72:
	popq	%r11
	movl	$1, %edi
	popq	%rbx
	call	exit@PLT
.L39:
	movabsq	$30064771079, %rax
	movl	$2, %edi
	leaq	.LC21(%rip), %rsi
	movl	$1, -2136(%rbp)
	movq	%rax, -2144(%rbp)
	movabsq	$68719476752, %rax
	movq	%rax, -2132(%rbp)
	xorl	%eax, %eax
	movl	$1, -2124(%rbp)
	.cfi_escape 0x2e,0
	call	__printf_chk@PLT
	movl	-2124(%rbp), %ecx
	movq	-2132(%rbp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	-2144(%rbp), %rdi
	movl	-2136(%rbp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L40
	movq	-2160(%rbp), %rsi
	movl	$128, %ecx
	movl	$100, %edx
	movq	-2168(%rbp), %rdi
	call	_ZL39__device_stub__Z15getDistance_gpuPfS_iiPfS_ii
.L40:
	movl	-2124(%rbp), %ecx
	movq	-2132(%rbp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	-2144(%rbp), %rdi
	movl	-2136(%rbp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L41
	movq	-2152(%rbp), %rsi
	movl	$128, %ecx
	movl	$100, %edx
	movq	-2160(%rbp), %rdi
	call	_ZL34__device_stub__Z10argMin_gpuPfPiiiPfPiii
.L41:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L42
	call	cudaGetErrorString@PLT
	leaq	.LC22(%rip), %r9
	pushq	%r10
	movl	$207, %r8d
	pushq	%rax
	jmp	.L80
.L42:
	movq	-2160(%rbp), %rsi
	movl	$2, %ecx
	movl	$40000, %edx
	movq	-2192(%rbp), %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L44
	call	cudaGetErrorString@PLT
	movl	$210, %r8d
	pushq	%r9
	leaq	.LC23(%rip), %r9
	pushq	%rax
	jmp	.L80
.L44:
	movq	-2152(%rbp), %rsi
	movl	$2, %ecx
	movl	$400, %edx
	movq	%r13, %rdi
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L45
	call	cudaGetErrorString@PLT
	leaq	.LC24(%rip), %r9
	pushq	%r8
	movl	$211, %r8d
	pushq	%rax
	jmp	.L80
.L45:
	leaq	.LC25(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC26(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	-2192(%rbp), %rdi
	movl	$100, %esi
	call	_ZL11printMatrixPfii.constprop.0
	leaq	-2120(%rbp), %rax
	movq	%rax, %rdi
	movq	%rax, -2208(%rbp)
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE2:
	leaq	-1608(%rbp), %rax
	movq	%rax, %rdi
	movq	%rax, -2184(%rbp)
.LEHB3:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE3:
	movq	-2184(%rbp), %rdi
	movl	$16, %edx
	leaq	.LC27(%rip), %rsi
.LEHB4:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	xorl	%r14d, %r14d
.L46:
	imulq	$400, %r14, %r15
	movq	-2192(%rbp), %rax
	movl	$1, %r12d
	addq	%rax, %r15
.L49:
	movsd	.LC28(%rip), %xmm1
	cvtss2sd	-4(%r15,%r12,4), %xmm0
	comisd	%xmm0, %xmm1
	jbe	.L47
	movq	-2184(%rbp), %rdi
	movl	%r12d, %esi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	movl	$1, %edx
	leaq	.LC29(%rip), %rsi
	call	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT
.L47:
	incq	%r12
	cmpq	$101, %r12
	jne	.L49
	movq	-2184(%rbp), %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	incq	%r14
	cmpq	$100, %r14
	jne	.L46
	movq	-2184(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
	movq	-2168(%rbp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L51
	call	cudaGetErrorString@PLT
	leaq	.LC30(%rip), %r9
	pushq	%rdi
	movl	$249, %r8d
	pushq	%rax
	jmp	.L76
.L51:
	movq	-2160(%rbp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L52
	call	cudaGetErrorString@PLT
	leaq	.LC31(%rip), %r9
	pushq	%rsi
	movl	$250, %r8d
	pushq	%rax
	jmp	.L76
.L52:
	movq	-2152(%rbp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L53
	call	cudaGetErrorString@PLT
	leaq	.LC32(%rip), %r9
	pushq	%rcx
	movl	$251, %r8d
	pushq	%rax
	jmp	.L76
.L53:
	movq	%rbx, %rdi
	call	free@PLT
	movq	-2192(%rbp), %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	call	cudaDeviceReset@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L54
	call	cudaGetErrorString@PLT
	pushq	%rdx
	leaq	.LC33(%rip), %r9
	movl	$261, %r8d
	pushq	%rax
.L76:
	movq	stderr(%rip), %rdi
	leaq	.LC13(%rip), %rcx
	leaq	.LC14(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	.cfi_escape 0x2e,0x10
	call	__fprintf_chk@PLT
	jmp	.L72
.L54:
	leaq	.LC34(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	.cfi_escape 0x2e,0
	call	__printf_chk@PLT
	leaq	.LC35(%rip), %rdi
	call	system@PLT
.LEHE4:
	movq	-2184(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	-2208(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	leaq	-576(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	leaq	-1096(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	xorl	%eax, %eax
	jmp	.L31
.L65:
	endbr64
	movq	%rax, %rbx
.L55:
	movq	-2184(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L56
.L64:
	endbr64
	movq	%rax, %rbx
.L56:
	movq	-2208(%rbp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L57
.L63:
	endbr64
	movq	%rax, %rbx
.L57:
	movq	-2216(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L58
.L62:
	endbr64
	movq	%rax, %rbx
.L58:
	movq	-2200(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L74
	movq	%rbx, %rdi
.LEHB5:
	call	_Unwind_Resume@PLT
.LEHE5:
.L31:
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L60
.L74:
	call	__stack_chk_fail@PLT
.L60:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3770:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3770:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3770-.LLSDACSB3770
.LLSDACSB3770:
	.uleb128 .LEHB0-.LFB3770
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3770
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L62-.LFB3770
	.uleb128 0
	.uleb128 .LEHB2-.LFB3770
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L63-.LFB3770
	.uleb128 0
	.uleb128 .LEHB3-.LFB3770
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L64-.LFB3770
	.uleb128 0
	.uleb128 .LEHB4-.LFB3770
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L65-.LFB3770
	.uleb128 0
	.uleb128 .LEHB5-.LFB3770
	.uleb128 .LEHE5-.LEHB5
	.uleb128 0
	.uleb128 0
.LLSDACSE3770:
	.section	.text.startup
	.size	main, .-main
	.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.cst4,"aM",@progbits,4
	.align 4
.LC6:
	.long	1203982336
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC28:
	.long	858993459
	.long	1070805811
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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:

/*
 *                         Tiled Matrix Multiplication
 *             (MP2, Fall 2014, GPU Programming/Auburn University)
 *
 *   Compile with -DTILE_WIDTH=16 (for example) to change the tile size.
 *   Compile with -DSEED=12 (for example) to seed the random number generator.
 */

 #include <assert.h>
 #include <hip/hip_runtime.h>
 #include <stdio.h>
 #include <math.h>
 #include <iostream>
 #include <fstream>
 /* Usage message displayed when invalid command line arguments are supplied */
 #define USAGE \
     "MP2 generates a random (m x k) matrix M and (k x n) matrix N\n" \
     "and multiplies M by N using tiled matrix multiplication.\n" \
     "The values of m, k, and n must be >= 1.\n" \
     "\n" \
     "Usage: mp2 m k n\n"
 
 /* Tile size -- define here if not defined using the -D compiler flag */
 #ifndef TILE_WIDTH
 #  define TILE_WIDTH 16
 #endif
 
 /* Seed for the random number generator -- define here if not using -D */
 #ifndef SEED
 #  define SEED 1
 #endif
 
 /* Maximum difference allowed between the GPU and CPU result matrices */
 #define EPSILON 1e-2
 
 /* If a CUDA call fails, display an error message and exit */
 #define CUDA_CHECK(e) { \
     hipError_t err = (e); \
     if (err != hipSuccess) \
     { \
         fprintf(stderr, "CUDA error: %s, line %d, %s: %s\n", \
             __FILE__, __LINE__, #e, hipGetErrorString(err)); \
         exit(EXIT_FAILURE); \
     } \
 }
 
 /* assert() is only supported on devices of compute capability >= 2.0 */
 #if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 200)
 #  undef  assert
 #  define assert(arg)
 #endif

void getDistance(float *h_M, float *h_P, int m, int k, int col, int row){
    float expected = 0.0;
    for (int i = 0; i < k; i++)
    {
        expected += pow(h_M[row*k+i] - h_M[col*k+i], 2);
    }
    expected = sqrt(expected);
    h_P[row*m+col] = expected;

 }
void argMin(float* h_M, int* result, int m, int k, int row){
    float minimum = 1e5;
    int pos = -1;
    for(int col = 0; col < m; col++){
        if (h_M[row*m+col] < minimum){
            pos = col;
            minimum = h_M[row*m+col];
        }
    }
    result[row] = pos;
}
 __global__ static void argMin_gpu(float* h_M, int* result, int m, int k){
    assert(blockDim.x == TILE_WIDTH && blockDim.y == TILE_WIDTH);

    int row = blockIdx.y * TILE_WIDTH + threadIdx.y;
    if(row >= m)
        return;
    float minimum = 1e5;
    int pos = -1;
    for(int col = 0; col < m; col++){
        if (h_M[row*m+col] < minimum){
            pos = col;
            minimum = h_M[row*m+col];
        }
    }
    result[row] = pos;
 }
 __global__ static void getDistance_gpu(float *d_M, float *d_P, int m, int k) {
    assert(blockDim.x == TILE_WIDTH && blockDim.y == TILE_WIDTH);

    int row = blockIdx.y * TILE_WIDTH + threadIdx.y;
    int col= blockIdx.x  * TILE_WIDTH + threadIdx.x;
    if(row >= m || col >= m)
        return;
    if(row == col){
        d_P[row*m+col] = 100;
        return;
    }

    float expected = 0.0;
    for (int i = 0; i < k; i++)
    {
        expected += pow(d_M[row*k+i] - d_M[col*k+i], 2);
    }
    expected = sqrt(expected);
    d_P[row*m+col] = expected;
}

 /* Displays one row of the given matrix */
 static void printRow(int row, float *matrix, int cols)
 {
     printf("[");
     if (cols >= 1) printf(" %3.3f", matrix[row*cols+0]);
     if (cols >= 2) printf(" %3.3f", matrix[row*cols+1]);
     if (cols >= 3) printf(" %3.3f", matrix[row*cols+2]);
     if (cols >= 6) printf(" ...");
     if (cols >= 5) printf(" %3.3f", matrix[row*cols+(cols-2)]);
     if (cols >= 4) printf(" %3.3f", matrix[row*cols+(cols-1)]);
     printf(" ]\n");
 }
 
 /* Displays the given matrix */
 static void printMatrix(float *matrix, int rows, int cols)
 {
     if (rows >= 1) printRow(0, matrix, cols);
     if (rows >= 2) printRow(1, matrix, cols);
     if (rows >= 3) printRow(2, matrix, cols);
     if (rows >= 6) printf("  ...\n");
     if (rows >= 5) printRow(rows-2, matrix, cols);
     if (rows >= 4) printRow(rows-1, matrix, cols);
 }
 
 /* Program entrypoint.  Invoke with three command line arguments: m k n */
 int main()
 {

    printf("%d, %d, %d, %d\n", sizeof(long), sizeof(long long), sizeof(bool), sizeof(char));
     /* Get command line arguments; save as m, k, and n */
     int m = 100;
     int k = 128;

     if (m < 1 || k < 1)
     {
         fprintf(stderr, USAGE);
         fprintf(stderr, "Invalid value for m or k (%d, %d)\n",
             m, k);
         return EXIT_FAILURE;
     }
     printf("using (%d x %d) tiles.\n", TILE_WIDTH, TILE_WIDTH);
 
     /********************************************/
     /* M is (m x k), P is (m x m) */
     /********************************************/
 
     /* Compute number of bytes needed to stores matrices M and P */
     size_t bytesForM = m * k * sizeof(float);
     size_t bytesForP = m * m * sizeof(float);
 
     /* Allocate host memory for matrices */
     float *h_M, *h_P;
     float *result = new float[m*m];
     int *index = new int[m];

     h_M = (float *)malloc(bytesForM);
     h_P = (float *)malloc(bytesForP);

     if (h_M == NULL || h_P == NULL)
     {
         fprintf(stderr, "Unable to allocate host memory\n");
         return EXIT_FAILURE;
     }
 
     /* Allocate device memory for matrices */
     float *d_M, *d_P;
     int *d_index;
     CUDA_CHECK(hipMalloc((void **)&d_M, bytesForM));
     CUDA_CHECK(hipMalloc((void **)&d_P, bytesForP));
     CUDA_CHECK(hipMalloc((void **)&d_index, m*sizeof(int)));
 
     /* Fill M (on host) */
 
     


     std::cout << "Loading matrices...\n";
     std::ifstream in1, in2;
	in1.open("descriptor.txt");
	for (int i = 0; i < m*k; ++i)
		in1 >> h_M[i];
    in1.close();

    printf("M =\n"); printMatrix(h_M, m, k);

     /* Copy M to device global memory */
     CUDA_CHECK(hipMemcpy(d_M, h_M, bytesForM, hipMemcpyHostToDevice));
 
     /* Launch the CUDA kernel */
     dim3 dimGrid((m+TILE_WIDTH-1)/TILE_WIDTH, (m+TILE_WIDTH-1)/TILE_WIDTH);
     dim3 dimBlock(TILE_WIDTH, TILE_WIDTH);
 
    printf("matMul called from host\n");
     
     getDistance_gpu<<<dimGrid, dimBlock>>>(d_M, d_P, m, k);
     argMin_gpu<<<dimGrid, dimBlock>>>(d_P, d_index, m, k);
     CUDA_CHECK(hipDeviceSynchronize());
 
     /* Copy result matrix from device global memory back to host memory */
     CUDA_CHECK(hipMemcpy(h_P, d_P, bytesForP, hipMemcpyDeviceToHost));
     CUDA_CHECK(hipMemcpy(index, d_index, m*sizeof(int), hipMemcpyDeviceToHost));
           
    printf(" product received from host\n");

    printf("P =\n"); printMatrix(h_P, m, m);

     std::ofstream out, out2;
     out2.open("matrix.txt");
     for (int i = 0; i < 100; i++){
        for (int j = 0; j < m; j++){
            if (h_P[i*m+j] < 0.3)
                out2 << j+1 << " ";
        }
        out2 << std::endl;
        
     }
     out2.close();

    /*
     
     for (int row = 0; row < m; row++)
     {
         for (int col = 0; col < m; col++)
         {
            getDistance(h_M, result, m, k, col, row);
         }
    }
     
     printf("\nExpected matrix:\n");
     printMatrix(result, m, m);

     printf("\n");
     for (int i = 0; i < m; i++){
        printf("%d ", index[i]);
    }
    printf("\n");
    */
     /* Free device global memory */
     CUDA_CHECK(hipFree(d_M));
     CUDA_CHECK(hipFree(d_P));
     CUDA_CHECK(hipFree(d_index));

 
     /* Free host memory */
     free(h_M);
     free(h_P);
     free(index);
     free(result);
 
     /* Reset the device (unnecessary if not profiling, but good practice) */
     CUDA_CHECK(hipDeviceReset());
 
     printf("Done\n");
     system("Pause");
     return EXIT_SUCCESS;
 }
 
	.text
	.file	"mp3.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z11getDistancePfS_iiii         # -- Begin function _Z11getDistancePfS_iiii
	.type	_Z11getDistancePfS_iiii,@function
_Z11getDistancePfS_iiii:                # @_Z11getDistancePfS_iiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r9d, %ebx
	movl	%r8d, %ebp
	movl	%edx, %r15d
	movq	%rsi, %r14
	xorps	%xmm1, %xmm1
	xorps	%xmm0, %xmm0
	testl	%ecx, %ecx
	jle	.LBB0_3
# %bb.1:                                # %.lr.ph
	movl	%ebx, %eax
	imull	%ecx, %eax
	movl	%ebp, %edx
	imull	%ecx, %edx
	movslq	%eax, %rsi
	movslq	%edx, %rdx
	movl	%ecx, %eax
	leaq	(%rdi,%rsi,4), %rcx
	leaq	(%rdi,%rdx,4), %rdx
	xorl	%esi, %esi
.LBB0_2:                                # =>This Inner Loop Header: Depth=1
	movss	(%rcx,%rsi,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	subss	(%rdx,%rsi,4), %xmm2
	cvtss2sd	%xmm2, %xmm2
	mulsd	%xmm2, %xmm2
	cvtss2sd	%xmm0, %xmm0
	addsd	%xmm2, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	incq	%rsi
	cmpq	%rsi, %rax
	jne	.LBB0_2
.LBB0_3:                                # %._crit_edge
	ucomiss	%xmm1, %xmm0
	jb	.LBB0_5
# %bb.4:
	sqrtss	%xmm0, %xmm0
	jmp	.LBB0_6
.LBB0_5:                                # %call.sqrt
	callq	sqrtf
.LBB0_6:                                # %._crit_edge.split
	imull	%r15d, %ebx
	addl	%ebp, %ebx
	movslq	%ebx, %rax
	movss	%xmm0, (%r14,%rax,4)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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_end0:
	.size	_Z11getDistancePfS_iiii, .Lfunc_end0-_Z11getDistancePfS_iiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z6argMinPfPiiii
.LCPI1_0:
	.long	0x47c35000                      # float 1.0E+5
	.text
	.globl	_Z6argMinPfPiiii
	.type	_Z6argMinPfPiiii,@function
_Z6argMinPfPiiii:                       # @_Z6argMinPfPiiii
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB1_1
# %bb.3:                                # %.lr.ph
	movl	%r8d, %eax
	imull	%edx, %eax
	cltq
	movl	%edx, %ecx
	leaq	(%rdi,%rax,4), %rdx
	movss	.LCPI1_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movl	$-1, %eax
	xorl	%edi, %edi
.LBB1_4:                                # =>This Inner Loop Header: Depth=1
	movss	(%rdx,%rdi,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm1, %xmm0
	cmoval	%edi, %eax
	minss	%xmm0, %xmm1
	incq	%rdi
	movaps	%xmm1, %xmm0
	cmpq	%rdi, %rcx
	jne	.LBB1_4
	jmp	.LBB1_2
.LBB1_1:
	movl	$-1, %eax
.LBB1_2:                                # %._crit_edge
	movslq	%r8d, %rcx
	movl	%eax, (%rsi,%rcx,4)
	retq
.Lfunc_end1:
	.size	_Z6argMinPfPiiii, .Lfunc_end1-_Z6argMinPfPiiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI2_0:
	.quad	0x3fd3333333333333              # double 0.29999999999999999
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$2120, %rsp                     # imm = 0x848
	.cfi_def_cfa_offset 2176
	.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	$.L.str, %edi
	movl	$8, %esi
	movl	$8, %edx
	movl	$1, %ecx
	movl	$1, %r8d
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.3, %edi
	movl	$16, %esi
	movl	$16, %edx
	xorl	%eax, %eax
	callq	printf
	movl	$40000, %edi                    # imm = 0x9C40
	callq	_Znam
	movq	%rax, %r14
	movl	$400, %edi                      # imm = 0x190
	callq	_Znam
	movq	%rax, %r12
	movl	$51200, %edi                    # imm = 0xC800
	callq	malloc
	movq	%rax, %r15
	movl	$40000, %edi                    # imm = 0x9C40
	callq	malloc
	testq	%r15, %r15
	je	.LBB2_50
# %bb.1:
	movq	%rax, %rbx
	testq	%rax, %rax
	je	.LBB2_50
# %bb.2:
	leaq	32(%rsp), %rdi
	movl	$51200, %esi                    # imm = 0xC800
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_51
# %bb.3:
	leaq	8(%rsp), %rdi
	movl	$40000, %esi                    # imm = 0x9C40
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_52
# %bb.4:
	leaq	24(%rsp), %rdi
	movl	$400, %esi                      # imm = 0x190
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_53
# %bb.5:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.10, %esi
	movl	$20, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	leaq	568(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev
.Ltmp0:
	leaq	1600(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev
.Ltmp1:
# %bb.6:
.Ltmp3:
	movq	%rbx, 16(%rsp)                  # 8-byte Spill
	leaq	568(%rsp), %rdi
	movl	$.L.str.11, %esi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp4:
# %bb.7:                                # %.preheader156.preheader
	xorl	%ebx, %ebx
	leaq	568(%rsp), %r13
.LBB2_8:                                # %.preheader156
                                        # =>This Inner Loop Header: Depth=1
	leaq	(%r15,%rbx), %rsi
.Ltmp5:
	movq	%r13, %rdi
	callq	_ZNSi10_M_extractIfEERSiRT_
.Ltmp6:
# %bb.9:                                # %_ZNSirsERf.exit
                                        #   in Loop: Header=BB2_8 Depth=1
	addq	$4, %rbx
	cmpq	$51200, %rbx                    # imm = 0xC800
	jne	.LBB2_8
# %bb.10:
.Ltmp8:
	leaq	568(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv
.Ltmp9:
# %bb.11:
	movl	$.Lstr, %edi
	callq	puts@PLT
	movq	%r15, %rdi
	movl	$128, %esi
	callq	_ZL11printMatrixPfii
	movq	32(%rsp), %rdi
.Ltmp11:
	movl	$51200, %edx                    # imm = 0xC800
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp12:
	movq	16(%rsp), %rbx                  # 8-byte Reload
# %bb.12:
	testl	%eax, %eax
	jne	.LBB2_54
# %bb.13:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
.Ltmp16:
	movabsq	$30064771079, %rdi              # imm = 0x700000007
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp17:
# %bb.14:
	testl	%eax, %eax
	jne	.LBB2_16
# %bb.15:
	movq	32(%rsp), %rdi
	movq	8(%rsp), %rsi
.Ltmp18:
	movl	$100, %edx
	movl	$128, %ecx
	callq	_ZL30__device_stub__getDistance_gpuPfS_ii
.Ltmp19:
.LBB2_16:
.Ltmp20:
	movabsq	$30064771079, %rdi              # imm = 0x700000007
	movabsq	$68719476752, %rdx              # imm = 0x1000000010
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp21:
# %bb.17:
	testl	%eax, %eax
	jne	.LBB2_19
# %bb.18:
	movq	8(%rsp), %rdi
	movq	24(%rsp), %rsi
.Ltmp22:
	movl	$100, %edx
	movl	$128, %ecx
	callq	_ZL25__device_stub__argMin_gpuPfPiii
.Ltmp23:
.LBB2_19:
.Ltmp25:
	callq	hipDeviceSynchronize
.Ltmp26:
# %bb.20:
	testl	%eax, %eax
	jne	.LBB2_56
# %bb.21:
	movq	8(%rsp), %rsi
.Ltmp30:
	movl	$40000, %edx                    # imm = 0x9C40
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp31:
# %bb.22:
	testl	%eax, %eax
	jne	.LBB2_58
# %bb.23:
	movq	24(%rsp), %rsi
.Ltmp35:
	movl	$400, %edx                      # imm = 0x190
	movq	%r12, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp36:
# %bb.24:
	testl	%eax, %eax
	jne	.LBB2_60
# %bb.25:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movq	%rbx, %rdi
	movl	$100, %esi
	callq	_ZL11printMatrixPfii
.Ltmp40:
	leaq	1088(%rsp), %r13
	movq	%r13, %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev
.Ltmp41:
# %bb.26:
.Ltmp43:
	leaq	56(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev
.Ltmp44:
# %bb.27:
.Ltmp46:
	movq	%r14, 48(%rsp)                  # 8-byte Spill
	leaq	56(%rsp), %rbp
	movl	$.L.str.20, %esi
	movq	%rbp, %rdi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp47:
# %bb.28:                               # %.preheader.preheader
	movq	%r12, 40(%rsp)                  # 8-byte Spill
	xorl	%ebx, %ebx
	movq	16(%rsp), %r12                  # 8-byte Reload
.LBB2_29:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_30 Depth 2
	xorl	%r14d, %r14d
.LBB2_30:                               #   Parent Loop BB2_29 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r12,%r14,4), %xmm0
	movsd	.LCPI2_0(%rip), %xmm1           # xmm1 = mem[0],zero
	ucomisd	%xmm0, %xmm1
	jbe	.LBB2_33
# %bb.31:                               #   in Loop: Header=BB2_30 Depth=2
	leal	1(%r14), %esi
.Ltmp48:
	movq	%rbp, %rdi
	callq	_ZNSolsEi
.Ltmp49:
# %bb.32:                               #   in Loop: Header=BB2_30 Depth=2
.Ltmp50:
	movl	$.L.str.21, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp51:
.LBB2_33:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
                                        #   in Loop: Header=BB2_30 Depth=2
	incq	%r14
	cmpq	$100, %r14
	jne	.LBB2_30
# %bb.34:                               #   in Loop: Header=BB2_29 Depth=1
	movq	56(%rsp), %rax
	movq	-24(%rax), %rdi
	addq	%rbp, %rdi
.Ltmp53:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp54:
# %bb.35:                               # %.noexc
                                        #   in Loop: Header=BB2_29 Depth=1
.Ltmp55:
	movsbl	%al, %esi
	movq	%rbp, %rdi
	callq	_ZNSo3putEc
.Ltmp56:
# %bb.36:                               # %.noexc147
                                        #   in Loop: Header=BB2_29 Depth=1
.Ltmp57:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp58:
# %bb.37:                               # %_ZNSolsEPFRSoS_E.exit
                                        #   in Loop: Header=BB2_29 Depth=1
	incq	%rbx
	addq	$400, %r12                      # imm = 0x190
	cmpq	$100, %rbx
	jne	.LBB2_29
# %bb.38:
.Ltmp60:
	leaq	56(%rsp), %rbp
	movq	%rbp, %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp61:
	movq	40(%rsp), %r14                  # 8-byte Reload
# %bb.39:
	movq	32(%rsp), %rdi
.Ltmp62:
	callq	hipFree
.Ltmp63:
	movq	48(%rsp), %rbx                  # 8-byte Reload
# %bb.40:
	testl	%eax, %eax
	jne	.LBB2_62
# %bb.41:
	movq	8(%rsp), %rdi
.Ltmp67:
	callq	hipFree
.Ltmp68:
# %bb.42:
	testl	%eax, %eax
	jne	.LBB2_64
# %bb.43:
	movq	24(%rsp), %rdi
.Ltmp72:
	callq	hipFree
.Ltmp73:
# %bb.44:
	testl	%eax, %eax
	jne	.LBB2_66
# %bb.45:
	movq	%r15, %rdi
	callq	free
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%r14, %rdi
	callq	free
	movq	%rbx, %rdi
	callq	free
.Ltmp77:
	callq	hipDeviceReset
.Ltmp78:
# %bb.46:
	testl	%eax, %eax
	jne	.LBB2_68
# %bb.47:
	movl	$.Lstr.4, %edi
	callq	puts@PLT
.Ltmp82:
	movl	$.L.str.27, %edi
	callq	system
.Ltmp83:
# %bb.48:
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rbx
	leaq	64(%rsp), %rdi
	movq	%rbx, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %r14
	movq	-24(%rbx), %rax
	movq	%r14, 56(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	movl	$248, %r15d
	addq	%r15, %rbp
	movq	%rbp, %rdi
	callq	_ZNSt8ios_baseD2Ev
	leaq	1096(%rsp), %rdi
	movq	%rbx, -8(%rdi)
	movq	-24(%rbx), %rax
	movq	%r14, 1088(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	addq	%r15, %r13
	movq	%r13, %rdi
	callq	_ZNSt8ios_baseD2Ev
	leaq	1600(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	leaq	568(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	xorl	%eax, %eax
.LBB2_49:
	addq	$2120, %rsp                     # imm = 0x848
	.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
.LBB2_50:
	.cfi_def_cfa_offset 2176
	movq	stderr(%rip), %rcx
	movl	$.L.str.4, %edi
	movl	$31, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movl	$1, %eax
	jmp	.LBB2_49
.LBB2_51:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.7, %r8d
	movq	%rbx, %rdi
	movl	$178, %ecx
	jmp	.LBB2_70
.LBB2_52:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.8, %r8d
	movq	%rbx, %rdi
	movl	$179, %ecx
	jmp	.LBB2_70
.LBB2_53:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.9, %r8d
	movq	%rbx, %rdi
	movl	$180, %ecx
	jmp	.LBB2_70
.LBB2_54:
	movq	stderr(%rip), %rbx
.Ltmp13:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp14:
# %bb.55:
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.13, %r8d
	movq	%rbx, %rdi
	movl	$197, %ecx
	jmp	.LBB2_70
.LBB2_56:
	movq	stderr(%rip), %rbx
.Ltmp27:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp28:
# %bb.57:
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.15, %r8d
	movq	%rbx, %rdi
	movl	$207, %ecx
	jmp	.LBB2_70
.LBB2_58:
	movq	stderr(%rip), %rbx
.Ltmp32:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp33:
# %bb.59:
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.16, %r8d
	movq	%rbx, %rdi
	movl	$210, %ecx
	jmp	.LBB2_70
.LBB2_60:
	movq	stderr(%rip), %rbx
.Ltmp37:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp38:
# %bb.61:
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.17, %r8d
	movq	%rbx, %rdi
	movl	$211, %ecx
	jmp	.LBB2_70
.LBB2_62:
	movq	stderr(%rip), %rbx
.Ltmp64:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp65:
# %bb.63:
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.22, %r8d
	movq	%rbx, %rdi
	movl	$249, %ecx
	jmp	.LBB2_70
.LBB2_64:
	movq	stderr(%rip), %rbx
.Ltmp69:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp70:
# %bb.65:
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.23, %r8d
	movq	%rbx, %rdi
	movl	$250, %ecx
	jmp	.LBB2_70
.LBB2_66:
	movq	stderr(%rip), %rbx
.Ltmp74:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp75:
# %bb.67:
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.24, %r8d
	movq	%rbx, %rdi
	movl	$251, %ecx
	jmp	.LBB2_70
.LBB2_68:
	movq	stderr(%rip), %rbx
.Ltmp79:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp80:
# %bb.69:
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	movl	$.L.str.25, %r8d
	movq	%rbx, %rdi
	movl	$261, %ecx                      # imm = 0x105
.LBB2_70:
	movq	%rax, %r9
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.LBB2_71:
.Ltmp45:
	movq	%rax, %rbx
	jmp	.LBB2_90
.LBB2_72:
.Ltmp42:
	jmp	.LBB2_83
.LBB2_73:
.Ltmp2:
	movq	%rax, %rbx
	jmp	.LBB2_92
.LBB2_74:
.Ltmp81:
	jmp	.LBB2_89
.LBB2_75:
.Ltmp76:
	jmp	.LBB2_89
.LBB2_76:
.Ltmp71:
	jmp	.LBB2_89
.LBB2_77:
.Ltmp66:
	jmp	.LBB2_89
.LBB2_78:
.Ltmp39:
	jmp	.LBB2_83
.LBB2_79:
.Ltmp34:
	jmp	.LBB2_83
.LBB2_80:
.Ltmp29:
	jmp	.LBB2_83
.LBB2_81:
.Ltmp15:
	jmp	.LBB2_83
.LBB2_82:
.Ltmp10:
	jmp	.LBB2_83
.LBB2_84:
.Ltmp24:
	jmp	.LBB2_83
.LBB2_85:
.Ltmp84:
	jmp	.LBB2_89
.LBB2_86:
.Ltmp7:
.LBB2_83:
	movq	%rax, %rbx
	jmp	.LBB2_91
.LBB2_87:
.Ltmp59:
	jmp	.LBB2_89
.LBB2_88:
.Ltmp52:
.LBB2_89:
	movq	%rax, %rbx
	leaq	56(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
.LBB2_90:
	leaq	1088(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
.LBB2_91:
	leaq	1600(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
.LBB2_92:
	leaq	568(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table2:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp10-.Lfunc_begin0          #     jumps to .Ltmp10
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp5-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp6-.Ltmp5                  #   Call between .Ltmp5 and .Ltmp6
	.uleb128 .Ltmp7-.Lfunc_begin0           #     jumps to .Ltmp7
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp8-.Lfunc_begin0           # >> Call Site 5 <<
	.uleb128 .Ltmp9-.Ltmp8                  #   Call between .Ltmp8 and .Ltmp9
	.uleb128 .Ltmp10-.Lfunc_begin0          #     jumps to .Ltmp10
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp11-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp12-.Ltmp11                #   Call between .Ltmp11 and .Ltmp12
	.uleb128 .Ltmp15-.Lfunc_begin0          #     jumps to .Ltmp15
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp16-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp23-.Ltmp16                #   Call between .Ltmp16 and .Ltmp23
	.uleb128 .Ltmp24-.Lfunc_begin0          #     jumps to .Ltmp24
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp25-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp26-.Ltmp25                #   Call between .Ltmp25 and .Ltmp26
	.uleb128 .Ltmp29-.Lfunc_begin0          #     jumps to .Ltmp29
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp30-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp31-.Ltmp30                #   Call between .Ltmp30 and .Ltmp31
	.uleb128 .Ltmp34-.Lfunc_begin0          #     jumps to .Ltmp34
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp35-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp36-.Ltmp35                #   Call between .Ltmp35 and .Ltmp36
	.uleb128 .Ltmp39-.Lfunc_begin0          #     jumps to .Ltmp39
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp40-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp41-.Ltmp40                #   Call between .Ltmp40 and .Ltmp41
	.uleb128 .Ltmp42-.Lfunc_begin0          #     jumps to .Ltmp42
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp43-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp44-.Ltmp43                #   Call between .Ltmp43 and .Ltmp44
	.uleb128 .Ltmp45-.Lfunc_begin0          #     jumps to .Ltmp45
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp46-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Ltmp47-.Ltmp46                #   Call between .Ltmp46 and .Ltmp47
	.uleb128 .Ltmp84-.Lfunc_begin0          #     jumps to .Ltmp84
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp48-.Lfunc_begin0          # >> Call Site 14 <<
	.uleb128 .Ltmp51-.Ltmp48                #   Call between .Ltmp48 and .Ltmp51
	.uleb128 .Ltmp52-.Lfunc_begin0          #     jumps to .Ltmp52
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp53-.Lfunc_begin0          # >> Call Site 15 <<
	.uleb128 .Ltmp58-.Ltmp53                #   Call between .Ltmp53 and .Ltmp58
	.uleb128 .Ltmp59-.Lfunc_begin0          #     jumps to .Ltmp59
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp60-.Lfunc_begin0          # >> Call Site 16 <<
	.uleb128 .Ltmp61-.Ltmp60                #   Call between .Ltmp60 and .Ltmp61
	.uleb128 .Ltmp84-.Lfunc_begin0          #     jumps to .Ltmp84
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp62-.Lfunc_begin0          # >> Call Site 17 <<
	.uleb128 .Ltmp63-.Ltmp62                #   Call between .Ltmp62 and .Ltmp63
	.uleb128 .Ltmp66-.Lfunc_begin0          #     jumps to .Ltmp66
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp67-.Lfunc_begin0          # >> Call Site 18 <<
	.uleb128 .Ltmp68-.Ltmp67                #   Call between .Ltmp67 and .Ltmp68
	.uleb128 .Ltmp71-.Lfunc_begin0          #     jumps to .Ltmp71
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp72-.Lfunc_begin0          # >> Call Site 19 <<
	.uleb128 .Ltmp73-.Ltmp72                #   Call between .Ltmp72 and .Ltmp73
	.uleb128 .Ltmp76-.Lfunc_begin0          #     jumps to .Ltmp76
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp77-.Lfunc_begin0          # >> Call Site 20 <<
	.uleb128 .Ltmp78-.Ltmp77                #   Call between .Ltmp77 and .Ltmp78
	.uleb128 .Ltmp81-.Lfunc_begin0          #     jumps to .Ltmp81
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp82-.Lfunc_begin0          # >> Call Site 21 <<
	.uleb128 .Ltmp83-.Ltmp82                #   Call between .Ltmp82 and .Ltmp83
	.uleb128 .Ltmp84-.Lfunc_begin0          #     jumps to .Ltmp84
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp83-.Lfunc_begin0          # >> Call Site 22 <<
	.uleb128 .Ltmp13-.Ltmp83                #   Call between .Ltmp83 and .Ltmp13
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp13-.Lfunc_begin0          # >> Call Site 23 <<
	.uleb128 .Ltmp14-.Ltmp13                #   Call between .Ltmp13 and .Ltmp14
	.uleb128 .Ltmp15-.Lfunc_begin0          #     jumps to .Ltmp15
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp27-.Lfunc_begin0          # >> Call Site 24 <<
	.uleb128 .Ltmp28-.Ltmp27                #   Call between .Ltmp27 and .Ltmp28
	.uleb128 .Ltmp29-.Lfunc_begin0          #     jumps to .Ltmp29
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp32-.Lfunc_begin0          # >> Call Site 25 <<
	.uleb128 .Ltmp33-.Ltmp32                #   Call between .Ltmp32 and .Ltmp33
	.uleb128 .Ltmp34-.Lfunc_begin0          #     jumps to .Ltmp34
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp37-.Lfunc_begin0          # >> Call Site 26 <<
	.uleb128 .Ltmp38-.Ltmp37                #   Call between .Ltmp37 and .Ltmp38
	.uleb128 .Ltmp39-.Lfunc_begin0          #     jumps to .Ltmp39
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp64-.Lfunc_begin0          # >> Call Site 27 <<
	.uleb128 .Ltmp65-.Ltmp64                #   Call between .Ltmp64 and .Ltmp65
	.uleb128 .Ltmp66-.Lfunc_begin0          #     jumps to .Ltmp66
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp69-.Lfunc_begin0          # >> Call Site 28 <<
	.uleb128 .Ltmp70-.Ltmp69                #   Call between .Ltmp69 and .Ltmp70
	.uleb128 .Ltmp71-.Lfunc_begin0          #     jumps to .Ltmp71
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp74-.Lfunc_begin0          # >> Call Site 29 <<
	.uleb128 .Ltmp75-.Ltmp74                #   Call between .Ltmp74 and .Ltmp75
	.uleb128 .Ltmp76-.Lfunc_begin0          #     jumps to .Ltmp76
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp79-.Lfunc_begin0          # >> Call Site 30 <<
	.uleb128 .Ltmp80-.Ltmp79                #   Call between .Ltmp79 and .Ltmp80
	.uleb128 .Ltmp81-.Lfunc_begin0          #     jumps to .Ltmp81
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp80-.Lfunc_begin0          # >> Call Site 31 <<
	.uleb128 .Lfunc_end2-.Ltmp80            #   Call between .Ltmp80 and .Lfunc_end2
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.type	_ZL11printMatrixPfii,@function  # -- Begin function _ZL11printMatrixPfii
_ZL11printMatrixPfii:                   # @_ZL11printMatrixPfii
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	%esi, %ebx
	movq	%rdi, %r14
	xorl	%edi, %edi
	movq	%r14, %rsi
	movl	%ebx, %edx
	callq	_ZL8printRowiPfi
	movl	$1, %edi
	movq	%r14, %rsi
	movl	%ebx, %edx
	callq	_ZL8printRowiPfi
	movl	$2, %edi
	movq	%r14, %rsi
	movl	%ebx, %edx
	callq	_ZL8printRowiPfi
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	movl	$98, %edi
	movq	%r14, %rsi
	movl	%ebx, %edx
	callq	_ZL8printRowiPfi
	movl	$99, %edi
	movq	%r14, %rsi
	movl	%ebx, %edx
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_ZL8printRowiPfi                # TAILCALL
.Lfunc_end3:
	.size	_ZL11printMatrixPfii, .Lfunc_end3-_ZL11printMatrixPfii
	.cfi_endproc
                                        # -- End function
	.type	_ZL30__device_stub__getDistance_gpuPfS_ii,@function # -- Begin function _ZL30__device_stub__getDistance_gpuPfS_ii
_ZL30__device_stub__getDistance_gpuPfS_ii: # @_ZL30__device_stub__getDistance_gpuPfS_ii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_ZL15getDistance_gpuPfS_ii, %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_end4:
	.size	_ZL30__device_stub__getDistance_gpuPfS_ii, .Lfunc_end4-_ZL30__device_stub__getDistance_gpuPfS_ii
	.cfi_endproc
                                        # -- End function
	.type	_ZL25__device_stub__argMin_gpuPfPiii,@function # -- Begin function _ZL25__device_stub__argMin_gpuPfPiii
_ZL25__device_stub__argMin_gpuPfPiii:   # @_ZL25__device_stub__argMin_gpuPfPiii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	8(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_ZL10argMin_gpuPfPiii, %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_end5:
	.size	_ZL25__device_stub__argMin_gpuPfPiii, .Lfunc_end5-_ZL25__device_stub__argMin_gpuPfPiii
	.cfi_endproc
                                        # -- End function
	.type	_ZL8printRowiPfi,@function      # -- Begin function _ZL8printRowiPfi
_ZL8printRowiPfi:                       # @_ZL8printRowiPfi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movl	%edx, %r14d
	movq	%rsi, %rbx
	movl	%edi, %r15d
	movl	$91, %edi
	callq	putchar@PLT
	imull	%r14d, %r15d
	cvtss2sd	(%rbx,%r15,4), %xmm0
	movl	$.L.str.30, %edi
	movb	$1, %al
	callq	printf
	movslq	%r15d, %r15
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rbx,%r15,4), %xmm0
	movl	$.L.str.30, %edi
	movb	$1, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	8(%rbx,%r15,4), %xmm0
	movl	$.L.str.30, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.31, %edi
	xorl	%eax, %eax
	callq	printf
	leal	(%r15,%r14), %eax
	addl	$-2, %eax
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%rax,4), %xmm0
	movl	$.L.str.30, %edi
	movb	$1, %al
	callq	printf
	leal	(%r15,%r14), %eax
	decl	%eax
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbx,%rax,4), %xmm0
	movl	$.L.str.30, %edi
	movb	$1, %al
	callq	printf
	movl	$.Lstr.6, %edi
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	puts@PLT                        # TAILCALL
.Lfunc_end6:
	.size	_ZL8printRowiPfi, .Lfunc_end6-_ZL8printRowiPfi
	.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	.LBB7_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB7_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_ZL15getDistance_gpuPfS_ii, %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	$_ZL10argMin_gpuPfPiii, %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_end7:
	.size	__hip_module_ctor, .Lfunc_end7-__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	.LBB8_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
.LBB8_2:
	retq
.Lfunc_end8:
	.size	__hip_module_dtor, .Lfunc_end8-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%d, %d, %d, %d\n"
	.size	.L.str, 16

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"using (%d x %d) tiles.\n"
	.size	.L.str.3, 24

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Unable to allocate host memory\n"
	.size	.L.str.4, 32

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"CUDA error: %s, line %d, %s: %s\n"
	.size	.L.str.5, 33

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/goldenpartner/Face-recognition/master/mp3.hip"
	.size	.L.str.6, 108

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"hipMalloc((void **)&d_M, bytesForM)"
	.size	.L.str.7, 36

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"hipMalloc((void **)&d_P, bytesForP)"
	.size	.L.str.8, 36

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"hipMalloc((void **)&d_index, m*sizeof(int))"
	.size	.L.str.9, 44

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Loading matrices...\n"
	.size	.L.str.10, 21

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"descriptor.txt"
	.size	.L.str.11, 15

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"hipMemcpy(d_M, h_M, bytesForM, hipMemcpyHostToDevice)"
	.size	.L.str.13, 54

	.type	_ZL15getDistance_gpuPfS_ii,@object # @_ZL15getDistance_gpuPfS_ii
	.section	.rodata,"a",@progbits
	.p2align	3, 0x0
_ZL15getDistance_gpuPfS_ii:
	.quad	_ZL30__device_stub__getDistance_gpuPfS_ii
	.size	_ZL15getDistance_gpuPfS_ii, 8

	.type	_ZL10argMin_gpuPfPiii,@object   # @_ZL10argMin_gpuPfPiii
	.p2align	3, 0x0
_ZL10argMin_gpuPfPiii:
	.quad	_ZL25__device_stub__argMin_gpuPfPiii
	.size	_ZL10argMin_gpuPfPiii, 8

	.type	.L.str.15,@object               # @.str.15
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.15:
	.asciz	"hipDeviceSynchronize()"
	.size	.L.str.15, 23

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"hipMemcpy(h_P, d_P, bytesForP, hipMemcpyDeviceToHost)"
	.size	.L.str.16, 54

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"hipMemcpy(index, d_index, m*sizeof(int), hipMemcpyDeviceToHost)"
	.size	.L.str.17, 64

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"matrix.txt"
	.size	.L.str.20, 11

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

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"hipFree(d_M)"
	.size	.L.str.22, 13

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"hipFree(d_P)"
	.size	.L.str.23, 13

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"hipFree(d_index)"
	.size	.L.str.24, 17

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"hipDeviceReset()"
	.size	.L.str.25, 17

	.type	.L.str.27,@object               # @.str.27
.L.str.27:
	.asciz	"Pause"
	.size	.L.str.27, 6

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	" %3.3f"
	.size	.L.str.30, 7

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

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

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_ZL10argMin_gpuPfPiii"
	.size	.L__unnamed_2, 22

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"M ="
	.size	.Lstr, 4

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"matMul called from host"
	.size	.Lstr.1, 24

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	" product received from host"
	.size	.Lstr.2, 28

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"P ="
	.size	.Lstr.3, 4

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Done"
	.size	.Lstr.4, 5

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"  ..."
	.size	.Lstr.5, 6

	.type	.Lstr.6,@object                 # @str.6
.Lstr.6:
	.asciz	" ]"
	.size	.Lstr.6, 3

	.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 __gxx_personality_v0
	.addrsig_sym _ZL30__device_stub__getDistance_gpuPfS_ii
	.addrsig_sym _ZL25__device_stub__argMin_gpuPfPiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _ZSt4cout
	.addrsig_sym _ZL15getDistance_gpuPfS_ii
	.addrsig_sym _ZL10argMin_gpuPfPiii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.section	.text._ZL10argMin_gpuPfPiii,"axG",@progbits,_ZL10argMin_gpuPfPiii,comdat
	.globl	_ZL10argMin_gpuPfPiii           ; -- Begin function _ZL10argMin_gpuPfPiii
	.p2align	8
	.type	_ZL10argMin_gpuPfPiii,@function
_ZL10argMin_gpuPfPiii:                  ; @_ZL10argMin_gpuPfPiii
; %bb.0:
	s_load_b32 s4, s[0:1], 0x10
	v_bfe_u32 v0, v0, 10, 10
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshl_add_u32 v0, s15, 4, v0
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_i32_e64 s4, v0
	s_cbranch_execz .LBB0_6
; %bb.1:                                ; %.preheader
	s_load_b128 s[0:3], s[0:1], 0x0
	s_cmp_lt_i32 s4, 1
	s_cbranch_scc1 .LBB0_4
; %bb.2:                                ; %.lr.ph
	v_mul_lo_u32 v1, v0, s4
	v_dual_mov_b32 v3, -1 :: v_dual_mov_b32 v4, 0x47c35000
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v1, vcc_lo, s0, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo
	s_mov_b32 s1, 0
.LBB0_3:                                ; =>This Inner Loop Header: Depth=1
	global_load_b32 v5, v[1:2], off
	v_add_co_u32 v1, vcc_lo, v1, 4
	v_add_co_ci_u32_e32 v2, vcc_lo, 0, v2, vcc_lo
	s_waitcnt vmcnt(0)
	v_cmp_lt_f32_e64 s0, v5, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_cndmask_b32_e64 v4, v4, v5, s0
	v_cndmask_b32_e64 v3, v3, s1, s0
	s_add_i32 s1, s1, 1
	s_cmp_eq_u32 s4, s1
	s_cbranch_scc0 .LBB0_3
	s_branch .LBB0_5
.LBB0_4:
	v_mov_b32_e32 v3, -1
.LBB0_5:                                ; %Flow36
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v0, vcc_lo, s2, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[0:1], v3, off
.LBB0_6:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _ZL10argMin_gpuPfPiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 24
		.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 6
		.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
	.section	.text._ZL10argMin_gpuPfPiii,"axG",@progbits,_ZL10argMin_gpuPfPiii,comdat
.Lfunc_end0:
	.size	_ZL10argMin_gpuPfPiii, .Lfunc_end0-_ZL10argMin_gpuPfPiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 252
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; 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
	.section	.text._ZL15getDistance_gpuPfS_ii,"axG",@progbits,_ZL15getDistance_gpuPfS_ii,comdat
	.globl	_ZL15getDistance_gpuPfS_ii      ; -- Begin function _ZL15getDistance_gpuPfS_ii
	.p2align	8
	.type	_ZL15getDistance_gpuPfS_ii,@function
_ZL15getDistance_gpuPfS_ii:             ; @_ZL15getDistance_gpuPfS_ii
; %bb.0:
	s_load_b64 s[4:5], s[0:1], 0x10
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v2, 0x3ff, v0
	s_mov_b32 s2, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshl_add_u32 v0, s15, 4, v1
	v_lshl_add_u32 v1, s14, 4, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_max_i32_e32 v2, v0, v1
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_i32_e64 s4, v2
	s_cbranch_execz .LBB1_10
; %bb.1:
	s_load_b128 s[0:3], s[0:1], 0x0
	s_mov_b32 s6, exec_lo
                                        ; implicit-def: $vgpr4
                                        ; implicit-def: $vgpr2
	v_cmpx_ne_u32_e64 v0, v1
	s_xor_b32 s6, exec_lo, s6
	s_cbranch_execz .LBB1_7
; %bb.2:                                ; %.preheader
	s_cmp_lt_i32 s5, 1
	s_cbranch_scc1 .LBB1_5
; %bb.3:                                ; %.lr.ph
	v_mul_lo_u32 v2, v1, s5
	v_mul_lo_u32 v4, v0, s5
	v_mov_b32_e32 v6, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v3, 31, v2
	v_ashrrev_i32_e32 v5, 31, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	v_lshlrev_b64 v[4:5], 2, v[4:5]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v4, vcc_lo, s0, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	s_mov_b32 s0, 0x3e76c4e1
.LBB1_4:                                ; =>This Inner Loop Header: Depth=1
	global_load_b32 v7, v[4:5], off
	global_load_b32 v8, v[2:3], off
	s_add_i32 s5, s5, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s5, 0
	s_waitcnt vmcnt(0)
	v_sub_f32_e32 v7, v7, v8
	v_frexp_mant_f32_e64 v8, |v7|
	v_frexp_exp_i32_f32_e32 v9, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_cmp_gt_f32_e32 vcc_lo, 0x3f2aaaab, v8
	v_cndmask_b32_e64 v10, 0, 1, vcc_lo
	v_subrev_co_ci_u32_e32 v9, vcc_lo, 0, v9, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ldexp_f32 v8, v8, v10
	v_cvt_f32_i32_e32 v9, v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f32_e32 v10, 1.0, v8
	v_mul_f32_e32 v14, 0x3f317218, v9
	v_cmp_neq_f32_e64 s1, 0x7f800000, |v7|
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v13, -1.0, v10
	v_dual_add_f32 v11, -1.0, v8 :: v_dual_sub_f32 v8, v8, v13
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v13, 0x3f317218, v9, -v14
	v_fmac_f32_e32 v13, 0xb102e308, v9
	v_rcp_f32_e32 v12, v10
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v15, v11, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v9, v10, v15
	v_fma_f32 v10, v15, v10, -v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v10, v15, v8
	v_add_f32_e32 v8, v9, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_f32_e32 v16, v11, v8
	v_sub_f32_e32 v11, v11, v16
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_sub_f32 v9, v8, v9 :: v_dual_sub_f32 v8, v11, v8
	v_sub_f32_e32 v9, v9, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v8, v9, v8
	v_add_f32_e32 v8, v16, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v8, v12, v8
	v_add_f32_e32 v9, v15, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_f32_e32 v10, v9, v15
	v_dual_mul_f32 v11, v9, v9 :: v_dual_sub_f32 v8, v8, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_fma_f32 v10, v9, v9, -v11
	v_ldexp_f32 v12, v9, 1
	v_add_f32_e32 v15, v8, v8
	v_ldexp_f32 v16, v8, 1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v10, v9, v15
	v_add_f32_e32 v15, v11, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmaak_f32 v17, s0, v15, 0x3e91f4c4
	v_fmaak_f32 v17, v15, v17, 0x3ecccdef
	v_sub_f32_e32 v11, v15, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_dual_mul_f32 v18, v9, v15 :: v_dual_mul_f32 v19, v15, v17
	v_sub_f32_e32 v10, v10, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v11, v15, v9, -v18
	v_fmac_f32_e32 v11, v15, v8
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v8, v15, v17, -v19
	v_fmac_f32_e32 v11, v10, v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v8, v10, v17
	v_add_f32_e32 v10, v19, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_f32_e32 v17, v10, v19
	v_sub_f32_e32 v8, v8, v17
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_add_f32 v8, 0x31739010, v8 :: v_dual_add_f32 v9, v18, v11
	v_sub_f32_e32 v15, v9, v18
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_add_f32 v18, 0x3f2aaaaa, v10 :: v_dual_sub_f32 v11, v11, v15
	v_add_f32_e32 v15, 0xbf2aaaaa, v18
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_f32_e32 v10, v10, v15
	v_add_f32_e32 v8, v8, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v10, v18, v8
	v_sub_f32_e32 v15, v18, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mul_f32 v17, v9, v10 :: v_dual_add_f32 v8, v8, v15
	v_fma_f32 v15, v9, v10, -v17
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v15, v9, v8
	v_fmac_f32_e32 v15, v11, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v8, v17, v15
	v_add_f32_e32 v9, v12, v8
	v_sub_f32_e32 v10, v8, v17
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_sub_f32 v10, v15, v10 :: v_dual_sub_f32 v11, v9, v12
	v_add_f32_e32 v10, v16, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_sub_f32 v8, v8, v11 :: v_dual_add_f32 v11, v14, v13
	v_add_f32_e32 v8, v10, v8
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_f32_e32 v10, v11, v14
	v_add_f32_e32 v12, v9, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_sub_f32 v10, v13, v10 :: v_dual_add_f32 v13, v11, v12
	v_dual_sub_f32 v9, v12, v9 :: v_dual_sub_f32 v14, v13, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_sub_f32 v8, v8, v9 :: v_dual_sub_f32 v9, v13, v14
	v_dual_sub_f32 v9, v11, v9 :: v_dual_sub_f32 v12, v12, v14
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_add_f32 v14, v10, v8 :: v_dual_add_f32 v9, v12, v9
	v_sub_f32_e32 v11, v14, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f32_e32 v9, v14, v9
	v_sub_f32_e32 v12, v14, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_dual_sub_f32 v8, v8, v11 :: v_dual_add_f32 v11, v13, v9
	v_sub_f32_e32 v10, v10, v12
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_f32_e32 v12, v11, v13
	v_dual_sub_f32 v9, v9, v12 :: v_dual_add_f32 v8, v8, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v8, v8, v9
	v_add_f32_e32 v9, v11, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_f32_e32 v10, v9, v11
	v_dual_sub_f32 v8, v8, v10 :: v_dual_add_f32 v11, v9, v9
	v_mul_f32_e32 v12, 0, v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v9, v9, 2.0, -v11
	v_fmac_f32_e32 v12, 2.0, v8
	v_cmp_class_f32_e64 vcc_lo, v11, 0x204
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v8, v9, v12
	v_add_f32_e32 v9, v11, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v10, v9, v11, vcc_lo
	v_sub_f32_e32 v9, v9, v11
	v_cmp_eq_f32_e32 vcc_lo, 0x42b17218, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_sub_f32_e32 v8, v8, v9
	v_cndmask_b32_e64 v12, 0, 0x37000000, vcc_lo
	v_cmp_neq_f32_e64 vcc_lo, 0x7f800000, |v10|
	v_sub_f32_e32 v13, v10, v12
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v8, 0, v8, vcc_lo
	v_mul_f32_e32 v14, 0x3fb8aa3b, v13
	v_cmp_ngt_f32_e32 vcc_lo, 0xc2ce8ed0, v13
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_f32_e32 v8, v12, v8
	v_fma_f32 v15, 0x3fb8aa3b, v13, -v14
	v_rndne_f32_e32 v16, v14
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_dual_fmac_f32 v15, 0x32a5705f, v13 :: v_dual_sub_f32 v14, v14, v16
	v_cvt_i32_f32_e32 v11, v16
	v_add_f32_e32 v14, v14, v15
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_exp_f32_e32 v14, v14
	s_waitcnt_depctr 0xfff
	v_ldexp_f32 v9, v14, v11
	v_cndmask_b32_e32 v9, 0, v9, vcc_lo
	v_cmp_nlt_f32_e32 vcc_lo, 0x42b17218, v13
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v9, 0x7f800000, v9, vcc_lo
	v_fma_f32 v8, v9, v8, v9
	v_cmp_eq_f32_e32 vcc_lo, 0x7f800000, v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_cndmask_b32_e32 v8, v8, v9, vcc_lo
	v_add_co_u32 v2, vcc_lo, v2, 4
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	v_cndmask_b32_e64 v8, 0x7f800000, |v8|, s1
	v_cmp_neq_f32_e32 vcc_lo, 0, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_cndmask_b32_e32 v7, 0, v8, vcc_lo
	v_add_co_u32 v4, vcc_lo, v4, 4
	v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo
	v_add_f32_e32 v6, v6, v7
	s_cbranch_scc0 .LBB1_4
	s_branch .LBB1_6
.LBB1_5:
	v_mov_b32_e32 v6, 0
.LBB1_6:                                ; %Flow56
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mul_f32_e32 v2, 0x4f800000, v6
	v_cmp_gt_f32_e32 vcc_lo, 0xf800000, v6
	v_cndmask_b32_e32 v4, v6, v2, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_sqrt_f32_e32 v2, v4
	s_waitcnt_depctr 0xfff
	v_add_nc_u32_e32 v3, -1, v2
	v_add_nc_u32_e32 v5, 1, v2
	v_fma_f32 v6, -v3, v2, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_fma_f32 v7, -v5, v2, v4
	s_waitcnt lgkmcnt(0)
	v_cmp_ge_f32_e64 s0, 0, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cndmask_b32_e64 v2, v2, v3, s0
	v_cmp_lt_f32_e64 s0, 0, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v2, v2, v5, s0
	v_mul_f32_e32 v3, 0x37800000, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_cndmask_b32_e32 v5, v2, v3, vcc_lo
	v_cmp_class_f32_e64 vcc_lo, v4, 0x260
	v_mad_u64_u32 v[2:3], null, v0, s4, v[1:2]
                                        ; implicit-def: $vgpr0
	v_cndmask_b32_e32 v4, v5, v4, vcc_lo
.LBB1_7:                                ; %Flow57
	s_waitcnt lgkmcnt(0)
	s_and_not1_saveexec_b32 s0, s6
; %bb.8:
	v_mad_u64_u32 v[2:3], null, v0, s4, v[0:1]
	v_mov_b32_e32 v4, 0x42c80000
; %bb.9:                                ; %.sink.split
	s_or_b32 exec_lo, exec_lo, s0
	s_delay_alu instid0(VALU_DEP_2) | 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, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[0:1], v4, off
.LBB1_10:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _ZL15getDistance_gpuPfS_ii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 24
		.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 20
		.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
	.section	.text._ZL15getDistance_gpuPfS_ii,"axG",@progbits,_ZL15getDistance_gpuPfS_ii,comdat
.Lfunc_end1:
	.size	_ZL15getDistance_gpuPfS_ii, .Lfunc_end1-_ZL15getDistance_gpuPfS_ii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1428
; NumSgprs: 18
; NumVgprs: 20
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 20
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 24
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _ZL10argMin_gpuPfPiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _ZL10argMin_gpuPfPiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .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
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 24
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _ZL15getDistance_gpuPfS_ii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _ZL15getDistance_gpuPfS_ii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     20
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
