#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cuda_runtime.h>
#include <cstdlib>
#include <sstream>
#include <iomanip>

using namespace std;

//input, filter and output considering maximum dimension possible
double a[1000][1000], h[10][10], c[1000][1000];

/**
 * CUDA Kernel Device code
 *
 * Computes the 2D convolution of input b with filter h and output c
 */

 __global__ void
 convolution2D(double *a_1, double *h_1, double *c_1, int rows_a, int columns_a, int rows_h, int columns_h)
{
    int idx = blockDim.x * blockIdx.x + threadIdx.x;
    int idy = blockDim.y * blockIdx.y + threadIdx.y;
    double sum;

    if((idx < (columns_h+columns_a - 1)) && (idy < (rows_h + rows_a - 1)))
    {
        sum = 0;
        for(int k=0; k< rows_h; k++)
        {
            for(int j=0; j< columns_h; j++)
            {
                if ((idy - k) >= 0 && (idx - j) >= 0 && (idy - k) < rows_a && (idx - j) < columns_a) 
                {
                    sum += a_1[((idy - k)*columns_a) + (idx - j)] * h_1[k*columns_h + j];
                }

            }
        }
        c_1[idy*(columns_a + columns_h - 1) + idx] = sum;
        __syncthreads();
    }
}

/**
 * Host main routine
 */
 int main(int argc, char** argv)
 {
     // Error code to check return values for CUDA calls
     cudaError_t err = cudaSuccess;

     int columns_a, columns_h, rows_a, rows_h, size_a, size_h;
     columns_a = columns_h = 0;
     size_a = size_h = rows_a = rows_h = 0;
     char *ip_file;
     string line;
     double input;
     ip_file = argv[1];
     int i, j, k;

     ifstream file(ip_file);
     if(file.is_open())
     {
         i=0;
         while(getline(file, line) && line != "")
         {
              j=0;
             stringstream ss(line);
             while(ss >> input)
             {
                 a[i][j] = input;
                 size_a++;
                 j++;
             }
             i++;
             rows_a++;
         }
         
         k=0;
         while(getline(file, line) && line != "")
         {
              j=0;
             stringstream ss(line);
             while(ss >> input)
             {
                 h[k][j] = input;
                 j++;
                 size_h++;
             }
             k++;
             rows_h++;
         }
     }
     file.close();
     columns_a = size_a/rows_a;
     columns_h = size_h/rows_h;
    
     int op_size = ((rows_a+rows_h-1)*(columns_a+columns_h-1));
     size_t size_ax = size_a*sizeof(double);
	 size_t size_hx = size_h*sizeof(double);
     size_t size_cx = op_size*sizeof(double);
     // Allocate the host input vector a
     double *h_a;
     cudaMallocManaged(&h_a, size_ax);
     // Allocate the host input vector h
     double *h_h;
     cudaMallocManaged(&h_h, size_hx);
     // Allocate the host output vector c
     double *h_c;
     cudaMallocManaged(&h_c, size_cx);

     for (int i = 0; i < rows_a; i++)
     {
         for(int j=0;j< columns_a; j++)
         {
            h_a[i*columns_a + j] = a[i][j];
         }
     }

     for (int i = 0; i < rows_h; i++)
     {
         for(int j=0;j< columns_h; j++)
         {
            h_h[i*columns_h + j] = h[i][j];
         }
     }

     // Launch the CUDA Kernel
     dim3 blocksPerGrid(((rows_a + rows_h - 2) / 32) + 1, ((columns_h + columns_a - 2) / 32) + 1, 1);
     dim3 threadsPerBlock(32,32,1);
     convolution2D<<<blocksPerGrid, threadsPerBlock>>>(h_a, h_h, h_c, rows_a, columns_a, rows_h, columns_h);
     err = cudaGetLastError();
 
     if (err != cudaSuccess)
     {
         fprintf(stderr, "Failed to launch convolution2D kernel (error code %s)!\n", cudaGetErrorString(err));
         exit(EXIT_FAILURE);
     }

     err = cudaDeviceSynchronize();
     if (err != cudaSuccess)
	 {
		fprintf(stderr, "Failed to synchronize (error code %s)!\n", cudaGetErrorString(err));
		exit(EXIT_FAILURE);
	 }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////

     for (int i = 0; i < rows_a + rows_h - 1; i++) {
        for (int j = 0; j < columns_a + columns_h - 1; j++) 
        {	
			cout << fixed << setprecision(3) << h_c[(i*(columns_h+columns_a-1))+j] << " ";
		}
		cout << endl;
	}

     // Free device global memory
     err = cudaFree(h_a);
 
     if (err != cudaSuccess)
     {
         fprintf(stderr, "Failed to free device vector a (error code %s)!\n", cudaGetErrorString(err));
         exit(EXIT_FAILURE);
     }
 
     err = cudaFree(h_h);
 
     if (err != cudaSuccess)
     {
         fprintf(stderr, "Failed to free device vector h (error code %s)!\n", cudaGetErrorString(err));
         exit(EXIT_FAILURE);
     }
 
     err = cudaFree(h_c);
 
     if (err != cudaSuccess)
     {
         fprintf(stderr, "Failed to free device vector c (error code %s)!\n", cudaGetErrorString(err));
         exit(EXIT_FAILURE);
     }
 
     // Reset the device and exit
     // cudaDeviceReset causes the driver to clean up all state. While
     // not mandatory in normal operation, it is good practice.  It is also
     // needed to ensure correct operation when the application is being
     // profiled. Calling cudaDeviceReset causes all profile data to be
     // flushed before the application exits
     err = cudaDeviceReset();
     if (err != cudaSuccess)
     {
         fprintf(stderr, "Failed to deinitialize the device! error=%s\n", cudaGetErrorString(err));
         exit(EXIT_FAILURE);
     }
 
     printf("Done\n");
     return 0;
 }

	.file	"tmpxft_00335cc8_00000000-6_exec2.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.section	.text._ZSt5fixedRSt8ios_base,"axG",@progbits,_ZSt5fixedRSt8ios_base,comdat
	.weak	_ZSt5fixedRSt8ios_base
	.type	_ZSt5fixedRSt8ios_base, @function
_ZSt5fixedRSt8ios_base:
.LFB3285:
	.cfi_startproc
	endbr64
	movl	24(%rdi), %edx
	movq	%rdi, %rax
	andl	$-261, %edx
	orl	$4, %edx
	movl	%edx, 24(%rdi)
	ret
	.cfi_endproc
.LFE3285:
	.size	_ZSt5fixedRSt8ios_base, .-_ZSt5fixedRSt8ios_base
	.text
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4009:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4009:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z41__device_stub__Z13convolution2DPdS_S_iiiiPdS_S_iiii
	.type	_Z41__device_stub__Z13convolution2DPdS_S_iiiiPdS_S_iiii, @function
