#include "imageprocessing.cuh"
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <assert.h>
#include <sstream>
#include <cuda_runtime.h>

// TODO: read about the CUDA programming model: https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#programming-model
// If everything is setup correctly, this file is compiled by the CUDA/C++ compiler (that is different from the C++ compiler).
// The CUDA/C++ compiler understands certain things that your C++ compiler doesn't understand - like '__global__', 'threadIdx', and function calls with triple-angle brackets, e.g., testArray<<<...>>>();
#define RIDX(X, Y, H, W) (X*W+Y)
#define GIDX(X, Y, H, W) ((H+X)*W+Y)
#define BIDX(X, Y, H, W) ((H*2+X)*W+Y)

#define KERNEL_SIZE 9
__constant__ float KERNEL[KERNEL_SIZE*KERNEL_SIZE];     // define a constant memory

__global__
void _brighten(unsigned char *out_image, unsigned char *in_image, float brightnessfactor, int height, int width) {
    // name the output before input as CUDA style
    int pos_x = threadIdx.x + blockIdx.x * blockDim.x;
    int pos_y = threadIdx.y + blockIdx.y * blockDim.y;
    if (pos_x >= width || pos_y >= height) return;

    // images are stacked horizontally
    int pos_r = pos_x * width + pos_y;  // get the position of r channel
    int pos_g = (height + pos_x) * width + pos_y;  // get the position of r channel
    int pos_b = (height * 2 + pos_x) * width + pos_y;  // get the position of r channel

    float val_r, val_g, val_b;
    // change brightness
    val_r = in_image[pos_r] * brightnessfactor;
    val_g = in_image[pos_g] * brightnessfactor;
    val_b = in_image[pos_b] * brightnessfactor;


    // check legality, assume it is 8 bit image
    if (val_r > 255)
        val_r = 255;
    if (val_g > 255)
        val_g = 255;
    if (val_b > 255)
        val_b = 255;

    out_image[pos_r] = val_r;
    out_image[pos_g] = val_g;
    out_image[pos_b] = val_b;
}

__global__
void _contrast(unsigned char *out_image, unsigned char *in_image, float contrastfactor, int height, int width) {
    int pos_x = threadIdx.x + blockIdx.x * blockDim.x;
    int pos_y = threadIdx.y + blockIdx.y * blockDim.y;
    if (pos_x >= width || pos_y >= height) return;

    // images are stacked horizontally
    int pos_r = pos_x * width + pos_y;  // get the position of r channel
    int pos_g = (height + pos_x) * width + pos_y;  // get the position of r channel
    int pos_b = (height * 2 + pos_x) * width + pos_y;  // get the position of r channel

    float val_r, val_g, val_b;
    val_r = in_image[pos_r] * contrastfactor + (1 - contrastfactor) * 255;
    val_g = in_image[pos_g] * contrastfactor + (1 - contrastfactor) * 255;
    val_b = in_image[pos_b] * contrastfactor + (1 - contrastfactor) * 255;


    // check legality, assume it is 8 bit image
    if (val_r > 255)
        val_r = 255;
    if (val_g > 255)
        val_g = 255;
    if (val_b > 255)
        val_b = 255;

    out_image[pos_r] = val_r;
    out_image[pos_g] = val_g;
    out_image[pos_b] = val_b;
}

__global__ void
_saturation(unsigned char *out_image, unsigned char *in_image, float saturationfactor, int height, int width) {
    int pos_x = threadIdx.x + blockIdx.x * blockDim.x;
    int pos_y = threadIdx.y + blockIdx.y * blockDim.y;
    if (pos_x >= width || pos_y >= height) return;

    // images are stacked horizontally
    int pos_r = pos_x * width + pos_y;  // get the position of r channel
    int pos_g = (height + pos_x) * width + pos_y;  // get the position of r channel
    int pos_b = (height * 2 + pos_x) * width + pos_y;  // get the position of r channel

    // intensity
    // lumCoeff: 0.2125, 0.7154, 0.0721
    float intensity = (0.2125 * in_image[pos_r] + 0.7154 * in_image[pos_g] + 0.0721 * in_image[pos_b]);

    float val_r, val_g, val_b;
    val_r = in_image[pos_r] * saturationfactor + (1 - saturationfactor) * intensity;
    val_g = in_image[pos_g] * saturationfactor + (1 - saturationfactor) * intensity;
    val_b = in_image[pos_b] * saturationfactor + (1 - saturationfactor) * intensity;

    // check legality, assume it is 8 bit image
    if (val_r > 255)
        val_r = 255;
    if (val_g > 255)
        val_g = 255;
    if (val_b > 255)
        val_b = 255;

    out_image[pos_r] = val_r;
    out_image[pos_g] = val_g;
    out_image[pos_b] = val_b;
}

__global__ void
_sharpen(unsigned char *out_image, unsigned char *in_image, float sharpenfactor, float *conv_kernel, int length,
         int height, int width) {
    int pos_x = threadIdx.x + blockIdx.x * blockDim.x;
    int pos_y = threadIdx.y + blockIdx.y * blockDim.y;
    if (pos_x >= width || pos_y >= height) return;
    int l = 2 * length + 1;

    float tmpr, tmpg, tmpb, originr, origing, originb;
    originr = ((float) in_image[RIDX(pos_x, pos_y, height, width)]) / 255.0f;
    origing = ((float) in_image[GIDX(pos_x, pos_y, height, width)]) / 255.0f;
    originb = ((float) in_image[BIDX(pos_x, pos_y, height, width)]) / 255.0f;
    tmpr = tmpg = tmpb = 0.0f;
    for (int i = (-length); i <= length; i++) {
        for (int j = (-length); j <= length; j++) {
            int convidx = (i + length) * l + j + length;
            if (pos_x + i < 0 || pos_x + i >= height || pos_y + j < 0 || pos_y + j >= width) {
                tmpr += conv_kernel[convidx] * originr;
                tmpg += conv_kernel[convidx] * origing;
                tmpb += conv_kernel[convidx] * originb;
            } else {
                tmpr += conv_kernel[convidx] * ((float) in_image[RIDX((pos_x + i), (pos_y + j), height, width)]) /
                        255.0f;
                tmpg += conv_kernel[convidx] * ((float) in_image[GIDX((pos_x + i), (pos_y + j), height, width)]) /
                        255.0f;
                tmpb += conv_kernel[convidx] * ((float) in_image[BIDX((pos_x + i), (pos_y + j), height, width)]) /
                        255.0f;
            }
        }
    }
    tmpr = (originr + sharpenfactor * tmpr)*255;
    tmpg = (origing + sharpenfactor * tmpg)*255;
    tmpb = (originb + sharpenfactor * tmpb)*255;

    // check legality, assume it is 8 bit image
    if (tmpr > 255)
        tmpr = 255;
    if (tmpg > 255)
        tmpg = 255;
    if (tmpb > 255)
        tmpb = 255;

    out_image[RIDX(pos_x, pos_y, height, width)] = tmpr;
    out_image[GIDX(pos_x, pos_y, height, width)] = tmpg;
    out_image[BIDX(pos_x, pos_y, height, width)] = tmpb;
}


