/*
 * Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#include <algorithm>
#include <cstring>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <utility>

#include <cuda_runtime.h>

#include <libpng/png.h>

struct pixel
{
    uint8_t red;
    uint8_t green;
    uint8_t blue;
    uint8_t alpha;
};

#define gpuErrchk(ans) gpuAssert((ans), __FILE__, __LINE__)
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
    if (code != cudaSuccess)
    {
        std::cerr << "GPU error: " << cudaGetErrorString(code) << " at " << file << ":" << line << "\n";
        if (abort)
        {
            std::exit(code);
        }
    }
}

constexpr unsigned BlockLength = 31;

__global__ void convolution(const pixel* image, const int width, const int height, const float* matrix, const int matrixLength, pixel* out)
{
    extern __shared__ float sMatrix[];
    pixel* subImage = (pixel*)(sMatrix + (matrixLength * matrixLength));
    const int subImageLength = BlockLength + (matrixLength / 2) * 2;

    const int xIdx = blockIdx.x * blockDim.x + threadIdx.x;
    const int yIdx = blockIdx.y * blockDim.y + threadIdx.y;

    // Copy convolution matrix to shared memory
    if (threadIdx.x < matrixLength && threadIdx.y < matrixLength)
    {
        sMatrix[threadIdx.x + threadIdx.y * matrixLength] = matrix[threadIdx.x + threadIdx.y * matrixLength];
    }

    const int apronSize = matrixLength / 2;

    const int shmemXIdx = matrixLength / 2 + threadIdx.x;
    const int shmemYIdx = matrixLength / 2 + threadIdx.y;

    // Clamping the accessed coordinates to the limits of the image, as we still
    // want threads that would be over that to participate in copying the image
    // chunk to shared memory
    const int cXIdx = min(width - 1, xIdx);
    const int cYIdx = min(height - 1, yIdx);

    // Copy center part of the image chunk in shared memory
    subImage[shmemXIdx + shmemYIdx * subImageLength] = image[cXIdx - cYIdx * width];

    // Copy apron part of the image chunk in shared memory
    if (threadIdx.x < apronSize)
    {
        subImage[shmemXIdx - apronSize + shmemYIdx * subImageLength] = image[max(0, cXIdx - apronSize) + cYIdx * width];
        // Copy a corner of the apron
        if (threadIdx.y < apronSize)
        {
            subImage[shmemXIdx - apronSize + (shmemYIdx - apronSize) * subImageLength] =
                image[max(0, cXIdx - apronSize) + max(0, cYIdx - apronSize) * width];
        }
    }

    if (threadIdx.y < apronSize)
    {
        subImage[shmemXIdx + (shmemYIdx - apronSize) * subImageLength] = image[cXIdx + max(0, cYIdx - apronSize) * width];
        if (threadIdx.x >= blockDim.x - apronSize)
        {
            subImage[shmemXIdx + apronSize + (shmemYIdx - apronSize) * subImageLength] =
                image[min(cXIdx + apronSize, width) + max(0, cYIdx - apronSize) * width];
        }
    }

    if (threadIdx.x >= (blockDim.x - apronSize))
    {
        subImage[shmemXIdx + apronSize + shmemYIdx * subImageLength] = image[min(cXIdx + apronSize, width - 1) + cYIdx * width];
        if (threadIdx.y >= blockDim.y - apronSize)
        {
            subImage[shmemXIdx + apronSize + (shmemYIdx + apronSize) * subImageLength] =
                image[min(cXIdx + apronSize, width - 1) + min(height - 1, cYIdx + apronSize) * width];
        }
    }

    if (threadIdx.y >= (blockDim.y - apronSize))
    {
        subImage[shmemXIdx + (shmemYIdx + apronSize) * subImageLength] = image[cXIdx + min(height - 1, cYIdx + apronSize) * width];
        if (threadIdx.x < apronSize)
        {
            subImage[shmemXIdx - apronSize + (shmemYIdx + apronSize) * subImageLength] =
                image[max(0, cXIdx - apronSize) + min(height - 1, cYIdx + apronSize) * width];
        }
    }

    // At this point we are done copying the sub-image to the shared memory

    // Discard threads that do not participate in the final image
    if (xIdx > width || yIdx >= height)
    {
        return;
    }

    float accR = 0.0;
    float accG = 0.0;
    float accB = 0.0;

    // Apply the convolution
    for (int i = 0; i < matrixLength; i++)
    {
        for (int j = 0; j < matrixLength; j++)
        {
            int baseX = shmemXIdx - apronSize;
            int baseY = shmemYIdx - apronSize;
            accR += (sMatrix[i * matrixLength + j] * subImage[baseX + j + (baseY + i) * subImageLength].red);
            accG += (sMatrix[i * matrixLength + j] * subImage[baseX + j + (baseY + i) * subImageLength].green);
            accB += (sMatrix[i * matrixLength + j] * subImage[baseX + j + (baseY + i) * subImageLength].blue);
        }
    }

    // Clamp values to avoid overflows
    accR = max(0., min(accR, 255.));
    accG = max(0., min(accG, 255.));
    accB = max(0., min(accB, 255.));

    const pixel res = {(uint8_t)accR, (uint8_t)accG, (uint8_t)accB, 255};
    out[xIdx + yIdx * width] = res;
}

static void loadImage(const std::string& filename, png_image& header, std::vector<uint8_t>& image)
{
    std::memset(&header, 0, sizeof(header));
    header.version = PNG_IMAGE_VERSION;

    // Load image metadata from fs
    if (!png_image_begin_read_from_file(&header, filename.c_str()))
    {
        std::cerr << "Failed to open image" << filename << "\n";
        std::exit(1);
    }
    std::cout << "Image "<< filename << " size: " << header.width << " * " << header.height << "\n";

    // Load image data from fs
    header.format = PNG_FORMAT_RGBA;
    image.resize(PNG_IMAGE_SIZE(header));
    if (!png_image_finish_read(&header, NULL/*background*/, image.data(), 0/*row_stride*/, NULL/*colormap*/))
    {
        std::cerr << "Failed to read image " << filename << "\n";
        std::exit(1);
    }
}

static uint8_t* copyImageToDevice(const png_image& header, const std::vector<uint8_t>& image)
{
    uint8_t* dImage;
    gpuErrchk(cudaMalloc(&dImage, PNG_IMAGE_SIZE(header)));
    gpuErrchk(cudaMemcpy(dImage, image.data(), PNG_IMAGE_SIZE(header), cudaMemcpyHostToDevice));
    return dImage;
}

static void runConvolutionKernel(const png_image& header, std::vector<uint8_t>& hImage, uint8_t* dImage, const float* dMatrix, const int matrixLength, uint8_t* dOutput)
{
    dim3 blockSize(BlockLength, BlockLength);
    dim3 gridSize(header.width / blockSize.x + ((header.width % blockSize.x) != 0),
                  header.height / blockSize.y + ((header.height % blockSize.y) != 0));

    int subImageLength = BlockLength + (matrixLength / 2) * 2;
    int sharedMemorySize = (matrixLength * matrixLength * sizeof(float)) + (subImageLength * subImageLength * sizeof(pixel));

    std::cout << "Grid size: " << gridSize.x << " * " << gridSize.y << " * " << gridSize.z << "\n";
    std::cout << "Block size: " << blockSize.x << " * " << blockSize.y << " * " << blockSize.z << "\n";

    convolution<<<gridSize, blockSize, sharedMemorySize>>>((pixel*)dImage, header.width, header.height, dMatrix, matrixLength, (pixel*)dOutput);
    gpuErrchk(cudaGetLastError());
    gpuErrchk(cudaDeviceSynchronize());

    gpuErrchk(cudaMemcpy(hImage.data(), dOutput, PNG_IMAGE_SIZE(header), cudaMemcpyDeviceToHost));
}


static void saveImage(const std::string& filename, png_image& header, std::vector<uint8_t>& image)
{
    if (!png_image_write_to_file(&header, filename.c_str(), 0/*convert_to_8bit*/, image.data(), 0/*row_stride*/, NULL/*colormap*/))
    {
        std::cerr << "Failed to save image " << filename << "\n";
        std::exit(1);
    }
}

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

    std::string imagePath = ".";

    if (argc > 1)
    {
        imagePath = argv[1];
    }

    png_image headerChecker;
    std::vector<uint8_t> imageChecker;
    loadImage(imagePath + "/checkerboard.png", headerChecker, imageChecker);

    uint8_t* dImageChecker = copyImageToDevice(headerChecker, imageChecker);
    uint8_t* dOutputChecker;
    gpuErrchk(cudaMalloc(&dOutputChecker, PNG_IMAGE_SIZE(headerChecker)));

    png_image headerIcon;
    std::vector<uint8_t> imageIcon;
    loadImage(imagePath + "/icon.png", headerIcon, imageIcon);

    uint8_t* dImageIcon = copyImageToDevice(headerIcon, imageIcon);
    uint8_t* dOutputIcon;
    gpuErrchk(cudaMalloc(&dOutputIcon, PNG_IMAGE_SIZE(headerIcon)));

    // Allocate convolution matrix buffer (in this example, we use at most a 5x5 matrix)
    float* dMatrix;
    gpuErrchk(cudaMalloc(&dMatrix, 5 * 5 * sizeof(double)));

    const float edgeDetectionMatrix[9] = {-1.f, -1.f, -1.f,
                                          -1.f, 8.f,  -1.f,
                                          -1.f, -1.f, -1.f};

    gpuErrchk(cudaMemcpy(dMatrix, edgeDetectionMatrix, sizeof(edgeDetectionMatrix), cudaMemcpyHostToDevice));

    runConvolutionKernel(headerChecker, imageChecker, dImageChecker, dMatrix, 3, dOutputChecker);

    gpuErrchk(cudaFree(dImageChecker));

    saveImage(imagePath + "/checkerboard-out.png", headerChecker, imageChecker);

    float identityMatrix[9] = {0.f, };
    identityMatrix[4] = 1.f;
    gpuErrchk(cudaMemcpy(dMatrix, identityMatrix, sizeof(identityMatrix), cudaMemcpyHostToDevice));

    runConvolutionKernel(headerIcon, imageIcon, dImageIcon, dMatrix, 3, dOutputIcon);

    gpuErrchk(cudaFree(dImageIcon));

    saveImage(imagePath + "/icon-out.png", headerIcon, imageIcon);

    // TODO: Uncomment me when reaching step 06
/*
    png_image headerCoffee;
    std::vector<uint8_t> imageCoffee;
    loadImage(imagePath + "/coffee.png", headerCoffee, imageCoffee);
    uint8_t* dImageCoffee = copyImageToDevice(headerCoffee, imageCoffee);

    uint8_t* dOutputCoffee;
    gpuErrchk(cudaMalloc(&dOutputCoffee, PNG_IMAGE_SIZE(headerCoffee)));

    const float gaussianBlurMatrix[25] = {1.f / 256.f,  4.f / 256.f,  6.f / 256.f,  4.f / 256.f, 1.f / 256.f,
                                          4.f / 256.f, 16.f / 256.f, 24.f / 256.f, 16.f / 256.f, 4.f / 256.f,
                                          6.f / 256.f, 24.f / 256.f, 36.f / 256.f, 24.f / 256.f, 6.f / 256.f,
                                          4.f / 256.f, 16.f / 256.f, 24.f / 256.f, 16.f / 256.f, 4.f / 256.f,
                                          1.f / 256.f,  4.f / 256.f,  6.f / 256.f,  4.f / 256.f, 1.f / 256.f};

    gpuErrchk(cudaMemcpy(dMatrix, gaussianBlurMatrix, 25, cudaMemcpyHostToDevice));

    runConvolutionKernel(headerCoffee, imageCoffee, dImageCoffee, dMatrix, 5, dOutputCoffee);

    gpuErrchk(cudaFree(dImageCoffee));

    saveImage(imagePath + "/coffee-out.png", headerCoffee, imageCoffee);
*/

    cudaDeviceReset();

    return 0;
}

	.file	"tmpxft_002261f3_00000000-6_convolution.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4270:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4270:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0.str1.1,"aMS",@progbits,1
