#include <cmath>
#include <chrono>
#include <cstring>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include "tiffio.h"

#define THREAD_DIM 20
#define MAX_FILTER_DIM 7

// saves TIFF file from data in `raster`
void save_tiff(const char *fname, uint32 *raster, uint32 w, uint32 h) {
    TIFF *tif = TIFFOpen(fname, "w");
    if (! raster) {
        throw std::runtime_error("Could not open output file");
    }
    TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, w);
    TIFFSetField(tif, TIFFTAG_IMAGELENGTH, h);
    TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
    TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE);
    TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
    TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
    TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
    TIFFWriteEncodedStrip(tif, 0, raster, w*h*4);
    TIFFClose(tif);
}

// loads image data from `fname` (allocating dynamic memory)
// *w and *h are updated with the image dimensions
// raster is a matrix flattened into an array using row-major order
// every uint32 in the array is 4 bytes, enconding 8-bit packed ABGR
// A: transparency attribute (can be ignored)
// B: blue pixel
// G: green pixel
// R: red pixel
uint32 *load_tiff(const char *fname, uint32 *w, uint32 *h) {
    TIFF *tif = TIFFOpen(fname, "r");
    if (! tif) {
        throw std::runtime_error("Could not open input file");
    }
    TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, w);
    TIFFGetField(tif, TIFFTAG_IMAGELENGTH, h);
    uint32 *raster = (uint32 *) _TIFFmalloc(*w * *h * sizeof (uint32));
    if (! raster) {
        TIFFClose(tif);
        throw std::runtime_error("Memory allocation error");
    }
    if (! TIFFReadRGBAImageOriented(tif, *w, *h, raster, ORIENTATION_TOPLEFT, 0)) {
        TIFFClose(tif);
        throw std::runtime_error("Could not read raster from TIFF image");
    }
    TIFFClose(tif);
    return raster;
}

// Clamp function able to be used on the GPU
__device__ void cudaClamp(float *val) {
    if (*val < 0) *val = 0;
    if (*val > 255) *val = 255;
}

void clamp(float *val) {
    if (*val < 0) *val = 0;
    if (*val > 255) *val = 255;
}

// Kernel for calculation of one pixel in the raster
__global__ void convolve(uint32 *raster, uint32 *copy,
    int w, int h, const float *filter, int st, int d) {


	// Calculate the row and column indices of the pixel to handle based on the block and thread	
    int row = st + (blockIdx.y * blockDim.y) + threadIdx.y;
    int col = st + (blockIdx.x * blockDim.x) + threadIdx.x;
    
    int accumIndex = row*w + col;
    
	// Check to make sure we are in a valid part of the grid (blocks overflow off the grid)    
    if (row < h-st && col < w-st) {
		
		// Shared memory that holds the pixels to be worked on by this thread block
    	__shared__ uint32 support[(THREAD_DIM+MAX_FILTER_DIM) * (THREAD_DIM+MAX_FILTER_DIM)];

		int supportDim = THREAD_DIM+(st*2);
		
		int supportRow = st+threadIdx.y;
		int supportCol = st+threadIdx.x;
		
		// Load in the pixels this thread is responsible for bringing into thread block shared memory
		// from the GPU global memory
		
    	// General case (load in the pixel you want to work on)
    	support[supportRow*supportDim + supportCol] = copy[row*w + col];

    	// Left edge of block
    	if (threadIdx.x == 0) { 
    		for (int k = -st; k < 0; k++) {
	    		support[supportRow*supportDim + supportCol+k] = copy[row*w + col+k];
	    	}

    		// Top left corner
    		if (threadIdx.y == 0) {
    			for (int i = -st; i <= 0; i++) {
					for (int k = -st; k <= 0; k++) {
						support[(supportRow+i)*supportDim + supportCol+k] = copy[(row+i)*w + col+k];
					}
				}
	    	}
    		// Bottom Left corner
    		if (threadIdx.y == blockDim.y-1 || row == h-st-st) {
    			for (int i = 0; i <= st; i++) {
					for (int k = -st; k < 0; k++) {
						support[(supportRow+i)*supportDim + supportCol+k] = copy[(row+i)*w + col+k];
					}
				}
    		}
    	}
    	// Right edge of block
    	if (threadIdx.x == blockDim.x-1 || col == w-st-st) {
    		for (int k = 0; k <= st; k++) {
    			support[supportRow*supportDim + supportCol+k] = copy[row*w + col+k];
    		}
    		
    		// Top right corner
    		if (threadIdx.y == 0) {
    			for (int i = -st; i <= 0; i++) {
					for (int k = 0; k <= st; k++) {
						support[(supportRow+i)*supportDim + supportCol+k] = copy[(row+i)*w + col+k];
    				}
				}
    		}
    		// Bottom right corner
    		if (threadIdx.y == blockDim.y-1 || row == h-st-st) {
				for (int i = 0; i <= st; i++) {
					for (int k = 0; k <= st; k++) {
						support[(supportRow+i)*supportDim + supportCol+k] = copy[(row+i)*w + col+k];
    				}
				}
    		}
    	}
    	// Top edge of block
    	if (threadIdx.y == 0) {
			for (int i = -st; i < 0; i++) {
	    		support[(supportRow+i)*supportDim + supportCol] = copy[(row+i)*w + col];
	    	}
    	}
    	// Bottom edge of block
    	if (threadIdx.y == blockDim.y-1 || row == h-st-st) {
			for (int i = 0; i <= st; i++) {
	    		support[(supportRow+i)*supportDim + supportCol] = copy[(row+i)*w + col];
	    	}
    	}
    	// Done creating support (in shared memory) in parallel, syncing
    	__syncthreads();

    	// Accumulate RGB values
    	float sumR, sumG, sumB;
        uint32 idx, pixel;
        
        sumR = sumG = sumB = 0;
        for (uint32 k = 0 ; k < d ; k ++) {
            idx = (supportRow-st+k)*supportDim + (supportCol-st);
            for (uint32 l = 0 ; l < d ; l++) {
                pixel = support[idx++];
                sumR += (filter[k*d + l] * TIFFGetR(pixel));
                sumG += (filter[k*d + l] * TIFFGetG(pixel));
                sumB += (filter[k*d + l] * TIFFGetB(pixel));
            }
        }
        // Check that RGB channels to write to the raster are not <0 or >255
        cudaClamp(&sumR);
        cudaClamp(&sumG);
        cudaClamp(&sumB);

        // Write the ARGB channels to the pixel using bitwise shifts and ORing of bits
        raster[row*w + col] = TIFFGetA(copy[row*w + col]) << 24 | ((uint32) sumB << 16) | ((uint32) sumG << 8) | ((uint32) sumR);
    }
}

void filter_image_seq(uint32 *raster, uint32 w, uint32 h, const float *filter, int f_len) {
    // to get RGB values from a pixel, you can either use bitwise masks
    // or rely on the following macros:
    // TIFFGetR(raster[i]) red
    // TIFFGetG(raster[i]) green
    // TIFFGetB(raster[i]) blue
    // TIFFGetA(raster[i]) this value should be ignored
    //
    // to modify RGB values from a pixel, you can use bitwise shifts or masks
    // each pixel stores values in the order ABGR
    //
    // TODO: here you will filter the image in raster
    //
    uint32 *copy = new uint32[w*h];
    std::memcpy(copy, raster, sizeof(uint32)*w*h);
    uint32 d = (uint32) std::sqrt(f_len);
    uint32 idx, pixel;
    uint32 st = d / 2;
    uint32 end_w = w - d/2;
    uint32 end_h = h - d/2;
    float sumR, sumG, sumB;
    // applies filter
    for (uint32 i = st ; i < end_h ; i++) {
        for (uint32 j = st ; j < end_w ; j++) {
            sumR = sumG = sumB = 0;
            for (uint32 k = 0 ; k < d ; k ++) {
                idx = (i-st+k)*w + (j-st);
                for (uint32 l = 0 ; l < d ; l++) {
                    pixel = copy[idx++];
                    sumR += (filter[k*d + l] * TIFFGetR(pixel));
                    sumG += (filter[k*d + l] * TIFFGetG(pixel));
                    sumB += (filter[k*d + l] * TIFFGetB(pixel));
                }
            }
            clamp(&sumR);
            clamp(&sumG);
            clamp(&sumB);
            raster[i*w + j] = TIFFGetA(raster[i*w + j]) << 24 | ((uint32) sumB << 16) | ((uint32) sumG << 8) | ((uint32) sumR);
        }
    }
    delete [] copy;
}

void filter_image_par(uint32 *raster, uint32 w, uint32 h, const float *filter, int f_len) {
    //
    // TODO: here you will filter the image in raster using GPU threads
    //

    // to get RGB values from a pixel, you can either use bitwise masks
    // or rely on the following macros:
    // TIFFGetR(raster[i]) red
    // TIFFGetG(raster[i]) green
    // TIFFGetB(raster[i]) blue
    // TIFFGetA(raster[i]) this value should be ignored
    //
    // to modify RGB values from a pixel, you can use bitwise shifts or masks
    // each pixel stores values in the order ABGR
    //
    // TODO: here you will filter the image in raster
    //
    uint32 d = (uint32) std::sqrt(f_len);
    uint32 st = d / 2;
    uint32 end_w = w - d/2;
    uint32 end_h = h - d/2;
    // CUDA CODE---------------------------------------------------------------------------
    // create pointers for the CUDA arrays
    uint32 *dev_raster;
    float *dev_filter;
    uint32 *dev_copy;
    
    // variable to check for CUDA errors
    cudaError_t status;

	// choose GPU to run
    status = cudaSetDevice(0);
    if (status != cudaSuccess) std::cerr << "cudaSetDevice failed!" << std::endl;
	
    // allocate space for the arrays in the GPU
    status = cudaMalloc(&dev_raster, sizeof(uint32) * (w*h));
    if (status != cudaSuccess) std::cerr << "cudaMalloc (in) failed!" << std::endl;
    status = cudaMalloc(&dev_copy, sizeof(uint32) * (w*h));
    if (status != cudaSuccess) std::cerr << "cudaMalloc (in) failed!" << std::endl;
    status = cudaMalloc(&dev_filter, sizeof(float) * f_len);
    if (status != cudaSuccess) std::cerr << "cudaMalloc (in) failed!" << std::endl;
    
    // transfer data from CPU to GPU
    status = cudaMemcpy(dev_raster, raster, sizeof(float) * (w*h), cudaMemcpyHostToDevice);
    if (status != cudaSuccess) std::cerr << "cudaMemcpy H2D failed!" << std::endl;
    status = cudaMemcpy(dev_copy, raster, sizeof(float) * (w*h), cudaMemcpyHostToDevice);
    if (status != cudaSuccess) std::cerr << "cudaMemcpy H2D failed!" << std::endl;
    status = cudaMemcpy(dev_filter, filter, sizeof(float) * (f_len), cudaMemcpyHostToDevice);
    if (status != cudaSuccess) std::cerr << "cudaMemcpy H2D failed!" << std::endl;

    // Computes how many blocks will fit into the image with one thread per pixel
    // Overflows past the end of the image rows and columns when the image dimensions (x&y) don't divide evenly by the block dimensions (x&y) 
    dim3 threadsPerBlock(THREAD_DIM, THREAD_DIM, 1);
    dim3 numBlocks((int)std::ceil((float)(end_w-st)/(float)threadsPerBlock.x),
                    (int)std::ceil((float)(end_h-st)/(float)threadsPerBlock.y), 1);

    // do the work in the GPU
    convolve<<<numBlocks, threadsPerBlock>>>(dev_raster, dev_copy, w, h, dev_filter, st, d);

	// wait for the kernel to finish, and check for errors
    status = cudaThreadSynchronize();
    if (status != cudaSuccess) std::cerr << "error code " << status << " returned after kernel!" << std::endl;


    // transfer results from GPU to CPU
    status = cudaMemcpy(raster, dev_raster, sizeof(uint32) * (w*h), cudaMemcpyDeviceToHost);
    if (status != cudaSuccess) std::cerr << "cudaMemcpy D2H failed!" << std::endl;

    // free the memory allocated in the GPU
    cudaFree(dev_raster);
    cudaFree(dev_filter);

}

float *load_filter(const char *fname, int *n) {
    std::ifstream myfile(fname);
    if (! myfile) {
        throw std::runtime_error("Could not open filter file");
    }
    myfile >> *n;
    float *filter = new float[*n];
    for (int i = 0 ; i < *n ; i++) myfile >> filter[i];
    myfile.close();
    return filter;
}