__global__ void
_conv2d(unsigned char *out_image, unsigned char *in_image, float *conv_kernel, int length, int height, int width) {
    int pos_x = threadIdx.x + blockIdx.x * blockDim.x;
    int pos_y = threadIdx.y + blockIdx.y * blockDim.y;
    if (pos_x >= width || pos_y >= height) return;
    int l = 2 * length + 1;

    float tmpr, tmpg, tmpb, originr, origing, originb;
    originr = ((float) in_image[RIDX(pos_x, pos_y, height, width)]) / 255.0f;
    origing = ((float) in_image[GIDX(pos_x, pos_y, height, width)]) / 255.0f;
    originb = ((float) in_image[BIDX(pos_x, pos_y, height, width)]) / 255.0f;
    tmpr = tmpg = tmpb = 0.0f;
    for (int i = (-length); i <= length; i++) {
        for (int j = (-length); j <= length; j++) {
            int convidx = (i + length) * l + j + length;
            if (pos_x + i < 0 || pos_x + i >= height || pos_y + j < 0 || pos_y + j >= width) {
                tmpr += conv_kernel[convidx] * originr;
                tmpg += conv_kernel[convidx] * origing;
                tmpb += conv_kernel[convidx] * originb;
            } else {
                // min
                tmpr += conv_kernel[convidx] * ((float) in_image[RIDX((pos_x + i), (pos_y + j), height, width)]) /
                        255.0f;
                tmpg += conv_kernel[convidx] * ((float) in_image[GIDX((pos_x + i), (pos_y + j), height, width)]) /
                        255.0f;
                tmpb += conv_kernel[convidx] * ((float) in_image[BIDX((pos_x + i), (pos_y + j), height, width)]) /
                        255.0f;
            }
        }
    }
    tmpr = tmpr*255;
    tmpg = tmpg*255;
    tmpb = tmpb*255;
    // check legality, assume it is 8 bit image
    if (tmpr > 255)
        tmpr = 255;
    if (tmpg > 255)
        tmpg = 255;
    if (tmpb > 255)
        tmpb = 255;

    out_image[RIDX(pos_x, pos_y, height, width)] = tmpr;
    out_image[GIDX(pos_x, pos_y, height, width)] = tmpg;
    out_image[BIDX(pos_x, pos_y, height, width)] = tmpb;
}


__global__ void
_conv2d_constant_memory(unsigned char *out_image, unsigned char *in_image, int height, int width) {
    // since we are using constant memory, we remote the conv_kernel from the kernel function signature.
    int pos_x = threadIdx.x + blockIdx.x * blockDim.x;
    int pos_y = threadIdx.y + blockIdx.y * blockDim.y;
    if (pos_x >= width || pos_y >= height) return;

    int length = KERNEL_SIZE/2;
    int l = KERNEL_SIZE;

    float tmpr, tmpg, tmpb, originr, origing, originb;
    originr = ((float) in_image[RIDX(pos_x, pos_y, height, width)]) / 255.0f;
    origing = ((float) in_image[GIDX(pos_x, pos_y, height, width)]) / 255.0f;
    originb = ((float) in_image[BIDX(pos_x, pos_y, height, width)]) / 255.0f;
    tmpr = tmpg = tmpb = 0.0f;
    for (int i = (-length); i <= length; i++) {
        for (int j = (-length); j <= length; j++) {
            int convidx = (i + length) * l + j + length;
            if (pos_x + i < 0 || pos_x + i >= height || pos_y + j < 0 || pos_y + j >= width) {
                tmpr += KERNEL[convidx] * originr;
                tmpg += KERNEL[convidx] * origing;
                tmpb += KERNEL[convidx] * originb;
            } else {
                tmpr += KERNEL[convidx] * ((float) in_image[RIDX((pos_x + i), (pos_y + j), height, width)]) /
                        255.0f;
                tmpg += KERNEL[convidx] * ((float) in_image[GIDX((pos_x + i), (pos_y + j), height, width)]) /
                        255.0f;
                tmpb += KERNEL[convidx] * ((float) in_image[BIDX((pos_x + i), (pos_y + j), height, width)]) /
                        255.0f;
            }
        }
    }
    tmpr = tmpr*255;
    tmpg = tmpg*255;
    tmpb = tmpb*255;
    // check legality, assume it is 8 bit image
    if (tmpr > 255)
        tmpr = 255;
    if (tmpg > 255)
        tmpg = 255;
    if (tmpb > 255)
        tmpb = 255;

    out_image[RIDX(pos_x, pos_y, height, width)] = tmpr;
    out_image[GIDX(pos_x, pos_y, height, width)] = tmpg;
    out_image[BIDX(pos_x, pos_y, height, width)] = tmpb;

}

__global__ void
_conv2d_shared_mem(unsigned char *out_image, unsigned char *in_image, float *conv_kernel,
                   int length, int height, int width) {
    int pos_x = threadIdx.x + blockIdx.x * blockDim.x;
    int pos_y = threadIdx.y + blockIdx.y * blockDim.y;
    if (pos_x >= width || pos_y >= height) return;

    const int share_size=16;
    __shared__ float sdata[share_size * share_size * 3];
    __shared__ float sconv_kernel[share_size * share_size * 3];

    if (threadIdx.x * share_size + threadIdx.y < length * length * 3)
        sconv_kernel[threadIdx.x * share_size + threadIdx.y] = conv_kernel[threadIdx.x * share_size + threadIdx.y];

    sdata[threadIdx.x * share_size + threadIdx.y] = ((float) in_image[RIDX(pos_x, pos_y, height, width)]) / 255.0f;
    sdata[threadIdx.x * share_size + threadIdx.y + share_size * share_size] = ((float) in_image[GIDX(pos_x, pos_y, height, width)]) / 255.0f;
    sdata[threadIdx.x * share_size + threadIdx.y + share_size * share_size * 2] =
            ((float) in_image[BIDX(pos_x, pos_y, height, width)]) / 255.0f;
    __syncthreads(); // then other process will be free using the shared memory based on cache mechanism.

    int l = 2 * length + 1;
    float tmpr, tmpg, tmpb, originr, origing, originb;

    originr = sdata[threadIdx.x * share_size + threadIdx.y];
    origing = sdata[threadIdx.x * share_size + threadIdx.y + share_size * share_size];
    originb = sdata[threadIdx.x * share_size + threadIdx.y + share_size * share_size * 2];
    tmpr = tmpg = tmpb = 0.0f;


    for (int i = (-length); i <= length; i++) {
        for (int j = (-length); j <= length; j++) {
            int convidx = (i + length) * l + j + length;
            if (pos_x + i < 0 || pos_x + i >= height || pos_y + j < 0 || pos_y + j >= width) {
                tmpr += sconv_kernel[convidx] * originr;
                tmpg += sconv_kernel[convidx] * origing;
                tmpb += sconv_kernel[convidx] * originb;
            } else {
                int idx = (int) threadIdx.x;
                int idy = (int) threadIdx.y;
                if (idx + i < 0 || idx + i >= 16 || idy + j < 0 || idy + j >= 16) {
                    tmpr += sconv_kernel[convidx] * ((float) in_image[RIDX((pos_x + i), (pos_y + j), height, width)]) /
                            255.0f;
                    tmpg += sconv_kernel[convidx] * ((float) in_image[GIDX((pos_x + i), (pos_y + j), height, width)]) /
                            255.0f;
                    tmpb += sconv_kernel[convidx] * ((float) in_image[BIDX((pos_x + i), (pos_y + j), height, width)]) /
                            255.0f;
                } else {
                    tmpr += sconv_kernel[convidx] * sdata[(threadIdx.x + i) * 16 + threadIdx.y];
                    tmpg += sconv_kernel[convidx] * sdata[(threadIdx.x + i) * 16 + threadIdx.y + 16 * 16];
                    tmpb += sconv_kernel[convidx] * sdata[(threadIdx.x + i) * 16 + threadIdx.y + 16 * 16 * 2];
                }
            }
        }
    }
    if (tmpr >= 1.0f) tmpr = 1.0f;
    if (tmpg >= 1.0f) tmpg = 1.0f;
    if (tmpb >= 1.0f) tmpb = 1.0f;
    out_image[RIDX(pos_x, pos_y, height, width)] = (unsigned char) (tmpr * 255.0f);
    out_image[GIDX(pos_x, pos_y, height, width)] = (unsigned char) (tmpg * 255.0f);
    out_image[BIDX(pos_x, pos_y, height, width)] = (unsigned char) (tmpb * 255.0f);
}