.LC1:
	.string	"basic_string::append"
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0,"axG",@progbits,_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,comdat
	.align 2
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0, @function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0:
.LFB5015:
	.cfi_startproc
	movabsq	$4611686018427387903, %rax
	subq	8(%rdi), %rax
	cmpq	%rdx, %rax
	jnb	.L3
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	.LC1(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L3:
	.cfi_def_cfa_offset 8
	jmp	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_appendEPKcm@PLT
	.cfi_endproc
.LFE5015:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0, .-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"Failed to save image "
.LC3:
	.string	"\n"
	.text
	.type	_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE.isra.0, @function
_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE.isra.0:
.LFB5017:
	.cfi_startproc
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	movq	%rsi, %rdi
	movq	%rdx, %rcx
	movq	(%rbx), %rsi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	xorl	%edx, %edx
	call	png_image_write_to_file@PLT
	testl	%eax, %eax
	jne	.L8
	leaq	.LC2(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsIcSt11char_traitsIcESaIcEERSt13basic_ostreamIT_T0_ES7_RKNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$1, %edi
	call	exit@PLT
.L8:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE5017:
	.size	_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE.isra.0, .-_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE.isra.0
	.section	.rodata._Z9gpuAssert9cudaErrorPKcib.str1.1,"aMS",@progbits,1
.LC4:
	.string	"GPU error: "
.LC5:
	.string	" at "
.LC6:
	.string	":"
	.section	.text._Z9gpuAssert9cudaErrorPKcib,"axG",@progbits,_Z9gpuAssert9cudaErrorPKcib,comdat
	.weak	_Z9gpuAssert9cudaErrorPKcib
	.type	_Z9gpuAssert9cudaErrorPKcib, @function
_Z9gpuAssert9cudaErrorPKcib:
.LFB4252:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L17
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rsi, %r13
	leaq	.LC4(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	%edi, %ebx
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %edi
	movq	%rax, %r14
	call	cudaGetErrorString@PLT
	movq	%r14, %rdi
	movq	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC5(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%r12d, %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	testb	%bpl, %bpl
	je	.L11
	movl	%ebx, %edi
	call	exit@PLT
.L11:
	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
.L17:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	ret
	.cfi_endproc
.LFE4252:
	.size	_Z9gpuAssert9cudaErrorPKcib, .-_Z9gpuAssert9cudaErrorPKcib
	.section	.rodata.str1.1
.LC7:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/NVIDIA/nsight-training/master/cuda/2021_gtc/x-ac-04-v1/task1/task/sanitizer/code/convolution.cu"
	.text
	.type	_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE, @function
_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE:
.LFB4254:
	.cfi_startproc
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movl	20(%rdi), %edx
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movl	$1, %eax
	movl	%edx, %edi
	andl	$8, %edi
	jne	.L21
	movl	%edx, %eax
	shrl	$2, %eax
	andl	$1, %eax
	incl	%eax
.L21:
	movl	16(%rbx), %esi
	movl	$1, %ecx
	testl	%edi, %edi
	jne	.L22
	andl	$3, %edx
	leal	1(%rdx), %ecx
.L22:
	imull	12(%rbx), %esi
	movq	%rsp, %rdi
	leaq	.LC7(%rip), %rbp
	imull	%eax, %esi
	imull	%ecx, %esi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$189, %edx
	movq	%rbp, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movl	20(%rbx), %ecx
	movl	$1, %eax
	movl	%ecx, %edi
	andl	$8, %edi
	jne	.L23
	movl	%ecx, %eax
	shrl	$2, %eax
	andl	$1, %eax
	incl	%eax
.L23:
	movl	16(%rbx), %edx
	movl	$1, %esi
	testl	%edi, %edi
	jne	.L24
	andl	$3, %ecx
	leal	1(%rcx), %esi
.L24:
	imull	12(%rbx), %edx
	movq	(%rsp), %rdi
	movl	$1, %ecx
	imull	%eax, %edx
	imull	%esi, %edx
	movq	(%r12), %rsi
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$190, %edx
	movq	%rbp, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	(%rsp), %rax
	movq	8(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4254:
	.size	_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE, .-_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE
	.globl	_Z46__device_stub__Z11convolutionPK5pixeliiPKfiPS_PK5pixeliiPKfiPS_
	.type	_Z46__device_stub__Z11convolutionPK5pixeliiPKfiPS_PK5pixeliiPKfiPS_, @function
_Z46__device_stub__Z11convolutionPK5pixeliiPKfiPS_PK5pixeliiPKfiPS_:
.LFB4292:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movl	%esi, 36(%rsp)
	leaq	84(%rsp), %rsi
	movl	%edx, 32(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 24(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 20(%rsp)
	movq	%r9, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L32
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z11convolutionPK5pixeliiPKfiPS_(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L32:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4292:
	.size	_Z46__device_stub__Z11convolutionPK5pixeliiPKfiPS_PK5pixeliiPKfiPS_, .-_Z46__device_stub__Z11convolutionPK5pixeliiPKfiPS_PK5pixeliiPKfiPS_
	.globl	_Z11convolutionPK5pixeliiPKfiPS_
	.type	_Z11convolutionPK5pixeliiPKfiPS_, @function
_Z11convolutionPK5pixeliiPKfiPS_:
.LFB4293:
	.cfi_startproc
	endbr64
	jmp	_Z46__device_stub__Z11convolutionPK5pixeliiPKfiPS_PK5pixeliiPKfiPS_
	.cfi_endproc
.LFE4293:
	.size	_Z11convolutionPK5pixeliiPKfiPS_, .-_Z11convolutionPK5pixeliiPKfiPS_
	.section	.rodata.str1.1
.LC8:
	.string	"Grid size: "
.LC9:
	.string	" * "
.LC10:
	.string	"Block size: "
	.text
	.type	_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_.constprop.0, @function
_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_.constprop.0:
.LFB5020:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	_ZSt4cout(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC3(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	leaq	.LC8(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movl	16(%rdi), %eax
	movq	%rdx, 16(%rsp)
	xorl	%edx, %edx
	movq	%rcx, 24(%rsp)
	movl	$31, %ecx
	divl	%ecx
	movq	%r8, 8(%rsp)
	cmpl	$1, %edx
	sbbl	$-1, %eax
	xorl	%edx, %edx
	movl	%eax, %ebx
	movl	12(%rdi), %eax
	movq	%r15, %rdi
	divl	%ecx
	cmpl	$1, %edx
	sbbl	$-1, %eax
	movl	%eax, %ebp
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebp, %esi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	leaq	.LC9(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebx, %esi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	leaq	.LC9(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$1, %esi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	movq	%r14, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC10(%rip), %rsi
	movq	%r15, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$31, %esi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	leaq	.LC9(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$31, %esi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	leaq	.LC9(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$1, %esi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	movq	%r14, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	%ebp, 52(%rsp)
	xorl	%r9d, %r9d
	movl	$4392, %r8d
	movl	%ebx, 56(%rsp)
	movq	52(%rsp), %rdi
	movl	$1, %ecx
	movabsq	$133143986207, %rdx
	movl	$1, %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L38
	movl	16(%r12), %edx
	movl	12(%r12), %esi
	movl	$3, %r8d
	movq	8(%rsp), %r9
	movq	24(%rsp), %rcx
	movq	16(%rsp), %rdi
	call	_Z46__device_stub__Z11convolutionPK5pixeliiPKfiPS_PK5pixeliiPKfiPS_
.L38:
	call	cudaGetLastError@PLT
	movl	$1, %ecx
	movl	$207, %edx
	leaq	.LC7(%rip), %rbx
	movl	%eax, %edi
	movq	%rbx, %rsi
	call	_Z9gpuAssert9cudaErrorPKcib
	call	cudaDeviceSynchronize@PLT
	movl	$1, %ecx
	movl	$208, %edx
	movq	%rbx, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movl	20(%r12), %ecx
	movl	$1, %eax
	movl	%ecx, %edi
	andl	$8, %edi
	jne	.L39
	movl	%ecx, %eax
	shrl	$2, %eax
	andl	$1, %eax
	incl	%eax
.L39:
	movl	16(%r12), %edx
	movl	$1, %esi
	testl	%edi, %edi
	jne	.L40
	andl	$3, %ecx
	leal	1(%rcx), %esi
.L40:
	imull	12(%r12), %edx
	movq	0(%r13), %rdi
	movl	$2, %ecx
	imull	%eax, %edx
	imull	%esi, %edx
	movq	8(%rsp), %rsi
	call	cudaMemcpy@PLT
	addq	$72, %rsp
	.cfi_def_cfa_offset 56
	movq	%rbx, %rsi
	movl	$1, %ecx
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	%eax, %edi
	popq	%rbp
	.cfi_def_cfa_offset 40
	movl	$210, %edx
	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	_Z9gpuAssert9cudaErrorPKcib
	.cfi_endproc
.LFE5020:
	.size	_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_.constprop.0, .-_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_.constprop.0
	.section	.rodata.str1.1
.LC11:
	.string	"_Z11convolutionPK5pixeliiPKfiPS_"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4295:
	.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	.LC11(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z11convolutionPK5pixeliiPKfiPS_(%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
.LFE4295:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZNSt6vectorIhSaIhEED2Ev,"axG",@progbits,_ZNSt6vectorIhSaIhEED5Ev,comdat
	.align 2
	.weak	_ZNSt6vectorIhSaIhEED2Ev
	.type	_ZNSt6vectorIhSaIhEED2Ev, @function
_ZNSt6vectorIhSaIhEED2Ev:
.LFB4616:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L46
	movq	16(%rdi), %rsi
	movq	%rax, %rdi
	subq	%rax, %rsi
	jmp	_ZdlPvm@PLT
.L46:
	ret
	.cfi_endproc
.LFE4616:
	.size	_ZNSt6vectorIhSaIhEED2Ev, .-_ZNSt6vectorIhSaIhEED2Ev
	.weak	_ZNSt6vectorIhSaIhEED1Ev
	.set	_ZNSt6vectorIhSaIhEED1Ev,_ZNSt6vectorIhSaIhEED2Ev
	.section	.text._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,"axG",@progbits,_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,comdat
	.weak	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
	.type	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_, @function
_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_:
.LFB4618:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4618
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rdi, %rbx
	movq	%rdx, %rdi
	call	strlen@PLT
	movq	8(%r13), %r14
	movq	0(%r13), %r13
	movq	%rbx, %rdi
	movq	%rax, %r12
	leaq	16(%rbx), %rax
	movb	$0, 16(%rbx)
	movq	%rax, (%rbx)
	xorl	%eax, %eax
	leaq	(%r12,%r14), %rsi
	movq	%rax, 8(%rbx)
.LEHB0:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm@PLT
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm.isra.0
.LEHE0:
	movq	%rbx, %rax
	popq	%rbx
	.cfi_remember_state
	.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
.L51:
	.cfi_restore_state
	endbr64
	movq	%rax, %rbp
.L50:
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	%rbp, %rdi
.LEHB1:
	call	_Unwind_Resume@PLT
.LEHE1:
	.cfi_endproc
.LFE4618:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,"aG",@progbits,_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,comdat
.LLSDA4618:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4618-.LLSDACSB4618
.LLSDACSB4618:
	.uleb128 .LEHB0-.LFB4618
	.uleb128 .LEHE0-.LEHB0
	.uleb128 .L51-.LFB4618
	.uleb128 0
	.uleb128 .LEHB1-.LFB4618
	.uleb128 .LEHE1-.LEHB1
	.uleb128 0
	.uleb128 0
.LLSDACSE4618:
	.section	.text._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,"axG",@progbits,_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_,comdat
	.size	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_, .-_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
	.section	.text._ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPhmEET_S3_T0_,"axG",@progbits,_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPhmEET_S3_T0_,comdat
	.weak	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPhmEET_S3_T0_
	.type	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPhmEET_S3_T0_, @function
_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPhmEET_S3_T0_:
.LFB4980:
	.cfi_startproc
	endbr64
	movq	%rdi, %rdx
	testq	%rsi, %rsi
	je	.L55
	movb	$0, (%rdi)
	leaq	1(%rdi), %r8
	cmpq	$1, %rsi
	je	.L56
	leaq	-1(%rsi), %rcx
	xorl	%eax, %eax
	movq	%r8, %rdi
	addq	%rsi, %rdx
	rep stosb
	jmp	.L55
.L56:
	movq	%r8, %rdx
.L55:
	movq	%rdx, %rax
	ret
	.cfi_endproc
.LFE4980:
	.size	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPhmEET_S3_T0_, .-_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPhmEET_S3_T0_
	.section	.rodata._ZNSt6vectorIhSaIhEE17_M_default_appendEm.str1.1,"aMS",@progbits,1
.LC12:
	.string	"vector::_M_default_append"
	.section	.text._ZNSt6vectorIhSaIhEE17_M_default_appendEm,"axG",@progbits,_ZNSt6vectorIhSaIhEE17_M_default_appendEm,comdat
	.align 2
	.weak	_ZNSt6vectorIhSaIhEE17_M_default_appendEm
	.type	_ZNSt6vectorIhSaIhEE17_M_default_appendEm, @function
_ZNSt6vectorIhSaIhEE17_M_default_appendEm:
.LFB4763:
	.cfi_startproc
	endbr64
	testq	%rsi, %rsi
	je	.L74
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	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
	movq	%rsi, %rbx
	pushq	%rdx
	.cfi_def_cfa_offset 64
	movq	8(%rdi), %rdi
	movq	16(%r14), %rax
	movq	(%r14), %r15
	subq	%rdi, %rax
	cmpq	%rsi, %rax
	jb	.L62
	call	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPhmEET_S3_T0_
	movq	%rax, 8(%r14)
	jmp	.L60
.L62:
	movabsq	$9223372036854775807, %rax
	subq	%r15, %rdi
	subq	%rdi, %rax
	movq	%rdi, %rbp
	cmpq	%rsi, %rax
	jnb	.L63
	leaq	.LC12(%rip), %rdi
	call	_ZSt20__throw_length_errorPKc@PLT
.L63:
	movabsq	$9223372036854775807, %rax
	cmpq	%rdi, %rsi
	movq	%rdi, %r13
	cmovnb	%rsi, %r13
	addq	%rdi, %r13
	cmpq	%rax, %r13
	cmova	%rax, %r13
	movq	%r13, %rdi
	call	_Znwm@PLT
	movq	%rbx, %rsi
	leaq	(%rax,%rbp), %rdi
	movq	%rax, %r12
	call	_ZNSt27__uninitialized_default_n_1ILb1EE18__uninit_default_nIPhmEET_S3_T0_
	testq	%rbp, %rbp
	je	.L64
	movq	%rbp, %rdx
	movq	%r15, %rsi
	movq	%r12, %rdi
	call	memmove@PLT
	jmp	.L65
.L64:
	testq	%r15, %r15
	je	.L66
.L65:
	movq	16(%r14), %rsi
	movq	%r15, %rdi
	subq	%r15, %rsi
	call	_ZdlPvm@PLT
.L66:
	addq	%rbp, %rbx
	movq	%r12, (%r14)
	addq	%r12, %rbx
	addq	%r13, %r12
	movq	%rbx, 8(%r14)
	movq	%r12, 16(%r14)
.L60:
	popq	%rax
	.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
.L74:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	ret
	.cfi_endproc
.LFE4763:
	.size	_ZNSt6vectorIhSaIhEE17_M_default_appendEm, .-_ZNSt6vectorIhSaIhEE17_M_default_appendEm
	.section	.rodata.str1.1
.LC13:
	.string	"Failed to open image"
.LC14:
	.string	"Image "
.LC15:
	.string	" size: "
.LC16:
	.string	"Failed to read image "
	.text
	.type	_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE, @function
_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE:
.LFB4253:
	.cfi_startproc
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%eax, %eax
	leaq	.LC3(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	movq	%rsi, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rsi, %rbx
	pushq	%rcx
	.cfi_def_cfa_offset 48
	movl	$26, %ecx
	rep stosl
	movl	$1, 8(%rsi)
	movq	%rbx, %rdi
	movq	(%r12), %rsi
	call	png_image_begin_read_from_file@PLT
	leaq	.LC13(%rip), %rsi
	testl	%eax, %eax
	je	.L83
	leaq	.LC14(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsIcSt11char_traitsIcESaIcEERSt13basic_ostreamIT_T0_ES7_RKNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
	leaq	.LC15(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	12(%rbx), %esi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	leaq	.LC9(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	16(%rbx), %esi
	movq	%rax, %rdi
	call	_ZNSo9_M_insertImEERSoT_@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	16(%rbx), %eax
	imull	12(%rbx), %eax
	movl	$3, 20(%rbx)
	movq	8(%rbp), %rcx
	leal	0(,%rax,4), %esi
	movq	0(%rbp), %rax
	movq	%rcx, %rdx
	subq	%rax, %rdx
	cmpq	%rsi, %rdx
	jnb	.L79
	subq	%rdx, %rsi
	movq	%rbp, %rdi
	call	_ZNSt6vectorIhSaIhEE17_M_default_appendEm
	jmp	.L80
.L79:
	cmpq	%rdx, %rsi
	jnb	.L80
	addq	%rsi, %rax
	cmpq	%rax, %rcx
	je	.L80
	movq	%rax, 8(%rbp)
.L80:
	movq	0(%rbp), %rdx
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	png_image_finish_read@PLT
	testl	%eax, %eax
	jne	.L77
	leaq	.LC16(%rip), %rsi
.L83:
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsIcSt11char_traitsIcESaIcEERSt13basic_ostreamIT_T0_ES7_RKNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
	movq	%r13, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	$1, %edi
	call	exit@PLT
.L77:
	popq	%rax
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4253:
	.size	_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE, .-_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
	.section	.rodata.str1.1
.LC17:
	.string	"."
.LC18:
	.string	"/checkerboard.png"
.LC19:
	.string	"/icon.png"
.LC20:
	.string	"/checkerboard-out.png"
.LC22:
	.string	"/icon-out.png"
	.section	.rodata
	.align 32
.LC0:
	.long	-1082130432
	.long	-1082130432
	.long	-1082130432
	.long	-1082130432
	.long	1090519040
	.long	-1082130432
	.long	-1082130432
	.long	-1082130432
	.long	-1082130432
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB4257:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4257
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	1+.LC17(%rip), %rdx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	leaq	-1(%rdx), %rsi
	subq	$472, %rsp
	.cfi_def_cfa_offset 528
	movq	%fs:40, %rax
	movq	%rax, 456(%rsp)
	xorl	%eax, %eax
	leaq	120(%rsp), %rdi
	leaq	104(%rsp), %rax
	movq	%rax, 8(%rsp)
	movq	%rdi, 104(%rsp)
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcPKcS7_@PLT
	movq	104(%rsp), %rax
	decl	%ebp
	movq	$1, 112(%rsp)
	movb	$0, 1(%rax)
	jg	.L85
.L87:
	xorl	%edx, %edx
	movq	8(%rsp), %rsi
	leaq	56(%rsp), %rax
	leaq	352(%rsp), %rbp
	movq	%rdx, 56(%rsp)
	movq	%rbp, %rdi
	movq	%rdx, 64(%rsp)
	movq	%rdx, 72(%rsp)
	leaq	.LC18(%rip), %rdx
	movq	%rax, 24(%rsp)
.LEHB2:
	call	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
.LEHE2:
	jmp	.L116
.L85:
	movq	8(%rbx), %rbx
	movq	%rbx, %rdi
	call	strlen@PLT
	movq	112(%rsp), %rdx
	movq	%rbx, %rcx
	xorl	%esi, %esi
	movq	8(%rsp), %rdi
	movq	%rax, %r8
.LEHB3:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm@PLT
.LEHE3:
	jmp	.L87
.L116:
	leaq	248(%rsp), %r14
	movq	24(%rsp), %rdx
	movq	%rbp, %rdi
	movq	%r14, %rsi
.LEHB4:
	call	_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
.LEHE4:
	movq	%rbp, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	24(%rsp), %rsi
	movq	%r14, %rdi
.LEHB5:
	call	_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE
	movl	268(%rsp), %edx
	movq	%rax, %r15
	movl	$1, %eax
	movl	%edx, %edi
	andl	$8, %edi
	jne	.L88
	movl	%edx, %eax
	shrl	$2, %eax
	andl	$1, %eax
	incl	%eax
.L88:
	movl	264(%rsp), %esi
	movl	$1, %ecx
	testl	%edi, %edi
	jne	.L89
	andl	$3, %edx
	leal	1(%rdx), %ecx
.L89:
	imull	260(%rsp), %esi
	leaq	32(%rsp), %rdi
	imull	%eax, %esi
	imull	%ecx, %esi
	call	cudaMalloc@PLT
	leaq	.LC7(%rip), %r12
	movl	%eax, %edi
	movl	$1, %ecx
	movl	$239, %edx
	movq	%r12, %rsi
	call	_Z9gpuAssert9cudaErrorPKcib
.LEHE5:
	xorl	%eax, %eax
	leaq	208(%rsp), %rbx
	movq	8(%rsp), %rsi
	leaq	.LC19(%rip), %rdx
	movq	%rax, 80(%rsp)
	movq	%rbx, %rdi
	movq	%rax, 88(%rsp)
	movq	%rax, 96(%rsp)
	leaq	80(%rsp), %rax
	movq	%rax, 16(%rsp)
.LEHB6:
	call	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
.LEHE6:
	movq	16(%rsp), %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
.LEHB7:
	call	_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
.LEHE7:
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	16(%rsp), %rsi
	movq	%rbp, %rdi
.LEHB8:
	call	_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE
	movl	372(%rsp), %edx
	movq	%rax, %r13
	movl	$1, %eax
	movl	%edx, %edi
	andl	$8, %edi
	jne	.L90
	movl	%edx, %eax
	shrl	$2, %eax
	andl	$1, %eax
	incl	%eax
.L90:
	movl	368(%rsp), %esi
	movl	$1, %ecx
	testl	%edi, %edi
	jne	.L91
	andl	$3, %edx
	leal	1(%rdx), %ecx
.L91:
	imull	364(%rsp), %esi
	leaq	40(%rsp), %rdi
	imull	%eax, %esi
	imull	%ecx, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	movl	$1, %ecx
	movl	$247, %edx
	movq	%r12, %rsi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	48(%rsp), %rdi
	movl	$200, %esi
	call	cudaMalloc@PLT
	movl	%eax, %edi
	movl	$1, %ecx
	movl	$251, %edx
	movq	%r12, %rsi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	172(%rsp), %rdi
	movl	$9, %ecx
	movl	$36, %edx
	leaq	.LC0(%rip), %rsi
	rep movsl
	movq	48(%rsp), %rdi
	leaq	172(%rsp), %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	movl	$1, %ecx
	movl	$257, %edx
	movq	%r12, %rsi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	32(%rsp), %r8
	movq	48(%rsp), %rcx
	movq	%r15, %rdx
	movq	%r14, %rdi
	movq	24(%rsp), %rsi
	call	_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_.constprop.0
	movq	%r15, %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	movl	$1, %ecx
	movl	$261, %edx
	movq	%r12, %rsi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	8(%rsp), %rsi
	leaq	.LC20(%rip), %rdx
	movq	%rbx, %rdi
	call	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
.LEHE8:
	movq	56(%rsp), %rdx
	movq	%r14, %rsi
	movq	%rbx, %rdi
.LEHB9:
	call	_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE.isra.0
.LEHE9:
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movl	$9, %ecx
	xorl	%eax, %eax
	movq	%rbx, %rdi
	rep stosl
	movq	48(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$0x3f800000, 224(%rsp)
	movl	$36, %edx
.LEHB10:
	call	cudaMemcpy@PLT
	movl	%eax, %edi
	movl	$1, %ecx
	movl	$267, %edx
	movq	%r12, %rsi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	40(%rsp), %r8
	movq	48(%rsp), %rcx
	movq	%r13, %rdx
	movq	%rbp, %rdi
	movq	16(%rsp), %rsi
	call	_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_.constprop.0
	movq	%r13, %rdi
	call	cudaFree@PLT
	movl	%eax, %edi
	movl	$1, %ecx
	movl	$271, %edx
	movq	%r12, %rsi
	call	_Z9gpuAssert9cudaErrorPKcib
	leaq	136(%rsp), %r12
	movq	8(%rsp), %rsi
	leaq	.LC22(%rip), %rdx
	movq	%r12, %rdi
	call	_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
.LEHE10:
	movq	80(%rsp), %rdx
	movq	%rbp, %rsi
	movq	%r12, %rdi
.LEHB11:
	call	_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE.isra.0
.LEHE11:
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
.LEHB12:
	call	cudaDeviceReset@PLT
.LEHE12:
	movq	16(%rsp), %rdi
	call	_ZNSt6vectorIhSaIhEED1Ev
	leaq	56(%rsp), %rdi
	call	_ZNSt6vectorIhSaIhEED1Ev
	leaq	104(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	456(%rsp), %rax
	subq	%fs:40, %rax
	je	.L100
	jmp	.L113
.L106:
	endbr64
	movq	%rax, %rbx
.L92:
	movq	%rbp, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L93
.L108:
	endbr64
	jmp	.L115
.L110:
	endbr64
.L115:
	movq	%rax, %rbp
.L96:
	movq	%rbx, %rdi
	movq	%rbp, %rbx
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L95
.L111:
	endbr64
	movq	%rax, %rbx
.L97:
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L95
.L109:
	endbr64
	movq	%rax, %rbx
.L95:
	movq	16(%rsp), %rdi
	call	_ZNSt6vectorIhSaIhEED1Ev
	jmp	.L93
.L107:
	endbr64
	movq	%rax, %rbx
.L93:
	movq	24(%rsp), %rdi
	call	_ZNSt6vectorIhSaIhEED1Ev
	jmp	.L98
.L105:
	endbr64
	movq	%rax, %rbx
.L98:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	456(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L113
	movq	%rbx, %rdi
.LEHB13:
	call	_Unwind_Resume@PLT
.LEHE13:
.L113:
	call	__stack_chk_fail@PLT
.L100:
	addq	$472, %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
.LFE4257:
	.section	.gcc_except_table,"a",@progbits
.LLSDA4257:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4257-.LLSDACSB4257
.LLSDACSB4257:
	.uleb128 .LEHB2-.LFB4257
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L107-.LFB4257
	.uleb128 0
	.uleb128 .LEHB3-.LFB4257
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L105-.LFB4257
	.uleb128 0
	.uleb128 .LEHB4-.LFB4257
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L106-.LFB4257
	.uleb128 0
	.uleb128 .LEHB5-.LFB4257
	.uleb128 .LEHE5-.LEHB5
	.uleb128 .L107-.LFB4257
	.uleb128 0
	.uleb128 .LEHB6-.LFB4257
	.uleb128 .LEHE6-.LEHB6
	.uleb128 .L109-.LFB4257
	.uleb128 0
	.uleb128 .LEHB7-.LFB4257
	.uleb128 .LEHE7-.LEHB7
	.uleb128 .L108-.LFB4257
	.uleb128 0
	.uleb128 .LEHB8-.LFB4257
	.uleb128 .LEHE8-.LEHB8
	.uleb128 .L109-.LFB4257
	.uleb128 0
	.uleb128 .LEHB9-.LFB4257
	.uleb128 .LEHE9-.LEHB9
	.uleb128 .L110-.LFB4257
	.uleb128 0
	.uleb128 .LEHB10-.LFB4257
	.uleb128 .LEHE10-.LEHB10
	.uleb128 .L109-.LFB4257
	.uleb128 0
	.uleb128 .LEHB11-.LFB4257
	.uleb128 .LEHE11-.LEHB11
	.uleb128 .L111-.LFB4257
	.uleb128 0
	.uleb128 .LEHB12-.LFB4257
	.uleb128 .LEHE12-.LEHB12
	.uleb128 .L109-.LFB4257
	.uleb128 0
	.uleb128 .LEHB13-.LFB4257
	.uleb128 .LEHE13-.LEHB13
	.uleb128 0
	.uleb128 0
.LLSDACSE4257:
	.section	.text.startup
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.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:

/*
 * Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#include <algorithm>
#include <cstring>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <utility>

#include <hip/hip_runtime.h>

#include <libpng/png.h>

struct pixel
{
    uint8_t red;
    uint8_t green;
    uint8_t blue;
    uint8_t alpha;
};

#define gpuErrchk(ans) gpuAssert((ans), __FILE__, __LINE__)
inline void gpuAssert(hipError_t code, const char *file, int line, bool abort=true)
{
    if (code != hipSuccess)
    {
        std::cerr << "GPU error: " << hipGetErrorString(code) << " at " << file << ":" << line << "\n";
        if (abort)
        {
            std::exit(code);
        }
    }
}

constexpr unsigned BlockLength = 31;

__global__ void convolution(const pixel* image, const int width, const int height, const float* matrix, const int matrixLength, pixel* out)
{
    extern __shared__ float sMatrix[];
    pixel* subImage = (pixel*)(sMatrix + (matrixLength * matrixLength));
    const int subImageLength = BlockLength + (matrixLength / 2) * 2;

    const int xIdx = blockIdx.x * blockDim.x + threadIdx.x;
    const int yIdx = blockIdx.y * blockDim.y + threadIdx.y;

    // Copy convolution matrix to shared memory
    if (threadIdx.x < matrixLength && threadIdx.y < matrixLength)
    {
        sMatrix[threadIdx.x + threadIdx.y * matrixLength] = matrix[threadIdx.x + threadIdx.y * matrixLength];
    }

    const int apronSize = matrixLength / 2;

    const int shmemXIdx = matrixLength / 2 + threadIdx.x;
    const int shmemYIdx = matrixLength / 2 + threadIdx.y;

    // Clamping the accessed coordinates to the limits of the image, as we still
    // want threads that would be over that to participate in copying the image
    // chunk to shared memory
    const int cXIdx = min(width - 1, xIdx);
    const int cYIdx = min(height - 1, yIdx);

    // Copy center part of the image chunk in shared memory
    subImage[shmemXIdx + shmemYIdx * subImageLength] = image[cXIdx - cYIdx * width];

    // Copy apron part of the image chunk in shared memory
    if (threadIdx.x < apronSize)
    {
        subImage[shmemXIdx - apronSize + shmemYIdx * subImageLength] = image[max(0, cXIdx - apronSize) + cYIdx * width];
        // Copy a corner of the apron
        if (threadIdx.y < apronSize)
        {
            subImage[shmemXIdx - apronSize + (shmemYIdx - apronSize) * subImageLength] =
                image[max(0, cXIdx - apronSize) + max(0, cYIdx - apronSize) * width];
        }
    }

    if (threadIdx.y < apronSize)
    {
        subImage[shmemXIdx + (shmemYIdx - apronSize) * subImageLength] = image[cXIdx + max(0, cYIdx - apronSize) * width];
        if (threadIdx.x >= blockDim.x - apronSize)
        {
            subImage[shmemXIdx + apronSize + (shmemYIdx - apronSize) * subImageLength] =
                image[min(cXIdx + apronSize, width) + max(0, cYIdx - apronSize) * width];
        }
    }

    if (threadIdx.x >= (blockDim.x - apronSize))
    {
        subImage[shmemXIdx + apronSize + shmemYIdx * subImageLength] = image[min(cXIdx + apronSize, width - 1) + cYIdx * width];
        if (threadIdx.y >= blockDim.y - apronSize)
        {
            subImage[shmemXIdx + apronSize + (shmemYIdx + apronSize) * subImageLength] =
                image[min(cXIdx + apronSize, width - 1) + min(height - 1, cYIdx + apronSize) * width];
        }
    }

    if (threadIdx.y >= (blockDim.y - apronSize))
    {
        subImage[shmemXIdx + (shmemYIdx + apronSize) * subImageLength] = image[cXIdx + min(height - 1, cYIdx + apronSize) * width];
        if (threadIdx.x < apronSize)
        {
            subImage[shmemXIdx - apronSize + (shmemYIdx + apronSize) * subImageLength] =
                image[max(0, cXIdx - apronSize) + min(height - 1, cYIdx + apronSize) * width];
        }
    }

    // At this point we are done copying the sub-image to the shared memory

    // Discard threads that do not participate in the final image
    if (xIdx > width || yIdx >= height)
    {
        return;
    }

    float accR = 0.0;
    float accG = 0.0;
    float accB = 0.0;

    // Apply the convolution
    for (int i = 0; i < matrixLength; i++)
    {
        for (int j = 0; j < matrixLength; j++)
        {
            int baseX = shmemXIdx - apronSize;
            int baseY = shmemYIdx - apronSize;
            accR += (sMatrix[i * matrixLength + j] * subImage[baseX + j + (baseY + i) * subImageLength].red);
            accG += (sMatrix[i * matrixLength + j] * subImage[baseX + j + (baseY + i) * subImageLength].green);
            accB += (sMatrix[i * matrixLength + j] * subImage[baseX + j + (baseY + i) * subImageLength].blue);
        }
    }

    // Clamp values to avoid overflows
    accR = max(0., min(accR, 255.));
    accG = max(0., min(accG, 255.));
    accB = max(0., min(accB, 255.));

    const pixel res = {(uint8_t)accR, (uint8_t)accG, (uint8_t)accB, 255};
    out[xIdx + yIdx * width] = res;
}

static void loadImage(const std::string& filename, png_image& header, std::vector<uint8_t>& image)
{
    std::memset(&header, 0, sizeof(header));
    header.version = PNG_IMAGE_VERSION;

    // Load image metadata from fs
    if (!png_image_begin_read_from_file(&header, filename.c_str()))
    {
        std::cerr << "Failed to open image" << filename << "\n";
        std::exit(1);
    }
    std::cout << "Image "<< filename << " size: " << header.width << " * " << header.height << "\n";

    // Load image data from fs
    header.format = PNG_FORMAT_RGBA;
    image.resize(PNG_IMAGE_SIZE(header));
    if (!png_image_finish_read(&header, NULL/*background*/, image.data(), 0/*row_stride*/, NULL/*colormap*/))
    {
        std::cerr << "Failed to read image " << filename << "\n";
        std::exit(1);
    }
}

static uint8_t* copyImageToDevice(const png_image& header, const std::vector<uint8_t>& image)
{
    uint8_t* dImage;
    gpuErrchk(hipMalloc(&dImage, PNG_IMAGE_SIZE(header)));
    gpuErrchk(hipMemcpy(dImage, image.data(), PNG_IMAGE_SIZE(header), hipMemcpyHostToDevice));
    return dImage;
}

static void runConvolutionKernel(const png_image& header, std::vector<uint8_t>& hImage, uint8_t* dImage, const float* dMatrix, const int matrixLength, uint8_t* dOutput)
{
    dim3 blockSize(BlockLength, BlockLength);
    dim3 gridSize(header.width / blockSize.x + ((header.width % blockSize.x) != 0),
                  header.height / blockSize.y + ((header.height % blockSize.y) != 0));

    int subImageLength = BlockLength + (matrixLength / 2) * 2;
    int sharedMemorySize = (matrixLength * matrixLength * sizeof(float)) + (subImageLength * subImageLength * sizeof(pixel));

    std::cout << "Grid size: " << gridSize.x << " * " << gridSize.y << " * " << gridSize.z << "\n";
    std::cout << "Block size: " << blockSize.x << " * " << blockSize.y << " * " << blockSize.z << "\n";

    convolution<<<gridSize, blockSize, sharedMemorySize>>>((pixel*)dImage, header.width, header.height, dMatrix, matrixLength, (pixel*)dOutput);
    gpuErrchk(hipGetLastError());
    gpuErrchk(hipDeviceSynchronize());

    gpuErrchk(hipMemcpy(hImage.data(), dOutput, PNG_IMAGE_SIZE(header), hipMemcpyDeviceToHost));
}


static void saveImage(const std::string& filename, png_image& header, std::vector<uint8_t>& image)
{
    if (!png_image_write_to_file(&header, filename.c_str(), 0/*convert_to_8bit*/, image.data(), 0/*row_stride*/, NULL/*colormap*/))
    {
        std::cerr << "Failed to save image " << filename << "\n";
        std::exit(1);
    }
}

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

    std::string imagePath = ".";

    if (argc > 1)
    {
        imagePath = argv[1];
    }

    png_image headerChecker;
    std::vector<uint8_t> imageChecker;
    loadImage(imagePath + "/checkerboard.png", headerChecker, imageChecker);

    uint8_t* dImageChecker = copyImageToDevice(headerChecker, imageChecker);
    uint8_t* dOutputChecker;
    gpuErrchk(hipMalloc(&dOutputChecker, PNG_IMAGE_SIZE(headerChecker)));

    png_image headerIcon;
    std::vector<uint8_t> imageIcon;
    loadImage(imagePath + "/icon.png", headerIcon, imageIcon);

    uint8_t* dImageIcon = copyImageToDevice(headerIcon, imageIcon);
    uint8_t* dOutputIcon;
    gpuErrchk(hipMalloc(&dOutputIcon, PNG_IMAGE_SIZE(headerIcon)));

    // Allocate convolution matrix buffer (in this example, we use at most a 5x5 matrix)
    float* dMatrix;
    gpuErrchk(hipMalloc(&dMatrix, 5 * 5 * sizeof(double)));

    const float edgeDetectionMatrix[9] = {-1.f, -1.f, -1.f,
                                          -1.f, 8.f,  -1.f,
                                          -1.f, -1.f, -1.f};

    gpuErrchk(hipMemcpy(dMatrix, edgeDetectionMatrix, sizeof(edgeDetectionMatrix), hipMemcpyHostToDevice));

    runConvolutionKernel(headerChecker, imageChecker, dImageChecker, dMatrix, 3, dOutputChecker);

    gpuErrchk(hipFree(dImageChecker));

    saveImage(imagePath + "/checkerboard-out.png", headerChecker, imageChecker);

    float identityMatrix[9] = {0.f, };
    identityMatrix[4] = 1.f;
    gpuErrchk(hipMemcpy(dMatrix, identityMatrix, sizeof(identityMatrix), hipMemcpyHostToDevice));

    runConvolutionKernel(headerIcon, imageIcon, dImageIcon, dMatrix, 3, dOutputIcon);

    gpuErrchk(hipFree(dImageIcon));

    saveImage(imagePath + "/icon-out.png", headerIcon, imageIcon);

    // TODO: Uncomment me when reaching step 06
/*
    png_image headerCoffee;
    std::vector<uint8_t> imageCoffee;
    loadImage(imagePath + "/coffee.png", headerCoffee, imageCoffee);
    uint8_t* dImageCoffee = copyImageToDevice(headerCoffee, imageCoffee);

    uint8_t* dOutputCoffee;
    gpuErrchk(cudaMalloc(&dOutputCoffee, PNG_IMAGE_SIZE(headerCoffee)));

    const float gaussianBlurMatrix[25] = {1.f / 256.f,  4.f / 256.f,  6.f / 256.f,  4.f / 256.f, 1.f / 256.f,
                                          4.f / 256.f, 16.f / 256.f, 24.f / 256.f, 16.f / 256.f, 4.f / 256.f,
                                          6.f / 256.f, 24.f / 256.f, 36.f / 256.f, 24.f / 256.f, 6.f / 256.f,
                                          4.f / 256.f, 16.f / 256.f, 24.f / 256.f, 16.f / 256.f, 4.f / 256.f,
                                          1.f / 256.f,  4.f / 256.f,  6.f / 256.f,  4.f / 256.f, 1.f / 256.f};

    gpuErrchk(cudaMemcpy(dMatrix, gaussianBlurMatrix, 25, cudaMemcpyHostToDevice));

    runConvolutionKernel(headerCoffee, imageCoffee, dImageCoffee, dMatrix, 5, dOutputCoffee);

    gpuErrchk(cudaFree(dImageCoffee));

    saveImage(imagePath + "/coffee-out.png", headerCoffee, imageCoffee);
*/

    hipDeviceReset();

    return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z26__device_stub__convolutionPK5pixeliiPKfiPS_ # -- Begin function _Z26__device_stub__convolutionPK5pixeliiPKfiPS_
	.type	_Z26__device_stub__convolutionPK5pixeliiPKfiPS_,@function
_Z26__device_stub__convolutionPK5pixeliiPKfiPS_: # @_Z26__device_stub__convolutionPK5pixeliiPKfiPS_
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.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	20(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	16(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	48(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	12(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	40(%rsp), %r8
	movq	%r9, (%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	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	$_Z11convolutionPK5pixeliiPKfiPS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z26__device_stub__convolutionPK5pixeliiPKfiPS_, .Lfunc_end0-_Z26__device_stub__convolutionPK5pixeliiPKfiPS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI1_0:
	.long	0xbf800000                      # float -1
	.long	0xbf800000                      # float -1
	.long	0xbf800000                      # float -1
	.long	0xbf800000                      # float -1
.LCPI1_1:
	.long	0x41000000                      # float 8
	.long	0xbf800000                      # float -1
	.long	0xbf800000                      # float -1
	.long	0xbf800000                      # float -1
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.exit
	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	$456, %rsp                      # imm = 0x1C8
	.cfi_def_cfa_offset 512
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movl	%edi, %ebp
	leaq	32(%rsp), %r12
	movq	%r12, -16(%r12)
	leaq	16(%rsp), %rdi
	movl	$.L.str, %esi
	movl	$.L.str+1, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	cmpl	$2, %ebp
	jl	.LBB1_2
# %bb.1:
	movq	8(%rbx), %rbx
	leaq	16(%rsp), %r14
	movq	8(%r14), %r15
	movq	%rbx, %rdi
	callq	strlen
.Ltmp0:
	movq	%r14, %rdi
	xorl	%esi, %esi
	movq	%r15, %rdx
	movq	%rbx, %rcx
	movq	%rax, %r8
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm
.Ltmp1:
.LBB1_2:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc.exit
	xorl	%eax, %eax
	movq	%rax, 96(%rsp)
	xorps	%xmm0, %xmm0
	movaps	%xmm0, 80(%rsp)
	movq	16(%rsp), %rbx
	movq	24(%rsp), %r14
	leaq	264(%rsp), %r15
	movq	%r15, -16(%r15)
	movq	%rax, -8(%r15)
	movb	$0, (%r15)
	leaq	17(%r14), %rsi
.Ltmp3:
	leaq	248(%rsp), %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm
.Ltmp4:
# %bb.3:
.Ltmp5:
	leaq	248(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp6:
# %bb.4:
.Ltmp7:
	leaq	248(%rsp), %rdi
	movl	$.L.str.1, %esi
	movl	$17, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp8:
# %bb.5:                                # %_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_.exit
.Ltmp10:
	leaq	248(%rsp), %rdi
	leaq	352(%rsp), %rsi
	leaq	80(%rsp), %rdx
	callq	_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
.Ltmp11:
# %bb.6:
	movq	248(%rsp), %rdi
	cmpq	%r15, %rdi
	je	.LBB1_8
# %bb.7:                                # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
	callq	_ZdlPv
.LBB1_8:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
.Ltmp13:
	leaq	352(%rsp), %rdi
	leaq	80(%rsp), %rsi
	callq	_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE
.Ltmp14:
# %bb.9:
	movq	%rax, %r14
	movl	364(%rsp), %esi
	movl	372(%rsp), %eax
	btl	$2, %eax
	movl	$1, %ecx
	movl	$1, %edx
	adcl	$0, %edx
	movl	%eax, %edi
	andl	$3, %edi
	incl	%edi
	testb	$8, %al
	cmovnel	%ecx, %edx
	cmovnel	%ecx, %edi
	imull	368(%rsp), %esi
	imull	%edi, %esi
	imull	%edx, %esi
.Ltmp16:
	leaq	240(%rsp), %rdi
	callq	hipMalloc
.Ltmp17:
# %bb.10:                               # %_ZL9hipMallocIhE10hipError_tPPT_m.exit
.Ltmp18:
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$239, %edx
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
.Ltmp19:
# %bb.11:
	xorl	%eax, %eax
	movq	%rax, 64(%rsp)
	xorps	%xmm0, %xmm0
	movaps	%xmm0, 48(%rsp)
	movq	16(%rsp), %rbx
	movq	24(%rsp), %r15
	leaq	176(%rsp), %r13
	movq	%r13, -16(%r13)
	movq	%rax, -8(%r13)
	movb	$0, (%r13)
	leaq	9(%r15), %rsi
.Ltmp21:
	leaq	160(%rsp), %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm
.Ltmp22:
# %bb.12:
.Ltmp23:
	leaq	160(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r15, %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp24:
# %bb.13:
.Ltmp25:
	leaq	160(%rsp), %rdi
	movl	$.L.str.3, %esi
	movl	$9, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp26:
# %bb.14:                               # %_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_.exit48
.Ltmp28:
	leaq	160(%rsp), %rdi
	leaq	248(%rsp), %rsi
	leaq	48(%rsp), %rdx
	callq	_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
.Ltmp29:
# %bb.15:
	movq	160(%rsp), %rdi
	cmpq	%r13, %rdi
	je	.LBB1_17
# %bb.16:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i49
	callq	_ZdlPv
.LBB1_17:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit51
.Ltmp31:
	leaq	248(%rsp), %rdi
	leaq	48(%rsp), %rsi
	callq	_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE
.Ltmp32:
# %bb.18:
	movq	%rax, %rbx
	movl	260(%rsp), %esi
	movl	268(%rsp), %eax
	btl	$2, %eax
	movl	$1, %ecx
	movl	$1, %edx
	adcl	$0, %edx
	movl	%eax, %edi
	andl	$3, %edi
	incl	%edi
	testb	$8, %al
	cmovnel	%ecx, %edx
	cmovnel	%ecx, %edi
	imull	264(%rsp), %esi
	imull	%edi, %esi
	imull	%edx, %esi
.Ltmp34:
	leaq	232(%rsp), %rdi
	callq	hipMalloc
.Ltmp35:
# %bb.19:                               # %_ZL9hipMallocIhE10hipError_tPPT_m.exit52
.Ltmp36:
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$247, %edx
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
.Ltmp37:
# %bb.20:
.Ltmp39:
	leaq	8(%rsp), %rdi
	movl	$200, %esi
	callq	hipMalloc
.Ltmp40:
# %bb.21:                               # %_ZL9hipMallocIfE10hipError_tPPT_m.exit
.Ltmp41:
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$251, %edx
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
.Ltmp42:
# %bb.22:
	movaps	.LCPI1_0(%rip), %xmm0           # xmm0 = [-1.0E+0,-1.0E+0,-1.0E+0,-1.0E+0]
	leaq	160(%rsp), %rsi
	movaps	%xmm0, (%rsi)
	movaps	.LCPI1_1(%rip), %xmm0           # xmm0 = [8.0E+0,-1.0E+0,-1.0E+0,-1.0E+0]
	movaps	%xmm0, 16(%rsi)
	movl	$-1082130432, 32(%rsi)          # imm = 0xBF800000
	movq	8(%rsp), %rdi
.Ltmp44:
	movl	$36, %edx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp45:
# %bb.23:
.Ltmp46:
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$257, %edx                      # imm = 0x101
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
.Ltmp47:
# %bb.24:
	movq	8(%rsp), %rcx
	movq	240(%rsp), %r8
.Ltmp48:
	leaq	352(%rsp), %rdi
	leaq	80(%rsp), %rsi
	movq	%r14, %rdx
	callq	_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_
.Ltmp49:
# %bb.25:
.Ltmp50:
	movq	%r14, %rdi
	callq	hipFree
.Ltmp51:
# %bb.26:
.Ltmp52:
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$261, %edx                      # imm = 0x105
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
.Ltmp53:
# %bb.27:
	movq	16(%rsp), %r14
	movq	24(%rsp), %r15
	leaq	128(%rsp), %r13
	movq	%r13, -16(%r13)
	movq	$0, -8(%r13)
	movb	$0, (%r13)
	leaq	21(%r15), %rsi
.Ltmp55:
	leaq	112(%rsp), %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm
.Ltmp56:
# %bb.28:
.Ltmp57:
	leaq	112(%rsp), %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp58:
# %bb.29:
.Ltmp59:
	leaq	112(%rsp), %rdi
	movl	$.L.str.4, %esi
	movl	$21, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp60:
# %bb.30:                               # %_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_.exit58
.Ltmp62:
	leaq	112(%rsp), %rdi
	leaq	352(%rsp), %rsi
	leaq	80(%rsp), %rdx
	callq	_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
.Ltmp63:
# %bb.31:
	movq	112(%rsp), %rdi
	cmpq	%r13, %rdi
	je	.LBB1_33
# %bb.32:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i59
	callq	_ZdlPv
.LBB1_33:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit61
	xorps	%xmm0, %xmm0
	leaq	112(%rsp), %rsi
	movaps	%xmm0, 16(%rsi)
	movaps	%xmm0, (%rsi)
	movl	$0, 32(%rsi)
	movl	$1065353216, 16(%rsi)           # imm = 0x3F800000
	movq	8(%rsp), %rdi
.Ltmp65:
	movl	$36, %edx
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp66:
# %bb.34:
.Ltmp67:
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$267, %edx                      # imm = 0x10B
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
.Ltmp68:
# %bb.35:
	movq	8(%rsp), %rcx
	movq	232(%rsp), %r8
.Ltmp69:
	leaq	248(%rsp), %rdi
	leaq	48(%rsp), %rsi
	movq	%rbx, %rdx
	callq	_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_
.Ltmp70:
# %bb.36:
.Ltmp71:
	movq	%rbx, %rdi
	callq	hipFree
.Ltmp72:
# %bb.37:
.Ltmp73:
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$271, %edx                      # imm = 0x10F
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
.Ltmp74:
# %bb.38:
	movq	16(%rsp), %rbx
	movq	24(%rsp), %r14
	leaq	216(%rsp), %r15
	movq	%r15, -16(%r15)
	movq	$0, -8(%r15)
	movb	$0, (%r15)
	leaq	13(%r14), %rsi
.Ltmp75:
	leaq	200(%rsp), %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7reserveEm
.Ltmp76:
# %bb.39:
.Ltmp77:
	leaq	200(%rsp), %rdi
	movq	%rbx, %rsi
	movq	%r14, %rdx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp78:
# %bb.40:
.Ltmp79:
	leaq	200(%rsp), %rdi
	movl	$.L.str.5, %esi
	movl	$13, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm
.Ltmp80:
# %bb.41:                               # %_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_.exit67
.Ltmp82:
	leaq	200(%rsp), %rdi
	leaq	248(%rsp), %rsi
	leaq	48(%rsp), %rdx
	callq	_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
.Ltmp83:
# %bb.42:
	movq	200(%rsp), %rdi
	cmpq	%r15, %rdi
	je	.LBB1_44
# %bb.43:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i68
	callq	_ZdlPv
.LBB1_44:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit70
.Ltmp85:
	callq	hipDeviceReset
.Ltmp86:
# %bb.45:
	movq	48(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB1_47
# %bb.46:
	callq	_ZdlPv
.LBB1_47:                               # %_ZNSt6vectorIhSaIhEED2Ev.exit
	movq	80(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB1_49
# %bb.48:
	callq	_ZdlPv
.LBB1_49:                               # %_ZNSt6vectorIhSaIhEED2Ev.exit72
	movq	16(%rsp), %rdi
	cmpq	%r12, %rdi
	je	.LBB1_51
# %bb.50:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i73
	callq	_ZdlPv
.LBB1_51:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit75
	xorl	%eax, %eax
	addq	$456, %rsp                      # imm = 0x1C8
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB1_52:
	.cfi_def_cfa_offset 512
.Ltmp2:
	movq	%rax, %rbx
	jmp	.LBB1_80
.LBB1_53:
.Ltmp84:
	jmp	.LBB1_64
.LBB1_54:
.Ltmp64:
	jmp	.LBB1_66
.LBB1_55:
.Ltmp33:
	jmp	.LBB1_75
.LBB1_56:
.Ltmp30:
	jmp	.LBB1_68
.LBB1_57:
.Ltmp15:
	jmp	.LBB1_58
.LBB1_59:
.Ltmp12:
	jmp	.LBB1_72
.LBB1_60:
.Ltmp43:
	jmp	.LBB1_75
.LBB1_61:
.Ltmp38:
	jmp	.LBB1_75
.LBB1_62:
.Ltmp20:
.LBB1_58:
	movq	%rax, %rbx
	jmp	.LBB1_78
.LBB1_63:
.Ltmp81:
.LBB1_64:
	movq	%rax, %rbx
	movq	200(%rsp), %rdi
	cmpq	%r15, %rdi
	jne	.LBB1_70
	jmp	.LBB1_76
.LBB1_65:
.Ltmp61:
.LBB1_66:
	movq	%rax, %rbx
	movq	112(%rsp), %rdi
	jmp	.LBB1_69
.LBB1_67:
.Ltmp27:
.LBB1_68:
	movq	%rax, %rbx
	movq	160(%rsp), %rdi
.LBB1_69:
	cmpq	%r13, %rdi
	je	.LBB1_76
.LBB1_70:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i85
	callq	_ZdlPv
	jmp	.LBB1_76
.LBB1_71:
.Ltmp9:
.LBB1_72:
	movq	%rax, %rbx
	movq	248(%rsp), %rdi
	cmpq	%r15, %rdi
	jne	.LBB1_77
	jmp	.LBB1_78
.LBB1_73:
.Ltmp54:
	jmp	.LBB1_75
.LBB1_74:
.Ltmp87:
.LBB1_75:
	movq	%rax, %rbx
.LBB1_76:
	movq	48(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB1_78
.LBB1_77:
	callq	_ZdlPv
.LBB1_78:
	movq	80(%rsp), %rdi
	testq	%rdi, %rdi
	je	.LBB1_80
# %bb.79:
	callq	_ZdlPv
.LBB1_80:
	movq	16(%rsp), %rdi
	cmpq	%r12, %rdi
	je	.LBB1_82
# %bb.81:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i92
	callq	_ZdlPv
.LBB1_82:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit94
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp8-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp8
	.uleb128 .Ltmp9-.Lfunc_begin0           #     jumps to .Ltmp9
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp10-.Lfunc_begin0          # >> Call Site 4 <<
	.uleb128 .Ltmp11-.Ltmp10                #   Call between .Ltmp10 and .Ltmp11
	.uleb128 .Ltmp12-.Lfunc_begin0          #     jumps to .Ltmp12
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp13-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp14-.Ltmp13                #   Call between .Ltmp13 and .Ltmp14
	.uleb128 .Ltmp15-.Lfunc_begin0          #     jumps to .Ltmp15
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp16-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp19-.Ltmp16                #   Call between .Ltmp16 and .Ltmp19
	.uleb128 .Ltmp20-.Lfunc_begin0          #     jumps to .Ltmp20
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp21-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp26-.Ltmp21                #   Call between .Ltmp21 and .Ltmp26
	.uleb128 .Ltmp27-.Lfunc_begin0          #     jumps to .Ltmp27
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp28-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp29-.Ltmp28                #   Call between .Ltmp28 and .Ltmp29
	.uleb128 .Ltmp30-.Lfunc_begin0          #     jumps to .Ltmp30
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp31-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp32-.Ltmp31                #   Call between .Ltmp31 and .Ltmp32
	.uleb128 .Ltmp33-.Lfunc_begin0          #     jumps to .Ltmp33
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp34-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp37-.Ltmp34                #   Call between .Ltmp34 and .Ltmp37
	.uleb128 .Ltmp38-.Lfunc_begin0          #     jumps to .Ltmp38
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp39-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp42-.Ltmp39                #   Call between .Ltmp39 and .Ltmp42
	.uleb128 .Ltmp43-.Lfunc_begin0          #     jumps to .Ltmp43
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp44-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp53-.Ltmp44                #   Call between .Ltmp44 and .Ltmp53
	.uleb128 .Ltmp54-.Lfunc_begin0          #     jumps to .Ltmp54
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp55-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Ltmp60-.Ltmp55                #   Call between .Ltmp55 and .Ltmp60
	.uleb128 .Ltmp61-.Lfunc_begin0          #     jumps to .Ltmp61
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp62-.Lfunc_begin0          # >> Call Site 14 <<
	.uleb128 .Ltmp63-.Ltmp62                #   Call between .Ltmp62 and .Ltmp63
	.uleb128 .Ltmp64-.Lfunc_begin0          #     jumps to .Ltmp64
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp65-.Lfunc_begin0          # >> Call Site 15 <<
	.uleb128 .Ltmp74-.Ltmp65                #   Call between .Ltmp65 and .Ltmp74
	.uleb128 .Ltmp87-.Lfunc_begin0          #     jumps to .Ltmp87
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp75-.Lfunc_begin0          # >> Call Site 16 <<
	.uleb128 .Ltmp80-.Ltmp75                #   Call between .Ltmp75 and .Ltmp80
	.uleb128 .Ltmp81-.Lfunc_begin0          #     jumps to .Ltmp81
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp82-.Lfunc_begin0          # >> Call Site 17 <<
	.uleb128 .Ltmp83-.Ltmp82                #   Call between .Ltmp82 and .Ltmp83
	.uleb128 .Ltmp84-.Lfunc_begin0          #     jumps to .Ltmp84
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp85-.Lfunc_begin0          # >> Call Site 18 <<
	.uleb128 .Ltmp86-.Ltmp85                #   Call between .Ltmp85 and .Ltmp86
	.uleb128 .Ltmp87-.Lfunc_begin0          #     jumps to .Ltmp87
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp86-.Lfunc_begin0          # >> Call Site 19 <<
	.uleb128 .Lfunc_end1-.Ltmp86            #   Call between .Ltmp86 and .Lfunc_end1
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.type	_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE,@function # -- Begin function _ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE: # @_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.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 %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r15
	movq	%rsi, %r14
	movq	%rdi, %rbx
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rsi)
	movups	%xmm0, 80(%rsi)
	movups	%xmm0, 64(%rsi)
	movups	%xmm0, 48(%rsi)
	movups	%xmm0, 32(%rsi)
	movups	%xmm0, 16(%rsi)
	movq	$0, 96(%rsi)
	movl	$1, 8(%rsi)
	movq	(%rdi), %rsi
	movq	%r14, %rdi
	callq	png_image_begin_read_from_file
	testl	%eax, %eax
	je	.LBB2_1
# %bb.3:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$6, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%rbx), %rsi
	movq	8(%rbx), %rdx
	movl	$_ZSt4cout, %edi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%rax, %r12
	movl	$.L.str.9, %esi
	movl	$7, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	12(%r14), %esi
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertImEERSoT_
	movq	%rax, %r12
	movl	$.L.str.10, %esi
	movl	$3, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	16(%r14), %esi
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertImEERSoT_
	movl	$.L.str.7, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$3, 20(%r14)
	movl	16(%r14), %esi
	imull	12(%r14), %esi
	shll	$2, %esi
	movq	%r15, %rdi
	callq	_ZNSt6vectorIhSaIhEE6resizeEm
	movq	(%r15), %rdx
	movq	%r14, %rdi
	xorl	%esi, %esi
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	callq	png_image_finish_read
	testl	%eax, %eax
	je	.LBB2_4
# %bb.5:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB2_1:
	.cfi_def_cfa_offset 48
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.6, %esi
	jmp	.LBB2_2
.LBB2_4:
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.11, %esi
.LBB2_2:
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	_ZStlsIcSt11char_traitsIcESaIcEERSt13basic_ostreamIT_T0_ES7_RKNSt7__cxx1112basic_stringIS4_S5_T1_EE
	movl	$.L.str.7, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$1, %edi
	callq	exit
.Lfunc_end2:
	.size	_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE, .Lfunc_end2-_ZL9loadImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
	.cfi_endproc
                                        # -- End function
	.type	_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE,@function # -- Begin function _ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE
_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE: # @_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE
	.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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r15
	movq	%rdi, %rbx
	movl	12(%rdi), %esi
	movl	20(%rdi), %eax
	xorl	%ebp, %ebp
	btl	$2, %eax
	movl	$1, %r12d
	movl	$0, %ecx
	adcl	%r12d, %ecx
	movl	%eax, %edx
	andl	$3, %edx
	incl	%edx
	testb	$8, %al
	cmovnel	%r12d, %ecx
	cmovnel	%r12d, %edx
	imull	16(%rdi), %esi
	imull	%edx, %esi
	imull	%ecx, %esi
	leaq	8(%rsp), %r14
	movq	%r14, %rdi
	callq	hipMalloc
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$189, %edx
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
	movq	(%r14), %rdi
	movq	(%r15), %rsi
	movl	12(%rbx), %edx
	movl	20(%rbx), %eax
	btl	$2, %eax
	adcl	%r12d, %ebp
	movl	%eax, %ecx
	andl	$3, %ecx
	incl	%ecx
	testb	$8, %al
	cmovnel	%r12d, %ebp
	cmovnel	%r12d, %ecx
	imull	16(%rbx), %edx
	imull	%ecx, %edx
	imull	%ebp, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$190, %edx
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
	movq	(%r14), %rax
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	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
.Lfunc_end3:
	.size	_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE, .Lfunc_end3-_ZL17copyImageToDeviceRK9png_imageRKSt6vectorIhSaIhEE
	.cfi_endproc
                                        # -- End function
	.section	.text._Z9gpuAssert10hipError_tPKcib,"axG",@progbits,_Z9gpuAssert10hipError_tPKcib,comdat
	.weak	_Z9gpuAssert10hipError_tPKcib   # -- Begin function _Z9gpuAssert10hipError_tPKcib
	.type	_Z9gpuAssert10hipError_tPKcib,@function
_Z9gpuAssert10hipError_tPKcib:          # @_Z9gpuAssert10hipError_tPKcib
	.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	%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
	testl	%edi, %edi
	je	.LBB4_8
# %bb.1:
	movl	%ecx, %ebp
	movl	%edx, %r14d
	movq	%rsi, %r15
	movl	%edi, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.13, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	%ebx, %edi
	callq	hipGetErrorString
	testq	%rax, %rax
	je	.LBB4_2
# %bb.3:
	movq	%rax, %r12
	movq	%rax, %rdi
	callq	strlen
	movl	$_ZSt4cerr, %edi
	movq	%r12, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB4_4
.LBB4_2:
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cerr(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB4_4:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.14, %esi
	movl	$4, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	testq	%r15, %r15
	je	.LBB4_5
# %bb.6:
	movq	%r15, %rdi
	callq	strlen
	movl	$_ZSt4cerr, %edi
	movq	%r15, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB4_7
.LBB4_5:
	movq	_ZSt4cerr(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cerr(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB4_7:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit6
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.15, %esi
	movl	$1, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cerr, %edi
	movl	%r14d, %esi
	callq	_ZNSolsEi
	movl	$.L.str.7, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	testb	%bpl, %bpl
	jne	.LBB4_9
.LBB4_8:
	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
.LBB4_9:
	.cfi_def_cfa_offset 48
	movl	%ebx, %edi
	callq	exit
.Lfunc_end4:
	.size	_Z9gpuAssert10hipError_tPKcib, .Lfunc_end4-_Z9gpuAssert10hipError_tPKcib
	.cfi_endproc
                                        # -- End function
	.text
	.type	_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_,@function # -- Begin function _ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_
_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_: # @_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r8, %rbx
	movq	%rcx, 16(%rsp)                  # 8-byte Spill
	movq	%rdx, 8(%rsp)                   # 8-byte Spill
	movq	%rdi, %r14
	movl	12(%rdi), %r12d
	movl	16(%rdi), %ebp
	imulq	$138547333, %r12, %rax          # imm = 0x8421085
	shrq	$32, %rax
	imull	$-1108378657, %r12d, %ecx       # imm = 0xBDEF7BDF
	subl	%eax, %r12d
	shrl	%r12d
	addl	%eax, %r12d
	shrl	$4, %r12d
	movl	$138547333, %eax                # imm = 0x8421085
	cmpl	%eax, %ecx
	sbbl	$-1, %r12d
	imulq	$138547333, %rbp, %rcx          # imm = 0x8421085
	shrq	$32, %rcx
	imull	$-1108378657, %ebp, %edx        # imm = 0xBDEF7BDF
	subl	%ecx, %ebp
	shrl	%ebp
	addl	%ecx, %ebp
	shrl	$4, %ebp
	cmpl	%eax, %edx
	sbbl	$-1, %ebp
	movq	%rsi, %r13
	movq	%rbp, %r15
	shlq	$32, %r15
	orq	%r12, %r15
	movl	$_ZSt4cout, %edi
	movl	$.L.str.16, %esi
	movl	$11, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movq	%r12, %rsi
	callq	_ZNSo9_M_insertImEERSoT_
	movq	%rax, %r12
	movl	$.L.str.10, %esi
	movl	$3, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%r12, %rdi
	movq	%rbp, %rsi
	callq	_ZNSo9_M_insertImEERSoT_
	movq	%rax, %r12
	movl	$.L.str.10, %esi
	movl	$3, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$1, %esi
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertImEERSoT_
	movl	$.L.str.7, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.17, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$31, %esi
	callq	_ZNSo9_M_insertImEERSoT_
	movq	%rax, %r12
	movl	$.L.str.10, %esi
	movl	$3, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$31, %esi
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertImEERSoT_
	movq	%rax, %r12
	movl	$.L.str.10, %esi
	movl	$3, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$1, %esi
	movq	%r12, %rdi
	callq	_ZNSo9_M_insertImEERSoT_
	movl	$.L.str.7, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	xorl	%r12d, %r12d
	movabsq	$133143986207, %rdx             # imm = 0x1F0000001F
	movl	$1, %ebp
	movl	$4392, %r8d                     # imm = 0x1128
	movq	%r15, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_2
# %bb.1:
	movl	12(%r14), %esi
	movl	16(%r14), %edx
	movq	8(%rsp), %rdi                   # 8-byte Reload
	movq	16(%rsp), %rcx                  # 8-byte Reload
	movl	$3, %r8d
	movq	%rbx, %r9
	callq	_Z26__device_stub__convolutionPK5pixeliiPKfiPS_
.LBB5_2:
	callq	hipGetLastError
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$207, %edx
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
	callq	hipDeviceSynchronize
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$208, %edx
	movl	$1, %ecx
	callq	_Z9gpuAssert10hipError_tPKcib
	movq	(%r13), %rdi
	movl	12(%r14), %edx
	movl	20(%r14), %eax
	btl	$2, %eax
	adcl	%ebp, %r12d
	movl	%eax, %ecx
	andl	$3, %ecx
	incl	%ecx
	testb	$8, %al
	cmovnel	%ebp, %r12d
	cmovnel	%ebp, %ecx
	imull	16(%r14), %edx
	imull	%ecx, %edx
	imull	%r12d, %edx
	movq	%rbx, %rsi
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$210, %edx
	movl	$1, %ecx
	addq	$24, %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	_Z9gpuAssert10hipError_tPKcib   # TAILCALL
.Lfunc_end5:
	.size	_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_, .Lfunc_end5-_ZL20runConvolutionKernelRK9png_imageRSt6vectorIhSaIhEEPhPKfiS6_
	.cfi_endproc
                                        # -- End function
	.type	_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE,@function # -- Begin function _ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE: # @_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rsi, %rax
	movq	%rdi, %rbx
	movq	(%rdi), %rsi
	movq	(%rdx), %rcx
	movq	%rax, %rdi
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	png_image_write_to_file
	testl	%eax, %eax
	je	.LBB6_2
# %bb.1:
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB6_2:
	.cfi_def_cfa_offset 16
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.18, %esi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	movq	%rbx, %rsi
	callq	_ZStlsIcSt11char_traitsIcESaIcEERSt13basic_ostreamIT_T0_ES7_RKNSt7__cxx1112basic_stringIS4_S5_T1_EE
	movl	$.L.str.7, %esi
	movq	%rax, %rdi
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movl	$1, %edi
	callq	exit
.Lfunc_end6:
	.size	_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE, .Lfunc_end6-_ZL9saveImageRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEER9png_imageRSt6vectorIhSaIhEE
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt6vectorIhSaIhEE6resizeEm,"axG",@progbits,_ZNSt6vectorIhSaIhEE6resizeEm,comdat
	.weak	_ZNSt6vectorIhSaIhEE6resizeEm   # -- Begin function _ZNSt6vectorIhSaIhEE6resizeEm
	.p2align	1, 0x90
	.type	_ZNSt6vectorIhSaIhEE6resizeEm,@function
_ZNSt6vectorIhSaIhEE6resizeEm:          # @_ZNSt6vectorIhSaIhEE6resizeEm
	.cfi_startproc
# %bb.0:
	movq	(%rdi), %rcx
	movq	8(%rdi), %rdx
	movq	%rdx, %r8
	subq	%rcx, %r8
	movq	%rsi, %rax
	subq	%r8, %rax
	jbe	.LBB7_1
# %bb.5:
	movq	%rax, %rsi
	jmp	_ZNSt6vectorIhSaIhEE17_M_default_appendEm # TAILCALL
.LBB7_1:
	jae	.LBB7_4
# %bb.2:
	addq	%rsi, %rcx
	cmpq	%rcx, %rdx
	je	.LBB7_4
# %bb.3:
	movq	%rcx, 8(%rdi)
.LBB7_4:                                # %_ZNSt6vectorIhSaIhEE15_M_erase_at_endEPh.exit
	retq
.Lfunc_end7:
	.size	_ZNSt6vectorIhSaIhEE6resizeEm, .Lfunc_end7-_ZNSt6vectorIhSaIhEE6resizeEm
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt6vectorIhSaIhEE17_M_default_appendEm,"axG",@progbits,_ZNSt6vectorIhSaIhEE17_M_default_appendEm,comdat
	.weak	_ZNSt6vectorIhSaIhEE17_M_default_appendEm # -- Begin function _ZNSt6vectorIhSaIhEE17_M_default_appendEm
	.p2align	1, 0x90
	.type	_ZNSt6vectorIhSaIhEE17_M_default_appendEm,@function
_ZNSt6vectorIhSaIhEE17_M_default_appendEm: # @_ZNSt6vectorIhSaIhEE17_M_default_appendEm
	.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	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	testq	%rsi, %rsi
	je	.LBB8_13
# %bb.1:
	movq	%rsi, %r14
	movq	%rdi, %rbx
	movq	8(%rdi), %r15
	movq	16(%rdi), %rax
	subq	%r15, %rax
	cmpq	%rsi, %rax
	jae	.LBB8_2
# %bb.5:
	movq	(%rbx), %rax
	movq	%r15, %r13
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	subq	%rax, %r13
	movabsq	$9223372036854775807, %rax      # imm = 0x7FFFFFFFFFFFFFFF
	movq	%r13, %rcx
	xorq	%rax, %rcx
	cmpq	%r14, %rcx
	jb	.LBB8_14
# %bb.6:                                # %_ZNKSt6vectorIhSaIhEE12_M_check_lenEmPKc.exit
	cmpq	%r14, %r13
	movq	%r14, %r12
	cmovaq	%r13, %r12
	addq	%r13, %r12
	cmpq	%rax, %r12
	cmovaeq	%rax, %r12
	movq	%r12, %rdi
	callq	_Znwm
	movq	%rax, %rbp
	leaq	(%rax,%r13), %rcx
	movb	$0, (%rax,%r13)
	movq	%r14, %rdx
	decq	%rdx
	movq	%rcx, 8(%rsp)                   # 8-byte Spill
	je	.LBB8_8
# %bb.7:
	leaq	1(%rcx), %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movq	8(%rsp), %rcx                   # 8-byte Reload
.LBB8_8:                                # %_ZSt27__uninitialized_default_n_aIPhmhET_S1_T0_RSaIT1_E.exit31
	movq	16(%rsp), %rax                  # 8-byte Reload
	cmpq	%rax, %r15
	movq	%rax, %r15
	je	.LBB8_10
# %bb.9:
	movq	%rbp, %rdi
	movq	%r15, %rsi
	movq	%r13, %rdx
	callq	memmove@PLT
	movq	8(%rsp), %rcx                   # 8-byte Reload
.LBB8_10:                               # %_ZNSt6vectorIhSaIhEE11_S_relocateEPhS2_S2_RS0_.exit
	testq	%r15, %r15
	je	.LBB8_12
# %bb.11:
	movq	%r15, %rdi
	callq	_ZdlPv
	movq	8(%rsp), %rcx                   # 8-byte Reload
.LBB8_12:                               # %_ZNSt12_Vector_baseIhSaIhEE13_M_deallocateEPhm.exit34
	movq	%rbp, (%rbx)
	addq	%r14, %rcx
	movq	%rcx, 8(%rbx)
	addq	%r12, %rbp
	movq	%rbp, 16(%rbx)
	jmp	.LBB8_13
.LBB8_2:
	movb	$0, (%r15)
	leaq	1(%r15), %rdi
	movq	%r14, %rdx
	decq	%rdx
	je	.LBB8_4
# %bb.3:
	addq	%r14, %r15
	xorl	%esi, %esi
	callq	memset@PLT
	movq	%r15, %rdi
.LBB8_4:                                # %_ZSt27__uninitialized_default_n_aIPhmhET_S1_T0_RSaIT1_E.exit
	movq	%rdi, 8(%rbx)
.LBB8_13:
	addq	$24, %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
.LBB8_14:
	.cfi_def_cfa_offset 80
	movl	$.L.str.12, %edi
	callq	_ZSt20__throw_length_errorPKc
.Lfunc_end8:
	.size	_ZNSt6vectorIhSaIhEE17_M_default_appendEm, .Lfunc_end8-_ZNSt6vectorIhSaIhEE17_M_default_appendEm
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.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 %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %rbx
	subq	%rsi, %r14
	movq	%r14, (%rsp)
	cmpq	$15, %r14
	jbe	.LBB9_1
# %bb.2:
	movq	%rsp, %r12
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm
	movq	%rax, (%rbx)
	movq	(%r12), %rcx
	movq	%rcx, 16(%rbx)
	jmp	.LBB9_3
.LBB9_1:                                # %._crit_edge
	movq	(%rbx), %rax
.LBB9_3:
	testq	%r14, %r14
	je	.LBB9_7
# %bb.4:
	cmpq	$1, %r14
	jne	.LBB9_6
# %bb.5:
	movb	(%r15), %cl
	movb	%cl, (%rax)
	jmp	.LBB9_7
.LBB9_6:
	movq	%rax, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
.LBB9_7:                                # %_ZZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tagEN6_GuardD2Ev.exit
	movq	(%rsp), %rax
	movq	%rax, 8(%rbx)
	movq	(%rbx), %rcx
	movb	$0, (%rcx,%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end9:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag, .Lfunc_end9-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB10_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB10_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11convolutionPK5pixeliiPKfiPS_, %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_end10:
	.size	__hip_module_ctor, .Lfunc_end10-__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	.LBB11_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
.LBB11_2:
	retq
.Lfunc_end11:
	.size	__hip_module_dtor, .Lfunc_end11-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z11convolutionPK5pixeliiPKfiPS_,@object # @_Z11convolutionPK5pixeliiPKfiPS_
	.section	.rodata,"a",@progbits
	.globl	_Z11convolutionPK5pixeliiPKfiPS_
	.p2align	3, 0x0
_Z11convolutionPK5pixeliiPKfiPS_:
	.quad	_Z26__device_stub__convolutionPK5pixeliiPKfiPS_
	.size	_Z11convolutionPK5pixeliiPKfiPS_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"."
	.size	.L.str, 2

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"/checkerboard.png"
	.size	.L.str.1, 18

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/NVIDIA/nsight-training/master/cuda/2021_gtc/x-ac-04-v1/task1/task/sanitizer/code/convolution.hip"
	.size	.L.str.2, 159

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"/icon.png"
	.size	.L.str.3, 10

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"/checkerboard-out.png"
	.size	.L.str.4, 22

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"/icon-out.png"
	.size	.L.str.5, 14

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Failed to open image"
	.size	.L.str.6, 21

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

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Image "
	.size	.L.str.8, 7

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

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	" * "
	.size	.L.str.10, 4

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"Failed to read image "
	.size	.L.str.11, 22

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"vector::_M_default_append"
	.size	.L.str.12, 26

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"GPU error: "
	.size	.L.str.13, 12

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

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

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Grid size: "
	.size	.L.str.16, 12

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Block size: "
	.size	.L.str.17, 13

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Failed to save image "
	.size	.L.str.18, 22

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z11convolutionPK5pixeliiPKfiPS_"
	.size	.L__unnamed_1, 33

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z26__device_stub__convolutionPK5pixeliiPKfiPS_
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z11convolutionPK5pixeliiPKfiPS_
	.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	_Z11convolutionPK5pixeliiPKfiPS_ ; -- Begin function _Z11convolutionPK5pixeliiPKfiPS_
	.globl	_Z11convolutionPK5pixeliiPKfiPS_
	.p2align	8
	.type	_Z11convolutionPK5pixeliiPKfiPS_,@function
_Z11convolutionPK5pixeliiPKfiPS_:       ; @_Z11convolutionPK5pixeliiPKfiPS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x18
	s_load_b32 s2, s[0:1], 0x34
	v_and_b32_e32 v3, 0x3ff, v0
	v_bfe_u32 v4, v0, 10, 10
	s_mov_b32 s4, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_max_u32_e32 v0, v3, v4
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_u32_e64 s3, v0
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b64 s[6:7], s[0:1], 0x10
	v_mad_u64_u32 v[0:1], null, v4, s3, v[3:4]
	v_mov_b32_e32 v1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[1:2], 2, v[0:1]
	v_lshl_add_u32 v0, v0, 2, 0
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v1, vcc_lo, s6, v1
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v2, vcc_lo, s7, v2, vcc_lo
	global_load_b32 v1, v[1:2], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v0, v1
.LBB0_2:
	s_or_b32 exec_lo, exec_lo, s4
	s_load_b128 s[4:7], s[0:1], 0x0
	s_lshr_b32 s13, s2, 16
	s_mul_i32 s9, s3, s3
	v_mad_u64_u32 v[0:1], null, s15, s13, v[4:5]
	s_and_b32 s15, s2, 0xffff
	s_lshr_b32 s2, s3, 31
	v_mad_u64_u32 v[1:2], null, s14, s15, v[3:4]
	s_add_i32 s2, s3, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_ashr_i32 s8, s2, 1
	s_and_b32 s10, s2, -2
	s_lshl_b32 s2, s9, 2
	s_add_i32 s10, s10, 31
	s_add_i32 s11, s2, 0
	s_waitcnt lgkmcnt(0)
	s_add_i32 s12, s7, -1
	s_add_i32 s14, s6, -1
	v_min_i32_e32 v6, s12, v0
	v_min_i32_e32 v5, s14, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v9, v6, s6
	v_sub_nc_u32_e32 v7, v5, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v8, 31, v7
	v_lshlrev_b64 v[7:8], 2, v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v7, vcc_lo, s4, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s5, v8, vcc_lo
	v_cmp_gt_u32_e32 vcc_lo, s8, v3
	global_load_b32 v2, v[7:8], off
	v_add_nc_u32_e32 v7, s8, v4
	v_add_nc_u32_e32 v8, s8, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v10, s10, v7
	v_lshl_add_u32 v8, v8, 2, s11
	s_delay_alu instid0(VALU_DEP_1)
	v_lshl_add_u32 v11, v10, 2, v8
	s_waitcnt vmcnt(0)
	ds_store_b32 v11, v2
	s_and_saveexec_b32 s16, vcc_lo
	s_cbranch_execz .LBB0_5
; %bb.3:
	v_subrev_nc_u32_e32 v2, s8, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_max_i32_e32 v2, 0, v2
	v_add_nc_u32_e32 v11, v2, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v12, 31, v11
	v_lshlrev_b64 v[11:12], 2, v[11:12]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v11, s2, s4, v11
	v_add_co_ci_u32_e64 v12, s2, s5, v12, s2
	v_cmp_gt_u32_e64 s2, s8, v4
	global_load_b32 v12, v[11:12], off
	v_lshl_add_u32 v11, v3, 2, s11
	s_delay_alu instid0(VALU_DEP_1)
	v_lshl_add_u32 v13, v10, 2, v11
	s_waitcnt vmcnt(0)
	ds_store_b32 v13, v12
	s_and_b32 exec_lo, exec_lo, s2
	s_cbranch_execz .LBB0_5
; %bb.4:
	v_subrev_nc_u32_e32 v12, s8, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_max_i32_e32 v14, 0, v12
	v_mad_u64_u32 v[12:13], null, v14, s6, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v13, 31, v12
	v_lshlrev_b64 v[12:13], 2, v[12:13]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v12, s2, s4, v12
	v_add_co_ci_u32_e64 v13, s2, s5, v13, s2
	global_load_b32 v2, v[12:13], off
	v_mul_lo_u32 v12, s10, v4
	s_delay_alu instid0(VALU_DEP_1)
	v_lshl_add_u32 v11, v12, 2, v11
	s_waitcnt vmcnt(0)
	ds_store_b32 v11, v2
.LBB0_5:
	s_or_b32 exec_lo, exec_lo, s16
	v_cmp_le_u32_e64 s2, s8, v4
                                        ; implicit-def: $sgpr17
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_saveexec_b32 s16, s2
	s_xor_b32 s2, exec_lo, s16
; %bb.6:                                ; %._crit_edge222
	s_sub_i32 s17, s15, s8
; %bb.7:                                ; %Flow265
	s_or_saveexec_b32 s16, s2
	v_mov_b32_e32 v2, s17
	s_xor_b32 exec_lo, exec_lo, s16
	s_cbranch_execz .LBB0_11
; %bb.8:
	v_subrev_nc_u32_e32 v2, s8, v6
	s_sub_i32 s15, s15, s8
	s_mov_b32 s17, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_max_i32_e32 v2, 0, v2
	v_mul_lo_u32 v2, v2, s6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v11, v2, v5
	v_ashrrev_i32_e32 v12, 31, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[11:12], 2, v[11:12]
	v_add_co_u32 v11, s2, s4, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v12, s2, s5, v12, s2
	global_load_b32 v12, v[11:12], off
	v_mul_lo_u32 v11, s10, v4
	v_lshl_add_u32 v13, v11, 2, v8
	s_waitcnt vmcnt(0)
	ds_store_b32 v13, v12
	v_cmpx_le_u32_e64 s15, v3
	s_cbranch_execz .LBB0_10
; %bb.9:
	v_add_nc_u32_e32 v12, s8, v5
	v_lshlrev_b32_e32 v11, 2, v11
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_min_i32_e32 v12, s6, v12
	v_add_nc_u32_e32 v12, v2, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v13, 31, v12
	v_lshlrev_b64 v[12:13], 2, v[12:13]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v12, s2, s4, v12
	v_add_co_ci_u32_e64 v13, s2, s5, v13, s2
	s_lshl_b32 s2, s8, 2
	s_delay_alu instid0(SALU_CYCLE_1)
	v_add3_u32 v11, v8, s2, v11
	global_load_b32 v2, v[12:13], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v11, v2
.LBB0_10:                               ; %Flow264
	s_or_b32 exec_lo, exec_lo, s17
	v_mov_b32_e32 v2, s15
.LBB0_11:
	s_or_b32 exec_lo, exec_lo, s16
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_mov_b32 s15, exec_lo
                                        ; implicit-def: $sgpr16
	v_cmpx_ge_u32_e64 v3, v2
	s_xor_b32 s15, exec_lo, s15
	s_cbranch_execz .LBB0_15
; %bb.12:
	v_add_nc_u32_e32 v2, s8, v5
	s_sub_i32 s16, s13, s8
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_min_i32_e32 v2, s14, v2
	s_mov_b32 s14, exec_lo
	v_add_nc_u32_e32 v11, v2, v9
	v_lshl_add_u32 v9, s8, 2, v8
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v12, 31, v11
	v_lshl_add_u32 v10, v10, 2, v9
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[11:12], 2, v[11:12]
	v_add_co_u32 v11, s2, s4, v11
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v12, s2, s5, v12, s2
	global_load_b32 v11, v[11:12], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v10, v11
	v_cmpx_le_u32_e64 s16, v4
	s_cbranch_execz .LBB0_14
; %bb.13:
	v_add_nc_u32_e32 v10, s8, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_min_i32_e32 v12, s12, v10
	v_mad_u64_u32 v[10:11], null, v12, s6, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v11, 31, v10
	v_lshlrev_b64 v[10:11], 2, v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v10, s2, s4, v10
	v_add_co_ci_u32_e64 v11, s2, s5, v11, s2
	global_load_b32 v2, v[10:11], off
	v_add_nc_u32_e32 v10, s8, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v10, v10, s10
	v_lshl_add_u32 v9, v10, 2, v9
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v2
.LBB0_14:                               ; %Flow262
	s_or_b32 exec_lo, exec_lo, s14
.LBB0_15:                               ; %Flow263
	s_or_saveexec_b32 s2, s15
	v_mov_b32_e32 v2, s16
	s_xor_b32 exec_lo, exec_lo, s2
; %bb.16:                               ; %._crit_edge221
	s_sub_i32 s13, s13, s8
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mov_b32_e32 v2, s13
; %bb.17:
	s_or_b32 exec_lo, exec_lo, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_mov_b32 s13, exec_lo
	v_cmpx_ge_u32_e64 v4, v2
	s_cbranch_execz .LBB0_20
; %bb.18:
	v_add_nc_u32_e32 v2, s8, v6
	v_add_nc_u32_e32 v6, s8, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_min_i32_e32 v2, s12, v2
	v_mul_lo_u32 v6, v6, s10
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v2, v2, s6
	v_lshl_add_u32 v7, v6, 2, v8
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v9, v2, v5
	v_ashrrev_i32_e32 v10, 31, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[9:10], 2, v[9:10]
	v_add_co_u32 v9, s2, s4, v9
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v10, s2, s5, v10, s2
	global_load_b32 v9, v[9:10], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v7, v9
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB0_20
; %bb.19:
	v_subrev_nc_u32_e32 v5, s8, v5
	v_lshlrev_b32_e32 v6, 2, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_max_i32_e32 v5, 0, v5
	v_add_nc_u32_e32 v7, v2, v5
	v_lshlrev_b32_e32 v5, 2, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v8, 31, v7
	v_add3_u32 v5, s11, v5, v6
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[7:8], 2, v[7:8]
	v_add_co_u32 v7, vcc_lo, s4, v7
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v8, vcc_lo, s5, v8, vcc_lo
	global_load_b32 v2, v[7:8], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v5, v2
.LBB0_20:
	s_or_b32 exec_lo, exec_lo, s13
	v_cmp_ge_i32_e32 vcc_lo, s6, v1
	v_cmp_gt_i32_e64 s2, s7, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s4, s2
	s_cbranch_execz .LBB0_28
; %bb.21:                               ; %.preheader203
	v_mov_b32_e32 v5, 0
	v_mov_b32_e32 v6, 0
	s_cmp_lt_i32 s3, 1
	s_delay_alu instid0(VALU_DEP_1)
	v_dual_mov_b32 v10, v6 :: v_dual_mov_b32 v9, v5
	v_dual_mov_b32 v8, v6 :: v_dual_mov_b32 v7, v5
	s_cbranch_scc1 .LBB0_27
; %bb.22:                               ; %.preheader.preheader
	v_mul_lo_u32 v2, v4, s10
	v_lshlrev_b32_e32 v4, 2, v3
	s_lshl_b32 s5, s8, 3
	s_lshl_b32 s2, s3, 2
	s_mov_b32 s4, 0
	s_addk_i32 s5, 0x7c
	s_mov_b32 s7, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_mov_b32 v3, 0 :: v_dual_lshlrev_b32 v2, 2, v2
	v_lshl_add_u32 v5, s9, 2, v2
	v_mov_b32_e32 v2, 0
	s_delay_alu instid0(VALU_DEP_2)
	v_add3_u32 v5, v5, v4, 0
	v_mov_b32_e32 v4, 0
.LBB0_23:                               ; %.preheader
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_24 Depth 2
	s_delay_alu instid0(VALU_DEP_2)
	v_mov_b32_e32 v6, v5
	s_mov_b32 s8, s4
	s_mov_b32 s9, s3
.LBB0_24:                               ;   Parent Loop BB0_23 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	v_mov_b32_e32 v7, s8
	s_add_i32 s9, s9, -1
	s_add_i32 s8, s8, 4
	s_cmp_eq_u32 s9, 0
	ds_load_b32 v8, v6
	ds_load_b32 v7, v7
	v_add_nc_u32_e32 v6, 4, v6
	s_waitcnt lgkmcnt(1)
	v_cvt_f32_ubyte0_e32 v9, v8
	v_cvt_f32_ubyte1_e32 v10, v8
	v_cvt_f32_ubyte2_e32 v8, v8
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fmac_f32_e32 v2, v7, v9
	v_fmac_f32_e32 v3, v7, v10
	s_delay_alu instid0(VALU_DEP_3)
	v_fmac_f32_e32 v4, v7, v8
	s_cbranch_scc0 .LBB0_24
; %bb.25:                               ; %._crit_edge
                                        ;   in Loop: Header=BB0_23 Depth=1
	v_add_nc_u32_e32 v5, s5, v5
	s_add_i32 s7, s7, 1
	s_add_i32 s4, s4, s2
	s_cmp_eq_u32 s7, s3
	s_cbranch_scc0 .LBB0_23
; %bb.26:                               ; %._crit_edge214.loopexit
	v_cvt_f64_f32_e32 v[5:6], v2
	v_cvt_f64_f32_e32 v[9:10], v3
	v_cvt_f64_f32_e32 v[7:8], v4
.LBB0_27:                               ; %._crit_edge214
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_max_f64 v[2:3], v[9:10], v[9:10]
	v_max_f64 v[4:5], v[5:6], v[5:6]
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_max_f64 v[6:7], v[7:8], v[7:8]
	s_load_b64 s[0:1], s[0:1], 0x20
	v_min_f64 v[2:3], 0x406fe000, v[2:3]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_min_f64 v[4:5], 0x406fe000, v[4:5]
	v_min_f64 v[6:7], 0x406fe000, v[6:7]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_max_f64 v[2:3], v[2:3], 0
	v_max_f64 v[4:5], v[4:5], 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_max_f64 v[6:7], v[6:7], 0
	v_cvt_f32_f64_e32 v8, v[2:3]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cvt_f32_f64_e32 v4, v[4:5]
	v_cvt_f32_f64_e32 v5, v[6:7]
	v_mad_u64_u32 v[2:3], null, v0, s6, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	v_ashrrev_i32_e32 v3, 31, v2
	v_cvt_i32_f32_e32 v0, v8
	v_cvt_i32_f32_e32 v1, v4
	v_cvt_i32_f32_e32 v4, v5
	v_lshlrev_b16 v0, 8, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_or_b32_e32 v4, 0xffffff00, v4
	v_or_b32_e32 v5, v1, v0
	v_lshlrev_b64 v[0:1], 2, v[2:3]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b32_e32 v3, 16, v4
	v_and_b32_e32 v2, 0xffff, v5
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v0, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_or_b32_e32 v2, v2, v3
	global_store_b32 v[0:1], v2, off
.LBB0_28:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11convolutionPK5pixeliiPKfiPS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 15
		.amdhsa_next_free_sgpr 18
		.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	_Z11convolutionPK5pixeliiPKfiPS_, .Lfunc_end0-_Z11convolutionPK5pixeliiPKfiPS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1844
; NumSgprs: 20
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 20
; NumVGPRsForWavesPerEU: 15
; 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
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .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
      - .offset:         160
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11convolutionPK5pixeliiPKfiPS_
    .private_segment_fixed_size: 0
    .sgpr_count:     20
    .sgpr_spill_count: 0
    .symbol:         _Z11convolutionPK5pixeliiPKfiPS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