int main(int argc, char* argv[]) {
    if (argc != 5) {
        std::cout << "Usage:\t./filter <in_fname> <out_fname> <filter_fname> <algo>" << std::endl;
        std::cout << "<in_fname> path to the input image" << std::endl;
        std::cout << "<out_fname> path to the output image" << std::endl;
        std::cout << "<filter_fname> path to the filter file" << std::endl;
        std::cout << "<algo> whether to use the sequential (seq) or parallel algorithm (par)" << std::endl;
        return 0;
    }

    uint32 width, height;

    // loads the filter
    int f_len;
    float *filter = load_filter(argv[3], &f_len);

    // loads image bytes from file name supplied as a command line argument
    // this function allocates memory dynamically
    uint32 *image = load_tiff(argv[1], &width, &height);

	// Make a malloc in the GPU to load the CUDA library and make sure that it is working properly
    uint32 *dev_initCuda;
    cudaError_t status;
    status = cudaMalloc(&dev_initCuda, 1);
    if (status != cudaSuccess) std::cerr << "cudaMalloc (in) failed!" << std::endl;
    
    // measure time of the algorithm
    auto start = std::chrono::high_resolution_clock::now();
    if (! std::strcmp(argv[4], "seq")) {
        // call the sequential implementation
        filter_image_seq(image, width, height, filter, f_len);
    } else if (! std::strcmp(argv[4], "par")) {
        // TODO: call the parallel implementation
        filter_image_par(image, width, height, filter, f_len);
    }
    auto end = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end - start;
    std::cout << diff.count();

    // save new file with filtered image
    save_tiff(argv[2], image, width, height);

    // frees memory allocated by load_filter and load_tiff
    delete [] filter;
    _TIFFfree(image);

    return 0;
}

	.file	"tmpxft_002f7a6d_00000000-6_conv2d-CUDA-shared-memory.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3879:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3879:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4644:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4644:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"w"
.LC1:
	.string	"Could not open output file"
	.text
	.globl	_Z9save_tiffPKcPjjj
	.type	_Z9save_tiffPKcPjjj, @function