void brighten_func(unsigned char *out_image, unsigned char *in_image,
                    float brightness_factor, int height, int width) {
    dim3 grid(1, 512);
    dim3 block(512, 1);
    int imgproduct = height * width;

    unsigned char *cuda_out, *cuda_in;
    cudaMalloc((void **) &cuda_in, imgproduct * 3 * sizeof(unsigned char));
    cudaMalloc((void **) &cuda_out, imgproduct * 3 * sizeof(unsigned char));

    // copy the original_image into cuda
    cudaMemcpy(cuda_in, in_image, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyHostToDevice);

    // cudaEvent
    cudaEvent_t start, stop;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    cudaEventRecord(start);

    _brighten <<< grid, block >>> (cuda_out, cuda_in, brightness_factor, height, width);

    cudaEventRecord(stop);
    cudaEventSynchronize(stop);

    // copy the output into the image array
    cudaMemcpy(out_image, cuda_out, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyDeviceToHost);
    cudaFree(cuda_out);
    cudaFree(cuda_in);

    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess)
        printf("Error: %s\n", cudaGetErrorString(err));

    float milliseconds = 0;
    cudaEventElapsedTime(&milliseconds, start, stop);
    printf("contrast takes time: %f ms \n", milliseconds);
}

void contrast_func(unsigned char *out_image, unsigned char *in_image,
                  float contrastfactor, int height, int width) {
    dim3 grid(1, 512);
    dim3 block(512, 1);
    int imgproduct = height * width;

    unsigned char *cuda_out, *cuda_in;
    cudaMalloc((void **) &cuda_in, imgproduct * 3 * sizeof(unsigned char));
    cudaMalloc((void **) &cuda_out, imgproduct * 3 * sizeof(unsigned char));

    // copy the original_image into cuda
    cudaMemcpy(cuda_in, in_image, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyHostToDevice);


    // cudaEvent
    cudaEvent_t start, stop;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    cudaEventRecord(start);

    _contrast <<< grid, block >>> (cuda_out, cuda_in, contrastfactor, height, width);

    cudaEventRecord(stop);
    cudaEventSynchronize(stop);

    // copy the output into the image array
    cudaMemcpy(out_image, cuda_out, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyDeviceToHost);
    cudaFree(cuda_out);
    cudaFree(cuda_in);

    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess)
        printf("Error: %s\n", cudaGetErrorString(err));

    float milliseconds = 0;
    cudaEventElapsedTime(&milliseconds, start, stop);
    printf("contrast takes time: %f ms \n", milliseconds);
}

void saturation_func(unsigned char *out_image, unsigned char *in_image,
                    float saturationfactor, int height, int width) {
    dim3 grid(1, 512);
    dim3 block(512, 1);
    int imgproduct = height * width;

    unsigned char *cuda_out, *cuda_in;
    cudaMalloc((void **) &cuda_in, imgproduct * 3 * sizeof(unsigned char));
    cudaMalloc((void **) &cuda_out, imgproduct * 3 * sizeof(unsigned char));

    // copy the original_image into cuda
    cudaMemcpy(cuda_in, in_image, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyHostToDevice);

    // cudaEvent
    cudaEvent_t start, stop;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    cudaEventRecord(start);

    _saturation <<< grid, block >>> (cuda_out, cuda_in, saturationfactor, height, width);

    cudaEventRecord(stop);
    cudaEventSynchronize(stop);

    // copy the output into the image array
    cudaMemcpy(out_image, cuda_out, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyDeviceToHost);
    cudaFree(cuda_out);
    cudaFree(cuda_in);


    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess)
        printf("Error: %s\n", cudaGetErrorString(err));

    float milliseconds = 0;
    cudaEventElapsedTime(&milliseconds, start, stop);
    printf("saturation takes time: %f ms \n", milliseconds);
}

void sharpen_func(unsigned char *out_image, unsigned char *in_image, float sharpenfactor,
                  float *conv_kernel, int length, int height, int width) {
    assert(length % 2 == 1);
    int halflen = length / 2;

    dim3 grid(1, 512);
    dim3 block(512, 1);
    int imgproduct = height * width;

    unsigned char *cuda_out, *cuda_in;
    float *cuda_conv_kernel;
    cudaMalloc((void **) &cuda_in, imgproduct * 3 * sizeof(unsigned char));
    cudaMalloc((void **) &cuda_out, imgproduct * 3 * sizeof(unsigned char));
    cudaMalloc((void **) &cuda_conv_kernel, length * length * sizeof(float));

    // copy the original_image into cuda
    cudaMemcpy(cuda_in, in_image, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyHostToDevice);
    cudaMemcpy(cuda_conv_kernel, conv_kernel, length * length * sizeof(float), cudaMemcpyHostToDevice);

    // cudaEvent
    cudaEvent_t start, stop;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    cudaEventRecord(start);

    _sharpen <<< grid, block >>> (cuda_out, cuda_in, sharpenfactor, cuda_conv_kernel, halflen, height, width);

    cudaEventRecord(stop);
    cudaEventSynchronize(stop);

    // copy the output into the image array
    cudaMemcpy(out_image, cuda_out, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyDeviceToHost);

    cudaFree(cuda_in);
    cudaFree(cuda_out);
    cudaFree(cuda_conv_kernel);

    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess)
        printf("Error: %s\n", cudaGetErrorString(err));

    float milliseconds = 0;
    cudaEventElapsedTime(&milliseconds, start, stop);
    printf("sharpening takes time: %f ms \n", milliseconds);
}