_Z41__device_stub__Z13convolution2DPdS_S_iiiiPdS_S_iiii:
.LFB4031:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	56(%rsp), %rcx
	movl	%r8d, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	192(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L3
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z13convolution2DPdS_S_iiii(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L3:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4031:
	.size	_Z41__device_stub__Z13convolution2DPdS_S_iiiiPdS_S_iiii, .-_Z41__device_stub__Z13convolution2DPdS_S_iiiiPdS_S_iiii
	.globl	_Z13convolution2DPdS_S_iiii
	.type	_Z13convolution2DPdS_S_iiii, @function
_Z13convolution2DPdS_S_iiii:
.LFB4032:
	.cfi_startproc
	endbr64
	jmp	_Z41__device_stub__Z13convolution2DPdS_S_iiiiPdS_S_iiii
	.cfi_endproc
.LFE4032:
	.size	_Z13convolution2DPdS_S_iiii, .-_Z13convolution2DPdS_S_iiii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z13convolution2DPdS_S_iiii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4034:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z13convolution2DPdS_S_iiii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE4034:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_,"axG",@progbits,_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_,comdat
	.weak	_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_
	.type	_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_, @function
_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_:
.LFB4547:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movq	8(%rdi), %r12
	movq	%rsi, %rdi
	movq	%rsi, 8(%rsp)
	call	strlen@PLT
	movq	8(%rsp), %rsi
	movq	%rax, %rdx
	xorl	%eax, %eax
	cmpq	%rdx, %r12
	jne	.L11
	movb	$1, %al
	testq	%r12, %r12
	je	.L11
	movq	(%rbx), %rdi
	movq	%r12, %rdx
	call	memcmp@PLT
	testl	%eax, %eax
	sete	%al
.L11:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4547:
	.size	_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_, .-_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_
	.section	.rodata.str1.1
.LC1:
	.string	""
.LC2:
	.string	"Failed to launch convolution2D kernel (error code %s)!\n"
.LC3:
	.string	"Failed to synchronize (error code %s)!\n"
.LC4:
	.string	" "
.LC5:
	.string	"Failed to free device vector a (error code %s)!\n"
.LC6:
	.string	"Failed to free device vector h (error code %s)!\n"
.LC7:
	.string	"Failed to free device vector c (error code %s)!\n"
.LC8:
	.string	"Failed to deinitialize the device! error=%s\n"
.LC9:
	.string	"Done\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB4005:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4005
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	xorl	%r8d, %r8d
	movl	$8, %edx
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$1064, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	8(%rsi), %rsi
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	leaq	-984(%rbp), %rax
	movq	%r8, -992(%rbp)
	movq	%rax, -1000(%rbp)
	leaq	-576(%rbp), %rax
	movq	%rax, %rdi
	movb	$0, -984(%rbp)
	movq	%rax, -1072(%rbp)
.LEHB0:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE0:
	leaq	-456(%rbp), %rdi
	call	_ZNKSt12__basic_fileIcE7is_openEv@PLT
	testb	%al, %al
	jne	.L54
	xorl	%edi, %edi
	xorl	%r12d, %r12d
	xorl	%ebx, %ebx
	xorl	%r13d, %r13d
	movl	%edi, -1060(%rbp)
	jmp	.L18
.L54:
	leaq	-1000(%rbp), %rax
	xorl	%r14d, %r14d
	xorl	%ebx, %ebx
	movq	%rax, -1080(%rbp)
.L17:
	movq	-1080(%rbp), %rsi
	movq	-1072(%rbp), %rdi
	movl	%r14d, %r13d
.LEHB1:
	call	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	jne	.L20
	movq	-1080(%rbp), %rdi
	leaq	.LC1(%rip), %rsi
	call	_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_
	testb	%al, %al
	je	.L21
.L20:
	xorl	%esi, %esi
	leaq	h(%rip), %r14
	xorl	%r12d, %r12d
	movl	%esi, -1060(%rbp)
	jmp	.L22
.L21:
	leaq	-968(%rbp), %r12
	movq	-1080(%rbp), %rsi
	movl	$24, %edx
	movq	%r12, %rdi
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode@PLT
.LEHE1:
	imulq	$8000, %r14, %rax
	leaq	-1056(%rbp), %r13
	movq	%rax, %rcx
	leaq	a(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %r15
.L23:
	movq	%r13, %rsi
	movq	%r12, %rdi
.LEHB2:
	call	_ZNSi10_M_extractIdEERSiRT_@PLT
.LEHE2:
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	jne	.L71
	movq	%r15, %rax
	movsd	-1056(%rbp), %xmm0
	incl	%ebx
	addq	$8, %rax
	movsd	%xmm0, (%r15)
	movq	%rax, %r15
	jmp	.L23
.L71:
	movq	%r12, %rdi
	incq	%r14
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev@PLT
	jmp	.L17
.L72:
	movq	-1088(%rbp), %rdi
	incl	-1060(%rbp)
	addq	$80, %r14
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev@PLT
.L22:
	movq	-1080(%rbp), %rsi
	movq	-1072(%rbp), %rdi
.LEHB3:
	call	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	jne	.L18
	movq	-1080(%rbp), %rdi
	leaq	.LC1(%rip), %rsi
	call	_ZSteqIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_
	testb	%al, %al
	jne	.L18
	leaq	-968(%rbp), %rax
	movq	-1080(%rbp), %rsi
	movl	$24, %edx
	movq	%rax, %rdi
	movq	%rax, -1088(%rbp)
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode@PLT
.LEHE3:
	leaq	-1056(%rbp), %rax
	movq	%r14, %r15
	movq	%rax, -1096(%rbp)
.L25:
	movq	-1096(%rbp), %rsi
	movq	-1088(%rbp), %rdi
.LEHB4:
	call	_ZNSi10_M_extractIdEERSiRT_@PLT
.LEHE4:
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	jne	.L72
	movsd	-1056(%rbp), %xmm0
	incl	%r12d
	addq	$8, %r15
	movsd	%xmm0, -8(%r15)
	jmp	.L25
.L18:
	movq	-1072(%rbp), %rdi
.LEHB5:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv@PLT
	movl	%ebx, %eax
	movslq	%ebx, %rsi
	leaq	-1048(%rbp), %rdi
	cltd
	salq	$3, %rsi
	idivl	%r13d
	movl	%eax, %r14d
	movl	%r12d, %eax
	movslq	%r12d, %r12
	cltd
	salq	$3, %r12
	idivl	-1060(%rbp)
	movl	$1, %edx
	movl	%eax, %r15d
	movl	-1060(%rbp), %eax
	addl	%r13d, %eax
	movl	%eax, -1088(%rbp)
	decl	%eax
	movl	%eax, -1096(%rbp)
	leal	(%r14,%r15), %eax
	movl	%eax, -1064(%rbp)
	decl	%eax
	movl	%eax, -1080(%rbp)
	movl	-1096(%rbp), %eax
	movl	-1080(%rbp), %ecx
	imull	%ecx, %eax
	cltq
	salq	$3, %rax
	movq	%rax, -1104(%rbp)
	call	cudaMallocManaged@PLT
	leaq	-1040(%rbp), %rdi
	movl	$1, %edx
	movq	%r12, %rsi
	call	cudaMallocManaged@PLT
	movq	-1104(%rbp), %rsi
	leaq	-1032(%rbp), %rdi
	movl	$1, %edx
	call	cudaMallocManaged@PLT
	movq	-1048(%rbp), %r8
	leaq	a(%rip), %rsi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
.L26:
	cmpl	%ecx, %r13d
	je	.L28
	movslq	%edx, %rax
	leaq	(%r8,%rax,8), %rdi
	xorl	%eax, %eax
.L29:
	cmpl	%eax, %r14d
	jle	.L73
	movsd	(%rsi,%rax,8), %xmm0
	movsd	%xmm0, (%rdi,%rax,8)
	incq	%rax
	jmp	.L29
.L73:
	incl	%ecx
	addl	%r14d, %edx
	addq	$8000, %rsi
	jmp	.L26
.L28:
	movq	-1040(%rbp), %r8
	leaq	h(%rip), %rsi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
.L30:
	cmpl	%ecx, -1060(%rbp)
	je	.L32
	movslq	%edx, %rax
	leaq	(%r8,%rax,8), %rdi
	xorl	%eax, %eax
.L33:
	cmpl	%eax, %r15d
	jle	.L74
	movsd	(%rsi,%rax,8), %xmm0
	movsd	%xmm0, (%rdi,%rax,8)
	incq	%rax
	jmp	.L33
.L74:
	incl	%ecx
	addl	%r15d, %edx
	addq	$80, %rsi
	jmp	.L30
.L32:
	movl	$32, %ecx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %esi
	movl	$1, -1016(%rbp)
	movl	-1088(%rbp), %eax
	movl	$1, -1004(%rbp)
	subl	$2, %eax
	cltd
	idivl	%ecx
	incl	%eax
	movl	%eax, -1024(%rbp)
	movl	-1064(%rbp), %eax
	subl	$2, %eax
	cltd
	idivl	%ecx
	movabsq	$137438953504, %rdx
	movl	$1, %ecx
	movq	%rdx, -1012(%rbp)
	incl	%eax
	movl	%eax, -1020(%rbp)
	movq	-1024(%rbp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	je	.L34
.L36:
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L37
	jmp	.L75
.L34:
	pushq	%rcx
	movl	-1060(%rbp), %r9d
	movl	%r14d, %r8d
	movl	%r13d, %ecx
	movq	-1032(%rbp), %rdx
	movq	-1040(%rbp), %rsi
	pushq	%r15
	movq	-1048(%rbp), %rdi
	.cfi_escape 0x2e,0x10
	call	_Z41__device_stub__Z13convolution2DPdS_S_iiiiPdS_S_iiii
	popq	%rax
	popq	%rdx
	jmp	.L36
.L75:
	.cfi_escape 0x2e,0
	call	cudaGetErrorString@PLT
	movq	%rax, %rcx
	leaq	.LC2(%rip), %rdx
.L65:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L37:
	call	cudaDeviceSynchronize@PLT
	movl	%eax, %ebx
	xorl	%r13d, %r13d
	leaq	_ZSt4cout(%rip), %r14
	testl	%eax, %eax
	je	.L39
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rax, %rcx
	leaq	.LC3(%rip), %rdx
	jmp	.L65
.L41:
	leaq	_ZSt5fixedRSt8ios_base(%rip), %rsi
	movq	%r14, %rdi
	call	_ZNSolsEPFRSt8ios_baseS0_E@PLT
	movq	%rax, %rdi
	movq	(%rax), %rax
	movq	-24(%rax), %rax
	movq	$3, 8(%rdi,%rax)
	movq	-1032(%rbp), %rax
	movsd	(%rax,%r15), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	movl	$1, %edx
	leaq	.LC4(%rip), %rsi
	call	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT
	movq	%r15, %rax
	incl	%r12d
	addq	$8, %rax
	movq	%rax, %r15
.L43:
	cmpl	%r12d, -1080(%rbp)
	jg	.L41
	movq	%r14, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	-1080(%rbp), %eax
	incl	%r13d
	addl	%eax, %ebx
.L39:
	cmpl	%r13d, -1096(%rbp)
	jle	.L42
	movslq	%ebx, %rax
	xorl	%r12d, %r12d
	salq	$3, %rax
	movq	%rax, %r15
	jmp	.L43
.L42:
	movq	-1048(%rbp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L44
	call	cudaGetErrorString@PLT
	movq	%rax, %rcx
	leaq	.LC5(%rip), %rdx
	jmp	.L65
.L44:
	movq	-1040(%rbp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L45
	call	cudaGetErrorString@PLT
	movq	%rax, %rcx
	leaq	.LC6(%rip), %rdx
	jmp	.L65
.L45:
	movq	-1032(%rbp), %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L46
	call	cudaGetErrorString@PLT
	movq	%rax, %rcx
	leaq	.LC7(%rip), %rdx
	jmp	.L65
.L46:
	call	cudaDeviceReset@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L47
	call	cudaGetErrorString@PLT
	movq	%rax, %rcx
	leaq	.LC8(%rip), %rdx
	jmp	.L65
.L47:
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.LEHE5:
	movq	-1072(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	leaq	-1000(%rbp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L53
	jmp	.L62
.L57:
	endbr64
	movq	%rax, %rbx
.L48:
	movq	%r12, %rdi
	jmp	.L70
.L59:
	endbr64
	movq	%rax, %rbx
.L50:
	movq	-1088(%rbp), %rdi
.L70:
	call	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED1Ev@PLT
	jmp	.L49
.L58:
	endbr64
	movq	%rax, %rbx
.L49:
	movq	-1072(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L51
.L56:
	endbr64
	movq	%rax, %rbx
.L51:
	leaq	-1000(%rbp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L62
	movq	%rbx, %rdi
.LEHB6:
	call	_Unwind_Resume@PLT
.LEHE6:
.L62:
	call	__stack_chk_fail@PLT
.L53:
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4005:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4005:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4005-.LLSDACSB4005
.LLSDACSB4005:
	.uleb128 .LEHB0-.LFB4005
	.uleb128 .LEHE0-.LEHB0
	.uleb128 .L56-.LFB4005
	.uleb128 0
	.uleb128 .LEHB1-.LFB4005
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L58-.LFB4005
	.uleb128 0
	.uleb128 .LEHB2-.LFB4005
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L57-.LFB4005
	.uleb128 0
	.uleb128 .LEHB3-.LFB4005
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L58-.LFB4005
	.uleb128 0
	.uleb128 .LEHB4-.LFB4005
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L59-.LFB4005
	.uleb128 0
	.uleb128 .LEHB5-.LFB4005
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L58-.LFB4005
	.uleb128 0
	.uleb128 .LEHB6-.LFB4005
	.uleb128 .LEHE6-.LEHB6
	.uleb128 0
	.uleb128 0
.LLSDACSE4005:
	.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
	.globl	c
	.bss
	.align 32
	.type	c, @object
	.size	c, 8000000
c:
	.zero	8000000
	.globl	h
	.align 32
	.type	h, @object
	.size	h, 800
h:
	.zero	800
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 8000000
a:
	.zero	8000000
	.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:

#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <hip/hip_runtime.h>
#include <cstdlib>
#include <sstream>
#include <iomanip>

using namespace std;

//input, filter and output considering maximum dimension possible
double a[1000][1000], h[10][10], c[1000][1000];

/**
 * CUDA Kernel Device code
 *
 * Computes the 2D convolution of input b with filter h and output c
 */

 __global__ void
 convolution2D(double *a_1, double *h_1, double *c_1, int rows_a, int columns_a, int rows_h, int columns_h)
{
    int idx = blockDim.x * blockIdx.x + threadIdx.x;
    int idy = blockDim.y * blockIdx.y + threadIdx.y;
    double sum;

    if((idx < (columns_h+columns_a - 1)) && (idy < (rows_h + rows_a - 1)))
    {
        sum = 0;
        for(int k=0; k< rows_h; k++)
        {
            for(int j=0; j< columns_h; j++)
            {
                if ((idy - k) >= 0 && (idx - j) >= 0 && (idy - k) < rows_a && (idx - j) < columns_a) 
                {
                    sum += a_1[((idy - k)*columns_a) + (idx - j)] * h_1[k*columns_h + j];
                }

            }
        }
        c_1[idy*(columns_a + columns_h - 1) + idx] = sum;
        __syncthreads();
    }
}

/**
 * Host main routine
 */
 int main(int argc, char** argv)
 {
     // Error code to check return values for CUDA calls
     hipError_t err = hipSuccess;

     int columns_a, columns_h, rows_a, rows_h, size_a, size_h;
     columns_a = columns_h = 0;
     size_a = size_h = rows_a = rows_h = 0;
     char *ip_file;
     string line;
     double input;
     ip_file = argv[1];
     int i, j, k;

     ifstream file(ip_file);
     if(file.is_open())
     {
         i=0;
         while(getline(file, line) && line != "")
         {
              j=0;
             stringstream ss(line);
             while(ss >> input)
             {
                 a[i][j] = input;
                 size_a++;
                 j++;
             }
             i++;
             rows_a++;
         }
         
         k=0;
         while(getline(file, line) && line != "")
         {
              j=0;
             stringstream ss(line);
             while(ss >> input)
             {
                 h[k][j] = input;
                 j++;
                 size_h++;
             }
             k++;
             rows_h++;
         }
     }
     file.close();
     columns_a = size_a/rows_a;
     columns_h = size_h/rows_h;
    
     int op_size = ((rows_a+rows_h-1)*(columns_a+columns_h-1));
     size_t size_ax = size_a*sizeof(double);
	 size_t size_hx = size_h*sizeof(double);
     size_t size_cx = op_size*sizeof(double);
     // Allocate the host input vector a
     double *h_a;
     hipMallocManaged(&h_a, size_ax);
     // Allocate the host input vector h
     double *h_h;
     hipMallocManaged(&h_h, size_hx);
     // Allocate the host output vector c
     double *h_c;
     hipMallocManaged(&h_c, size_cx);

     for (int i = 0; i < rows_a; i++)
     {
         for(int j=0;j< columns_a; j++)
         {
            h_a[i*columns_a + j] = a[i][j];
         }
     }

     for (int i = 0; i < rows_h; i++)
     {
         for(int j=0;j< columns_h; j++)
         {
            h_h[i*columns_h + j] = h[i][j];
         }
     }

     // Launch the CUDA Kernel
     dim3 blocksPerGrid(((rows_a + rows_h - 2) / 32) + 1, ((columns_h + columns_a - 2) / 32) + 1, 1);
     dim3 threadsPerBlock(32,32,1);
     convolution2D<<<blocksPerGrid, threadsPerBlock>>>(h_a, h_h, h_c, rows_a, columns_a, rows_h, columns_h);
     err = hipGetLastError();
 
     if (err != hipSuccess)
     {
         fprintf(stderr, "Failed to launch convolution2D kernel (error code %s)!\n", hipGetErrorString(err));
         exit(EXIT_FAILURE);
     }

     err = hipDeviceSynchronize();
     if (err != hipSuccess)
	 {
		fprintf(stderr, "Failed to synchronize (error code %s)!\n", hipGetErrorString(err));
		exit(EXIT_FAILURE);
	 }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////

     for (int i = 0; i < rows_a + rows_h - 1; i++) {
        for (int j = 0; j < columns_a + columns_h - 1; j++) 
        {	
			cout << fixed << setprecision(3) << h_c[(i*(columns_h+columns_a-1))+j] << " ";
		}
		cout << endl;
	}

     // Free device global memory
     err = hipFree(h_a);
 
     if (err != hipSuccess)
     {
         fprintf(stderr, "Failed to free device vector a (error code %s)!\n", hipGetErrorString(err));
         exit(EXIT_FAILURE);
     }
 
     err = hipFree(h_h);
 
     if (err != hipSuccess)
     {
         fprintf(stderr, "Failed to free device vector h (error code %s)!\n", hipGetErrorString(err));
         exit(EXIT_FAILURE);
     }
 
     err = hipFree(h_c);
 
     if (err != hipSuccess)
     {
         fprintf(stderr, "Failed to free device vector c (error code %s)!\n", hipGetErrorString(err));
         exit(EXIT_FAILURE);
     }
 
     // Reset the device and exit
     // cudaDeviceReset causes the driver to clean up all state. While
     // not mandatory in normal operation, it is good practice.  It is also
     // needed to ensure correct operation when the application is being
     // profiled. Calling cudaDeviceReset causes all profile data to be
     // flushed before the application exits
     err = hipDeviceReset();
     if (err != hipSuccess)
     {
         fprintf(stderr, "Failed to deinitialize the device! error=%s\n", hipGetErrorString(err));
         exit(EXIT_FAILURE);
     }
 
     printf("Done\n");
     return 0;
 }

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

                                        # End of file scope inline assembly
	.globl	_Z28__device_stub__convolution2DPdS_S_iiii # -- Begin function _Z28__device_stub__convolution2DPdS_S_iiii
	.type	_Z28__device_stub__convolution2DPdS_S_iiii,@function
_Z28__device_stub__convolution2DPdS_S_iiii: # @_Z28__device_stub__convolution2DPdS_S_iiii
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	20(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	16(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	12(%rsp), %r8
	movl	%r9d, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%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	$_Z13convolution2DPdS_S_iiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z28__device_stub__convolution2DPdS_S_iiii, .Lfunc_end0-_Z28__device_stub__convolution2DPdS_S_iiii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	$1000, %rsp                     # imm = 0x3E8
	.cfi_def_cfa_offset 1056
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	72(%rsp), %rax
	movq	%rax, -16(%rax)
	movq	$0, -8(%rax)
	movb	$0, (%rax)
	movq	8(%rsi), %rsi
.Ltmp0:
	leaq	480(%rsp), %r15
	movq	%r15, %rdi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
.Ltmp1:
# %bb.1:
	leaq	600(%rsp), %rdi
	callq	_ZNKSt12__basic_fileIcE7is_openEv
	xorl	%r13d, %r13d
	movl	$0, %ebp
	movl	$0, %ecx
	movq	%rcx, 8(%rsp)                   # 8-byte Spill
	movl	$0, %ecx
	movq	%rcx, 16(%rsp)                  # 8-byte Spill
	testb	%al, %al
	je	.LBB1_33
# %bb.2:                                # %.preheader189
	xorl	%eax, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	$a, %r14d
	leaq	56(%rsp), %r12
	leaq	88(%rsp), %rbx
	leaq	40(%rsp), %r13
	xorl	%ebp, %ebp
.LBB1_3:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_19 Depth 2
	movq	480(%rsp), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
.Ltmp3:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp4:
# %bb.4:                                # %.noexc
                                        #   in Loop: Header=BB1_3 Depth=1
.Ltmp5:
	movsbl	%al, %edx
	movq	%r15, %rdi
	movq	%r12, %rsi
	callq	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_
.Ltmp6:
# %bb.5:                                #   in Loop: Header=BB1_3 Depth=1
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	jne	.LBB1_7
# %bb.6:                                #   in Loop: Header=BB1_3 Depth=1
	cmpq	$0, 64(%rsp)
	je	.LBB1_7
# %bb.17:                               # %_ZStneIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_.exit.thread
                                        #   in Loop: Header=BB1_3 Depth=1
.Ltmp8:
	movq	%rbx, %rdi
	movq	%r12, %rsi
	movl	$24, %edx
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode
.Ltmp9:
# %bb.18:                               # %.preheader188.preheader
                                        #   in Loop: Header=BB1_3 Depth=1
	movq	%r14, %r15
.LBB1_19:                               # %.preheader188
                                        #   Parent Loop BB1_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
.Ltmp11:
	movq	%rbx, %rdi
	movq	%r13, %rsi
	callq	_ZNSi10_M_extractIdEERSiRT_
.Ltmp12:
# %bb.20:                               #   in Loop: Header=BB1_19 Depth=2
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	jne	.LBB1_29
# %bb.21:                               #   in Loop: Header=BB1_19 Depth=2
	movsd	40(%rsp), %xmm0                 # xmm0 = mem[0],zero
	movsd	%xmm0, (%r15)
	incl	%ebp
	addq	$8, %r15
	jmp	.LBB1_19
.LBB1_29:                               #   in Loop: Header=BB1_3 Depth=1
	incq	16(%rsp)                        # 8-byte Folded Spill
	movl	$_ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE, %esi
	movq	%rbx, %rdi
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED2Ev
	leaq	216(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	addq	$8000, %r14                     # imm = 0x1F40
	leaq	480(%rsp), %r15
	jmp	.LBB1_3
.LBB1_7:                                # %.critedge.preheader
	xorl	%eax, %eax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movl	$h, %r12d
	leaq	88(%rsp), %rbx
	leaq	40(%rsp), %r14
	xorl	%r13d, %r13d
.LBB1_8:                                # %.critedge
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_14 Depth 2
	movq	480(%rsp), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
.Ltmp14:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp15:
# %bb.9:                                # %.noexc152
                                        #   in Loop: Header=BB1_8 Depth=1
.Ltmp16:
	movsbl	%al, %edx
	movq	%r15, %rdi
	leaq	56(%rsp), %rsi
	callq	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_
.Ltmp17:
# %bb.10:                               #   in Loop: Header=BB1_8 Depth=1
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	jne	.LBB1_33
# %bb.11:                               #   in Loop: Header=BB1_8 Depth=1
	cmpq	$0, 64(%rsp)
	je	.LBB1_33
# %bb.12:                               # %_ZStneIcSt11char_traitsIcESaIcEEbRKNSt7__cxx1112basic_stringIT_T0_T1_EEPKS5_.exit157.thread
                                        #   in Loop: Header=BB1_8 Depth=1
.Ltmp19:
	movq	%rbx, %rdi
	leaq	56(%rsp), %rsi
	movl	$24, %edx
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode
.Ltmp20:
# %bb.13:                               # %.preheader187.preheader
                                        #   in Loop: Header=BB1_8 Depth=1
	movq	%r12, %r15
.LBB1_14:                               # %.preheader187
                                        #   Parent Loop BB1_8 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
.Ltmp22:
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_ZNSi10_M_extractIdEERSiRT_
.Ltmp23:
# %bb.15:                               #   in Loop: Header=BB1_14 Depth=2
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	jne	.LBB1_32
# %bb.16:                               #   in Loop: Header=BB1_14 Depth=2
	movsd	40(%rsp), %xmm0                 # xmm0 = mem[0],zero
	movsd	%xmm0, (%r15)
	incl	%r13d
	addq	$8, %r15
	jmp	.LBB1_14
.LBB1_32:                               #   in Loop: Header=BB1_8 Depth=1
	incq	8(%rsp)                         # 8-byte Folded Spill
	movl	$_ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE, %esi
	movq	%rbx, %rdi
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED2Ev
	leaq	216(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	addq	$80, %r12
	leaq	480(%rsp), %r15
	jmp	.LBB1_8
.LBB1_33:                               # %.critedge2
.Ltmp25:
	leaq	480(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv
.Ltmp26:
# %bb.34:
	movl	%ebp, %eax
	cltd
	idivl	16(%rsp)                        # 4-byte Folded Reload
	movl	%eax, %r15d
	movl	%r13d, %eax
	cltd
	idivl	8(%rsp)                         # 4-byte Folded Reload
	movl	%eax, %r12d
	movslq	%ebp, %rsi
	shlq	$3, %rsi
.Ltmp28:
	leaq	88(%rsp), %rdi
	movl	$1, %edx
	callq	hipMallocManaged
.Ltmp29:
# %bb.35:                               # %_ZL16hipMallocManagedIdE10hipError_tPPT_mj.exit
	movslq	%r13d, %rsi
	shlq	$3, %rsi
.Ltmp31:
	leaq	32(%rsp), %rdi
	movl	$1, %edx
	callq	hipMallocManaged
.Ltmp32:
# %bb.36:                               # %_ZL16hipMallocManagedIdE10hipError_tPPT_mj.exit163
.Ltmp34:
	movq	16(%rsp), %rbx                  # 8-byte Reload
	movq	8(%rsp), %r13                   # 8-byte Reload
	leal	(%rbx,%r13), %ebp
	decl	%ebp
	leal	(%r12,%r15), %r14d
	decl	%r14d
	movl	%r14d, %eax
	imull	%ebp, %eax
	movslq	%eax, %rsi
	shlq	$3, %rsi
	leaq	24(%rsp), %rdi
	movl	$1, %edx
	callq	hipMallocManaged
.Ltmp35:
# %bb.37:                               # %_ZL16hipMallocManagedIdE10hipError_tPPT_mj.exit165.preheader
	movq	%rbx, %rcx
	addl	%ebx, %r13d
	leal	(%r12,%r15), %eax
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movq	88(%rsp), %rax
	cmpl	$1, %ecx
                                        # kill: def $ecx killed $ecx killed $rcx def $rcx
	adcl	$0, %ecx
	movl	%r15d, %edx
	xorl	%esi, %esi
	movl	$a, %edi
	xorl	%r8d, %r8d
.LBB1_38:                               # %.preheader186
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_40 Depth 2
	testl	%r15d, %r15d
	jle	.LBB1_41
# %bb.39:                               # %.lr.ph
                                        #   in Loop: Header=BB1_38 Depth=1
	movl	%esi, %r9d
	leaq	(%rax,%r9,8), %r9
	xorl	%r10d, %r10d
.LBB1_40:                               #   Parent Loop BB1_38 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rdi,%r10,8), %xmm0            # xmm0 = mem[0],zero
	movsd	%xmm0, (%r9,%r10,8)
	incq	%r10
	cmpq	%r10, %rdx
	jne	.LBB1_40
.LBB1_41:                               # %_ZL16hipMallocManagedIdE10hipError_tPPT_mj.exit165
                                        #   in Loop: Header=BB1_38 Depth=1
	incq	%r8
	addl	%r15d, %esi
	addq	$8000, %rdi                     # imm = 0x1F40
	cmpq	%rcx, %r8
	jne	.LBB1_38
# %bb.42:                               # %.preheader185
	movq	32(%rsp), %rax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	cmpl	$1, %ecx
                                        # kill: def $ecx killed $ecx killed $rcx def $rcx
	adcl	$0, %ecx
	movl	%r12d, %edx
	xorl	%esi, %esi
	movl	$h, %edi
	xorl	%r8d, %r8d
.LBB1_43:                               # %.preheader184
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_45 Depth 2
	testl	%r12d, %r12d
	jle	.LBB1_46
# %bb.44:                               # %.lr.ph210
                                        #   in Loop: Header=BB1_43 Depth=1
	movl	%esi, %r9d
	leaq	(%rax,%r9,8), %r9
	xorl	%r10d, %r10d
.LBB1_45:                               #   Parent Loop BB1_43 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	(%rdi,%r10,8), %xmm0            # xmm0 = mem[0],zero
	movsd	%xmm0, (%r9,%r10,8)
	incq	%r10
	cmpq	%r10, %rdx
	jne	.LBB1_45
.LBB1_46:                               # %._crit_edge211
                                        #   in Loop: Header=BB1_43 Depth=1
	incq	%r8
	addl	%r12d, %esi
	addq	$80, %rdi
	cmpq	%rcx, %r8
	jne	.LBB1_43
# %bb.47:
	leal	-2(%r13), %eax
	leal	29(%r13), %ecx
	testl	%eax, %eax
	cmovnsl	%eax, %ecx
	sarl	$5, %ecx
	incl	%ecx
	movq	48(%rsp), %rdx                  # 8-byte Reload
	leal	-2(%rdx), %eax
	leal	29(%rdx), %edi
	testl	%eax, %eax
	cmovnsl	%eax, %edi
	sarl	$5, %edi
	incl	%edi
	shlq	$32, %rdi
	orq	%rcx, %rdi
.Ltmp37:
	movabsq	$137438953504, %rdx             # imm = 0x2000000020
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp38:
# %bb.48:
	testl	%eax, %eax
	jne	.LBB1_50
# %bb.49:
	movq	88(%rsp), %rdi
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdx
.Ltmp39:
	movl	%r12d, (%rsp)
	movq	16(%rsp), %rcx                  # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
	movl	%r15d, %r8d
	movq	8(%rsp), %r9                    # 8-byte Reload
                                        # kill: def $r9d killed $r9d killed $r9
	callq	_Z28__device_stub__convolution2DPdS_S_iiii
.Ltmp40:
.LBB1_50:
.Ltmp41:
	callq	hipGetLastError
.Ltmp42:
# %bb.51:
	testl	%eax, %eax
	jne	.LBB1_52
# %bb.57:
.Ltmp45:
	callq	hipDeviceSynchronize
.Ltmp46:
# %bb.58:
	testl	%eax, %eax
	jne	.LBB1_70
# %bb.59:                               # %.preheader183
	cmpl	$2, %r13d
	jb	.LBB1_66
# %bb.60:                               # %.preheader.lr.ph
	cmpl	$2, %r14d
	movl	$1, %eax
	movl	$1, %ecx
	cmovgel	%r14d, %ecx
	movq	%rcx, 8(%rsp)                   # 8-byte Spill
	movslq	%r14d, %r14
	cmpl	$2, %ebp
	cmovgel	%ebp, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	shlq	$3, %r14
	xorl	%r15d, %r15d
	movl	$-261, %ebx                     # imm = 0xFEFB
	xorl	%ebp, %ebp
.LBB1_61:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_72 Depth 2
	movq	8(%rsp), %r12                   # 8-byte Reload
	movq	%r15, %r13
	cmpl	$2, 48(%rsp)                    # 4-byte Folded Reload
	jl	.LBB1_62
.LBB1_72:                               #   Parent Loop BB1_61 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rcx
	movl	_ZSt4cout+24(%rcx), %edx
	andl	%ebx, %edx
	orl	$4, %edx
	movl	%edx, _ZSt4cout+24(%rcx)
	movq	-24(%rax), %rax
	movq	$3, _ZSt4cout+8(%rax)
	movq	24(%rsp), %rax
	movsd	(%rax,%r13), %xmm0              # xmm0 = mem[0],zero
.Ltmp49:
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp50:
# %bb.73:                               # %_ZNSolsEd.exit
                                        #   in Loop: Header=BB1_72 Depth=2
.Ltmp51:
	movl	$.L.str.3, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp52:
# %bb.74:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
                                        #   in Loop: Header=BB1_72 Depth=2
	addq	$8, %r13
	decq	%r12
	jne	.LBB1_72
.LBB1_62:                               # %._crit_edge216
                                        #   in Loop: Header=BB1_61 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
.Ltmp54:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp55:
# %bb.63:                               # %.noexc173
                                        #   in Loop: Header=BB1_61 Depth=1
.Ltmp56:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp57:
# %bb.64:                               # %.noexc174
                                        #   in Loop: Header=BB1_61 Depth=1
.Ltmp58:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp59:
# %bb.65:                               # %_ZNSolsEPFRSoS_E.exit
                                        #   in Loop: Header=BB1_61 Depth=1
	incq	%rbp
	addq	%r14, %r15
	cmpq	16(%rsp), %rbp                  # 8-byte Folded Reload
	jne	.LBB1_61
.LBB1_66:                               # %._crit_edge218
	movq	88(%rsp), %rdi
.Ltmp61:
	callq	hipFree
.Ltmp62:
# %bb.67:
	testl	%eax, %eax
	jne	.LBB1_68
# %bb.77:
	movq	32(%rsp), %rdi
.Ltmp65:
	callq	hipFree
.Ltmp66:
# %bb.78:
	testl	%eax, %eax
	jne	.LBB1_79
# %bb.81:
	movq	24(%rsp), %rdi
.Ltmp69:
	callq	hipFree
.Ltmp70:
# %bb.82:
	testl	%eax, %eax
	jne	.LBB1_83
# %bb.85:
.Ltmp73:
	callq	hipDeviceReset
.Ltmp74:
# %bb.86:
	testl	%eax, %eax
	jne	.LBB1_87
# %bb.89:
	movl	$.Lstr, %edi
	callq	puts@PLT
	leaq	480(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	56(%rsp), %rdi
	leaq	72(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB1_91
# %bb.90:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
	callq	_ZdlPv
.LBB1_91:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
	xorl	%eax, %eax
	addq	$1000, %rsp                     # imm = 0x3E8
	.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
.LBB1_52:
	.cfi_def_cfa_offset 1056
	movq	stderr(%rip), %rbx
.Ltmp43:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp44:
# %bb.53:
	movl	$.L.str.1, %esi
	jmp	.LBB1_54
.LBB1_70:
	movq	stderr(%rip), %rbx
.Ltmp47:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp48:
# %bb.71:
	movl	$.L.str.2, %esi
	jmp	.LBB1_54
.LBB1_68:
	movq	stderr(%rip), %rbx
.Ltmp63:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp64:
# %bb.69:
	movl	$.L.str.4, %esi
	jmp	.LBB1_54
.LBB1_79:
	movq	stderr(%rip), %rbx
.Ltmp67:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp68:
# %bb.80:
	movl	$.L.str.5, %esi
	jmp	.LBB1_54
.LBB1_83:
	movq	stderr(%rip), %rbx
.Ltmp71:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp72:
# %bb.84:
	movl	$.L.str.6, %esi
	jmp	.LBB1_54
.LBB1_87:
	movq	stderr(%rip), %rbx
.Ltmp75:
	movl	%eax, %edi
	callq	hipGetErrorString
.Ltmp76:
# %bb.88:
	movl	$.L.str.7, %esi
.LBB1_54:
	movq	%rbx, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.LBB1_92:
.Ltmp36:
	jmp	.LBB1_93
.LBB1_56:
.Ltmp33:
	jmp	.LBB1_93
.LBB1_55:
.Ltmp30:
	jmp	.LBB1_93
.LBB1_25:                               # %.loopexit.split-lp.loopexit.split-lp
.Ltmp27:
	jmp	.LBB1_93
.LBB1_22:
.Ltmp2:
	movq	%rax, %rbx
	jmp	.LBB1_95
.LBB1_98:
.Ltmp77:
	jmp	.LBB1_93
.LBB1_30:
.Ltmp21:
	jmp	.LBB1_93
.LBB1_26:
.Ltmp10:
	jmp	.LBB1_93
.LBB1_23:                               # %.loopexit
.Ltmp18:
	jmp	.LBB1_93
.LBB1_24:                               # %.loopexit.split-lp.loopexit
.Ltmp7:
	jmp	.LBB1_93
.LBB1_76:
.Ltmp60:
	jmp	.LBB1_93
.LBB1_31:
.Ltmp24:
	jmp	.LBB1_28
.LBB1_27:
.Ltmp13:
.LBB1_28:                               # %.loopexit.split-lp
	movq	%rax, %rbx
	leaq	88(%rsp), %rdi
	movl	$_ZTTNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEE, %esi
	callq	_ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEED2Ev
	leaq	216(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	jmp	.LBB1_94
.LBB1_75:
.Ltmp53:
.LBB1_93:                               # %.loopexit.split-lp
	movq	%rax, %rbx
.LBB1_94:                               # %.loopexit.split-lp
	leaq	480(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
.LBB1_95:
	movq	56(%rsp), %rdi
	leaq	72(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB1_97
# %bb.96:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i170
	callq	_ZdlPv
.LBB1_97:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit172
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.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 .Ltmp0-.Lfunc_begin0           # >> Call Site 1 <<
	.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 2 <<
	.uleb128 .Ltmp6-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp6
	.uleb128 .Ltmp7-.Lfunc_begin0           #     jumps to .Ltmp7
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp8-.Lfunc_begin0           # >> Call Site 3 <<
	.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 4 <<
	.uleb128 .Ltmp12-.Ltmp11                #   Call between .Ltmp11 and .Ltmp12
	.uleb128 .Ltmp13-.Lfunc_begin0          #     jumps to .Ltmp13
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp14-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp17-.Ltmp14                #   Call between .Ltmp14 and .Ltmp17
	.uleb128 .Ltmp18-.Lfunc_begin0          #     jumps to .Ltmp18
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp19-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp20-.Ltmp19                #   Call between .Ltmp19 and .Ltmp20
	.uleb128 .Ltmp21-.Lfunc_begin0          #     jumps to .Ltmp21
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp22-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp23-.Ltmp22                #   Call between .Ltmp22 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 .Ltmp27-.Lfunc_begin0          #     jumps to .Ltmp27
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp28-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp29-.Ltmp28                #   Call between .Ltmp28 and .Ltmp29
	.uleb128 .Ltmp30-.Lfunc_begin0          #     jumps to .Ltmp30
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp31-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp32-.Ltmp31                #   Call between .Ltmp31 and .Ltmp32
	.uleb128 .Ltmp33-.Lfunc_begin0          #     jumps to .Ltmp33
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp34-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp35-.Ltmp34                #   Call between .Ltmp34 and .Ltmp35
	.uleb128 .Ltmp36-.Lfunc_begin0          #     jumps to .Ltmp36
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp37-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp46-.Ltmp37                #   Call between .Ltmp37 and .Ltmp46
	.uleb128 .Ltmp77-.Lfunc_begin0          #     jumps to .Ltmp77
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp49-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Ltmp52-.Ltmp49                #   Call between .Ltmp49 and .Ltmp52
	.uleb128 .Ltmp53-.Lfunc_begin0          #     jumps to .Ltmp53
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp54-.Lfunc_begin0          # >> Call Site 14 <<
	.uleb128 .Ltmp59-.Ltmp54                #   Call between .Ltmp54 and .Ltmp59
	.uleb128 .Ltmp60-.Lfunc_begin0          #     jumps to .Ltmp60
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp61-.Lfunc_begin0          # >> Call Site 15 <<
	.uleb128 .Ltmp76-.Ltmp61                #   Call between .Ltmp61 and .Ltmp76
	.uleb128 .Ltmp77-.Lfunc_begin0          #     jumps to .Ltmp77
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp76-.Lfunc_begin0          # >> Call Site 16 <<
	.uleb128 .Lfunc_end1-.Ltmp76            #   Call between .Ltmp76 and .Lfunc_end1
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z13convolution2DPdS_S_iiii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	a,@object                       # @a
	.bss
	.globl	a
	.p2align	4, 0x0
a:
	.zero	8000000
	.size	a, 8000000

	.type	h,@object                       # @h
	.globl	h
	.p2align	4, 0x0
h:
	.zero	800
	.size	h, 800

	.type	c,@object                       # @c
	.globl	c
	.p2align	4, 0x0
c:
	.zero	8000000
	.size	c, 8000000

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"Failed to launch convolution2D kernel (error code %s)!\n"
	.size	.L.str.1, 56

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Failed to synchronize (error code %s)!\n"
	.size	.L.str.2, 40

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Failed to free device vector a (error code %s)!\n"
	.size	.L.str.4, 49

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Failed to free device vector h (error code %s)!\n"
	.size	.L.str.5, 49

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Failed to free device vector c (error code %s)!\n"
	.size	.L.str.6, 49

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Failed to deinitialize the device! error=%s\n"
	.size	.L.str.7, 45

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z13convolution2DPdS_S_iiii"
	.size	.L__unnamed_1, 28

	.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	"Done"
	.size	.Lstr, 5

	.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 _Z28__device_stub__convolution2DPdS_S_iiii
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z13convolution2DPdS_S_iiii
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z13convolution2DPdS_S_iiii ; -- Begin function _Z13convolution2DPdS_S_iiii
	.globl	_Z13convolution2DPdS_S_iiii
	.p2align	8
	.type	_Z13convolution2DPdS_S_iiii,@function
_Z13convolution2DPdS_S_iiii:            ; @_Z13convolution2DPdS_S_iiii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b128 s[4:7], s[0:1], 0x18
	v_and_b32_e32 v3, 0x3ff, v0
	s_mov_b32 s8, exec_lo
	s_waitcnt lgkmcnt(0)
	s_and_b32 s3, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s14, s3, v[3:4]
	s_add_i32 s3, s5, s7
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_i32 s3, s3, -1
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB0_14
; %bb.1:
	v_bfe_u32 v0, v0, 10, 10
	s_lshr_b32 s2, s2, 16
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[2:3], null, s15, s2, v[0:1]
	s_add_i32 s2, s4, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_i32 s2, s2, -1
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_cmp_gt_i32_e32 vcc_lo, s2, v2
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_14
; %bb.2:                                ; %.preheader52
	s_clause 0x1
	s_load_b128 s[8:11], s[0:1], 0x0
	s_load_b64 s[12:13], s[0:1], 0x10
	s_cmp_lt_i32 s6, 1
	s_cbranch_scc1 .LBB0_12
; %bb.3:                                ; %.preheader.lr.ph
	v_mul_lo_u32 v0, s5, v2
	v_mov_b32_e32 v3, 0
	v_mov_b32_e32 v4, 0
	s_cmp_gt_i32 s7, 0
	s_mov_b32 s15, 0
	s_cselect_b32 s16, -1, 0
	s_mov_b32 s17, 0
	s_mov_b32 s18, 0
.LBB0_4:                                ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_6 Depth 2
	s_and_not1_b32 vcc_lo, exec_lo, s16
	s_cbranch_vccnz .LBB0_11
; %bb.5:                                ; %.lr.ph
                                        ;   in Loop: Header=BB0_4 Depth=1
	v_subrev_nc_u32_e32 v5, s18, v2
	s_mov_b32 s14, s17
	s_mov_b32 s19, s7
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_lt_i32_e32 vcc_lo, -1, v5
	v_cmp_gt_i32_e64 s0, s4, v5
	v_mov_b32_e32 v5, v1
.LBB0_6:                                ;   Parent Loop BB0_4 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_and_saveexec_b32 s20, vcc_lo
	s_cbranch_execz .LBB0_10
; %bb.7:                                ;   in Loop: Header=BB0_6 Depth=2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cmp_lt_i32_e64 s1, -1, v5
	v_cmp_gt_i32_e64 s2, s5, v5
	s_and_b32 s1, s0, s1
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	s_and_b32 s1, s2, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s2, s1
	s_cbranch_execz .LBB0_9
; %bb.8:                                ;   in Loop: Header=BB0_6 Depth=2
	v_add_nc_u32_e32 v6, v0, v5
	s_lshl_b64 s[22:23], s[14:15], 3
	s_waitcnt lgkmcnt(0)
	s_add_u32 s22, s10, s22
	s_addc_u32 s23, s11, s23
	v_ashrrev_i32_e32 v7, 31, v6
	s_load_b64 s[22:23], s[22:23], 0x0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[6:7], 3, v[6:7]
	v_add_co_u32 v6, s1, s8, v6
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v7, s1, s9, v7, s1
	global_load_b64 v[6:7], v[6:7], off
	s_waitcnt vmcnt(0) lgkmcnt(0)
	v_fma_f64 v[3:4], v[6:7], s[22:23], v[3:4]
.LBB0_9:                                ; %Flow
                                        ;   in Loop: Header=BB0_6 Depth=2
	s_or_b32 exec_lo, exec_lo, s2
.LBB0_10:                               ;   in Loop: Header=BB0_6 Depth=2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_or_b32 exec_lo, exec_lo, s20
	v_add_nc_u32_e32 v5, -1, v5
	s_add_i32 s19, s19, -1
	s_add_i32 s14, s14, 1
	s_cmp_eq_u32 s19, 0
	s_cbranch_scc0 .LBB0_6
.LBB0_11:                               ; %._crit_edge
                                        ;   in Loop: Header=BB0_4 Depth=1
	v_subrev_nc_u32_e32 v0, s5, v0
	s_add_i32 s18, s18, 1
	s_add_i32 s17, s17, s7
	s_cmp_eq_u32 s18, s6
	s_cbranch_scc0 .LBB0_4
	s_branch .LBB0_13
.LBB0_12:
	v_mov_b32_e32 v3, 0
	v_mov_b32_e32 v4, 0
.LBB0_13:                               ; %._crit_edge57
	v_mad_u64_u32 v[5:6], null, v2, s3, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v6, 31, v5
	v_lshlrev_b64 v[0:1], 3, v[5:6]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v0, vcc_lo, s12, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s13, v1, vcc_lo
	global_store_b64 v[0:1], v[3:4], off
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
.LBB0_14:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z13convolution2DPdS_S_iiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 8
		.amdhsa_next_free_sgpr 24
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z13convolution2DPdS_S_iiii, .Lfunc_end0-_Z13convolution2DPdS_S_iiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 512
; NumSgprs: 26
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 26
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