_Z9save_tiffPKcPjjj:
.LFB3865:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3865
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%ecx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rsi, %r12
	leaq	.LC0(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%r8
	.cfi_def_cfa_offset 48
.LEHB0:
	call	TIFFOpen@PLT
.LEHE0:
	testq	%r12, %r12
	jne	.L4
	movl	$16, %edi
	call	__cxa_allocate_exception@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, %rbx
.LEHB1:
	call	_ZNSt13runtime_errorC1EPKc@PLT
.LEHE1:
	movq	_ZNSt13runtime_errorD1Ev@GOTPCREL(%rip), %rdx
	leaq	_ZTISt13runtime_error(%rip), %rsi
	movq	%rbx, %rdi
.LEHB2:
	call	__cxa_throw@PLT
.L4:
	movq	%rax, %rbx
	movl	%ebp, %edx
	movq	%rax, %rdi
	movl	$256, %esi
	xorl	%eax, %eax
	imull	%r13d, %ebp
	call	TIFFSetField@PLT
	movl	%r13d, %edx
	movq	%rbx, %rdi
	movl	$257, %esi
	xorl	%eax, %eax
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$4, %edx
	xorl	%eax, %eax
	movl	$277, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$8, %edx
	xorl	%eax, %eax
	movl	$258, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$32946, %edx
	xorl	%eax, %eax
	movl	$259, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$1, %edx
	xorl	%eax, %eax
	movl	$274, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$2, %edx
	xorl	%eax, %eax
	movl	$262, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movl	$1, %edx
	xorl	%eax, %eax
	movl	$284, %esi
	call	TIFFSetField@PLT
	movq	%rbx, %rdi
	movq	%r12, %rdx
	xorl	%esi, %esi
	leal	0(,%rbp,4), %ecx
	call	TIFFWriteEncodedStrip@PLT
	popq	%rax
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	movq	%rbx, %rdi
	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
	jmp	TIFFClose@PLT
.L6:
	.cfi_restore_state
	endbr64
	movq	%rax, %rbp
.L5:
	movq	%rbx, %rdi
	call	__cxa_free_exception@PLT
	movq	%rbp, %rdi
	call	_Unwind_Resume@PLT
.LEHE2:
	.cfi_endproc
.LFE3865:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3865:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3865-.LLSDACSB3865
.LLSDACSB3865:
	.uleb128 .LEHB0-.LFB3865
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3865
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L6-.LFB3865
	.uleb128 0
	.uleb128 .LEHB2-.LFB3865
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE3865:
	.text
	.size	_Z9save_tiffPKcPjjj, .-_Z9save_tiffPKcPjjj
	.section	.rodata.str1.1
.LC2:
	.string	"r"
.LC3:
	.string	"Could not open input file"
.LC4:
	.string	"Memory allocation error"
.LC5:
	.string	"Could not read raster from TIFF image"
	.text
	.globl	_Z9load_tiffPKcPjS1_
	.type	_Z9load_tiffPKcPjS1_, @function
_Z9load_tiffPKcPjS1_:
.LFB3866:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3866
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movq	%rdx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rsi, %r12
	leaq	.LC2(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	pushq	%rcx
	.cfi_def_cfa_offset 48
.LEHB3:
	call	TIFFOpen@PLT
.LEHE3:
	testq	%rax, %rax
	jne	.L10
	movl	$16, %edi
	call	__cxa_allocate_exception@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, %rbx
.LEHB4:
	call	_ZNSt13runtime_errorC1EPKc@PLT
.LEHE4:
	jmp	.L22
.L10:
	movq	%rax, %rdi
	movq	%rax, %rbx
	movq	%r12, %rdx
	movl	$256, %esi
	xorl	%eax, %eax
.LEHB5:
	call	TIFFGetField@PLT
	movq	%r13, %rdx
	movl	$257, %esi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	TIFFGetField@PLT
	movl	(%r12), %edi
	imull	0(%r13), %edi
	salq	$2, %rdi
	call	_TIFFmalloc@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	jne	.L11
	movq	%rbx, %rdi
	call	TIFFClose@PLT
.LEHE5:
	movl	$16, %edi
	call	__cxa_allocate_exception@PLT
	leaq	.LC4(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, %rbx
.LEHB6:
	call	_ZNSt13runtime_errorC1EPKc@PLT
.LEHE6:
	jmp	.L22
.L11:
	movl	0(%r13), %edx
	movl	(%r12), %esi
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	movl	$1, %r8d
	movq	%rax, %rcx
.LEHB7:
	call	TIFFReadRGBAImageOriented@PLT
	movq	%rbx, %rdi
	testl	%eax, %eax
	jne	.L12
	call	TIFFClose@PLT
.LEHE7:
	movl	$16, %edi
	call	__cxa_allocate_exception@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, %rbx
.LEHB8:
	call	_ZNSt13runtime_errorC1EPKc@PLT
.LEHE8:
.L22:
	movq	_ZNSt13runtime_errorD1Ev@GOTPCREL(%rip), %rdx
	leaq	_ZTISt13runtime_error(%rip), %rsi
	movq	%rbx, %rdi
.LEHB9:
	call	__cxa_throw@PLT
.L16:
	endbr64
	jmp	.L23
.L17:
	endbr64
	jmp	.L23
.L18:
	endbr64
.L23:
	movq	%rax, %rbp
.L15:
	movq	%rbx, %rdi
	call	__cxa_free_exception@PLT
	movq	%rbp, %rdi
	call	_Unwind_Resume@PLT
.L12:
	call	TIFFClose@PLT
.LEHE9:
	popq	%rdx
	.cfi_def_cfa_offset 40
	movq	%rbp, %rax
	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
.LFE3866:
	.section	.gcc_except_table
.LLSDA3866:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3866-.LLSDACSB3866
.LLSDACSB3866:
	.uleb128 .LEHB3-.LFB3866
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB4-.LFB3866
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L16-.LFB3866
	.uleb128 0
	.uleb128 .LEHB5-.LFB3866
	.uleb128 .LEHE5-.LEHB5
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB6-.LFB3866
	.uleb128 .LEHE6-.LEHB6
	.uleb128 .L17-.LFB3866
	.uleb128 0
	.uleb128 .LEHB7-.LFB3866
	.uleb128 .LEHE7-.LEHB7
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB8-.LFB3866
	.uleb128 .LEHE8-.LEHB8
	.uleb128 .L18-.LFB3866
	.uleb128 0
	.uleb128 .LEHB9-.LFB3866
	.uleb128 .LEHE9-.LEHB9
	.uleb128 0
	.uleb128 0
.LLSDACSE3866:
	.text
	.size	_Z9load_tiffPKcPjS1_, .-_Z9load_tiffPKcPjS1_
	.globl	_Z9cudaClampPf
	.type	_Z9cudaClampPf, @function
_Z9cudaClampPf:
.LFB3867:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE3867:
	.size	_Z9cudaClampPf, .-_Z9cudaClampPf
	.globl	_Z5clampPf
	.type	_Z5clampPf, @function
_Z5clampPf:
.LFB3868:
	.cfi_startproc
	endbr64
	movss	(%rdi), %xmm0
	xorps	%xmm1, %xmm1
	comiss	%xmm0, %xmm1
	jbe	.L33
	movss	%xmm1, (%rdi)
	ret
.L33:
	comiss	.LC7(%rip), %xmm0
	jbe	.L26
	movl	$0x437f0000, (%rdi)
.L26:
	ret
	.cfi_endproc
.LFE3868:
	.size	_Z5clampPf, .-_Z5clampPf
	.globl	_Z16filter_image_seqPjjjPKfi
	.type	_Z16filter_image_seqPjjjPKfi, @function
_Z16filter_image_seqPjjjPKfi:
.LFB3869:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%r8d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	imull	%edx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rcx, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	salq	$2, %r14
	movl	%esi, %ebx
	movq	%r14, %rdi
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	_Znam@PLT
	movl	%ebx, %edx
	movq	%r14, %rcx
	movq	%rbp, %rsi
	movq	%rax, 8(%rsp)
	movl	%r13d, %eax
	movq	8(%rsp), %rdi
	imulq	%rax, %rdx
	salq	$2, %rdx
	call	__memcpy_chk@PLT
	cvtsi2sdl	%r15d, %xmm0
	call	sqrt@PLT
	movl	%ebx, %ecx
	leal	1(%rbx), %r9d
	xorl	%r8d, %r8d
	cvttsd2siq	%xmm0, %rax
	xorl	%r11d, %r11d
	movl	%eax, %r10d
	shrl	%eax
	subl	%eax, %ecx
	imull	%eax, %r9d
	subl	%eax, %r13d
	movl	%ecx, 20(%rsp)
	movl	%r13d, 24(%rsp)
.L35:
	movl	24(%rsp), %ecx
	leal	(%rax,%r11), %edx
	cmpl	%ecx, %edx
	jnb	.L40
	leal	(%r9,%r8), %ecx
	movl	%ecx, 28(%rsp)
	xorl	%ecx, %ecx
.L41:
	movl	20(%rsp), %esi
	leal	(%rax,%rcx), %edx
	cmpl	%esi, %edx
	jnb	.L50
	xorl	%esi, %esi
	movl	$0x00000000, 52(%rsp)
	xorps	%xmm2, %xmm2
	xorl	%r13d, %r13d
	movl	$0x00000000, 48(%rsp)
	movaps	%xmm2, %xmm1
	xorl	%edx, %edx
	movaps	%xmm2, %xmm0
	movl	$0x00000000, 44(%rsp)
	leal	(%r8,%rcx), %r14d
	movl	%esi, 16(%rsp)
.L36:
	cmpl	%r10d, 16(%rsp)
	je	.L51
	xorl	%esi, %esi
.L37:
	movq	8(%rsp), %rdi
	leal	(%rsi,%r14), %edx
	leal	(%rsi,%r13), %r15d
	incl	%esi
	movss	(%r12,%r15,4), %xmm4
	movl	(%rdi,%rdx,4), %edx
	movzbl	%dl, %r15d
	movzbl	%dh, %edi
	shrl	$16, %edx
	cvtsi2ssl	%r15d, %xmm3
	movzbl	%dl, %edx
	mulss	%xmm4, %xmm3
	addss	%xmm3, %xmm0
	cvtsi2ssl	%edi, %xmm3
	mulss	%xmm4, %xmm3
	addss	%xmm3, %xmm1
	cvtsi2ssl	%edx, %xmm3
	mulss	%xmm4, %xmm3
	addss	%xmm3, %xmm2
	cmpl	%esi, %r10d
	jne	.L37
	incl	16(%rsp)
	addl	%ebx, %r14d
	addl	%r10d, %r13d
	movb	$1, %dl
	jmp	.L36
.L51:
	testb	%dl, %dl
	je	.L38
	movss	%xmm2, 52(%rsp)
	movss	%xmm1, 48(%rsp)
	movss	%xmm0, 44(%rsp)
.L38:
	leaq	44(%rsp), %rdi
	call	_Z5clampPf
	leaq	48(%rsp), %rdi
	call	_Z5clampPf
	leaq	52(%rsp), %rdi
	call	_Z5clampPf
	movl	28(%rsp), %esi
	cvttss2siq	48(%rsp), %rdi
	leal	(%rsi,%rcx), %edx
	incl	%ecx
	leaq	0(%rbp,%rdx,4), %rsi
	cvttss2siq	52(%rsp), %rdx
	sall	$8, %edi
	sall	$16, %edx
	orl	%edx, %edi
	cvttss2siq	44(%rsp), %rdx
	orl	%edi, %edx
	movl	(%rsi), %edi
	andl	$-16777216, %edi
	orl	%edi, %edx
	movl	%edx, (%rsi)
	jmp	.L41
.L50:
	incl	%r11d
	addl	%ebx, %r8d
	jmp	.L35
.L40:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	movq	8(%rsp), %rdi
	addq	$72, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_ZdaPv@PLT
	.cfi_endproc
.LFE3869:
	.size	_Z16filter_image_seqPjjjPKfi, .-_Z16filter_image_seqPjjjPKfi
	.globl	_Z36__device_stub__Z8convolvePjS_iiPKfiiPjS_iiPKfii
	.type	_Z36__device_stub__Z8convolvePjS_iiPKfiiPjS_iiPKfii, @function
_Z36__device_stub__Z8convolvePjS_iiPKfiiPjS_iiPKfii:
.LFB3901:
	.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
	movl	%edx, 28(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 24(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 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	28(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	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	.L52
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z8convolvePjS_iiPKfii(%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
.L52:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L54
	call	__stack_chk_fail@PLT
.L54:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3901:
	.size	_Z36__device_stub__Z8convolvePjS_iiPKfiiPjS_iiPKfii, .-_Z36__device_stub__Z8convolvePjS_iiPKfiiPjS_iiPKfii
	.globl	_Z8convolvePjS_iiPKfii
	.type	_Z8convolvePjS_iiPKfii, @function
_Z8convolvePjS_iiPKfii:
.LFB3902:
	.cfi_startproc
	endbr64
	jmp	_Z36__device_stub__Z8convolvePjS_iiPKfiiPjS_iiPKfii
	.cfi_endproc
.LFE3902:
	.size	_Z8convolvePjS_iiPKfii, .-_Z8convolvePjS_iiPKfii
	.section	.rodata.str1.1
.LC8:
	.string	"cudaSetDevice failed!"
.LC9:
	.string	"cudaMalloc (in) failed!"
.LC10:
	.string	"cudaMemcpy H2D failed!"
.LC12:
	.string	"error code "
.LC13:
	.string	" returned after kernel!"
.LC14:
	.string	"cudaMemcpy D2H failed!"
	.text
	.globl	_Z16filter_image_parPjjjPKfi
	.type	_Z16filter_image_parPjjjPKfi, @function
_Z16filter_image_parPjjjPKfi:
.LFB3870:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rcx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movslq	%r8d, %rbx
	cvtsi2sdl	%ebx, %xmm0
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	call	sqrt@PLT
	xorl	%edi, %edi
	cvttsd2siq	%xmm0, %r15
	movl	%r15d, %r14d
	shrl	%r14d
	call	cudaSetDevice@PLT
	testl	%eax, %eax
	je	.L58
	leaq	.LC8(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L58:
	movl	%ebp, %eax
	leaq	24(%rsp), %rdi
	imull	%r12d, %eax
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, (%rsp)
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L59
	leaq	.LC9(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L59:
	movq	(%rsp), %rsi
	leaq	40(%rsp), %rdi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L60
	leaq	.LC9(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L60:
	salq	$2, %rbx
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L61
	leaq	.LC9(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L61:
	movq	(%rsp), %rdx
	movq	8(%rsp), %rsi
	movl	$1, %ecx
	movq	24(%rsp), %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L62
	leaq	.LC10(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L62:
	movq	(%rsp), %rdx
	movq	8(%rsp), %rsi
	movl	$1, %ecx
	movq	40(%rsp), %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L63
	leaq	.LC10(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L63:
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rdx
	movq	%r13, %rsi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L64
	leaq	.LC10(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L64:
	leal	(%r14,%r14), %r13d
	movl	%r12d, %eax
	subl	%r13d, %eax
	cvtsi2ssq	%rax, %xmm0
	divss	.LC11(%rip), %xmm0
	call	ceilf@PLT
	movl	%ebp, %eax
	subl	%r13d, %eax
	movd	%xmm0, %ebx
	cvtsi2ssq	%rax, %xmm0
	divss	.LC11(%rip), %xmm0
	call	ceilf@PLT
	movd	%ebx, %xmm1
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	cvttss2sil	%xmm0, %eax
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$85899345940, %rdx
	movl	%eax, 60(%rsp)
	cvttss2sil	%xmm1, %eax
	movl	%eax, 64(%rsp)
	movq	60(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L69
	pushq	%rax
	.cfi_def_cfa_offset 152
	movl	%r12d, %ecx
	movl	%ebp, %edx
	movl	%r14d, %r9d
	pushq	%r15
	.cfi_def_cfa_offset 160
	movq	48(%rsp), %r8
	movq	56(%rsp), %rsi
	movq	40(%rsp), %rdi
	call	_Z36__device_stub__Z8convolvePjS_iiPKfiiPjS_iiPKfii
	popq	%rdx
	.cfi_def_cfa_offset 152
	popq	%rcx
	.cfi_def_cfa_offset 144
.L69:
	call	cudaThreadSynchronize@PLT
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L70
	leaq	.LC12(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC13(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L70:
	movq	(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	8(%rsp), %rdi
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L71
	leaq	.LC14(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L71:
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L72
	call	__stack_chk_fail@PLT
.L72:
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3870:
	.size	_Z16filter_image_parPjjjPKfi, .-_Z16filter_image_parPjjjPKfi
	.section	.rodata.str1.1
.LC15:
	.string	"_Z8convolvePjS_iiPKfii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3904:
	.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	.LC15(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z8convolvePjS_iiPKfii(%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
.LFE3904:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1
.LC16:
	.string	"Could not open filter file"
	.text
	.globl	_Z11load_filterPKcPi
	.type	_Z11load_filterPKcPi, @function
_Z11load_filterPKcPi:
.LFB3871:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3871
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$8, %edx
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rsi, %r12
	movq	%rdi, %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$528, %rsp
	.cfi_def_cfa_offset 576
	movq	%fs:40, %rax
	movq	%rax, 520(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbp
	movq	%rbp, %rdi
.LEHB10:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE10:
	movl	288(%rsp), %ebx
	andl	$5, %ebx
	je	.L104
	movl	$16, %edi
	call	__cxa_allocate_exception@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, %r12
.LEHB11:
	call	_ZNSt13runtime_errorC1EPKc@PLT
.LEHE11:
	movq	520(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L116
	movq	_ZNSt13runtime_errorD1Ev@GOTPCREL(%rip), %rdx
	leaq	_ZTISt13runtime_error(%rip), %rsi
	movq	%r12, %rdi
.LEHB12:
	call	__cxa_throw@PLT
.L104:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	_ZNSirsERi@PLT
	movabsq	$2305843009213693950, %rax
	movslq	(%r12), %rdi
	cmpq	%rdi, %rax
	jb	.L106
	salq	$2, %rdi
	call	_Znam@PLT
	movq	%rax, %r13
	movq	%rax, %r14
	jmp	.L107
.L106:
	movq	520(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L116
	call	__cxa_throw_bad_array_new_length@PLT
.L109:
	movq	%r14, %rsi
	movq	%rbp, %rdi
	call	_ZNSi10_M_extractIfEERSiRT_@PLT
	incl	%ebx
	addq	$4, %r14
.L107:
	cmpl	%ebx, (%r12)
	jg	.L109
	movq	%rbp, %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv@PLT
.LEHE12:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	520(%rsp), %rax
	subq	%fs:40, %rax
	je	.L113
	jmp	.L116
.L115:
	endbr64
	movq	%rax, %rbx
.L110:
	movq	%r12, %rdi
	call	__cxa_free_exception@PLT
	jmp	.L111
.L114:
	endbr64
	movq	%rax, %rbx
.L111:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	520(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L116
	movq	%rbx, %rdi
.LEHB13:
	call	_Unwind_Resume@PLT
.LEHE13:
.L116:
	call	__stack_chk_fail@PLT
.L113:
	addq	$528, %rsp
	.cfi_def_cfa_offset 48
	movq	%r13, %rax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3871:
	.section	.gcc_except_table
.LLSDA3871:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3871-.LLSDACSB3871
.LLSDACSB3871:
	.uleb128 .LEHB10-.LFB3871
	.uleb128 .LEHE10-.LEHB10
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB11-.LFB3871
	.uleb128 .LEHE11-.LEHB11
	.uleb128 .L115-.LFB3871
	.uleb128 0
	.uleb128 .LEHB12-.LFB3871
	.uleb128 .LEHE12-.LEHB12
	.uleb128 .L114-.LFB3871
	.uleb128 0
	.uleb128 .LEHB13-.LFB3871
	.uleb128 .LEHE13-.LEHB13
	.uleb128 0
	.uleb128 0
.LLSDACSE3871:
	.text
	.size	_Z11load_filterPKcPi, .-_Z11load_filterPKcPi
	.section	.rodata.str1.1
.LC17:
	.string	"Usage:\t./filter <in_fname> <out_fname> <filter_fname> <algo>"
.LC18:
	.string	"<in_fname> path to the input image"
.LC19:
	.string	"<out_fname> path to the output image"
.LC20:
	.string	"<filter_fname> path to the filter file"
.LC21:
	.string	"<algo> whether to use the sequential (seq) or parallel algorithm (par)"
.LC22:
	.string	"seq"
.LC23:
	.string	"par"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3872:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	_ZSt4cout(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	cmpl	$5, %edi
	je	.L120
	movq	%r13, %rdi
	leaq	.LC17(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%r13, %rdi
	leaq	.LC18(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%r13, %rdi
	leaq	.LC19(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%r13, %rdi
	leaq	.LC20(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	%r13, %rdi
	leaq	.LC21(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L121
.L120:
	movq	%rsi, %r12
	leaq	12(%rsp), %rsi
	movq	24(%r12), %rdi
	call	_Z11load_filterPKcPi
	movq	8(%r12), %rdi
	leaq	4(%rsp), %rsi
	leaq	8(%rsp), %rdx
	movq	%rax, %rbp
	call	_Z9load_tiffPKcPjS1_
	leaq	16(%rsp), %rdi
	movl	$1, %esi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L122
	leaq	.LC9(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L122:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	32(%r12), %r15
	leaq	.LC22(%rip), %rsi
	movq	%rax, %r14
	movq	%r15, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L123
	movl	12(%rsp), %r8d
	movl	8(%rsp), %edx
	movq	%rbp, %rcx
	movq	%rbx, %rdi
	movl	4(%rsp), %esi
	call	_Z16filter_image_seqPjjjPKfi
	jmp	.L124
.L123:
	leaq	.LC23(%rip), %rsi
	movq	%r15, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L124
	movl	12(%rsp), %r8d
	movl	8(%rsp), %edx
	movq	%rbp, %rcx
	movq	%rbx, %rdi
	movl	4(%rsp), %esi
	call	_Z16filter_image_parPjjjPKfi
.L124:
	call	_ZNSt6chrono3_V212system_clock3nowEv@PLT
	movq	%r13, %rdi
	subq	%r14, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC24(%rip), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movl	8(%rsp), %ecx
	movl	4(%rsp), %edx
	movq	%rbx, %rsi
	movq	16(%r12), %rdi
	call	_Z9save_tiffPKcPjjj
	testq	%rbp, %rbp
	je	.L125
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
.L125:
	movq	%rbx, %rdi
	call	_TIFFfree@PLT
.L121:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L126
	call	__stack_chk_fail@PLT
.L126:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3872:
	.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
.LC7:
	.long	1132396544
	.align 4
.LC11:
	.long	1101004800
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC24:
	.long	0
	.long	1104006501
	.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 <hip/hip_runtime.h>
#include <cmath>
#include <chrono>
#include <cstring>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include "tiffio.h"

#define THREAD_DIM 20
#define MAX_FILTER_DIM 7

// saves TIFF file from data in `raster`
void save_tiff(const char *fname, uint32 *raster, uint32 w, uint32 h) {
    TIFF *tif = TIFFOpen(fname, "w");
    if (! raster) {
        throw std::runtime_error("Could not open output file");
    }
    TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, w);
    TIFFSetField(tif, TIFFTAG_IMAGELENGTH, h);
    TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 4);
    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
    TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE);
    TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
    TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
    TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
    TIFFWriteEncodedStrip(tif, 0, raster, w*h*4);
    TIFFClose(tif);
}

// loads image data from `fname` (allocating dynamic memory)
// *w and *h are updated with the image dimensions
// raster is a matrix flattened into an array using row-major order
// every uint32 in the array is 4 bytes, enconding 8-bit packed ABGR
// A: transparency attribute (can be ignored)
// B: blue pixel
// G: green pixel
// R: red pixel
uint32 *load_tiff(const char *fname, uint32 *w, uint32 *h) {
    TIFF *tif = TIFFOpen(fname, "r");
    if (! tif) {
        throw std::runtime_error("Could not open input file");
    }
    TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, w);
    TIFFGetField(tif, TIFFTAG_IMAGELENGTH, h);
    uint32 *raster = (uint32 *) _TIFFmalloc(*w * *h * sizeof (uint32));
    if (! raster) {
        TIFFClose(tif);
        throw std::runtime_error("Memory allocation error");
    }
    if (! TIFFReadRGBAImageOriented(tif, *w, *h, raster, ORIENTATION_TOPLEFT, 0)) {
        TIFFClose(tif);
        throw std::runtime_error("Could not read raster from TIFF image");
    }
    TIFFClose(tif);
    return raster;
}

// Clamp function able to be used on the GPU
__device__ void cudaClamp(float *val) {
    if (*val < 0) *val = 0;
    if (*val > 255) *val = 255;
}

void clamp(float *val) {
    if (*val < 0) *val = 0;
    if (*val > 255) *val = 255;
}

// Kernel for calculation of one pixel in the raster
__global__ void convolve(uint32 *raster, uint32 *copy,
    int w, int h, const float *filter, int st, int d) {


	// Calculate the row and column indices of the pixel to handle based on the block and thread	
    int row = st + (blockIdx.y * blockDim.y) + threadIdx.y;
    int col = st + (blockIdx.x * blockDim.x) + threadIdx.x;
    
    int accumIndex = row*w + col;
    
	// Check to make sure we are in a valid part of the grid (blocks overflow off the grid)    
    if (row < h-st && col < w-st) {
		
		// Shared memory that holds the pixels to be worked on by this thread block
    	__shared__ uint32 support[(THREAD_DIM+MAX_FILTER_DIM) * (THREAD_DIM+MAX_FILTER_DIM)];

		int supportDim = THREAD_DIM+(st*2);
		
		int supportRow = st+threadIdx.y;
		int supportCol = st+threadIdx.x;
		
		// Load in the pixels this thread is responsible for bringing into thread block shared memory
		// from the GPU global memory
		
    	// General case (load in the pixel you want to work on)
    	support[supportRow*supportDim + supportCol] = copy[row*w + col];

    	// Left edge of block
    	if (threadIdx.x == 0) { 
    		for (int k = -st; k < 0; k++) {
	    		support[supportRow*supportDim + supportCol+k] = copy[row*w + col+k];
	    	}

    		// Top left corner
    		if (threadIdx.y == 0) {
    			for (int i = -st; i <= 0; i++) {
					for (int k = -st; k <= 0; k++) {
						support[(supportRow+i)*supportDim + supportCol+k] = copy[(row+i)*w + col+k];
					}
				}
	    	}
    		// Bottom Left corner
    		if (threadIdx.y == blockDim.y-1 || row == h-st-st) {
    			for (int i = 0; i <= st; i++) {
					for (int k = -st; k < 0; k++) {
						support[(supportRow+i)*supportDim + supportCol+k] = copy[(row+i)*w + col+k];
					}
				}
    		}
    	}
    	// Right edge of block
    	if (threadIdx.x == blockDim.x-1 || col == w-st-st) {
    		for (int k = 0; k <= st; k++) {
    			support[supportRow*supportDim + supportCol+k] = copy[row*w + col+k];
    		}
    		
    		// Top right corner
    		if (threadIdx.y == 0) {
    			for (int i = -st; i <= 0; i++) {
					for (int k = 0; k <= st; k++) {
						support[(supportRow+i)*supportDim + supportCol+k] = copy[(row+i)*w + col+k];
    				}
				}
    		}
    		// Bottom right corner
    		if (threadIdx.y == blockDim.y-1 || row == h-st-st) {
				for (int i = 0; i <= st; i++) {
					for (int k = 0; k <= st; k++) {
						support[(supportRow+i)*supportDim + supportCol+k] = copy[(row+i)*w + col+k];
    				}
				}
    		}
    	}
    	// Top edge of block
    	if (threadIdx.y == 0) {
			for (int i = -st; i < 0; i++) {
	    		support[(supportRow+i)*supportDim + supportCol] = copy[(row+i)*w + col];
	    	}
    	}
    	// Bottom edge of block
    	if (threadIdx.y == blockDim.y-1 || row == h-st-st) {
			for (int i = 0; i <= st; i++) {
	    		support[(supportRow+i)*supportDim + supportCol] = copy[(row+i)*w + col];
	    	}
    	}
    	// Done creating support (in shared memory) in parallel, syncing
    	__syncthreads();

    	// Accumulate RGB values
    	float sumR, sumG, sumB;
        uint32 idx, pixel;
        
        sumR = sumG = sumB = 0;
        for (uint32 k = 0 ; k < d ; k ++) {
            idx = (supportRow-st+k)*supportDim + (supportCol-st);
            for (uint32 l = 0 ; l < d ; l++) {
                pixel = support[idx++];
                sumR += (filter[k*d + l] * TIFFGetR(pixel));
                sumG += (filter[k*d + l] * TIFFGetG(pixel));
                sumB += (filter[k*d + l] * TIFFGetB(pixel));
            }
        }
        // Check that RGB channels to write to the raster are not <0 or >255
        cudaClamp(&sumR);
        cudaClamp(&sumG);
        cudaClamp(&sumB);

        // Write the ARGB channels to the pixel using bitwise shifts and ORing of bits
        raster[row*w + col] = TIFFGetA(copy[row*w + col]) << 24 | ((uint32) sumB << 16) | ((uint32) sumG << 8) | ((uint32) sumR);
    }
}

void filter_image_seq(uint32 *raster, uint32 w, uint32 h, const float *filter, int f_len) {
    // to get RGB values from a pixel, you can either use bitwise masks
    // or rely on the following macros:
    // TIFFGetR(raster[i]) red
    // TIFFGetG(raster[i]) green
    // TIFFGetB(raster[i]) blue
    // TIFFGetA(raster[i]) this value should be ignored
    //
    // to modify RGB values from a pixel, you can use bitwise shifts or masks
    // each pixel stores values in the order ABGR
    //
    // TODO: here you will filter the image in raster
    //
    uint32 *copy = new uint32[w*h];
    std::memcpy(copy, raster, sizeof(uint32)*w*h);
    uint32 d = (uint32) std::sqrt(f_len);
    uint32 idx, pixel;
    uint32 st = d / 2;
    uint32 end_w = w - d/2;
    uint32 end_h = h - d/2;
    float sumR, sumG, sumB;
    // applies filter
    for (uint32 i = st ; i < end_h ; i++) {
        for (uint32 j = st ; j < end_w ; j++) {
            sumR = sumG = sumB = 0;
            for (uint32 k = 0 ; k < d ; k ++) {
                idx = (i-st+k)*w + (j-st);
                for (uint32 l = 0 ; l < d ; l++) {
                    pixel = copy[idx++];
                    sumR += (filter[k*d + l] * TIFFGetR(pixel));
                    sumG += (filter[k*d + l] * TIFFGetG(pixel));
                    sumB += (filter[k*d + l] * TIFFGetB(pixel));
                }
            }
            clamp(&sumR);
            clamp(&sumG);
            clamp(&sumB);
            raster[i*w + j] = TIFFGetA(raster[i*w + j]) << 24 | ((uint32) sumB << 16) | ((uint32) sumG << 8) | ((uint32) sumR);
        }
    }
    delete [] copy;
}

void filter_image_par(uint32 *raster, uint32 w, uint32 h, const float *filter, int f_len) {
    //
    // TODO: here you will filter the image in raster using GPU threads
    //

    // to get RGB values from a pixel, you can either use bitwise masks
    // or rely on the following macros:
    // TIFFGetR(raster[i]) red
    // TIFFGetG(raster[i]) green
    // TIFFGetB(raster[i]) blue
    // TIFFGetA(raster[i]) this value should be ignored
    //
    // to modify RGB values from a pixel, you can use bitwise shifts or masks
    // each pixel stores values in the order ABGR
    //
    // TODO: here you will filter the image in raster
    //
    uint32 d = (uint32) std::sqrt(f_len);
    uint32 st = d / 2;
    uint32 end_w = w - d/2;
    uint32 end_h = h - d/2;
    // CUDA CODE---------------------------------------------------------------------------
    // create pointers for the CUDA arrays
    uint32 *dev_raster;
    float *dev_filter;
    uint32 *dev_copy;
    
    // variable to check for CUDA errors
    hipError_t status;

	// choose GPU to run
    status = hipSetDevice(0);
    if (status != hipSuccess) std::cerr << "hipSetDevice failed!" << std::endl;
	
    // allocate space for the arrays in the GPU
    status = hipMalloc(&dev_raster, sizeof(uint32) * (w*h));
    if (status != hipSuccess) std::cerr << "hipMalloc (in) failed!" << std::endl;
    status = hipMalloc(&dev_copy, sizeof(uint32) * (w*h));
    if (status != hipSuccess) std::cerr << "hipMalloc (in) failed!" << std::endl;
    status = hipMalloc(&dev_filter, sizeof(float) * f_len);
    if (status != hipSuccess) std::cerr << "hipMalloc (in) failed!" << std::endl;
    
    // transfer data from CPU to GPU
    status = hipMemcpy(dev_raster, raster, sizeof(float) * (w*h), hipMemcpyHostToDevice);
    if (status != hipSuccess) std::cerr << "hipMemcpy H2D failed!" << std::endl;
    status = hipMemcpy(dev_copy, raster, sizeof(float) * (w*h), hipMemcpyHostToDevice);
    if (status != hipSuccess) std::cerr << "hipMemcpy H2D failed!" << std::endl;
    status = hipMemcpy(dev_filter, filter, sizeof(float) * (f_len), hipMemcpyHostToDevice);
    if (status != hipSuccess) std::cerr << "hipMemcpy H2D failed!" << std::endl;

    // Computes how many blocks will fit into the image with one thread per pixel
    // Overflows past the end of the image rows and columns when the image dimensions (x&y) don't divide evenly by the block dimensions (x&y) 
    dim3 threadsPerBlock(THREAD_DIM, THREAD_DIM, 1);
    dim3 numBlocks((int)std::ceil((float)(end_w-st)/(float)threadsPerBlock.x),
                    (int)std::ceil((float)(end_h-st)/(float)threadsPerBlock.y), 1);

    // do the work in the GPU
    convolve<<<numBlocks, threadsPerBlock>>>(dev_raster, dev_copy, w, h, dev_filter, st, d);

	// wait for the kernel to finish, and check for errors
    status = hipDeviceSynchronize();
    if (status != hipSuccess) std::cerr << "error code " << status << " returned after kernel!" << std::endl;


    // transfer results from GPU to CPU
    status = hipMemcpy(raster, dev_raster, sizeof(uint32) * (w*h), hipMemcpyDeviceToHost);
    if (status != hipSuccess) std::cerr << "hipMemcpy D2H failed!" << std::endl;

    // free the memory allocated in the GPU
    hipFree(dev_raster);
    hipFree(dev_filter);

}

float *load_filter(const char *fname, int *n) {
    std::ifstream myfile(fname);
    if (! myfile) {
        throw std::runtime_error("Could not open filter file");
    }
    myfile >> *n;
    float *filter = new float[*n];
    for (int i = 0 ; i < *n ; i++) myfile >> filter[i];
    myfile.close();
    return filter;
}

int main(int argc, char* argv[]) {
    if (argc != 5) {
        std::cout << "Usage:\t./filter <in_fname> <out_fname> <filter_fname> <algo>" << std::endl;
        std::cout << "<in_fname> path to the input image" << std::endl;
        std::cout << "<out_fname> path to the output image" << std::endl;
        std::cout << "<filter_fname> path to the filter file" << std::endl;
        std::cout << "<algo> whether to use the sequential (seq) or parallel algorithm (par)" << std::endl;
        return 0;
    }

    uint32 width, height;

    // loads the filter
    int f_len;
    float *filter = load_filter(argv[3], &f_len);

    // loads image bytes from file name supplied as a command line argument
    // this function allocates memory dynamically
    uint32 *image = load_tiff(argv[1], &width, &height);

	// Make a malloc in the GPU to load the CUDA library and make sure that it is working properly
    uint32 *dev_initCuda;
    hipError_t status;
    status = hipMalloc(&dev_initCuda, 1);
    if (status != hipSuccess) std::cerr << "hipMalloc (in) failed!" << std::endl;
    
    // measure time of the algorithm
    auto start = std::chrono::high_resolution_clock::now();
    if (! std::strcmp(argv[4], "seq")) {
        // call the sequential implementation
        filter_image_seq(image, width, height, filter, f_len);
    } else if (! std::strcmp(argv[4], "par")) {
        // TODO: call the parallel implementation
        filter_image_par(image, width, height, filter, f_len);
    }
    auto end = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end - start;
    std::cout << diff.count();

    // save new file with filtered image
    save_tiff(argv[2], image, width, height);

    // frees memory allocated by load_filter and load_tiff
    delete [] filter;
    _TIFFfree(image);

    return 0;
}

	.text
	.file	"conv2d-CUDA-shared-memory.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z9save_tiffPKcPjjj             # -- Begin function _Z9save_tiffPKcPjjj
	.type	_Z9save_tiffPKcPjjj,@function
_Z9save_tiffPKcPjjj:                    # @_Z9save_tiffPKcPjjj
.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	%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	%ecx, %ebp
	movl	%edx, %ebx
	movq	%rsi, %r14
	movl	$.L.str, %esi
	callq	TIFFOpen
	testq	%r14, %r14
	je	.LBB0_1
# %bb.4:
	movq	%rax, %r15
	movq	%rax, %rdi
	movl	$256, %esi                      # imm = 0x100
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%r15, %rdi
	movl	$257, %esi                      # imm = 0x101
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%r15, %rdi
	movl	$277, %esi                      # imm = 0x115
	movl	$4, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%r15, %rdi
	movl	$258, %esi                      # imm = 0x102
	movl	$8, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%r15, %rdi
	movl	$259, %esi                      # imm = 0x103
	movl	$32946, %edx                    # imm = 0x80B2
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%r15, %rdi
	movl	$274, %esi                      # imm = 0x112
	movl	$1, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%r15, %rdi
	movl	$262, %esi                      # imm = 0x106
	movl	$2, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	movq	%r15, %rdi
	movl	$284, %esi                      # imm = 0x11C
	movl	$1, %edx
	xorl	%eax, %eax
	callq	TIFFSetField
	imull	%ebp, %ebx
	shll	$2, %ebx
	movq	%r15, %rdi
	xorl	%esi, %esi
	movq	%r14, %rdx
	movq	%rbx, %rcx
	callq	TIFFWriteEncodedStrip
	movq	%r15, %rdi
	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
	jmp	TIFFClose                       # TAILCALL
.LBB0_1:
	.cfi_def_cfa_offset 48
	movl	$16, %edi
	callq	__cxa_allocate_exception
	movq	%rax, %rbx
.Ltmp0:
	movl	$.L.str.1, %esi
	movq	%rax, %rdi
	callq	_ZNSt13runtime_errorC1EPKc
.Ltmp1:
# %bb.2:
	movl	$_ZTISt13runtime_error, %esi
	movl	$_ZNSt13runtime_errorD1Ev, %edx
	movq	%rbx, %rdi
	callq	__cxa_throw
.LBB0_3:
.Ltmp2:
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	__cxa_free_exception
	movq	%r14, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end0:
	.size	_Z9save_tiffPKcPjjj, .Lfunc_end0-_Z9save_tiffPKcPjjj
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table0:
.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 .Ltmp1-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Lfunc_end0-.Ltmp1             #   Call between .Ltmp1 and .Lfunc_end0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z9load_tiffPKcPjS1_            # -- Begin function _Z9load_tiffPKcPjS1_
	.type	_Z9load_tiffPKcPjS1_,@function
_Z9load_tiffPKcPjS1_:                   # @_Z9load_tiffPKcPjS1_
.Lfunc_begin1:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception1
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdx, %r14
	movq	%rsi, %r15
	movl	$.L.str.2, %esi
	callq	TIFFOpen
	testq	%rax, %rax
	je	.LBB1_1
# %bb.3:
	movq	%rax, %rbx
	movq	%rax, %rdi
	movl	$256, %esi                      # imm = 0x100
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	TIFFGetField
	movq	%rbx, %rdi
	movl	$257, %esi                      # imm = 0x101
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	TIFFGetField
	movl	(%r14), %edi
	imull	(%r15), %edi
	shlq	$2, %rdi
	callq	_TIFFmalloc
	testq	%rax, %rax
	je	.LBB1_4
# %bb.6:
	movq	%rax, %r12
	movl	(%r15), %esi
	movl	(%r14), %edx
	movq	%rbx, %rdi
	movq	%rax, %rcx
	movl	$1, %r8d
	xorl	%r9d, %r9d
	callq	TIFFReadRGBAImageOriented
	movl	%eax, %ebp
	movq	%rbx, %rdi
	callq	TIFFClose
	testl	%ebp, %ebp
	je	.LBB1_7
# %bb.9:
	movq	%r12, %rax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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_1:
	.cfi_def_cfa_offset 48
	movl	$16, %edi
	callq	__cxa_allocate_exception
	movq	%rax, %rbx
.Ltmp9:
	movl	$.L.str.3, %esi
	movq	%rax, %rdi
	callq	_ZNSt13runtime_errorC1EPKc
.Ltmp10:
	jmp	.LBB1_2
.LBB1_4:
	movq	%rbx, %rdi
	callq	TIFFClose
	movl	$16, %edi
	callq	__cxa_allocate_exception
	movq	%rax, %rbx
.Ltmp6:
	movl	$.L.str.4, %esi
	movq	%rax, %rdi
	callq	_ZNSt13runtime_errorC1EPKc
.Ltmp7:
	jmp	.LBB1_2
.LBB1_7:
	movl	$16, %edi
	callq	__cxa_allocate_exception
	movq	%rax, %rbx
.Ltmp3:
	movl	$.L.str.5, %esi
	movq	%rax, %rdi
	callq	_ZNSt13runtime_errorC1EPKc
.Ltmp4:
.LBB1_2:
	movl	$_ZTISt13runtime_error, %esi
	movl	$_ZNSt13runtime_errorD1Ev, %edx
	movq	%rbx, %rdi
	callq	__cxa_throw
.LBB1_8:
.Ltmp5:
	jmp	.LBB1_11
.LBB1_5:
.Ltmp8:
	jmp	.LBB1_11
.LBB1_10:
.Ltmp11:
.LBB1_11:
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	__cxa_free_exception
	movq	%r14, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	_Z9load_tiffPKcPjS1_, .Lfunc_end1-_Z9load_tiffPKcPjS1_
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.Lexception1:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end1-.Lcst_begin1
.Lcst_begin1:
	.uleb128 .Lfunc_begin1-.Lfunc_begin1    # >> Call Site 1 <<
	.uleb128 .Ltmp9-.Lfunc_begin1           #   Call between .Lfunc_begin1 and .Ltmp9
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp9-.Lfunc_begin1           # >> Call Site 2 <<
	.uleb128 .Ltmp10-.Ltmp9                 #   Call between .Ltmp9 and .Ltmp10
	.uleb128 .Ltmp11-.Lfunc_begin1          #     jumps to .Ltmp11
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp10-.Lfunc_begin1          # >> Call Site 3 <<
	.uleb128 .Ltmp6-.Ltmp10                 #   Call between .Ltmp10 and .Ltmp6
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp6-.Lfunc_begin1           # >> Call Site 4 <<
	.uleb128 .Ltmp7-.Ltmp6                  #   Call between .Ltmp6 and .Ltmp7
	.uleb128 .Ltmp8-.Lfunc_begin1           #     jumps to .Ltmp8
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp7-.Lfunc_begin1           # >> Call Site 5 <<
	.uleb128 .Ltmp3-.Ltmp7                  #   Call between .Ltmp7 and .Ltmp3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin1           # >> Call Site 6 <<
	.uleb128 .Ltmp4-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp4
	.uleb128 .Ltmp5-.Lfunc_begin1           #     jumps to .Ltmp5
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp4-.Lfunc_begin1           # >> Call Site 7 <<
	.uleb128 .Lfunc_end1-.Ltmp4             #   Call between .Ltmp4 and .Lfunc_end1
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end1:
	.p2align	2, 0x0
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z5clampPf
.LCPI2_0:
	.long	0x437f0000                      # float 255
	.text
	.globl	_Z5clampPf
	.type	_Z5clampPf,@function
_Z5clampPf:                             # @_Z5clampPf
	.cfi_startproc
# %bb.0:
	movss	(%rdi), %xmm1                   # xmm1 = mem[0],zero,zero,zero
	xorps	%xmm0, %xmm0
	ucomiss	%xmm1, %xmm0
	ja	.LBB2_2
# %bb.1:
	movss	.LCPI2_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	jbe	.LBB2_3
.LBB2_2:                                # %.sink.split
	movss	%xmm0, (%rdi)
.LBB2_3:
	retq
.Lfunc_end2:
	.size	_Z5clampPf, .Lfunc_end2-_Z5clampPf
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__convolvePjS_iiPKfii # -- Begin function _Z23__device_stub__convolvePjS_iiPKfii
	.type	_Z23__device_stub__convolvePjS_iiPKfii,@function
_Z23__device_stub__convolvePjS_iiPKfii: # @_Z23__device_stub__convolvePjS_iiPKfii
	.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	20(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	16(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	40(%rsp), %rcx
	movq	%r8, (%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	$_Z8convolvePjS_iiPKfii, %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_end3:
	.size	_Z23__device_stub__convolvePjS_iiPKfii, .Lfunc_end3-_Z23__device_stub__convolvePjS_iiPKfii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z16filter_image_seqPjjjPKfi
.LCPI4_0:
	.long	0x437f0000                      # float 255
	.text
	.globl	_Z16filter_image_seqPjjjPKfi
	.type	_Z16filter_image_seqPjjjPKfi,@function
_Z16filter_image_seqPjjjPKfi:           # @_Z16filter_image_seqPjjjPKfi
	.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	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.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	%r8d, 16(%rsp)                  # 4-byte Spill
	movq	%rcx, %rbx
	movl	%edx, %ebp
	movl	%esi, %r14d
	movq	%rdi, %r15
	movl	%edx, %edi
	imull	%esi, %edi
	shlq	$2, %rdi
	callq	_Znam
	movq	%rax, %r12
	movq	%r14, 32(%rsp)                  # 8-byte Spill
	movl	%r14d, %r13d
	movl	%ebp, %r14d
	movl	%ebp, %edx
	imulq	%r13, %rdx
	shlq	$2, %rdx
	movq	%rax, %rdi
	movq	%r15, %rsi
	callq	memcpy@PLT
	cvtsi2sdl	16(%rsp), %xmm0         # 4-byte Folded Reload
	xorpd	%xmm1, %xmm1
	ucomisd	%xmm1, %xmm0
	jb	.LBB4_2
# %bb.1:
	sqrtsd	%xmm0, %xmm0
	jmp	.LBB4_3
.LBB4_2:                                # %call.sqrt
	callq	sqrt
.LBB4_3:                                # %.split
	cvttsd2si	%xmm0, %rax
	movl	%eax, %ecx
	shrl	%ecx
	subl	%ecx, %r14d
	movl	%r14d, 28(%rsp)                 # 4-byte Spill
	movl	%ecx, 20(%rsp)                  # 4-byte Spill
	cmpl	%r14d, %ecx
	jae	.LBB4_21
# %bb.4:                                # %.preheader83.lr.ph
	movl	%eax, %ecx
	movq	32(%rsp), %rax                  # 8-byte Reload
	movl	%eax, %esi
	movl	20(%rsp), %edx                  # 4-byte Reload
	subl	%edx, %esi
	movl	%esi, 24(%rsp)                  # 4-byte Spill
	movl	%ecx, %esi
	shrl	%esi
	leal	(%rsi,%rax), %edi
	movl	%ecx, %eax
	andl	$-2, %eax
	subl	%eax, %edi
	movl	%edi, 16(%rsp)                  # 4-byte Spill
	movq	%rsi, 48(%rsp)                  # 8-byte Spill
                                        # kill: def $esi killed $esi killed $rsi def $rsi
	subl	%edx, %esi
	movq	%rsi, 40(%rsp)                  # 8-byte Spill
	movl	$255, %r9d
	movss	.LCPI4_0(%rip), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movl	%edx, 12(%rsp)                  # 4-byte Spill
.LBB4_5:                                # %.preheader83
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_7 Depth 2
                                        #       Child Loop BB4_23 Depth 3
                                        #         Child Loop BB4_24 Depth 4
	movl	24(%rsp), %eax                  # 4-byte Reload
	cmpl	%eax, 20(%rsp)                  # 4-byte Folded Reload
	jae	.LBB4_20
# %bb.6:                                # %.preheader.lr.ph
                                        #   in Loop: Header=BB4_5 Depth=1
	movl	12(%rsp), %eax                  # 4-byte Reload
	movl	%eax, %r11d
	imull	32(%rsp), %r11d                 # 4-byte Folded Reload
	movq	40(%rsp), %rsi                  # 8-byte Reload
	movq	48(%rsp), %r14                  # 8-byte Reload
.LBB4_7:                                # %.preheader
                                        #   Parent Loop BB4_5 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB4_23 Depth 3
                                        #         Child Loop BB4_24 Depth 4
	testq	%rcx, %rcx
	je	.LBB4_8
# %bb.22:                               # %.lr.ph
                                        #   in Loop: Header=BB4_7 Depth=2
	xorpd	%xmm1, %xmm1
	xorl	%edx, %edx
	movq	%rsi, %r8
	xorl	%eax, %eax
	xorps	%xmm2, %xmm2
	xorps	%xmm3, %xmm3
.LBB4_23:                               #   Parent Loop BB4_5 Depth=1
                                        #     Parent Loop BB4_7 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB4_24 Depth 4
	xorl	%ebp, %ebp
.LBB4_24:                               #   Parent Loop BB4_5 Depth=1
                                        #     Parent Loop BB4_7 Depth=2
                                        #       Parent Loop BB4_23 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	leal	(%r8,%rbp), %r10d
	movl	(%r12,%r10,4), %edi
	movl	%edi, %r10d
	andl	%r9d, %r10d
	xorps	%xmm4, %xmm4
	cvtsi2ss	%r10d, %xmm4
	leal	(%rdx,%rbp), %r10d
	movss	(%rbx,%r10,4), %xmm5            # xmm5 = mem[0],zero,zero,zero
	mulss	%xmm5, %xmm4
	movl	%edi, %r10d
	shrl	$8, %r10d
	andl	%r9d, %r10d
	xorps	%xmm6, %xmm6
	cvtsi2ss	%r10d, %xmm6
	addss	%xmm4, %xmm3
	mulss	%xmm5, %xmm6
	addss	%xmm6, %xmm2
	shrl	$16, %edi
	andl	%r9d, %edi
	xorps	%xmm4, %xmm4
	cvtsi2ss	%edi, %xmm4
	mulss	%xmm5, %xmm4
	addss	%xmm4, %xmm1
	incq	%rbp
	cmpq	%rbp, %rcx
	jne	.LBB4_24
# %bb.25:                               #   in Loop: Header=BB4_23 Depth=3
	incl	%eax
	addq	%rcx, %rdx
	addq	%r13, %r8
	cmpl	%ecx, %eax
	jne	.LBB4_23
# %bb.9:                                # %._crit_edge
                                        #   in Loop: Header=BB4_7 Depth=2
	xorps	%xmm5, %xmm5
	ucomiss	%xmm3, %xmm5
	xorps	%xmm4, %xmm4
	ja	.LBB4_12
# %bb.10:                               #   in Loop: Header=BB4_7 Depth=2
	ucomiss	%xmm0, %xmm3
	movaps	%xmm3, %xmm4
	jbe	.LBB4_12
# %bb.11:                               # %.sink.split.i
                                        #   in Loop: Header=BB4_7 Depth=2
	movaps	%xmm0, %xmm4
.LBB4_12:                               # %_Z5clampPf.exit
                                        #   in Loop: Header=BB4_7 Depth=2
	ucomiss	%xmm2, %xmm5
	ja	.LBB4_15
# %bb.13:                               #   in Loop: Header=BB4_7 Depth=2
	ucomiss	%xmm0, %xmm2
	movaps	%xmm2, %xmm5
	jbe	.LBB4_15
# %bb.14:                               # %.sink.split.i62
                                        #   in Loop: Header=BB4_7 Depth=2
	movaps	%xmm0, %xmm5
.LBB4_15:                               # %_Z5clampPf.exit64
                                        #   in Loop: Header=BB4_7 Depth=2
	xorps	%xmm2, %xmm2
	ucomiss	%xmm1, %xmm2
	ja	.LBB4_19
# %bb.16:                               #   in Loop: Header=BB4_7 Depth=2
	ucomiss	%xmm0, %xmm1
	jbe	.LBB4_17
# %bb.18:                               # %.sink.split.i65
                                        #   in Loop: Header=BB4_7 Depth=2
	movaps	%xmm0, %xmm2
	jmp	.LBB4_19
.LBB4_8:                                #   in Loop: Header=BB4_7 Depth=2
	xorps	%xmm5, %xmm5
	xorps	%xmm4, %xmm4
	xorps	%xmm2, %xmm2
	jmp	.LBB4_19
.LBB4_17:                               #   in Loop: Header=BB4_7 Depth=2
	movaps	%xmm1, %xmm2
.LBB4_19:                               # %_Z5clampPf.exit67
                                        #   in Loop: Header=BB4_7 Depth=2
	leal	(%r11,%r14), %eax
	movzbl	3(%r15,%rax,4), %edx
	shll	$24, %edx
	cvttss2si	%xmm2, %r8
	shll	$16, %r8d
	orl	%edx, %r8d
	cvttss2si	%xmm5, %rdx
	shll	$8, %edx
	cvttss2si	%xmm4, %rbp
	orl	%edx, %ebp
	orl	%r8d, %ebp
	movl	%ebp, (%r15,%rax,4)
	incq	%r14
	incq	%rsi
	cmpl	%r14d, 16(%rsp)                 # 4-byte Folded Reload
	jne	.LBB4_7
.LBB4_20:                               # %._crit_edge96
                                        #   in Loop: Header=BB4_5 Depth=1
	movl	12(%rsp), %eax                  # 4-byte Reload
	incl	%eax
	addq	%r13, 40(%rsp)                  # 8-byte Folded Spill
	movl	%eax, 12(%rsp)                  # 4-byte Spill
	cmpl	28(%rsp), %eax                  # 4-byte Folded Reload
	jne	.LBB4_5
.LBB4_21:                               # %._crit_edge98
	movq	%r12, %rdi
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_ZdaPv                          # TAILCALL
.Lfunc_end4:
	.size	_Z16filter_image_seqPjjjPKfi, .Lfunc_end4-_Z16filter_image_seqPjjjPKfi
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z16filter_image_parPjjjPKfi
.LCPI5_0:
	.long	0x41a00000                      # float 20
	.text
	.globl	_Z16filter_image_parPjjjPKfi
	.type	_Z16filter_image_parPjjjPKfi,@function
_Z16filter_image_parPjjjPKfi:           # @_Z16filter_image_parPjjjPKfi
	.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	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.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	%r8d, %r13d
	movq	%rcx, 48(%rsp)                  # 8-byte Spill
	movl	%edx, %ebp
	movl	%esi, %ebx
	cvtsi2sd	%r8d, %xmm0
	movq	%rdi, 16(%rsp)                  # 8-byte Spill
	xorpd	%xmm1, %xmm1
	ucomisd	%xmm1, %xmm0
	jb	.LBB5_2
# %bb.1:
	sqrtsd	%xmm0, %xmm0
	jmp	.LBB5_3
.LBB5_2:                                # %call.sqrt
	callq	sqrt
.LBB5_3:                                # %.split
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	xorl	%edi, %edi
	callq	hipSetDevice
	testl	%eax, %eax
	je	.LBB5_5
# %bb.4:
	movl	$_ZSt4cerr, %r14d
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.6, %esi
	movl	$20, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB5_5:
	movl	%ebp, %r14d
	imull	%ebx, %r14d
	shlq	$2, %r14
	leaq	8(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB5_7
# %bb.6:
	movl	$_ZSt4cerr, %r12d
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.7, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB5_7:
	leaq	40(%rsp), %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB5_9
# %bb.8:
	movl	$_ZSt4cerr, %r12d
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.7, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB5_9:
	movslq	%r13d, %r12
	shlq	$2, %r12
	leaq	24(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB5_11
# %bb.10:
	movl	$_ZSt4cerr, %r13d
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.7, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB5_11:
	movl	%ebp, %r15d
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB5_13
# %bb.12:
	movl	$_ZSt4cerr, %r13d
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.8, %esi
	movl	$21, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB5_13:
	cvttsd2si	32(%rsp), %r13          # 8-byte Folded Reload
	movq	40(%rsp), %rdi
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB5_15
# %bb.14:
	movl	$_ZSt4cerr, %ebp
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.8, %esi
	movl	$21, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbp, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB5_15:
	movq	24(%rsp), %rdi
	movq	48(%rsp), %rsi                  # 8-byte Reload
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB5_17
# %bb.16:
	movl	$_ZSt4cerr, %r12d
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.8, %esi
	movl	$21, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB5_17:
	movl	%r13d, %ebp
	andl	$-2, %ebp
	movl	%ebx, %eax
	subl	%ebp, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI5_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %r12d
	movl	%r15d, %eax
	subl	%ebp, %eax
	xorps	%xmm0, %xmm0
	cvtsi2ss	%rax, %xmm0
	divss	.LCPI5_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %edi
	shlq	$32, %rdi
	orq	%r12, %rdi
	movabsq	$85899345940, %rdx              # imm = 0x1400000014
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_19
# %bb.18:
	movq	8(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	24(%rsp), %r8
	movl	%r13d, (%rsp)
	shrl	%r13d
	movl	%ebx, %edx
	movl	%r15d, %ecx
	movl	%r13d, %r9d
	callq	_Z23__device_stub__convolvePjS_iiPKfii
.LBB5_19:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	je	.LBB5_21
# %bb.20:
	movl	%eax, %ebp
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.9, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cerr, %edi
	movl	%ebp, %esi
	callq	_ZNSolsEi
	movq	%rax, %r15
	movl	$.L.str.10, %esi
	movl	$23, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r15), %rax
	movq	-24(%rax), %rdi
	addq	%r15, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r15, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB5_21:
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB5_23
# %bb.22:
	movl	$_ZSt4cerr, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.11, %esi
	movl	$21, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB5_23:
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	24(%rsp), %rdi
	callq	hipFree
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z16filter_image_parPjjjPKfi, .Lfunc_end5-_Z16filter_image_parPjjjPKfi
	.cfi_endproc
                                        # -- End function
	.globl	_Z11load_filterPKcPi            # -- Begin function _Z11load_filterPKcPi
	.type	_Z11load_filterPKcPi,@function
_Z11load_filterPKcPi:                   # @_Z11load_filterPKcPi
.Lfunc_begin2:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception2
# %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	$528, %rsp                      # imm = 0x210
	.cfi_def_cfa_offset 576
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %rsi
	leaq	8(%rsp), %r14
	movq	%r14, %rdi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
	movq	(%r14), %rax
	movq	-24(%rax), %rax
	testb	$5, 40(%rsp,%rax)
	jne	.LBB6_1
# %bb.4:
.Ltmp17:
	leaq	8(%rsp), %rdi
	movq	%rbx, %rsi
	callq	_ZNSirsERi
.Ltmp18:
# %bb.5:
	movslq	(%rbx), %r15
	leaq	(,%r15,4), %rax
	testq	%r15, %r15
	movq	$-1, %rdi
	cmovnsq	%rax, %rdi
.Ltmp20:
	callq	_Znam
.Ltmp21:
# %bb.6:                                # %.preheader
	movq	%rax, %r14
	testl	%r15d, %r15d
	jle	.LBB6_10
# %bb.7:                                # %.lr.ph.preheader
	xorl	%r13d, %r13d
	leaq	8(%rsp), %r15
	movq	%r14, %r12
.LBB6_8:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
.Ltmp22:
	movq	%r15, %rdi
	movq	%r12, %rsi
	callq	_ZNSi10_M_extractIfEERSiRT_
.Ltmp23:
# %bb.9:                                # %_ZNSirsERf.exit
                                        #   in Loop: Header=BB6_8 Depth=1
	incq	%r13
	movslq	(%rbx), %rax
	addq	$4, %r12
	cmpq	%rax, %r13
	jl	.LBB6_8
.LBB6_10:                               # %._crit_edge
.Ltmp25:
	leaq	8(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv
.Ltmp26:
# %bb.11:
	leaq	8(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%r14, %rax
	addq	$528, %rsp                      # imm = 0x210
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB6_1:
	.cfi_def_cfa_offset 576
	movl	$16, %edi
	callq	__cxa_allocate_exception
	movq	%rax, %r14
.Ltmp12:
	movl	$.L.str.12, %esi
	movq	%rax, %rdi
	callq	_ZNSt13runtime_errorC1EPKc
.Ltmp13:
# %bb.2:
.Ltmp15:
	movl	$_ZTISt13runtime_error, %esi
	movl	$_ZNSt13runtime_errorD1Ev, %edx
	movq	%r14, %rdi
	callq	__cxa_throw
.Ltmp16:
# %bb.15:
.LBB6_3:
.Ltmp14:
	movq	%rax, %rbx
	movq	%r14, %rdi
	callq	__cxa_free_exception
	jmp	.LBB6_14
.LBB6_12:
.Ltmp19:
	jmp	.LBB6_13
.LBB6_16:
.Ltmp27:
	jmp	.LBB6_13
.LBB6_17:
.Ltmp24:
.LBB6_13:
	movq	%rax, %rbx
.LBB6_14:
	leaq	8(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end6:
	.size	_Z11load_filterPKcPi, .Lfunc_end6-_Z11load_filterPKcPi
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table6:
.Lexception2:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end2-.Lcst_begin2
.Lcst_begin2:
	.uleb128 .Lfunc_begin2-.Lfunc_begin2    # >> Call Site 1 <<
	.uleb128 .Ltmp17-.Lfunc_begin2          #   Call between .Lfunc_begin2 and .Ltmp17
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp17-.Lfunc_begin2          # >> Call Site 2 <<
	.uleb128 .Ltmp18-.Ltmp17                #   Call between .Ltmp17 and .Ltmp18
	.uleb128 .Ltmp19-.Lfunc_begin2          #     jumps to .Ltmp19
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp20-.Lfunc_begin2          # >> Call Site 3 <<
	.uleb128 .Ltmp21-.Ltmp20                #   Call between .Ltmp20 and .Ltmp21
	.uleb128 .Ltmp27-.Lfunc_begin2          #     jumps to .Ltmp27
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp22-.Lfunc_begin2          # >> Call Site 4 <<
	.uleb128 .Ltmp23-.Ltmp22                #   Call between .Ltmp22 and .Ltmp23
	.uleb128 .Ltmp24-.Lfunc_begin2          #     jumps to .Ltmp24
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp25-.Lfunc_begin2          # >> Call Site 5 <<
	.uleb128 .Ltmp26-.Ltmp25                #   Call between .Ltmp25 and .Ltmp26
	.uleb128 .Ltmp27-.Lfunc_begin2          #     jumps to .Ltmp27
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp26-.Lfunc_begin2          # >> Call Site 6 <<
	.uleb128 .Ltmp12-.Ltmp26                #   Call between .Ltmp26 and .Ltmp12
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp12-.Lfunc_begin2          # >> Call Site 7 <<
	.uleb128 .Ltmp13-.Ltmp12                #   Call between .Ltmp12 and .Ltmp13
	.uleb128 .Ltmp14-.Lfunc_begin2          #     jumps to .Ltmp14
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp15-.Lfunc_begin2          # >> Call Site 8 <<
	.uleb128 .Ltmp16-.Ltmp15                #   Call between .Ltmp15 and .Ltmp16
	.uleb128 .Ltmp19-.Lfunc_begin2          #     jumps to .Ltmp19
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp16-.Lfunc_begin2          # >> Call Site 9 <<
	.uleb128 .Lfunc_end6-.Ltmp16            #   Call between .Ltmp16 and .Lfunc_end6
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end2:
	.p2align	2, 0x0
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI7_0:
	.quad	0x41cdcd6500000000              # double 1.0E+9
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	cmpl	$5, %edi
	jne	.LBB7_1
# %bb.2:
	movq	%rsi, %rbx
	movq	24(%rsi), %rdi
	leaq	20(%rsp), %rsi
	callq	_Z11load_filterPKcPi
	movq	%rax, %r14
	movq	8(%rbx), %rdi
	leaq	16(%rsp), %rsi
	leaq	12(%rsp), %rdx
	callq	_Z9load_tiffPKcPjS1_
	movq	%rax, %r15
	leaq	24(%rsp), %rdi
	movl	$1, %esi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB7_4
# %bb.3:
	movl	$_ZSt4cerr, %r12d
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.7, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cerr, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.LBB7_4:
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	movq	%rax, %r12
	movq	32(%rbx), %r13
	movl	$.L.str.18, %esi
	movq	%r13, %rdi
	callq	strcmp
	testl	%eax, %eax
	je	.LBB7_5
# %bb.6:
	movl	$.L.str.19, %esi
	movq	%r13, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB7_8
# %bb.7:
	movl	16(%rsp), %esi
	movl	12(%rsp), %edx
	movl	20(%rsp), %r8d
	movq	%r15, %rdi
	movq	%r14, %rcx
	callq	_Z16filter_image_parPjjjPKfi
	jmp	.LBB7_8
.LBB7_1:
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.13, %esi
	movl	$60, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.14, %esi
	movl	$34, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.15, %esi
	movl	$36, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.16, %esi
	movl	$38, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.17, %esi
	movl	$70, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	jmp	.LBB7_9
.LBB7_5:
	movl	16(%rsp), %esi
	movl	12(%rsp), %edx
	movl	20(%rsp), %r8d
	movq	%r15, %rdi
	movq	%r14, %rcx
	callq	_Z16filter_image_seqPjjjPKfi
.LBB7_8:
	callq	_ZNSt6chrono3_V212system_clock3nowEv
	subq	%r12, %rax
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI7_0(%rip), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	16(%rbx), %rdi
	movl	16(%rsp), %edx
	movl	12(%rsp), %ecx
	movq	%r15, %rsi
	callq	_Z9save_tiffPKcPjjj
	movq	%r14, %rdi
	callq	_ZdaPv
	movq	%r15, %rdi
	callq	_TIFFfree
.LBB7_9:
	xorl	%eax, %eax
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	main, .Lfunc_end7-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8convolvePjS_iiPKfii, %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_end8:
	.size	__hip_module_ctor, .Lfunc_end8-__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	.LBB9_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
.LBB9_2:
	retq
.Lfunc_end9:
	.size	__hip_module_dtor, .Lfunc_end9-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"w"
	.size	.L.str, 2

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Could not open output file"
	.size	.L.str.1, 27

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Could not open input file"
	.size	.L.str.3, 26

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Memory allocation error"
	.size	.L.str.4, 24

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Could not read raster from TIFF image"
	.size	.L.str.5, 38

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

	.type	.L.str.6,@object                # @.str.6
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.6:
	.asciz	"hipSetDevice failed!"
	.size	.L.str.6, 21

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"hipMalloc (in) failed!"
	.size	.L.str.7, 23

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"hipMemcpy H2D failed!"
	.size	.L.str.8, 22

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"error code "
	.size	.L.str.9, 12

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	" returned after kernel!"
	.size	.L.str.10, 24

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"hipMemcpy D2H failed!"
	.size	.L.str.11, 22

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Could not open filter file"
	.size	.L.str.12, 27

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Usage:\t./filter <in_fname> <out_fname> <filter_fname> <algo>"
	.size	.L.str.13, 61

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"<in_fname> path to the input image"
	.size	.L.str.14, 35

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"<out_fname> path to the output image"
	.size	.L.str.15, 37

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"<filter_fname> path to the filter file"
	.size	.L.str.16, 39

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"<algo> whether to use the sequential (seq) or parallel algorithm (par)"
	.size	.L.str.17, 71

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"seq"
	.size	.L.str.18, 4

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"par"
	.size	.L.str.19, 4

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8convolvePjS_iiPKfii"
	.size	.L__unnamed_1, 23

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

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

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8convolvePjS_iiPKfii  ; -- Begin function _Z8convolvePjS_iiPKfii
	.globl	_Z8convolvePjS_iiPKfii
	.p2align	8
	.type	_Z8convolvePjS_iiPKfii,@function
_Z8convolvePjS_iiPKfii:                 ; @_Z8convolvePjS_iiPKfii
; %bb.0:
	s_clause 0x2
	s_load_b64 s[8:9], s[0:1], 0x20
	s_load_b32 s2, s[0:1], 0x34
	s_load_b64 s[10:11], s[0:1], 0x10
	v_bfe_u32 v7, v0, 10, 10
	s_mov_b32 s4, exec_lo
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_add_nc_u32_e32 v4, s8, v7
	s_lshr_b32 s3, s2, 16
	s_sub_i32 s11, s11, s8
	s_mul_i32 s15, s15, s3
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e32 v9, s15, v4
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s11, v9
	s_cbranch_execz .LBB0_42
; %bb.1:
	v_and_b32_e32 v6, 0x3ff, v0
	s_and_b32 s13, s2, 0xffff
	s_sub_i32 s16, s10, s8
	s_mul_i32 s14, s14, s13
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v8, s8, v6
	v_add_nc_u32_e32 v13, s14, v8
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_i32_e32 vcc_lo, s16, v13
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_42
; %bb.2:
	v_mul_lo_u32 v10, v9, s10
	s_load_b128 s[4:7], s[0:1], 0x0
	s_lshl_b32 s12, s8, 1
	s_mov_b32 s17, exec_lo
	s_add_i32 s12, s12, 20
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v14, s12, v4
	v_add_nc_u32_e32 v0, v10, v13
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v1, 31, v0
	v_add_nc_u32_e32 v11, v14, v8
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	v_lshlrev_b32_e32 v12, 2, v11
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v2, vcc_lo, s6, v0
	v_add_co_ci_u32_e32 v3, vcc_lo, s7, v1, vcc_lo
	global_load_b32 v5, v[2:3], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v12, v5
	v_cmpx_eq_u32_e32 0, v6
	s_cbranch_execz .LBB0_16
; %bb.3:
	s_sub_i32 s2, 0, s8
	s_cmp_gt_i32 s8, 0
	s_cselect_b32 s18, -1, 0
	s_cmp_lt_i32 s8, 1
	s_cbranch_scc1 .LBB0_6
; %bb.4:                                ; %.lr.ph.preheader
	v_lshlrev_b32_e32 v4, 2, v6
	s_delay_alu instid0(VALU_DEP_1)
	v_lshl_add_u32 v15, v14, 2, v4
	v_mov_b32_e32 v4, s2
.LBB0_5:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v5, 31, v4
	v_lshlrev_b64 v[16:17], 2, v[4:5]
	v_add_co_u32 v4, s19, v4, 1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v16, vcc_lo, v2, v16
	v_add_co_ci_u32_e32 v17, vcc_lo, v3, v17, vcc_lo
	s_and_b32 vcc_lo, exec_lo, s19
	global_load_b32 v5, v[16:17], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v15, v5
	v_add_nc_u32_e32 v15, 4, v15
	s_cbranch_vccz .LBB0_5
.LBB0_6:                                ; %._crit_edge
	v_cmp_eq_u32_e32 vcc_lo, 0, v7
	s_cmp_gt_i32 s8, -1
	s_cselect_b32 s19, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s20, vcc_lo, s19
	s_and_saveexec_b32 s19, s20
	s_cbranch_execz .LBB0_11
; %bb.7:                                ; %.preheader257.preheader
	v_add_nc_u32_e32 v4, s15, v7
	v_mul_lo_u32 v5, v7, s12
	v_lshlrev_b32_e32 v15, 2, v6
	s_lshl_b32 s21, s8, 3
	s_add_i32 s20, s8, 1
	v_mul_lo_u32 v4, s10, v4
	s_addk_i32 s21, 0x50
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshl_add_u32 v15, v5, 2, v15
	v_add3_u32 v16, v6, v4, s14
.LBB0_8:                                ; %.preheader257
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_9 Depth 2
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_mov_b32 v4, v16 :: v_dual_mov_b32 v17, v15
	s_mov_b32 s22, s20
.LBB0_9:                                ;   Parent Loop BB0_8 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s22, s22, -1
	s_cmp_eq_u32 s22, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[18:19], 2, v[4:5]
	v_add_nc_u32_e32 v4, 1, v4
	v_add_co_u32 v18, vcc_lo, s6, v18
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v19, vcc_lo, s7, v19, vcc_lo
	global_load_b32 v5, v[18:19], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v17, v5
	v_add_nc_u32_e32 v17, 4, v17
	s_cbranch_scc0 .LBB0_9
; %bb.10:                               ; %._crit_edge263
                                        ;   in Loop: Header=BB0_8 Depth=1
	v_add_nc_u32_e32 v15, s21, v15
	v_add_nc_u32_e32 v16, s10, v16
	s_add_i32 s22, s2, 1
	s_cmp_eq_u32 s2, 0
	s_mov_b32 s2, s22
	s_cbranch_scc0 .LBB0_8
.LBB0_11:                               ; %Flow447
	s_or_b32 exec_lo, exec_lo, s19
	s_add_i32 s2, s3, -1
	s_sub_i32 s19, s11, s8
	v_cmp_eq_u32_e32 vcc_lo, s2, v7
	v_cmp_eq_u32_e64 s2, s19, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_or_b32 s2, vcc_lo, s2
	s_cmp_gt_i32 s8, -1
	s_cselect_b32 s19, -1, 0
	s_and_b32 s2, s2, s19
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 exec_lo, exec_lo, s2
	s_cbranch_execz .LBB0_16
; %bb.12:                               ; %.preheader254.preheader
	v_lshlrev_b32_e32 v4, 2, v6
	v_add3_u32 v15, v6, v10, s14
	s_lshl_b32 s2, s8, 3
	s_mov_b32 s19, 0
	s_addk_i32 s2, 0x50
	v_lshl_add_u32 v14, v14, 2, v4
.LBB0_13:                               ; %.preheader254
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_14 Depth 2
	v_mov_b32_e32 v4, v15
	s_delay_alu instid0(VALU_DEP_2)
	v_mov_b32_e32 v16, v14
	s_and_not1_b32 vcc_lo, exec_lo, s18
	s_mov_b32 s20, s8
	s_cbranch_vccnz .LBB0_15
.LBB0_14:                               ;   Parent Loop BB0_13 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s20, s20, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s20, 0
	v_lshlrev_b64 v[17:18], 2, v[4:5]
	v_add_nc_u32_e32 v4, 1, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v17, vcc_lo, s6, v17
	v_add_co_ci_u32_e32 v18, vcc_lo, s7, v18, vcc_lo
	global_load_b32 v5, v[17:18], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v16, v5
	v_add_nc_u32_e32 v16, 4, v16
	s_cbranch_scc0 .LBB0_14
.LBB0_15:                               ; %._crit_edge267
                                        ;   in Loop: Header=BB0_13 Depth=1
	v_add_nc_u32_e32 v14, s2, v14
	v_add_nc_u32_e32 v15, s10, v15
	s_add_i32 s20, s19, 1
	s_cmp_eq_u32 s19, s8
	s_mov_b32 s19, s20
	s_cbranch_scc0 .LBB0_13
.LBB0_16:                               ; %Flow450
	s_or_b32 exec_lo, exec_lo, s17
	s_add_i32 s13, s13, -1
	s_sub_i32 s2, s16, s8
	v_cmp_eq_u32_e32 vcc_lo, s13, v6
	v_cmp_eq_u32_e64 s2, s2, v13
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s13, s2
	s_cbranch_execz .LBB0_30
; %bb.17:                               ; %.preheader253
	s_cmp_lt_i32 s8, 0
	s_cselect_b32 s16, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_b32 vcc_lo, exec_lo, s16
	s_cbranch_vccnz .LBB0_20
; %bb.18:                               ; %.lr.ph272.preheader
	v_dual_mov_b32 v5, v3 :: v_dual_mov_b32 v4, v2
	s_add_i32 s2, s8, 1
.LBB0_19:                               ; %.lr.ph272
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v13, v[4:5], off
	v_add_co_u32 v4, vcc_lo, v4, 4
	v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo
	s_add_i32 s2, s2, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s2, 0
	s_waitcnt vmcnt(0)
	ds_store_b32 v12, v13
	v_add_nc_u32_e32 v12, 4, v12
	s_cbranch_scc0 .LBB0_19
.LBB0_20:                               ; %._crit_edge273
	v_cmp_eq_u32_e32 vcc_lo, 0, v7
	s_cmp_gt_i32 s8, -1
	s_cselect_b32 s2, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s17, vcc_lo, s2
	s_and_saveexec_b32 s2, s17
	s_cbranch_execz .LBB0_25
; %bb.21:                               ; %.preheader251.lr.ph
	v_add_nc_u32_e32 v4, s15, v7
	v_mul_lo_u32 v5, v7, s12
	s_lshl_b32 s19, s8, 3
	s_sub_i32 s17, 0, s8
	s_add_i32 s18, s8, 1
	v_mul_lo_u32 v4, s10, v4
	s_addk_i32 s19, 0x50
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_lshl_u32 v12, v8, v5, 2
	v_add3_u32 v13, v8, v4, s14
.LBB0_22:                               ; %.preheader251
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_23 Depth 2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_mov_b32_e32 v4, v13
	v_mov_b32_e32 v14, v12
	s_mov_b32 s20, s18
.LBB0_23:                               ;   Parent Loop BB0_22 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s20, s20, -1
	s_cmp_eq_u32 s20, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[15:16], 2, v[4:5]
	v_add_nc_u32_e32 v4, 1, v4
	v_add_co_u32 v15, vcc_lo, s6, v15
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v16, vcc_lo, s7, v16, vcc_lo
	global_load_b32 v5, v[15:16], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v14, v5
	v_add_nc_u32_e32 v14, 4, v14
	s_cbranch_scc0 .LBB0_23
; %bb.24:                               ; %._crit_edge277
                                        ;   in Loop: Header=BB0_22 Depth=1
	v_add_nc_u32_e32 v12, s19, v12
	v_add_nc_u32_e32 v13, s10, v13
	s_add_i32 s20, s17, 1
	s_cmp_eq_u32 s17, 0
	s_mov_b32 s17, s20
	s_cbranch_scc0 .LBB0_22
.LBB0_25:                               ; %Flow438
	s_or_b32 exec_lo, exec_lo, s2
	s_add_i32 s2, s3, -1
	s_sub_i32 s17, s11, s8
	v_cmp_ne_u32_e32 vcc_lo, s2, v7
	v_cmp_ne_u32_e64 s2, s17, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_or_b32 s2, s2, s16
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s2, s2, -1
	s_and_b32 exec_lo, exec_lo, s2
	s_cbranch_execz .LBB0_30
; %bb.26:                               ; %.preheader248.preheader
	v_lshlrev_b32_e32 v4, 2, v11
	v_add3_u32 v5, v6, v10, s14
	s_lshl_b32 s16, s8, 3
	s_add_i32 s2, s8, 1
	s_addk_i32 s16, 0x50
	s_mov_b32 s17, 0
.LBB0_27:                               ; %.preheader248
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_28 Depth 2
	v_dual_mov_b32 v13, v4 :: v_dual_add_nc_u32 v12, s8, v5
	s_mov_b32 s18, 0
.LBB0_28:                               ;   Parent Loop BB0_27 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_add_nc_u32_e32 v14, s18, v12
	s_add_i32 s18, s18, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_cmp_eq_u32 s2, s18
	v_ashrrev_i32_e32 v15, 31, v14
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[14:15], 2, v[14:15]
	v_add_co_u32 v14, vcc_lo, s6, v14
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v15, vcc_lo, s7, v15, vcc_lo
	global_load_b32 v14, v[14:15], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v13, v14
	v_add_nc_u32_e32 v13, 4, v13
	s_cbranch_scc0 .LBB0_28
; %bb.29:                               ; %._crit_edge282
                                        ;   in Loop: Header=BB0_27 Depth=1
	v_add_nc_u32_e32 v4, s16, v4
	v_add_nc_u32_e32 v5, s10, v5
	s_add_i32 s18, s17, 1
	s_cmp_eq_u32 s17, s8
	s_mov_b32 s17, s18
	s_cbranch_scc0 .LBB0_27
.LBB0_30:                               ; %Flow441
	s_or_b32 exec_lo, exec_lo, s13
	v_mul_lo_u32 v12, v7, s12
	v_cmp_eq_u32_e32 vcc_lo, 0, v7
	s_cmp_gt_i32 s8, 0
	s_cselect_b32 s2, -1, 0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s12, vcc_lo, s2
	s_and_saveexec_b32 s2, s12
	s_cbranch_execz .LBB0_33
; %bb.31:                               ; %.lr.ph287.preheader
	v_add_nc_u32_e32 v4, s15, v7
	v_add_lshl_u32 v13, v8, v12, 2
	s_lshl_b32 s12, s8, 3
	s_mov_b32 s13, s8
	s_addk_i32 s12, 0x50
	v_mul_lo_u32 v4, s10, v4
	s_delay_alu instid0(VALU_DEP_1)
	v_add3_u32 v4, v8, v4, s14
.LBB0_32:                               ; %.lr.ph287
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s13, s13, -1
	s_cmp_lg_u32 s13, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[14:15], 2, v[4:5]
	v_add_nc_u32_e32 v4, s10, v4
	v_add_co_u32 v14, vcc_lo, s6, v14
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v15, vcc_lo, s7, v15, vcc_lo
	global_load_b32 v5, v[14:15], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v13, v5
	v_add_nc_u32_e32 v13, s12, v13
	s_cbranch_scc1 .LBB0_32
.LBB0_33:                               ; %Flow434
	s_or_b32 exec_lo, exec_lo, s2
	s_add_i32 s3, s3, -1
	s_sub_i32 s2, s11, s8
	v_cmp_eq_u32_e32 vcc_lo, s3, v7
	v_cmp_eq_u32_e64 s2, s2, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_or_b32 s2, vcc_lo, s2
	s_cmp_gt_i32 s8, -1
	s_cselect_b32 s3, -1, 0
	s_and_b32 s3, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s2, s3
	s_cbranch_execz .LBB0_36
; %bb.34:                               ; %.lr.ph290.preheader
	v_lshlrev_b32_e32 v7, 2, v11
	v_add3_u32 v4, v8, v10, s14
	s_lshl_b32 s11, s8, 3
	s_add_i32 s3, s8, 1
	s_addk_i32 s11, 0x50
.LBB0_35:                               ; %.lr.ph290
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_ashrrev_i32_e32 v5, 31, v4
	s_add_i32 s3, s3, -1
	s_cmp_lg_u32 s3, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[8:9], 2, v[4:5]
	v_add_nc_u32_e32 v4, s10, v4
	v_add_co_u32 v8, vcc_lo, s6, v8
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v9, vcc_lo, s7, v9, vcc_lo
	global_load_b32 v5, v[8:9], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v7, v5
	v_add_nc_u32_e32 v7, s11, v7
	s_cbranch_scc1 .LBB0_35
.LBB0_36:                               ; %Flow432
	s_or_b32 exec_lo, exec_lo, s2
	v_dual_mov_b32 v4, 0 :: v_dual_mov_b32 v7, 0
	v_mov_b32_e32 v5, 0
	s_cmp_eq_u32 s9, 0
	s_mov_b32 s3, 0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_41
; %bb.37:                               ; %.lr.ph301.preheader
	s_load_b64 s[0:1], s[0:1], 0x18
	v_dual_mov_b32 v7, 0 :: v_dual_lshlrev_b32 v4, 2, v6
	s_lshl_b32 s6, s8, 3
	s_mov_b32 s7, 0
	v_mov_b32_e32 v5, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_lshl_add_u32 v6, v12, 2, v4
	v_mov_b32_e32 v4, 0
	s_addk_i32 s6, 0x50
	s_mov_b32 s8, 0
.LBB0_38:                               ; %.lr.ph301
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_39 Depth 2
	s_delay_alu instid0(VALU_DEP_2)
	v_mov_b32_e32 v8, v6
	s_mov_b32 s10, 0
.LBB0_39:                               ;   Parent Loop BB0_38 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_i32 s2, s7, s10
	ds_load_b32 v9, v8
	s_lshl_b64 s[12:13], s[2:3], 2
	s_waitcnt lgkmcnt(0)
	s_add_u32 s12, s0, s12
	s_addc_u32 s13, s1, s13
	s_add_i32 s10, s10, 1
	s_load_b32 s2, s[12:13], 0x0
	s_cmp_eq_u32 s9, s10
	v_cvt_f32_ubyte0_e32 v10, v9
	v_cvt_f32_ubyte1_e32 v11, v9
	v_cvt_f32_ubyte2_e32 v9, v9
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_dual_fmac_f32 v5, s2, v10 :: v_dual_add_nc_u32 v8, 4, v8
	v_dual_fmac_f32 v7, s2, v11 :: v_dual_fmac_f32 v4, s2, v9
	s_cbranch_scc0 .LBB0_39
; %bb.40:                               ;   in Loop: Header=BB0_38 Depth=1
	v_add_nc_u32_e32 v6, s6, v6
	s_add_i32 s8, s8, 1
	s_add_i32 s7, s7, s9
	s_cmp_eq_u32 s8, s9
	s_cbranch_scc0 .LBB0_38
.LBB0_41:                               ; %Flow430
	global_load_b32 v2, v[2:3], off
	v_cmp_ngt_f32_e32 vcc_lo, 0, v7
	v_cndmask_b32_e32 v3, 0, v7, vcc_lo
	v_cmp_ngt_f32_e32 vcc_lo, 0, v4
	v_cndmask_b32_e32 v4, 0, v4, vcc_lo
	v_cmp_ngt_f32_e32 vcc_lo, 0, v5
	v_cndmask_b32_e32 v5, 0, v5, vcc_lo
	v_cmp_nlt_f32_e32 vcc_lo, 0x437f0000, v3
	v_cndmask_b32_e32 v3, 0x437f0000, v3, vcc_lo
	v_cmp_nlt_f32_e32 vcc_lo, 0x437f0000, v4
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v3, v3
	v_cndmask_b32_e32 v4, 0x437f0000, v4, vcc_lo
	v_cvt_u32_f32_e32 v4, v4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_3)
	v_lshlrev_b32_e32 v4, 16, v4
	v_cmp_nlt_f32_e32 vcc_lo, 0x437f0000, v5
	v_cndmask_b32_e32 v5, 0x437f0000, v5, vcc_lo
	v_add_co_u32 v0, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	v_cvt_u32_f32_e32 v5, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_lshl_or_b32 v3, v3, 8, v5
	s_waitcnt vmcnt(0)
	v_and_b32_e32 v2, 0xff000000, v2
	v_or3_b32 v2, v3, v4, v2
	global_store_b32 v[0:1], v2, off
.LBB0_42:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8convolvePjS_iiPKfii
		.amdhsa_group_segment_fixed_size 2916
		.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 20
		.amdhsa_next_free_sgpr 23
		.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	_Z8convolvePjS_iiPKfii, .Lfunc_end0-_Z8convolvePjS_iiPKfii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 2000
; NumSgprs: 25
; NumVgprs: 20
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 2916 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 25
; 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
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .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: 2916
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8convolvePjS_iiPKfii
    .private_segment_fixed_size: 0
    .sgpr_count:     25
    .sgpr_spill_count: 0
    .symbol:         _Z8convolvePjS_iiPKfii.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