void conv2d_func(unsigned char *out_image, unsigned char *in_image, float *conv_kernel, int length,
                int height, int width) {

    assert(length % 2 == 1);
    int halflen = length / 2;

    dim3 grid(512, 512);
    dim3 block(1, 1);
    int imgproduct = height * width;

    unsigned char *cuda_out, *cuda_in;
    float *cuda_conv_kernel;
    cudaMalloc((void **) &cuda_in, imgproduct * 3 * sizeof(unsigned char));
    cudaMalloc((void **) &cuda_out, imgproduct * 3 * sizeof(unsigned char));
    cudaMalloc((void **) &cuda_conv_kernel, length * length * sizeof(float));

    // copy the original_image into cuda
    cudaMemcpy(cuda_in, in_image, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyHostToDevice);
    cudaMemcpy(cuda_conv_kernel, conv_kernel, length * length * sizeof(float), cudaMemcpyHostToDevice);

    // cudaEvent
    cudaEvent_t start, stop;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    cudaEventRecord(start);

    _conv2d <<< grid, block >>> (cuda_out, cuda_in, cuda_conv_kernel, halflen, height, width);

    cudaEventRecord(stop);
    cudaEventSynchronize(stop);

    // copy the output into the image array
    cudaMemcpy(out_image, cuda_out, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyDeviceToHost);

    cudaFree(cuda_in);
    cudaFree(cuda_out);
    cudaFree(cuda_conv_kernel);

    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess)
        printf("Error: %s\n", cudaGetErrorString(err));

    float milliseconds = 0;
    cudaEventElapsedTime(&milliseconds, start, stop);
    printf("conv takes time: %f ms \n", milliseconds);
}


void conv2d_const_mem_func(unsigned char *out_image, unsigned char *in_image, float *conv_kernel,
                 int height, int width) {

    assert(KERNEL_SIZE % 2 == 1);

    dim3 grid(1, 512);
    dim3 block(512, 1);
    int imgproduct = height * width;

    unsigned char *cuda_out, *cuda_in;
    cudaMalloc((void **) &cuda_in, imgproduct * 3 * sizeof(unsigned char));
    cudaMalloc((void **) &cuda_out, imgproduct * 3 * sizeof(unsigned char));
//    cudaMalloc((void **) KERNEL, KERNEL_SIZE * KERNEL_SIZE * sizeof(float));

    // copy the original_image into cuda
    cudaMemcpy(cuda_in, in_image, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyHostToDevice);

    // show the err returned from here
    cudaError_t mem_err = cudaMemcpyToSymbol(KERNEL, conv_kernel, KERNEL_SIZE * KERNEL_SIZE * sizeof(float), cudaMemcpyHostToDevice);
    if (mem_err != cudaSuccess)
        printf("Mem copy Error: %s\n", cudaGetErrorString(mem_err));

    // cudaEvent
    cudaEvent_t start, stop;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    cudaEventRecord(start);

    // could do something similar here.
    _conv2d_constant_memory <<< grid, block >>> (cuda_out, cuda_in, height, width);

    cudaEventRecord(stop);
    cudaEventSynchronize(stop);

    // copy the output into the image array
    cudaMemcpy(out_image, cuda_out, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyDeviceToHost);

    cudaFree(cuda_in);
    cudaFree(cuda_out);

    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess)
        printf("Error: %s\n", cudaGetErrorString(err));


    float milliseconds = 0;
    cudaEventElapsedTime(&milliseconds, start, stop);
    printf("conv takes time: %f ms \n", milliseconds);
}


void conv2d_shared_mem_func(unsigned char *out_image, unsigned char *in_image, float *conv_kernel, int share_size,
        int length, int height, int width) {

    assert(length % 2 == 1);
    int halflen = length / 2;

    dim3 grid((int) (height*width/16), (int) (height*width/16));
    dim3 block(16, 16);
    int imgproduct = height * width;

    unsigned char *cuda_out, *cuda_in;
    float *cuda_conv_kernel;
    cudaMalloc((void **) &cuda_in, imgproduct * 3 * sizeof(unsigned char));
    cudaMalloc((void **) &cuda_out, imgproduct * 3 * sizeof(unsigned char));
    cudaMalloc((void **) &cuda_conv_kernel, length * length * sizeof(float));

    // copy the original_image into cuda
    cudaMemcpy(cuda_in, in_image, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyHostToDevice);
    cudaMemcpy(cuda_conv_kernel, conv_kernel, length * length * sizeof(float), cudaMemcpyHostToDevice);

    // cudaEvent
    cudaEvent_t start, stop;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    cudaEventRecord(start);
    _conv2d_shared_mem <<< grid, block >>> (cuda_out, cuda_in, cuda_conv_kernel, halflen, height, width);

    cudaEventRecord(stop);
    cudaEventSynchronize(stop);

    // copy the output into the image array
    cudaMemcpy(out_image, cuda_out, imgproduct * 3 * sizeof(unsigned char), cudaMemcpyDeviceToHost);

    cudaFree(cuda_in);
    cudaFree(cuda_out);
    cudaFree(cuda_conv_kernel);

    cudaError_t err = cudaGetLastError();
    if (err != cudaSuccess)
        printf("Error: %s\n", cudaGetErrorString(err));

    float milliseconds = 0;
    cudaEventElapsedTime(&milliseconds, start, stop);
    printf("conv takes time: %f ms \n", milliseconds);
}

// do not use this method for anything else than verifying cuda compiled, linked and executed
__global__ void testArray(float *dst, float value) {
    unsigned int index = threadIdx.x;
    dst[index] = value;
}

void testCudaCall() {
    // quick and dirty test of CUDA setup
    const unsigned int N = 1024;
    float *device_array;
    cudaMalloc(&device_array, N * sizeof(float));
    testArray <<< 1, N >>> (device_array, -0.5f);
    float x[N];
    cudaMemcpy(x, device_array, N * sizeof(float), cudaMemcpyDeviceToHost);
    std::cout << "quick and dirty test of CUDA setup: " << x[0] << " " << x[1] << " " << x[1023] << std::endl;
    cudaFree(device_array);

    // initilize global
//    cudaMalloc((void **) &KERNEL, KERNEL_SIZE * KERNEL_SIZE * sizeof(float));

}

	.file	"tmpxft_002ab318_00000000-6_imageprocessing.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3703:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3703:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z33__device_stub__Z9_brightenPhS_fiiPhS_fii
	.type	_Z33__device_stub__Z9_brightenPhS_fiiPhS_fii, @function
_Z33__device_stub__Z9_brightenPhS_fiiPhS_fii:
.LFB3725:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	40(%rsp), %rcx
	movss	%xmm0, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z9_brightenPhS_fii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L2:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3725:
	.size	_Z33__device_stub__Z9_brightenPhS_fiiPhS_fii, .-_Z33__device_stub__Z9_brightenPhS_fiiPhS_fii
	.globl	_Z9_brightenPhS_fii
	.type	_Z9_brightenPhS_fii, @function
_Z9_brightenPhS_fii:
.LFB3726:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z9_brightenPhS_fiiPhS_fii
	.cfi_endproc
.LFE3726:
	.size	_Z9_brightenPhS_fii, .-_Z9_brightenPhS_fii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Error: %s\n"
.LC2:
	.string	"contrast takes time: %f ms \n"
	.text
	.globl	_Z13brighten_funcPhS_fii
	.type	_Z13brighten_funcPhS_fii, @function
_Z13brighten_funcPhS_fii:
.LFB3693:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	%ecx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	%edx, %ebx
	imull	%ecx, %ebx
	subq	$96, %rsp
	.cfi_def_cfa_offset 144
	movss	%xmm0, 12(%rsp)
	leal	(%rbx,%rbx,2), %ebx
	leaq	40(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	movabsq	$2199023255553, %rax
	movslq	%ebx, %rbx
	movl	$1, 72(%rsp)
	movq	%rbx, %rsi
	movl	$1, 84(%rsp)
	movq	%rax, 64(%rsp)
	movl	$8388609, %eax
	salq	$9, %rax
	movq	%rax, 76(%rsp)
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	40(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	84(%rsp), %ecx
	movl	72(%rsp), %esi
	xorl	%r9d, %r9d
	movq	76(%rsp), %rdx
	movq	64(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	movss	12(%rsp), %xmm0
	testl	%eax, %eax
	jne	.L9
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdi
	movl	%r14d, %ecx
	movl	%r13d, %edx
	call	_Z33__device_stub__Z9_brightenPhS_fiiPhS_fii
.L9:
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	32(%rsp), %rsi
	movq	%rbx, %rdx
	movq	%rbp, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L10
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L10:
	movq	48(%rsp), %rsi
	movq	56(%rsp), %rdx
	leaq	28(%rsp), %rdi
	movl	$0x00000000, 28(%rsp)
	call	cudaEventElapsedTime@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	28(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	addq	$96, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3693:
	.size	_Z13brighten_funcPhS_fii, .-_Z13brighten_funcPhS_fii
	.globl	_Z33__device_stub__Z9_contrastPhS_fiiPhS_fii
	.type	_Z33__device_stub__Z9_contrastPhS_fiiPhS_fii, @function
_Z33__device_stub__Z9_contrastPhS_fiiPhS_fii:
.LFB3727:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	40(%rsp), %rcx
	movss	%xmm0, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L16
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z9_contrastPhS_fii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L16:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3727:
	.size	_Z33__device_stub__Z9_contrastPhS_fiiPhS_fii, .-_Z33__device_stub__Z9_contrastPhS_fiiPhS_fii
	.globl	_Z9_contrastPhS_fii
	.type	_Z9_contrastPhS_fii, @function
_Z9_contrastPhS_fii:
.LFB3728:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z9_contrastPhS_fiiPhS_fii
	.cfi_endproc
.LFE3728:
	.size	_Z9_contrastPhS_fii, .-_Z9_contrastPhS_fii
	.globl	_Z13contrast_funcPhS_fii
	.type	_Z13contrast_funcPhS_fii, @function
_Z13contrast_funcPhS_fii:
.LFB3694:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	%ecx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	%edx, %ebx
	imull	%ecx, %ebx
	subq	$96, %rsp
	.cfi_def_cfa_offset 144
	movss	%xmm0, 12(%rsp)
	leal	(%rbx,%rbx,2), %ebx
	leaq	40(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	movabsq	$2199023255553, %rax
	movslq	%ebx, %rbx
	movl	$1, 72(%rsp)
	movq	%rbx, %rsi
	movl	$1, 84(%rsp)
	movq	%rax, 64(%rsp)
	movl	$8388609, %eax
	salq	$9, %rax
	movq	%rax, 76(%rsp)
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	40(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	84(%rsp), %ecx
	movl	72(%rsp), %esi
	xorl	%r9d, %r9d
	movq	76(%rsp), %rdx
	movq	64(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	movss	12(%rsp), %xmm0
	testl	%eax, %eax
	jne	.L22
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdi
	movl	%r14d, %ecx
	movl	%r13d, %edx
	call	_Z33__device_stub__Z9_contrastPhS_fiiPhS_fii
.L22:
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	32(%rsp), %rsi
	movq	%rbx, %rdx
	movq	%rbp, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L23
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L23:
	movq	48(%rsp), %rsi
	movq	56(%rsp), %rdx
	leaq	28(%rsp), %rdi
	movl	$0x00000000, 28(%rsp)
	call	cudaEventElapsedTime@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	28(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	addq	$96, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3694:
	.size	_Z13contrast_funcPhS_fii, .-_Z13contrast_funcPhS_fii
	.globl	_Z36__device_stub__Z11_saturationPhS_fiiPhS_fii
	.type	_Z36__device_stub__Z11_saturationPhS_fiiPhS_fii, @function
_Z36__device_stub__Z11_saturationPhS_fiiPhS_fii:
.LFB3729:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 8(%rsp)
	leaq	32(%rsp), %rdx
	movl	%ecx, 4(%rsp)
	leaq	40(%rsp), %rcx
	movss	%xmm0, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	pushq	40(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z11_saturationPhS_fii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L29:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3729:
	.size	_Z36__device_stub__Z11_saturationPhS_fiiPhS_fii, .-_Z36__device_stub__Z11_saturationPhS_fiiPhS_fii
	.globl	_Z11_saturationPhS_fii
	.type	_Z11_saturationPhS_fii, @function
_Z11_saturationPhS_fii:
.LFB3730:
	.cfi_startproc
	endbr64
	jmp	_Z36__device_stub__Z11_saturationPhS_fiiPhS_fii
	.cfi_endproc
.LFE3730:
	.size	_Z11_saturationPhS_fii, .-_Z11_saturationPhS_fii
	.section	.rodata.str1.1
.LC3:
	.string	"saturation takes time: %f ms \n"
	.text
	.globl	_Z15saturation_funcPhS_fii
	.type	_Z15saturation_funcPhS_fii, @function
_Z15saturation_funcPhS_fii:
.LFB3695:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	%ecx, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	%edx, %ebx
	imull	%ecx, %ebx
	subq	$96, %rsp
	.cfi_def_cfa_offset 144
	movss	%xmm0, 12(%rsp)
	leal	(%rbx,%rbx,2), %ebx
	leaq	40(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	movabsq	$2199023255553, %rax
	movslq	%ebx, %rbx
	movl	$1, 72(%rsp)
	movq	%rbx, %rsi
	movl	$1, 84(%rsp)
	movq	%rax, 64(%rsp)
	movl	$8388609, %eax
	salq	$9, %rax
	movq	%rax, 76(%rsp)
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	40(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	84(%rsp), %ecx
	movl	72(%rsp), %esi
	xorl	%r9d, %r9d
	movq	76(%rsp), %rdx
	movq	64(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	movss	12(%rsp), %xmm0
	testl	%eax, %eax
	jne	.L35
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdi
	movl	%r14d, %ecx
	movl	%r13d, %edx
	call	_Z36__device_stub__Z11_saturationPhS_fiiPhS_fii
.L35:
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	32(%rsp), %rsi
	movq	%rbx, %rdx
	movq	%rbp, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L36
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L36:
	movq	48(%rsp), %rsi
	movq	56(%rsp), %rdx
	leaq	28(%rsp), %rdi
	movl	$0x00000000, 28(%rsp)
	call	cudaEventElapsedTime@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	28(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	addq	$96, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3695:
	.size	_Z15saturation_funcPhS_fii, .-_Z15saturation_funcPhS_fii
	.globl	_Z35__device_stub__Z8_sharpenPhS_fPfiiiPhS_fPfiii
	.type	_Z35__device_stub__Z8_sharpenPhS_fPfiiiPhS_fPfiii, @function
_Z35__device_stub__Z8_sharpenPhS_fPfiiiPhS_fPfiii:
.LFB3731:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 16(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 24(%rsp)
	leaq	56(%rsp), %rcx
	movl	%r8d, 12(%rsp)
	movl	%r9d, 8(%rsp)
	movss	%xmm0, 28(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L42
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z8_sharpenPhS_fPfiii(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L42:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	call	__stack_chk_fail@PLT
.L44:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3731:
	.size	_Z35__device_stub__Z8_sharpenPhS_fPfiiiPhS_fPfiii, .-_Z35__device_stub__Z8_sharpenPhS_fPfiiiPhS_fPfiii
	.globl	_Z8_sharpenPhS_fPfiii
	.type	_Z8_sharpenPhS_fPfiii, @function
_Z8_sharpenPhS_fPfiii:
.LFB3732:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z8_sharpenPhS_fPfiiiPhS_fPfiii
	.cfi_endproc
.LFE3732:
	.size	_Z8_sharpenPhS_fPfiii, .-_Z8_sharpenPhS_fPfiii
	.section	.rodata.str1.1
.LC4:
	.string	"sharpening takes time: %f ms \n"
	.text
	.globl	_Z12sharpen_funcPhS_fPfiii
	.type	_Z12sharpen_funcPhS_fPfiii, @function
_Z12sharpen_funcPhS_fPfiii:
.LFB3696:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rsi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%r9d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%r8d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%r8d, %ebx
	movl	%ebp, %r12d
	imull	%r9d, %ebx
	imull	%ebp, %r12d
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%rdx, 16(%rsp)
	leal	(%rbx,%rbx,2), %ebx
	movq	%rdi, 8(%rsp)
	movslq	%ebx, %rbx
	leaq	48(%rsp), %rdi
	movslq	%r12d, %r12
	movss	%xmm0, 28(%rsp)
	movq	%rbx, %rsi
	salq	$2, %r12
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	movabsq	$2199023255553, %rax
	movl	$1, 88(%rsp)
	movl	$1, 100(%rsp)
	movq	%rax, 80(%rsp)
	movl	$8388609, %eax
	salq	$9, %rax
	movq	%rax, 92(%rsp)
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movq	%r12, %rsi
	call	cudaMalloc@PLT
	movq	48(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	16(%rsp), %rsi
	movq	56(%rsp), %rdi
	movq	%r12, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	64(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	72(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	100(%rsp), %ecx
	movl	88(%rsp), %esi
	xorl	%r9d, %r9d
	movq	92(%rsp), %rdx
	movq	80(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	movss	28(%rsp), %xmm0
	testl	%eax, %eax
	jne	.L48
	movl	%ebp, %eax
	movl	$2, %ecx
	movq	48(%rsp), %rsi
	movl	%r14d, %r9d
	cltd
	movq	40(%rsp), %rdi
	movl	%r13d, %r8d
	idivl	%ecx
	movq	56(%rsp), %rdx
	movl	%eax, %ecx
	call	_Z35__device_stub__Z8_sharpenPhS_fPfiiiPhS_fPfiii
.L48:
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	72(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	40(%rsp), %rsi
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L49
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L49:
	movq	64(%rsp), %rsi
	movq	72(%rsp), %rdx
	leaq	36(%rsp), %rdi
	movl	$0x00000000, 36(%rsp)
	call	cudaEventElapsedTime@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	36(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L50
	call	__stack_chk_fail@PLT
.L50:
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3696:
	.size	_Z12sharpen_funcPhS_fPfiii, .-_Z12sharpen_funcPhS_fPfiii
	.globl	_Z33__device_stub__Z7_conv2dPhS_PfiiiPhS_Pfiii
	.type	_Z33__device_stub__Z7_conv2dPhS_PfiiiPhS_Pfiii, @function
_Z33__device_stub__Z7_conv2dPhS_PfiiiPhS_Pfiii:
.LFB3733:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%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	.L55
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z7_conv2dPhS_Pfiii(%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
.L55:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L57
	call	__stack_chk_fail@PLT
.L57:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3733:
	.size	_Z33__device_stub__Z7_conv2dPhS_PfiiiPhS_Pfiii, .-_Z33__device_stub__Z7_conv2dPhS_PfiiiPhS_Pfiii
	.globl	_Z7_conv2dPhS_Pfiii
	.type	_Z7_conv2dPhS_Pfiii, @function
_Z7_conv2dPhS_Pfiii:
.LFB3734:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z7_conv2dPhS_PfiiiPhS_Pfiii
	.cfi_endproc
.LFE3734:
	.size	_Z7_conv2dPhS_Pfiii, .-_Z7_conv2dPhS_Pfiii
	.section	.rodata.str1.1
.LC5:
	.string	"conv takes time: %f ms \n"
	.text
	.globl	_Z11conv2d_funcPhS_Pfiii
	.type	_Z11conv2d_funcPhS_Pfiii, @function
_Z11conv2d_funcPhS_Pfiii:
.LFB3697:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rsi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%r9d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%r8d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%r8d, %ebx
	movl	%ebp, %r12d
	imull	%r9d, %ebx
	imull	%ebp, %r12d
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdx, 8(%rsp)
	leal	(%rbx,%rbx,2), %ebx
	movq	%rdi, (%rsp)
	movslq	%ebx, %rbx
	leaq	32(%rsp), %rdi
	movslq	%r12d, %r12
	movq	%rbx, %rsi
	salq	$2, %r12
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	movabsq	$2199023256064, %rax
	movl	$1, 72(%rsp)
	movl	$1, 84(%rsp)
	movq	%rax, 64(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 76(%rsp)
	call	cudaMalloc@PLT
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	40(%rsp), %rdi
	movq	%r12, %rsi
	call	cudaMalloc@PLT
	movq	32(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	movq	40(%rsp), %rdi
	movq	%r12, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	84(%rsp), %ecx
	movl	72(%rsp), %esi
	xorl	%r9d, %r9d
	movq	76(%rsp), %rdx
	movq	64(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L61
	movl	%ebp, %eax
	movl	$2, %ecx
	movq	32(%rsp), %rsi
	movl	%r14d, %r9d
	cltd
	movq	24(%rsp), %rdi
	movl	%r13d, %r8d
	idivl	%ecx
	movq	40(%rsp), %rdx
	movl	%eax, %ecx
	call	_Z33__device_stub__Z7_conv2dPhS_PfiiiPhS_Pfiii
.L61:
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	24(%rsp), %rsi
	movq	(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L62
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L62:
	movq	48(%rsp), %rsi
	movq	56(%rsp), %rdx
	leaq	20(%rsp), %rdi
	movl	$0x00000000, 20(%rsp)
	call	cudaEventElapsedTime@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	20(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L63
	call	__stack_chk_fail@PLT
.L63:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3697:
	.size	_Z11conv2d_funcPhS_Pfiii, .-_Z11conv2d_funcPhS_Pfiii
	.globl	_Z47__device_stub__Z23_conv2d_constant_memoryPhS_iiPhS_ii
	.type	_Z47__device_stub__Z23_conv2d_constant_memoryPhS_iiPhS_ii, @function
_Z47__device_stub__Z23_conv2d_constant_memoryPhS_iiPhS_ii:
.LFB3735:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 8(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L68
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z23_conv2d_constant_memoryPhS_ii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L68:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L70
	call	__stack_chk_fail@PLT
.L70:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3735:
	.size	_Z47__device_stub__Z23_conv2d_constant_memoryPhS_iiPhS_ii, .-_Z47__device_stub__Z23_conv2d_constant_memoryPhS_iiPhS_ii
	.globl	_Z23_conv2d_constant_memoryPhS_ii
	.type	_Z23_conv2d_constant_memoryPhS_ii, @function
_Z23_conv2d_constant_memoryPhS_ii:
.LFB3736:
	.cfi_startproc
	endbr64
	jmp	_Z47__device_stub__Z23_conv2d_constant_memoryPhS_iiPhS_ii
	.cfi_endproc
.LFE3736:
	.size	_Z23_conv2d_constant_memoryPhS_ii, .-_Z23_conv2d_constant_memoryPhS_ii
	.section	.rodata.str1.1
.LC6:
	.string	"Mem copy Error: %s\n"
	.text
	.globl	_Z21conv2d_const_mem_funcPhS_Pfii
	.type	_Z21conv2d_const_mem_funcPhS_Pfii, @function
_Z21conv2d_const_mem_funcPhS_Pfii:
.LFB3698:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rsi, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdx, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%r8d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%ecx, %ebx
	imull	%r8d, %ebx
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	movabsq	$2199023255553, %rax
	leal	(%rbx,%rbx,2), %ebx
	leaq	24(%rsp), %rdi
	movl	$1, 56(%rsp)
	movslq	%ebx, %rbx
	movl	$1, 68(%rsp)
	movq	%rbx, %rsi
	movq	%rax, 48(%rsp)
	movl	$8388609, %eax
	salq	$9, %rax
	movq	%rax, 60(%rsp)
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movq	24(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r15, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$1, %r8d
	movl	$1, %ecx
	movq	%r14, %rsi
	movl	$324, %edx
	leaq	_ZL6KERNEL(%rip), %rdi
	call	cudaMemcpyToSymbol@PLT
	testl	%eax, %eax
	je	.L74
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L74:
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	68(%rsp), %ecx
	movl	56(%rsp), %esi
	xorl	%r9d, %r9d
	movq	60(%rsp), %rdx
	movq	48(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L75
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	movl	%r12d, %ecx
	movl	%ebp, %edx
	call	_Z47__device_stub__Z23_conv2d_constant_memoryPhS_iiPhS_ii
.L75:
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	16(%rsp), %rsi
	movq	%rbx, %rdx
	movq	%r13, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L76
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L76:
	movq	32(%rsp), %rsi
	movq	40(%rsp), %rdx
	leaq	12(%rsp), %rdi
	movl	$0x00000000, 12(%rsp)
	call	cudaEventElapsedTime@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	12(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L77
	call	__stack_chk_fail@PLT
.L77:
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3698:
	.size	_Z21conv2d_const_mem_funcPhS_Pfii, .-_Z21conv2d_const_mem_funcPhS_Pfii
	.globl	_Z45__device_stub__Z18_conv2d_shared_memPhS_PfiiiPhS_Pfiii
	.type	_Z45__device_stub__Z18_conv2d_shared_memPhS_PfiiiPhS_Pfiii, @function
_Z45__device_stub__Z18_conv2d_shared_memPhS_PfiiiPhS_Pfiii:
.LFB3737:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%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	.L85
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z18_conv2d_shared_memPhS_Pfiii(%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
.L85:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L87
	call	__stack_chk_fail@PLT
.L87:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3737:
	.size	_Z45__device_stub__Z18_conv2d_shared_memPhS_PfiiiPhS_Pfiii, .-_Z45__device_stub__Z18_conv2d_shared_memPhS_PfiiiPhS_Pfiii
	.globl	_Z18_conv2d_shared_memPhS_Pfiii
	.type	_Z18_conv2d_shared_memPhS_Pfiii, @function
_Z18_conv2d_shared_memPhS_Pfiii:
.LFB3738:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z18_conv2d_shared_memPhS_PfiiiPhS_Pfiii
	.cfi_endproc
.LFE3738:
	.size	_Z18_conv2d_shared_memPhS_Pfiii, .-_Z18_conv2d_shared_memPhS_Pfiii
	.globl	_Z22conv2d_shared_mem_funcPhS_Pfiiii
	.type	_Z22conv2d_shared_mem_funcPhS_Pfiiii, @function
_Z22conv2d_shared_mem_funcPhS_Pfiiii:
.LFB3699:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$16, %ecx
	movl	%r9d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rsi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdx, %r13
	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
	movl	%r8d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	movl	160(%rsp), %ebx
	leaq	32(%rsp), %rdi
	movl	$1, 72(%rsp)
	movl	$1, 84(%rsp)
	imull	%r9d, %ebx
	movl	%ebx, %eax
	leal	(%rbx,%rbx,2), %ebx
	cltd
	movslq	%ebx, %rbx
	idivl	%ecx
	movq	%rbx, %rsi
	movl	%eax, 64(%rsp)
	movl	%eax, 68(%rsp)
	movabsq	$68719476752, %rax
	movq	%rax, 76(%rsp)
	call	cudaMalloc@PLT
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movl	%ebp, %eax
	leaq	40(%rsp), %rdi
	imull	%ebp, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movq	32(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rdx
	movq	40(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	56(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	84(%rsp), %ecx
	movl	72(%rsp), %esi
	xorl	%r9d, %r9d
	movq	76(%rsp), %rdx
	movq	64(%rsp), %rdi
	xorl	%r8d, %r8d
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L91
	movl	%ebp, %eax
	movl	$2, %ecx
	movq	32(%rsp), %rsi
	movl	%r15d, %r8d
	cltd
	movl	160(%rsp), %r9d
	movq	24(%rsp), %rdi
	idivl	%ecx
	movq	40(%rsp), %rdx
	movl	%eax, %ecx
	call	_Z45__device_stub__Z18_conv2d_shared_memPhS_PfiiiPhS_Pfiii
.L91:
	movq	56(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	24(%rsp), %rsi
	movq	%rbx, %rdx
	movq	%r12, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	call	cudaGetLastError@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L92
	call	cudaGetErrorString@PLT
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L92:
	movq	48(%rsp), %rsi
	movq	56(%rsp), %rdx
	leaq	20(%rsp), %rdi
	movl	$0x00000000, 20(%rsp)
	call	cudaEventElapsedTime@PLT
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	20(%rsp), %xmm0
	call	__printf_chk@PLT
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L93
	call	__stack_chk_fail@PLT
.L93:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3699:
	.size	_Z22conv2d_shared_mem_funcPhS_Pfiiii, .-_Z22conv2d_shared_mem_funcPhS_Pfiiii
	.globl	_Z29__device_stub__Z9testArrayPffPff
	.type	_Z29__device_stub__Z9testArrayPffPff, @function
_Z29__device_stub__Z9testArrayPffPff:
.LFB3739:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movss	%xmm0, 4(%rsp)
	leaq	52(%rsp), %rsi
	leaq	40(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L98
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z9testArrayPff(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L98:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L100
	call	__stack_chk_fail@PLT
.L100:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3739:
	.size	_Z29__device_stub__Z9testArrayPffPff, .-_Z29__device_stub__Z9testArrayPffPff
	.globl	_Z9testArrayPff
	.type	_Z9testArrayPff, @function
_Z9testArrayPff:
.LFB3740:
	.cfi_startproc
	endbr64
	jmp	_Z29__device_stub__Z9testArrayPffPff
	.cfi_endproc
.LFE3740:
	.size	_Z9testArrayPff, .-_Z9testArrayPff
	.section	.rodata.str1.1
.LC8:
	.string	"quick and dirty test of CUDA setup: "
.LC9:
	.string	" "
	.text
	.globl	_Z12testCudaCallv
	.type	_Z12testCudaCallv, @function
_Z12testCudaCallv:
.LFB3700:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	subq	$4096, %rsp
	.cfi_def_cfa_offset 4112
	orq	$0, (%rsp)
	subq	$48, %rsp
	.cfi_def_cfa_offset 4160
	movl	$4096, %esi
	movq	%fs:40, %rax
	movq	%rax, 4136(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	salq	$10, %rdx
	movl	$1, %ecx
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L104
	movss	.LC7(%rip), %xmm0
	movq	8(%rsp), %rdi
	call	_Z29__device_stub__Z9testArrayPffPff
.L104:
	movq	8(%rsp), %rsi
	movl	$2, %ecx
	movl	$4096, %edx
	leaq	40(%rsp), %rdi
	leaq	.LC9(%rip), %rbx
	call	cudaMemcpy@PLT
	leaq	.LC8(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	40(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	44(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbx, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	4132(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	4136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L105
	call	__stack_chk_fail@PLT
.L105:
	addq	$4144, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3700:
	.size	_Z12testCudaCallv, .-_Z12testCudaCallv
	.section	.rodata.str1.1
.LC10:
	.string	"_Z9testArrayPff"
.LC11:
	.string	"_Z18_conv2d_shared_memPhS_Pfiii"
.LC12:
	.string	"_Z23_conv2d_constant_memoryPhS_ii"
.LC13:
	.string	"_Z7_conv2dPhS_Pfiii"
.LC14:
	.string	"_Z8_sharpenPhS_fPfiii"
.LC15:
	.string	"_Z11_saturationPhS_fii"
.LC16:
	.string	"_Z9_contrastPhS_fii"
.LC17:
	.string	"_Z9_brightenPhS_fii"
.LC18:
	.string	"KERNEL"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3742:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC10(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z9testArrayPff(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC11(%rip), %rdx
	movq	%rbx, %rdi
	leaq	_Z18_conv2d_shared_memPhS_Pfiii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC12(%rip), %rdx
	movq	%rbx, %rdi
	leaq	_Z23_conv2d_constant_memoryPhS_ii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC13(%rip), %rdx
	movq	%rbx, %rdi
	leaq	_Z7_conv2dPhS_Pfiii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC14(%rip), %rdx
	movq	%rbx, %rdi
	leaq	_Z8_sharpenPhS_fPfiii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC15(%rip), %rdx
	movq	%rbx, %rdi
	leaq	_Z11_saturationPhS_fii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC16(%rip), %rdx
	movq	%rbx, %rdi
	leaq	_Z9_contrastPhS_fii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC17(%rip), %rdx
	movq	%rbx, %rdi
	leaq	_Z9_brightenPhS_fii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	leaq	.LC18(%rip), %rdx
	pushq	$0
	.cfi_def_cfa_offset 24
	movq	%rdx, %rcx
	movl	$324, %r9d
	xorl	%r8d, %r8d
	pushq	$1
	.cfi_def_cfa_offset 32
	leaq	_ZL6KERNEL(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3742:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.local	_ZL6KERNEL
	.comm	_ZL6KERNEL,324,32
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC7:
	.long	-1090519040
	.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:

#pragma once
#include <hip/hip_runtime.h>


void brighten_func(unsigned char* out_image, unsigned char* in_image, float brightfactor, int height, int width);
void contrast_func(unsigned char* out_image, unsigned char* in_image, float contrastfactor, int height, int width);
void saturation_func(unsigned char* out_image, unsigned char* in_image, float saturationfactor, int height, int width);
void sharpen_func(unsigned char* out_image, unsigned char* in_image, float sharpenfactor, float *conv_kernel, int length, int height, int width);
void conv2d_func(unsigned char* out_image,  unsigned char* in_image, float *conv_kernel, int length,int height, int width);
void conv2d_const_mem_func(unsigned char* out_image,  unsigned char* in_image, float *conv_kernel, int height, int width);
void conv2d_shared_mem_func(unsigned char* out_image,  unsigned char* in_image, float *conv_kernel, int share_size, int length, int height, int width);

void testCudaCall();

	.text
	.file	"imageprocessing.hip"
	.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 __hip_cuid_

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
