#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <string.h> /* needed library to use strcmp function */
#include <cuda.h>

typedef struct {
    float posx;
    float posy;
    float range;
    float temp;
} heatsrc_t;

typedef struct {
    unsigned maxiter; /* maximum number of iterations */
    unsigned resolution; /* spatial resolution */
    int algorithm; /* 0=>Jacobi, 1=>Gauss */

    unsigned visres; /* visualization resolution */

    float *u, *uhelp;
    float *uvis;

    unsigned numsrcs; /* number of heat sources */
    heatsrc_t *heatsrcs;
} algoparam_t;

/* function declarations */
int read_input(FILE *infile, algoparam_t *param);
void print_params(algoparam_t *param);
int initialize(algoparam_t *param);
int finalize(algoparam_t *param);
void write_image(FILE * f, float *u, unsigned sizex, unsigned sizey);
int coarsen(float *uold, unsigned oldx, unsigned oldy, float *unew,
        unsigned newx, unsigned newy);

__device__ float dev_residual = 0.0;

__global__ void gpu_Heat(float *h, float *g, int N) {
    /* In this case, the stride is N */

    int i = blockIdx.y * blockDim.y + threadIdx.y;
    int j = blockIdx.x * blockDim.x + threadIdx.x;

    /* Assert if current thread belongs to first row or column of input matrix */
    bool is_first_row = threadIdx.y == 0 && blockIdx.y == 0;
    bool is_first_col = threadIdx.x == 0 && blockIdx.x == 0;

    if (i < N - 1 && j < N - 1 && !is_first_row && !is_first_col) {
        int pos = i * N + j;
        g[pos] = 0.25 * (h[pos - 1] + h[pos - N] + h[pos + 1] + h[pos + N]);
        float diff = g[pos] - h[pos];
        atomicAdd(&dev_residual, diff * diff);
    }
}

#define NB 8
#define min(a,b) ( ((a) < (b)) ? (a) : (b) )

float cpu_residual(float *u, float *utmp, unsigned sizex, unsigned sizey) {
    float diff, sum = 0.0;

    for (int i = 1; i < sizex - 1; i++)
        for (int j = 1; j < sizey - 1; j++) {
            diff = utmp[i * sizey + j] - u[i * sizey + j];
            sum += diff * diff;
        }
    return (sum);
}

float cpu_jacobi(float *u, float *utmp, unsigned sizex, unsigned sizey) {
    float diff, sum = 0.0;
    int nbx, bx, nby, by;

    nbx = NB;
    bx = sizex / nbx;
    nby = NB;
    by = sizey / nby;
    for (int ii = 0; ii < nbx; ii++)
        for (int jj = 0; jj < nby; jj++)
            for (int i = 1 + ii * bx; i <= min((ii+1)*bx, sizex-2); i++)
                for (int j = 1 + jj * by; j <= min((jj+1)*by, sizey-2); j++) {
                    utmp[i * sizey + j] = 0.25 * (u[i * sizey + (j - 1)] + /* left */
                            u[i * sizey + (j + 1)] + /* right */
                            u[(i - 1) * sizey + j] + /* top */
                            u[(i + 1) * sizey + j]); /* bottom */
                    diff = utmp[i * sizey + j] - u[i * sizey + j];
                    sum += diff * diff;
                }
    return (sum);
}

void usage(char *s) {
    fprintf(stderr, "Usage: %s <input file> -t threads -b blocks\n", s);
    fprintf(stderr,
            "       -t number of threads per block in each dimension (e.g. 16)\n");
}

int main(int argc, char *argv[]) {
    unsigned iter;
    FILE *infile, *resfile;
    char *resfilename;

    /* algorithmic parameters */
    algoparam_t param;
    int np;

    /* check arguments */
    if (argc < 4) {
        usage(argv[0]);
        return 1;
    }

    /* check input file */
    if (!(infile = fopen(argv[1], "r"))) {
        fprintf(stderr, "\nError: Cannot open \"%s\" for reading.\n\n",
                argv[1]);

        usage(argv[0]);
        return 1;
    }

    /* check result file */
    resfilename = "heat.ppm";

    if (!(resfile = fopen(resfilename, "w"))) {
        fprintf(stderr, "\nError: Cannot open \"%s\" for writing.\n\n",
                resfilename);
        usage(argv[0]);
        return 1;
    }

    /* check input */
    if (!read_input(infile, &param)) {
        fprintf(stderr, "\nError: Error parsing input file.\n\n");
        usage(argv[0]);
        return 1;
    }

    /* full size (param.resolution are only the inner points) */
    np = param.resolution + 2;

    int Grid_Dim, Block_Dim; /* Grid and Block structure values */
    if (strcmp(argv[2], "-t") == 0) {
        Block_Dim = atoi(argv[3]);
        Grid_Dim = np / Block_Dim + ((np % Block_Dim) != 0);
        ;
        if ((Block_Dim * Block_Dim) > 512) {
            printf("Error -- too many threads in block, try again\n");
            return 1;
        }
    } else {
        fprintf(stderr, "Usage: %s <input file> -t threads -b blocks\n",
                argv[0]);
        fprintf(stderr,
                "       -t number of threads per block in each dimension (e.g. 16)\n");
        return 0;
    }

    fprintf(stderr, "\nSolving Heat equation on the CPU and the GPU\n");
    fprintf(stderr, "--------------------------------------------\n");
    print_params(&param);

    fprintf(stdout,
            "\nExecution on CPU (sequential)\n-----------------------------\n");
    if (!initialize(&param)) {
        fprintf(stderr, "Error in Solver initialization.\n\n");
        return 1;
    }

    /* starting time */
    float elapsed_time_ms; /* which is applicable for asynchronous code also */
    cudaEvent_t start, stop; /* using cuda events to measure time */
    cudaEventCreate(&start); /* instrument code to measure start time */
    cudaEventCreate(&stop);

    cudaEventRecord(start, 0);
    cudaEventSynchronize(start);

    iter = 0;
    float residual;
    while (1) {
        residual = cpu_jacobi(param.u, param.uhelp, np, np);
        float * tmp = param.u;
        param.u = param.uhelp;
        param.uhelp = tmp;

        iter++;

        /* solution good enough ? */
        if (residual < 0.00005)
            break;

        /* max. iteration reached ? (no limit with maxiter=0) */
        if (iter >= param.maxiter)
            break;
    }

    cudaEventRecord(stop, 0); /* instrument code to measue end time */
    cudaEventSynchronize(stop);
    cudaEventElapsedTime(&elapsed_time_ms, start, stop);

    /* Flop count after iter iterations */
    float flop = iter * 11.0 * param.resolution * param.resolution;

    fprintf(stdout, "Time on CPU in ms.= %f ", elapsed_time_ms);
    fprintf(stdout, "(%3.3f GFlop => %6.2f MFlop/s)\n", flop / 1000000000.0,
            flop / elapsed_time_ms / 1000);
    fprintf(stdout, "Convergence to residual=%f: %d iterations\n", residual,
            iter);

    finalize(&param);

    fprintf(stdout, "\nExecution on GPU\n----------------\n");
    fprintf(stderr, "Number of threads per block in each dimension = %d\n",
            Block_Dim);
    fprintf(stderr, "Number of blocks per grid in each dimension   = %d\n",
            Grid_Dim);

    if (!initialize(&param)) {
        fprintf(stderr, "Error in Solver initialization.\n\n");
        return 1;
    }

    dim3 Grid(Grid_Dim, Grid_Dim);
    dim3 Block(Block_Dim, Block_Dim);

    /* starting time */
    cudaEventRecord(start, 0);
    cudaEventSynchronize(start);

    float *dev_u, *dev_uhelp;

    /* Allocation on GPU for matrices u and uhelp */
    size_t size = np * np * sizeof(float);
    cudaMalloc(&dev_u, size);
    cudaMalloc(&dev_uhelp, size);

    /* Copy initial values in u and uhelp from host to GPU */
    cudaMemcpy(dev_u, param.u, size, cudaMemcpyHostToDevice);
    cudaMemcpy(dev_uhelp, param.uhelp, size, cudaMemcpyHostToDevice);

    iter = 0;
    residual = 0.0;
    float residual_aux = 0.0, residual_acc;
    while (1) {
        if (iter > 0) {
            residual_aux = residual_acc;
        }
        gpu_Heat<<<Grid, Block>>>(dev_u, dev_uhelp, np);
        cudaThreadSynchronize(); /* wait for all threads to complete */

        /* residual is computed on host, we need to get from GPU values computed in u and uhelp */
        /* cudaMemcpy(param.u, dev_u, size, cudaMemcpyDeviceToHost); */
        /* cudaMemcpy(param.uhelp, dev_uhelp, size, cudaMemcpyDeviceToHost); */

        /* residual = cpu_residual (param.u, param.uhelp, np, np); */

        /* printf("Residual computation on GPU is ==> %f\n", residual); */

        /* Get the residual computation from global memory (on device)
         * and copy it into residual variable (host memory)
         */
        cudaMemcpyFromSymbol(&residual_acc, dev_residual, sizeof(float), 0, cudaMemcpyDeviceToHost);
        /* printf("Acumulate Residual computation on GPU is ==> %f\n", residual_acc); */

        /* Update the value of residual */
        residual = residual_acc - residual_aux;
        printf("Residual computation on GPU is ==> %f\n", residual);

        float * tmp = dev_u;
        dev_u = dev_uhelp;
        dev_uhelp = tmp;

        iter++;

        /* solution good enough ? */
        if (residual < 0.00005)
            break;

        /* max. iteration reached ? (no limit with maxiter=0) */
        if (iter >= param.maxiter)
            break;
    }

    /* get result matrix from GPU */
    cudaMemcpy(param.u, dev_u, size, cudaMemcpyDeviceToHost);
    cudaMemcpy(param.uhelp, dev_uhelp, size, cudaMemcpyDeviceToHost);

    /* free memory used in GPU */
    cudaFree(dev_u);
    cudaFree(dev_uhelp);

    cudaEventRecord( stop, 0 ); /* instrument code to measue end time */
    cudaEventSynchronize(stop);
    cudaEventElapsedTime(&elapsed_time_ms, start, stop);

    fprintf(stdout, "\nTime on GPU in ms. = %f ", elapsed_time_ms);
    fprintf(stdout, "(%3.3f GFlop => %6.2f MFlop/s)\n", flop / 1000000000.0,
            flop / elapsed_time_ms / 1000);
    fprintf(stdout, "Convergence to residual=%f: %d iterations\n", residual,
            iter);

    cudaEventDestroy(start);
    cudaEventDestroy(stop);

    /* for plot... */
    coarsen(param.u, np, np, param.uvis, param.visres + 2, param.visres + 2);

    write_image(resfile, param.uvis, param.visres + 2, param.visres + 2);

    finalize(&param);

    return 0;
}

/*
 * Initialize the iterative solver
 * - allocate memory for matrices
 * - set boundary conditions according to configuration
 */
int initialize(algoparam_t *param)

{
    int i, j;
    float dist;

    /* total number of points (including border) */
    const int np = param->resolution + 2;

    /* allocate memory */
    (param->u) = (float*) calloc(sizeof(float), np * np);
    (param->uhelp) = (float*) calloc(sizeof(float), np * np);
    (param->uvis) = (float*) calloc(sizeof(float),
            (param->visres + 2) * (param->visres + 2));

    if (!(param->u) || !(param->uhelp) || !(param->uvis)) {
        fprintf(stderr, "Error: Cannot allocate memory\n");
        return 0;
    }

    for (i = 0; i < param->numsrcs; i++) {
        /* top row */
        for (j = 0; j < np; j++) {
            dist = sqrt(
                    pow((float) j / (float) (np - 1) - param->heatsrcs[i].posx,
                            2) + pow(param->heatsrcs[i].posy, 2));

            if (dist <= param->heatsrcs[i].range) {
                (param->u)[j] += (param->heatsrcs[i].range - dist)
                        / param->heatsrcs[i].range * param->heatsrcs[i].temp;
            }
        }

        /* bottom row */
        for (j = 0; j < np; j++) {
            dist = sqrt(
                    pow((float) j / (float) (np - 1) - param->heatsrcs[i].posx,
                            2) + pow(1 - param->heatsrcs[i].posy, 2));

            if (dist <= param->heatsrcs[i].range) {
                (param->u)[(np - 1) * np + j] += (param->heatsrcs[i].range
                        - dist) / param->heatsrcs[i].range
                        * param->heatsrcs[i].temp;
            }
        }

        /* leftmost column */
        for (j = 1; j < np - 1; j++) {
            dist = sqrt(
                    pow(param->heatsrcs[i].posx, 2)
                            + pow(
                                    (float) j / (float) (np - 1)
                                            - param->heatsrcs[i].posy, 2));

            if (dist <= param->heatsrcs[i].range) {
                (param->u)[j * np] += (param->heatsrcs[i].range - dist)
                        / param->heatsrcs[i].range * param->heatsrcs[i].temp;
            }
        }

        /* rightmost column */
        for (j = 1; j < np - 1; j++) {
            dist = sqrt(
                    pow(1 - param->heatsrcs[i].posx, 2)
                            + pow(
                                    (float) j / (float) (np - 1)
                                            - param->heatsrcs[i].posy, 2));

            if (dist <= param->heatsrcs[i].range) {
                (param->u)[j * np + (np - 1)] += (param->heatsrcs[i].range
                        - dist) / param->heatsrcs[i].range
                        * param->heatsrcs[i].temp;
            }
        }
    }

    /* Copy u into uhelp */
    float *putmp, *pu;
    pu = param->u;
    putmp = param->uhelp;
    for (j = 0; j < np; j++)
        for (i = 0; i < np; i++)
            *putmp++ = *pu++;

    return 1;
}

/* free used memory */
int finalize(algoparam_t *param) {
    if (param->u) {
        free(param->u);
        param->u = 0;
    }

    if (param->uhelp) {
        free(param->uhelp);
        param->uhelp = 0;
    }

    if (param->uvis) {
        free(param->uvis);
        param->uvis = 0;
    }

    return 1;
}

/*
 * write the given temperature u matrix to rgb values
 * and write the resulting image to file f
 */
void write_image(FILE * f, float *u, unsigned sizex, unsigned sizey) {
    /* RGB table */
    unsigned char r[1024], g[1024], b[1024];
    int i, j, k;

    float min, max;

    j = 1023;

    /* prepare RGB table */
    for (i = 0; i < 256; i++) {
        r[j] = 255;
        g[j] = i;
        b[j] = 0;
        j--;
    }
    for (i = 0; i < 256; i++) {
        r[j] = 255 - i;
        g[j] = 255;
        b[j] = 0;
        j--;
    }
    for (i = 0; i < 256; i++) {
        r[j] = 0;
        g[j] = 255;
        b[j] = i;
        j--;
    }
    for (i = 0; i < 256; i++) {
        r[j] = 0;
        g[j] = 255 - i;
        b[j] = 255;
        j--;
    }

    min = DBL_MAX;
    max = -DBL_MAX;

    /* find minimum and maximum */
    for (i = 0; i < sizey; i++) {
        for (j = 0; j < sizex; j++) {
            if (u[i * sizex + j] > max)
                max = u[i * sizex + j];
            if (u[i * sizex + j] < min)
                min = u[i * sizex + j];
        }
    }

    fprintf(f, "P3\n");
    fprintf(f, "%u %u\n", sizex, sizey);
    fprintf(f, "%u\n", 255);

    for (i = 0; i < sizey; i++) {
        for (j = 0; j < sizex; j++) {
            k = (int) (1024.0 * (u[i * sizex + j] - min) / (max - min));
            fprintf(f, "%d %d %d  ", r[k], g[k], b[k]);
        }
        fprintf(f, "\n");
    }
}

int coarsen(float *uold, unsigned oldx, unsigned oldy, float *unew,
        unsigned newx, unsigned newy) {
    int i, j;

    int stepx;
    int stepy;
    int stopx = newx;
    int stopy = newy;

    if (oldx > newx)
        stepx = oldx / newx;
    else {
        stepx = 1;
        stopx = oldx;
    }
    if (oldy > newy)
        stepy = oldy / newy;
    else {
        stepy = 1;
        stopy = oldy;
    }

    /* NOTE: this only takes the top-left corner,
     * and doesnt' do any real coarsening
     */
    for (i = 0; i < stopy - 1; i++) {
        for (j = 0; j < stopx - 1; j++) {
            unew[i * newx + j] = uold[i * oldx * stepy + j * stepx];
        }
    }

    return 1;
}

#define BUFSIZE 100
int read_input(FILE *infile, algoparam_t *param) {
    int i, n;
    char buf[BUFSIZE];

    fgets(buf, BUFSIZE, infile);
    n = sscanf(buf, "%u", &(param->maxiter));
    if (n != 1)
        return 0;

    fgets(buf, BUFSIZE, infile);
    n = sscanf(buf, "%u", &(param->resolution));
    if (n != 1)
        return 0;

    param->visres = param->resolution;

    fgets(buf, BUFSIZE, infile);
    n = sscanf(buf, "%u", &(param->numsrcs));
    if (n != 1)
        return 0;

    (param->heatsrcs) = (heatsrc_t*) malloc(
            sizeof(heatsrc_t) * (param->numsrcs));

    for (i = 0; i < param->numsrcs; i++) {
        fgets(buf, BUFSIZE, infile);
        n = sscanf(buf, "%f %f %f %f", &(param->heatsrcs[i].posx),
                &(param->heatsrcs[i].posy), &(param->heatsrcs[i].range),
                &(param->heatsrcs[i].temp));

        if (n != 4)
            return 0;
    }

    return 1;
}

void print_params(algoparam_t *param) {
    int i;

    fprintf(stdout, "Iterations        : %u\n", param->maxiter);
    fprintf(stdout, "Resolution        : %u\n", param->resolution);
    fprintf(stdout, "Num. Heat sources : %u\n", param->numsrcs);

    for (i = 0; i < param->numsrcs; i++) {
        fprintf(stdout, "  %2d: (%2.2f, %2.2f) %2.2f %2.2f \n", i + 1,
                param->heatsrcs[i].posx, param->heatsrcs[i].posy,
                param->heatsrcs[i].range, param->heatsrcs[i].temp);
    }
}


	.file	"tmpxft_003226a0_00000000-6_heatCUDA.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2039:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2039:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z12cpu_residualPfS_jj
	.type	_Z12cpu_residualPfS_jj, @function
_Z12cpu_residualPfS_jj:
.LFB2027:
	.cfi_startproc
	endbr64
	movl	%ecx, %r9d
	movl	$1, %r8d
	xorps	%xmm1, %xmm1
	decl	%edx
	leal	-1(%rcx), %r11d
.L3:
	cmpl	%edx, %r8d
	jnb	.L8
	movl	$1, %eax
.L5:
	cmpl	%r11d, %eax
	jnb	.L9
	leal	(%rax,%r9), %r10d
	incl	%eax
	movss	(%rsi,%r10,4), %xmm0
	subss	(%rdi,%r10,4), %xmm0
	mulss	%xmm0, %xmm0
	addss	%xmm0, %xmm1
	jmp	.L5
.L9:
	incl	%r8d
	addl	%ecx, %r9d
	jmp	.L3
.L8:
	movaps	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z12cpu_residualPfS_jj, .-_Z12cpu_residualPfS_jj
	.globl	_Z10cpu_jacobiPfS_jj
	.type	_Z10cpu_jacobiPfS_jj, @function
_Z10cpu_jacobiPfS_jj:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%ecx, %eax
	movss	.LC1(%rip), %xmm2
	xorl	%r10d, %r10d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%ecx, %r14d
	xorl	%r8d, %r8d
	xorps	%xmm1, %xmm1
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	shrl	$3, %r14d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	shrl	$3, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%r12d, %ebx
	imull	%ecx, %ebx
	leal	-2(%rdx), %ecx
	movq	%rsi, -16(%rsp)
	movl	%ebx, -8(%rsp)
	leal	-2(%rax), %ebx
	movl	$8, -44(%rsp)
	movl	%ecx, -48(%rsp)
	movl	%ebx, -52(%rsp)
.L11:
	leal	1(%r8), %ecx
	movl	-48(%rsp), %edx
	addl	%r12d, %r8d
	cmpl	%r8d, -48(%rsp)
	movl	%ecx, -24(%rsp)
	leal	(%rax,%r10), %ecx
	movl	%eax, %r11d
	cmova	%r8d, %edx
	movl	$8, -40(%rsp)
	movl	%ecx, -4(%rsp)
	movl	%edx, -28(%rsp)
	xorl	%edx, %edx
.L16:
	leal	1(%rdx), %ecx
	movl	-52(%rsp), %ebx
	movl	%r10d, %ebp
	movl	%ecx, -20(%rsp)
	movl	%edx, %ecx
	addl	%r14d, %edx
	cmpl	%edx, -52(%rsp)
	cmova	%edx, %ebx
	movl	%ebx, -32(%rsp)
	movl	-4(%rsp), %ebx
	addl	%ebx, %ecx
	movl	-24(%rsp), %ebx
.L12:
	cmpl	%ebx, -28(%rsp)
	jb	.L20
	leal	(%rcx,%r11), %esi
	movl	-20(%rsp), %r9d
	movl	%esi, -36(%rsp)
	movl	%ecx, %esi
.L13:
	leal	1(%rsi), %r15d
	movl	%r15d, -56(%rsp)
	cmpl	%r9d, -32(%rsp)
	jb	.L21
	leal	2(%rsi), %r15d
	movl	-56(%rsp), %r13d
	movss	(%rdi,%r15,4), %xmm0
	addss	(%rdi,%rsi,4), %xmm0
	leal	(%r9,%rbp), %esi
	addss	(%rdi,%rsi,4), %xmm0
	movl	-36(%rsp), %esi
	addl	%r9d, %esi
	incl	%r9d
	movl	%esi, %esi
	addss	(%rdi,%rsi,4), %xmm0
	movq	-16(%rsp), %rsi
	mulss	%xmm2, %xmm0
	movss	%xmm0, (%rsi,%r13,4)
	subss	(%rdi,%r13,4), %xmm0
	movl	-56(%rsp), %esi
	mulss	%xmm0, %xmm0
	addss	%xmm0, %xmm1
	jmp	.L13
.L21:
	incl	%ebx
	addl	%eax, %ecx
	addl	%eax, %ebp
	jmp	.L12
.L20:
	subl	%r14d, %r11d
	decl	-40(%rsp)
	jne	.L16
	movl	-8(%rsp), %edx
	addl	%edx, %r10d
	decl	-44(%rsp)
	jne	.L11
	popq	%rbx
	.cfi_def_cfa_offset 48
	movaps	%xmm1, %xmm0
	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
.LFE2028:
	.size	_Z10cpu_jacobiPfS_jj, .-_Z10cpu_jacobiPfS_jj
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"Usage: %s <input file> -t threads -b blocks\n"
.LC3:
	.string	"       -t number of threads per block in each dimension (e.g. 16)\n"
	.text
	.globl	_Z5usagePc
	.type	_Z5usagePc, @function
_Z5usagePc:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rdi, %rcx
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	leaq	.LC2(%rip), %rdx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	stderr(%rip), %rdi
	leaq	.LC3(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	popq	%rcx
	.cfi_def_cfa_offset 8
	jmp	__fprintf_chk@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z5usagePc, .-_Z5usagePc
	.section	.rodata.str1.1
.LC4:
	.string	"Error: Cannot allocate memory\n"
	.text
	.globl	_Z10initializeP11algoparam_t
	.type	_Z10initializeP11algoparam_t, @function
_Z10initializeP11algoparam_t:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movl	4(%rdi), %r14d
	movl	$4, %edi
	leal	2(%r14), %r15d
	movl	%r15d, %r12d
	imull	%r15d, %r12d
	movslq	%r12d, %r12
	movq	%r12, %rsi
	call	calloc@PLT
	movq	%r12, %rsi
	movl	$4, %edi
	movq	%rax, 16(%rbp)
	movq	%rax, %rbx
	call	calloc@PLT
	movl	$4, %edi
	movq	%rax, 24(%rbp)
	movq	%rax, %r12
	movl	12(%rbp), %eax
	leal	2(%rax), %esi
	imull	%esi, %esi
	call	calloc@PLT
	testq	%r12, %r12
	sete	%cl
	testq	%rbx, %rbx
	movq	%rax, 32(%rbp)
	sete	%sil
	orb	%sil, %cl
	jne	.L25
	testq	%rax, %rax
	je	.L25
	incl	%r14d
	movl	%r15d, %eax
	imull	%r14d, %eax
	movl	%eax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rax, (%rsp)
	jmp	.L26
.L25:
	movq	stderr(%rip), %rdi
	leaq	.LC4(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	xorl	%eax, %eax
	jmp	.L24
.L30:
	cvtsi2ssl	%ecx, %xmm0
	movq	48(%rbp), %rsi
	movq	%rcx, 16(%rsp)
	cvtsi2ssl	%r14d, %xmm1
	addq	%r13, %rsi
	movq	%rsi, 8(%rsp)
	divss	%xmm1, %xmm0
	cvtss2sd	4(%rsi), %xmm1
	mulsd	%xmm1, %xmm1
	subss	(%rsi), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
	call	sqrt@PLT
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rcx
	cvtsd2ss	%xmm0, %xmm1
	movss	8(%rsi), %xmm2
	comiss	%xmm1, %xmm2
	jb	.L28
	movaps	%xmm2, %xmm0
	subss	%xmm1, %xmm0
	divss	%xmm2, %xmm0
	mulss	12(%rsi), %xmm0
	addss	(%rbx,%rcx,4), %xmm0
	movss	%xmm0, (%rbx,%rcx,4)
.L28:
	incq	%rcx
.L45:
	cmpl	%ecx, %r15d
	jg	.L30
	xorl	%ecx, %ecx
.L31:
	cmpl	%r15d, %ecx
	jl	.L34
	movl	%r15d, %esi
	movl	$1, %ecx
.L35:
	cmpl	%ecx, %r14d
	jg	.L38
	leal	(%r15,%r14), %esi
	movl	$1, %ecx
.L39:
	cmpl	%ecx, %r14d
	jg	.L42
	incq	(%rsp)
.L26:
	movl	(%rsp), %eax
	cmpl	40(%rbp), %eax
	jb	.L43
	movl	%r14d, %eax
	testl	%r15d, %r15d
	movl	$4, %ecx
	leaq	4(,%rax,4), %rax
	cmovle	%rcx, %rax
	xorl	%r8d, %r8d
	jmp	.L44
.L43:
	movq	(%rsp), %r13
	xorl	%ecx, %ecx
	salq	$4, %r13
	jmp	.L45
.L34:
	cvtsi2ssl	%ecx, %xmm0
	movq	48(%rbp), %rsi
	movl	%ecx, 16(%rsp)
	cvtsi2ssl	%r14d, %xmm1
	addq	%r13, %rsi
	movq	%rsi, 8(%rsp)
	divss	%xmm1, %xmm0
	movss	.LC5(%rip), %xmm1
	subss	4(%rsi), %xmm1
	cvtss2sd	%xmm1, %xmm1
	mulsd	%xmm1, %xmm1
	subss	(%rsi), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	%xmm0, %xmm0
	addsd	%xmm1, %xmm0
	call	sqrt@PLT
	movq	8(%rsp), %rsi
	movl	16(%rsp), %ecx
	cvtsd2ss	%xmm0, %xmm1
	movss	8(%rsi), %xmm2
	comiss	%xmm1, %xmm2
	jb	.L32
	movaps	%xmm2, %xmm0
	movl	24(%rsp), %eax
	subss	%xmm1, %xmm0
	leal	(%rcx,%rax), %edi
	movslq	%edi, %rdi
	divss	%xmm2, %xmm0
	leaq	(%rbx,%rdi,4), %rdi
	mulss	12(%rsi), %xmm0
	addss	(%rdi), %xmm0
	movss	%xmm0, (%rdi)
.L32:
	incl	%ecx
	jmp	.L31
.L38:
	cvtsi2ssl	%ecx, %xmm1
	movq	48(%rbp), %rdi
	movl	%esi, 28(%rsp)
	cvtsi2ssl	%r14d, %xmm3
	movl	%ecx, 16(%rsp)
	addq	%r13, %rdi
	cvtss2sd	(%rdi), %xmm2
	mulsd	%xmm2, %xmm2
	movq	%rdi, 8(%rsp)
	movaps	%xmm1, %xmm0
	divss	%xmm3, %xmm0
	subss	4(%rdi), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	%xmm0, %xmm0
	addsd	%xmm2, %xmm0
	call	sqrt@PLT
	movq	8(%rsp), %rdi
	movl	16(%rsp), %ecx
	cvtsd2ss	%xmm0, %xmm1
	movl	28(%rsp), %esi
	movss	8(%rdi), %xmm2
	comiss	%xmm1, %xmm2
	jb	.L36
	movaps	%xmm2, %xmm0
	movslq	%esi, %r8
	subss	%xmm1, %xmm0
	leaq	(%rbx,%r8,4), %r8
	divss	%xmm2, %xmm0
	mulss	12(%rdi), %xmm0
	addss	(%r8), %xmm0
	movss	%xmm0, (%r8)
.L36:
	incl	%ecx
	addl	%r15d, %esi
	jmp	.L35
.L42:
	cvtsi2ssl	%ecx, %xmm1
	movq	48(%rbp), %rdi
	movl	%esi, 28(%rsp)
	cvtsi2ssl	%r14d, %xmm3
	movss	.LC5(%rip), %xmm2
	movl	%ecx, 16(%rsp)
	addq	%r13, %rdi
	subss	(%rdi), %xmm2
	movq	%rdi, 8(%rsp)
	movaps	%xmm1, %xmm0
	divss	%xmm3, %xmm0
	cvtss2sd	%xmm2, %xmm2
	mulsd	%xmm2, %xmm2
	subss	4(%rdi), %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	%xmm0, %xmm0
	addsd	%xmm2, %xmm0
	call	sqrt@PLT
	movq	8(%rsp), %rdi
	movl	16(%rsp), %ecx
	cvtsd2ss	%xmm0, %xmm1
	movl	28(%rsp), %esi
	movss	8(%rdi), %xmm2
	comiss	%xmm1, %xmm2
	jb	.L40
	movaps	%xmm2, %xmm0
	movslq	%esi, %r8
	subss	%xmm1, %xmm0
	leaq	(%rbx,%r8,4), %r8
	divss	%xmm2, %xmm0
	mulss	12(%rdi), %xmm0
	addss	(%r8), %xmm0
	movss	%xmm0, (%r8)
.L40:
	incl	%ecx
	addl	%r15d, %esi
	jmp	.L39
.L44:
	cmpl	%r15d, %r8d
	jge	.L52
	movq	%r12, %rdi
	movq	%rbx, %rsi
	movq	%rax, %rcx
	incl	%r8d
	rep movsb
	movq	%rsi, %rbx
	movq	%rdi, %r12
	jmp	.L44
.L52:
	movl	$1, %eax
.L24:
	addq	$40, %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
.LFE2031:
	.size	_Z10initializeP11algoparam_t, .-_Z10initializeP11algoparam_t
	.globl	_Z8finalizeP11algoparam_t
	.type	_Z8finalizeP11algoparam_t, @function
_Z8finalizeP11algoparam_t:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	movq	16(%rdi), %rdi
	testq	%rdi, %rdi
	je	.L54
	call	free@PLT
	xorl	%ecx, %ecx
	movq	%rcx, 16(%rbx)
.L54:
	movq	24(%rbx), %rdi
	testq	%rdi, %rdi
	je	.L55
	call	free@PLT
	xorl	%edx, %edx
	movq	%rdx, 24(%rbx)
.L55:
	movq	32(%rbx), %rdi
	testq	%rdi, %rdi
	je	.L56
	call	free@PLT
	xorl	%eax, %eax
	movq	%rax, 32(%rbx)
.L56:
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2032:
	.size	_Z8finalizeP11algoparam_t, .-_Z8finalizeP11algoparam_t
	.section	.rodata.str1.1
.LC8:
	.string	"P3\n"
.LC9:
	.string	"%u %u\n"
.LC10:
	.string	"%u\n"
.LC12:
	.string	"%d %d %d  "
.LC13:
	.string	"\n"
	.text
	.globl	_Z11write_imageP8_IO_FILEPfjj
	.type	_Z11write_imageP8_IO_FILEPfjj, @function
_Z11write_imageP8_IO_FILEPfjj:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	movl	%ecx, %esi
	movl	$256, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$3112, %rsp
	.cfi_def_cfa_offset 3168
	movq	%rdi, (%rsp)
	leaq	792(%rsp), %rdx
	leaq	1048(%rsp), %r10
	movq	%rdx, %rdi
	movl	$1023, %edx
	movq	%fs:40, %rax
	movq	%rax, 3096(%rsp)
	xorl	%eax, %eax
	movb	$-1, %al
	rep stosb
.L68:
	movl	%edx, %eax
	decq	%rdx
	notl	%eax
	movb	%al, 1(%rdx,%r10)
	cmpq	$767, %rdx
	jne	.L68
	leaq	2840(%rsp), %r8
	movl	$64, %ecx
	xorl	%eax, %eax
	movq	%r8, %rdi
	leaq	24(%rsp), %r9
	rep stosl
.L69:
	movb	%dl, (%rdx,%r9)
	decq	%rdx
	cmpq	$511, %rdx
	jne	.L69
	movb	$-1, %r8b
	leaq	1560(%rsp), %r11
	movl	$256, %ecx
	movl	%r8d, %eax
	movq	%r11, %rdi
	leaq	2584(%rsp), %r11
	rep stosb
	xorl	%eax, %eax
	movq	%r11, %rdi
	movl	$64, %ecx
	rep stosl
	leaq	280(%rsp), %r11
	movl	$64, %ecx
	movq	%r11, %rdi
	leaq	1304(%rsp), %r11
	rep stosl
	movl	%r8d, %eax
	movl	$256, %ecx
	movq	%r11, %rdi
	rep stosb
	leaq	2072(%rsp), %r8
.L70:
	movl	%edx, %eax
	decq	%rdx
	notl	%eax
	movb	%al, 1(%rdx,%r8)
	cmpq	$255, %rdx
	jne	.L70
	movl	$64, %ecx
	xorl	%eax, %eax
	movq	%r9, %rdi
	rep stosl
.L71:
	movb	%dl, (%r10,%rdx)
	subq	$1, %rdx
	jnb	.L71
	movl	$256, %ecx
	movb	$-1, %al
	movq	%r8, %rdi
	xorl	%edx, %edx
	rep stosb
	movss	.LC6(%rip), %xmm3
	movss	.LC7(%rip), %xmm4
	xorl	%ebx, %ebx
	movss	%xmm3, 12(%rsp)
	movss	%xmm4, 8(%rsp)
.L72:
	cmpl	%esi, %ebx
	je	.L76
	xorl	%eax, %eax
.L77:
	cmpl	%r12d, %eax
	je	.L89
	leal	(%rax,%rdx), %ecx
	incl	%eax
	movss	0(%r13,%rcx,4), %xmm0
	movaps	%xmm0, %xmm2
	minss	8(%rsp), %xmm0
	maxss	12(%rsp), %xmm2
	movss	%xmm0, 8(%rsp)
	movss	%xmm2, 12(%rsp)
	jmp	.L77
.L89:
	incl	%ebx
	addl	%r12d, %edx
	jmp	.L72
.L76:
	movq	(%rsp), %rdi
	leaq	.LC8(%rip), %rdx
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	movl	$2, %esi
	xorl	%r14d, %r14d
	call	__fprintf_chk@PLT
	movq	(%rsp), %rdi
	movl	%ebx, %r8d
	movl	%r12d, %ecx
	leaq	.LC9(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	(%rsp), %rdi
	movl	$255, %ecx
	xorl	%eax, %eax
	leaq	.LC10(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
.L78:
	cmpq	%rbx, %r14
	je	.L90
	movl	%ebp, %r15d
.L80:
	leal	(%r12,%rbp), %eax
	cmpl	%r15d, %eax
	je	.L91
	movl	%r15d, %eax
	movss	12(%rsp), %xmm1
	movq	(%rsp), %rdi
	leaq	.LC12(%rip), %rdx
	movss	0(%r13,%rax,4), %xmm0
	subss	8(%rsp), %xmm0
	movl	$2, %esi
	incl	%r15d
	subss	8(%rsp), %xmm1
	cvtss2sd	%xmm0, %xmm0
	mulsd	.LC11(%rip), %xmm0
	cvtss2sd	%xmm1, %xmm1
	divsd	%xmm1, %xmm0
	cvttsd2sil	%xmm0, %eax
	cltq
	movzbl	2072(%rsp,%rax), %r9d
	movzbl	24(%rsp,%rax), %ecx
	movzbl	1048(%rsp,%rax), %r8d
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	jmp	.L80
.L91:
	movq	(%rsp), %rdi
	leaq	.LC13(%rip), %rdx
	xorl	%eax, %eax
	incq	%r14
	movl	$2, %esi
	movl	%r15d, %ebp
	call	__fprintf_chk@PLT
	jmp	.L78
.L90:
	movq	3096(%rsp), %rax
	subq	%fs:40, %rax
	je	.L81
	call	__stack_chk_fail@PLT
.L81:
	addq	$3112, %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
.LFE2033:
	.size	_Z11write_imageP8_IO_FILEPfjj, .-_Z11write_imageP8_IO_FILEPfjj
	.globl	_Z7coarsenPfjjS_jj
	.type	_Z7coarsenPfjjS_jj, @function
_Z7coarsenPfjjS_jj:
.LFB2034:
	.cfi_startproc
	endbr64
	movl	%esi, %r11d
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edx, %esi
	movq	%rcx, %r10
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	cmpl	%r11d, %r8d
	jnb	.L93
	movl	%r11d, %eax
	xorl	%edx, %edx
	movl	%r8d, %ecx
	divl	%r8d
	movl	%eax, %ebx
	jmp	.L94
.L93:
	movl	%r11d, %ecx
	movl	$1, %ebx
.L94:
	cmpl	%esi, %r9d
	jnb	.L95
	movl	%esi, %eax
	xorl	%edx, %edx
	divl	%r9d
	jmp	.L96
.L95:
	movl	%esi, %r9d
	movl	$1, %eax
.L96:
	imull	%r11d, %eax
	xorl	%r12d, %r12d
	xorl	%r11d, %r11d
	xorl	%ebp, %ebp
	decl	%r9d
	decl	%ecx
.L97:
	cmpl	%ebp, %r9d
	jle	.L99
	movl	%r11d, %esi
	xorl	%edx, %edx
.L100:
	cmpl	%edx, %ecx
	jle	.L102
	movl	%esi, %r13d
	addl	%ebx, %esi
	movss	(%rdi,%r13,4), %xmm0
	leal	(%rdx,%r12), %r13d
	incl	%edx
	movss	%xmm0, (%r10,%r13,4)
	jmp	.L100
.L102:
	incl	%ebp
	addl	%eax, %r11d
	addl	%r8d, %r12d
	jmp	.L97
.L99:
	popq	%rbx
	.cfi_def_cfa_offset 32
	movl	$1, %eax
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z7coarsenPfjjS_jj, .-_Z7coarsenPfjjS_jj
	.section	.rodata.str1.1
.LC14:
	.string	"%u"
.LC15:
	.string	"%f %f %f %f"
	.text
	.globl	_Z10read_inputP8_IO_FILEP11algoparam_t
	.type	_Z10read_inputP8_IO_FILEP11algoparam_t, @function
_Z10read_inputP8_IO_FILEP11algoparam_t:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %rcx
	movl	$100, %edx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC14(%rip), %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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	movl	$100, %esi
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rbp
	movq	%rbp, %rdi
	call	__fgets_chk@PLT
	xorl	%eax, %eax
	movq	%rbx, %rdx
	movq	%r13, %rsi
	movq	%rbp, %rdi
	call	__isoc23_sscanf@PLT
	decl	%eax
	je	.L104
.L106:
	xorl	%r13d, %r13d
	jmp	.L103
.L104:
	movq	%r12, %rcx
	movl	$100, %edx
	movl	$100, %esi
	movq	%rbp, %rdi
	call	__fgets_chk@PLT
	xorl	%eax, %eax
	leaq	4(%rbx), %rdx
	movq	%r13, %rsi
	movq	%rbp, %rdi
	call	__isoc23_sscanf@PLT
	decl	%eax
	jne	.L106
	movl	4(%rbx), %eax
	movq	%r12, %rcx
	movl	$100, %edx
	movl	$100, %esi
	movq	%rbp, %rdi
	movl	%eax, 12(%rbx)
	call	__fgets_chk@PLT
	movq	%r13, %rsi
	leaq	40(%rbx), %rdx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc23_sscanf@PLT
	movl	%eax, %r13d
	cmpl	$1, %eax
	jne	.L106
	movl	40(%rbx), %edi
	xorl	%r14d, %r14d
	leaq	.LC15(%rip), %r15
	salq	$4, %rdi
	call	malloc@PLT
	movq	%rax, 48(%rbx)
.L107:
	cmpl	40(%rbx), %r14d
	jnb	.L103
	movq	%r12, %rcx
	movl	$100, %edx
	movl	$100, %esi
	movq	%rbp, %rdi
	call	__fgets_chk@PLT
	movq	%r14, %rdx
	movq	%r15, %rsi
	movq	%rbp, %rdi
	salq	$4, %rdx
	addq	48(%rbx), %rdx
	xorl	%eax, %eax
	incq	%r14
	leaq	4(%rdx), %rcx
	leaq	12(%rdx), %r9
	leaq	8(%rdx), %r8
	call	__isoc23_sscanf@PLT
	cmpl	$4, %eax
	je	.L107
	jmp	.L106
.L103:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L109
	call	__stack_chk_fail@PLT
.L109:
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	movl	%r13d, %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
.LFE2035:
	.size	_Z10read_inputP8_IO_FILEP11algoparam_t, .-_Z10read_inputP8_IO_FILEP11algoparam_t
	.section	.rodata.str1.1
.LC16:
	.string	"Iterations        : %u\n"
.LC17:
	.string	"Resolution        : %u\n"
.LC18:
	.string	"Num. Heat sources : %u\n"
.LC19:
	.string	"  %2d: (%2.2f, %2.2f) %2.2f %2.2f \n"
	.text
	.globl	_Z12print_paramsP11algoparam_t
	.type	_Z12print_paramsP11algoparam_t, @function
_Z12print_paramsP11algoparam_t:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC16(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC19(%rip), %r12
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdi, %rbx
	movl	(%rdi), %ecx
	movq	stdout(%rip), %rdi
	call	__fprintf_chk@PLT
	movl	4(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stdout(%rip), %rdi
	leaq	.LC17(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	40(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stdout(%rip), %rdi
	leaq	.LC18(%rip), %rdx
	call	__fprintf_chk@PLT
.L112:
	cmpl	40(%rbx), %ebp
	jnb	.L115
	movq	%rbp, %rax
	movq	stdout(%rip), %rdi
	leal	1(%rbp), %ecx
	movq	%r12, %rdx
	salq	$4, %rax
	addq	48(%rbx), %rax
	movl	$2, %esi
	incq	%rbp
	cvtss2sd	(%rax), %xmm0
	cvtss2sd	12(%rax), %xmm3
	cvtss2sd	8(%rax), %xmm2
	cvtss2sd	4(%rax), %xmm1
	movb	$4, %al
	call	__fprintf_chk@PLT
	jmp	.L112
.L115:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z12print_paramsP11algoparam_t, .-_Z12print_paramsP11algoparam_t
	.globl	_Z30__device_stub__Z8gpu_HeatPfS_iPfS_i
	.type	_Z30__device_stub__Z8gpu_HeatPfS_iPfS_i, @function
_Z30__device_stub__Z8gpu_HeatPfS_iPfS_i:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%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)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L116
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z8gpu_HeatPfS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	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 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L116:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L118
	call	__stack_chk_fail@PLT
.L118:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z30__device_stub__Z8gpu_HeatPfS_iPfS_i, .-_Z30__device_stub__Z8gpu_HeatPfS_iPfS_i
	.globl	_Z8gpu_HeatPfS_i
	.type	_Z8gpu_HeatPfS_i, @function
_Z8gpu_HeatPfS_i:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z8gpu_HeatPfS_iPfS_i
	.cfi_endproc
.LFE2062:
	.size	_Z8gpu_HeatPfS_i, .-_Z8gpu_HeatPfS_i
	.section	.rodata.str1.1
.LC20:
	.string	"r"
.LC21:
	.string	"\nError: Cannot open \"%s\" for reading.\n\n"
.LC22:
	.string	"w"
.LC23:
	.string	"heat.ppm"
.LC24:
	.string	"\nError: Cannot open \"%s\" for writing.\n\n"
.LC25:
	.string	"\nError: Error parsing input file.\n\n"
.LC26:
	.string	"-t"
.LC27:
	.string	"Error -- too many threads in block, try again\n"
.LC28:
	.string	"\nSolving Heat equation on the CPU and the GPU\n"
.LC29:
	.string	"--------------------------------------------\n"
.LC30:
	.string	"\nExecution on CPU (sequential)\n-----------------------------\n"
.LC31:
	.string	"Error in Solver initialization.\n\n"
.LC34:
	.string	"Time on CPU in ms.= %f "
.LC37:
	.string	"(%3.3f GFlop => %6.2f MFlop/s)\n"
.LC38:
	.string	"Convergence to residual=%f: %d iterations\n"
.LC39:
	.string	"\nExecution on GPU\n----------------\n"
.LC40:
	.string	"Number of threads per block in each dimension = %d\n"
.LC41:
	.string	"Number of blocks per grid in each dimension   = %d\n"
.LC42:
	.string	"Residual computation on GPU is ==> %f\n"
.LC43:
	.string	"\nTime on GPU in ms. = %f "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	jle	.L145
	movq	8(%rsi), %rdi
	leaq	.LC20(%rip), %rsi
	call	fopen@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	jne	.L124
	movq	8(%rbp), %rcx
	leaq	.LC21(%rip), %rdx
.L147:
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L145:
	movq	0(%rbp), %rdi
	call	_Z5usagePc
.L123:
	movl	$1, %eax
	jmp	.L121
.L124:
	leaq	.LC23(%rip), %r12
	leaq	.LC22(%rip), %rsi
	movq	%r12, %rdi
	call	fopen@PLT
	movq	%r12, %rcx
	leaq	.LC24(%rip), %rdx
	movq	%rax, %r14
	testq	%rax, %rax
	je	.L147
	leaq	96(%rsp), %rax
	movq	%rbx, %rdi
	movq	%rax, %rsi
	movq	%rax, (%rsp)
	call	_Z10read_inputP8_IO_FILEP11algoparam_t
	testl	%eax, %eax
	jne	.L127
	movq	stderr(%rip), %rdi
	leaq	.LC25(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	jmp	.L145
.L127:
	movq	16(%rbp), %rdi
	leaq	.LC26(%rip), %rsi
	movl	100(%rsp), %ebx
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L128
	movq	24(%rbp), %rdi
	call	atoi@PLT
	movl	%eax, %ebp
	imull	%eax, %eax
	cmpl	$512, %eax
	jle	.L129
	leaq	.LC27(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L123
.L128:
	movq	0(%rbp), %rcx
	movq	stderr(%rip), %rdi
	leaq	.LC2(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	stderr(%rip), %rdi
	leaq	.LC3(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	jmp	.L130
.L129:
	movq	stderr(%rip), %rdi
	leaq	.LC28(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	stderr(%rip), %rdi
	leaq	.LC29(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	(%rsp), %rdi
	call	_Z12print_paramsP11algoparam_t
	movq	stdout(%rip), %rdi
	xorl	%eax, %eax
	leaq	.LC30(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	(%rsp), %rdi
	call	_Z10initializeP11algoparam_t
	testl	%eax, %eax
	je	.L146
	leaq	40(%rsp), %rdi
	addl	$2, %ebx
	xorl	%r13d, %r13d
	call	cudaEventCreate@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
.L133:
	movq	120(%rsp), %r12
	movq	112(%rsp), %rdi
	movl	%ebx, %ecx
	movl	%ebx, %edx
	incl	%r13d
	movq	%r12, %rsi
	call	_Z10cpu_jacobiPfS_jj
	movsd	.LC32(%rip), %xmm3
	movq	%r12, 112(%rsp)
	cvtss2sd	%xmm0, %xmm2
	movq	%rdi, 120(%rsp)
	comisd	%xmm2, %xmm3
	movsd	%xmm2, 8(%rsp)
	ja	.L132
	cmpl	96(%rsp), %r13d
	jb	.L133
.L132:
	movl	%ebx, %eax
	movq	48(%rsp), %rdi
	leaq	32(%rsp), %r15
	cltd
	idivl	%ebp
	cmpl	$1, %edx
	sbbl	$-1, %eax
	xorl	%esi, %esi
	movl	%eax, %r12d
	call	cudaEventRecord@PLT
	movq	48(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	%r15, %rdi
	call	cudaEventElapsedTime@PLT
	movl	100(%rsp), %eax
	movl	$2, %esi
	movq	stdout(%rip), %rdi
	leaq	.LC34(%rip), %rdx
	cvtsi2sdq	%rax, %xmm1
	movl	%r13d, %eax
	cvtsi2sdq	%rax, %xmm0
	mulsd	.LC33(%rip), %xmm0
	movb	$1, %al
	mulsd	%xmm1, %xmm0
	mulsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm5
	cvtss2sd	32(%rsp), %xmm0
	movss	%xmm5, 20(%rsp)
	call	__fprintf_chk@PLT
	movq	stdout(%rip), %rdi
	leaq	.LC37(%rip), %rdx
	movb	$2, %al
	movl	$2, %esi
	movss	20(%rsp), %xmm1
	cvtss2sd	20(%rsp), %xmm0
	divss	32(%rsp), %xmm1
	divsd	.LC35(%rip), %xmm0
	divss	.LC36(%rip), %xmm1
	movsd	%xmm0, 24(%rsp)
	cvtss2sd	%xmm1, %xmm1
	call	__fprintf_chk@PLT
	movsd	8(%rsp), %xmm0
	movl	%r13d, %ecx
	movb	$1, %al
	movq	stdout(%rip), %rdi
	leaq	.LC38(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	(%rsp), %rdi
	call	_Z8finalizeP11algoparam_t
	movq	stdout(%rip), %rdi
	leaq	.LC39(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	stderr(%rip), %rdi
	movl	%ebp, %ecx
	xorl	%eax, %eax
	leaq	.LC40(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	xorl	%eax, %eax
	movl	%r12d, %ecx
	movl	$2, %esi
	movq	stderr(%rip), %rdi
	leaq	.LC41(%rip), %rdx
	call	__fprintf_chk@PLT
	movq	(%rsp), %rdi
	call	_Z10initializeP11algoparam_t
	testl	%eax, %eax
	jne	.L138
.L146:
	movq	stderr(%rip), %rdi
	leaq	.LC31(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	jmp	.L123
.L138:
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	movl	%r12d, 72(%rsp)
	movl	%r12d, 76(%rsp)
	leaq	_ZL12dev_residual(%rip), %r12
	movl	%ebp, 84(%rsp)
	movl	%ebp, 88(%rsp)
	xorl	%ebp, %ebp
	movl	$1, 80(%rsp)
	movl	$1, 92(%rsp)
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movl	%ebx, %eax
	leaq	56(%rsp), %rdi
	imull	%ebx, %eax
	cltq
	leaq	0(,%rax,4), %r13
	movq	%r13, %rsi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	movq	%r13, %rsi
	call	cudaMalloc@PLT
	movq	112(%rsp), %rsi
	movq	56(%rsp), %rdi
	movq	%r13, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	120(%rsp), %rsi
	movq	64(%rsp), %rdi
	movq	%r13, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$0x00000000, 8(%rsp)
.L141:
	movl	92(%rsp), %ecx
	movq	84(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	72(%rsp), %rdi
	movl	80(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L139
	movq	64(%rsp), %rsi
	movq	56(%rsp), %rdi
	movl	%ebx, %edx
	call	_Z30__device_stub__Z8gpu_HeatPfS_iPfS_i
.L139:
	call	cudaThreadSynchronize@PLT
	xorl	%ecx, %ecx
	leaq	36(%rsp), %rdi
	movq	%r12, %rsi
	movl	$2, %r8d
	movl	$4, %edx
	incl	%ebp
	call	cudaMemcpyFromSymbol@PLT
	movss	36(%rsp), %xmm0
	subss	8(%rsp), %xmm0
	movb	$1, %al
	leaq	.LC42(%rip), %rsi
	movl	$2, %edi
	cvtss2sd	%xmm0, %xmm7
	movaps	%xmm7, %xmm0
	movsd	%xmm7, 8(%rsp)
	call	__printf_chk@PLT
	movq	56(%rsp), %rax
	movq	64(%rsp), %rsi
	movsd	.LC32(%rip), %xmm2
	comisd	8(%rsp), %xmm2
	movq	%rsi, 56(%rsp)
	movq	%rax, 64(%rsp)
	ja	.L140
	cmpl	96(%rsp), %ebp
	jnb	.L140
	movss	36(%rsp), %xmm4
	movss	%xmm4, 8(%rsp)
	jmp	.L141
.L140:
	movq	112(%rsp), %rdi
	movl	$2, %ecx
	movq	%r13, %rdx
	call	cudaMemcpy@PLT
	movq	64(%rsp), %rsi
	movq	120(%rsp), %rdi
	movq	%r13, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	64(%rsp), %rdi
	call	cudaFree@PLT
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	48(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	%r15, %rdi
	call	cudaEventElapsedTime@PLT
	movq	stdout(%rip), %rdi
	leaq	.LC43(%rip), %rdx
	movb	$1, %al
	movl	$2, %esi
	cvtss2sd	32(%rsp), %xmm0
	call	__fprintf_chk@PLT
	movsd	24(%rsp), %xmm0
	movl	$2, %esi
	movq	stdout(%rip), %rdi
	leaq	.LC37(%rip), %rdx
	movb	$2, %al
	movss	20(%rsp), %xmm1
	divss	32(%rsp), %xmm1
	divss	.LC36(%rip), %xmm1
	cvtss2sd	%xmm1, %xmm1
	call	__fprintf_chk@PLT
	movl	%ebp, %ecx
	movsd	8(%rsp), %xmm0
	movq	stdout(%rip), %rdi
	leaq	.LC38(%rip), %rdx
	movb	$1, %al
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	40(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movq	48(%rsp), %rdi
	call	cudaEventDestroy@PLT
	movl	108(%rsp), %eax
	movq	112(%rsp), %rdi
	movl	%ebx, %edx
	movq	128(%rsp), %rbp
	movl	%ebx, %esi
	leal	2(%rax), %r8d
	movl	%r8d, %r9d
	movq	%rbp, %rcx
	call	_Z7coarsenPfjjS_jj
	movq	%r14, %rdi
	movl	%r8d, %ecx
	movl	%r8d, %edx
	movq	%rbp, %rsi
	call	_Z11write_imageP8_IO_FILEPfjj
	movq	(%rsp), %rdi
	call	_Z8finalizeP11algoparam_t
.L130:
	xorl	%eax, %eax
.L121:
	movq	152(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L142
	call	__stack_chk_fail@PLT
.L142:
	addq	$168, %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
.LFE2030:
	.size	main, .-main
	.section	.rodata.str1.1
.LC44:
	.string	"_Z8gpu_HeatPfS_i"
.LC45:
	.string	"dev_residual"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2064:
	.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	.LC44(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z8gpu_HeatPfS_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC45(%rip), %rdx
	movl	$4, %r9d
	leaq	_ZL12dev_residual(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	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
.LFE2064:
	.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	_ZL12dev_residual
	.comm	_ZL12dev_residual,4,4
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC1:
	.long	1048576000
	.align 4
.LC5:
	.long	1065353216
	.align 4
.LC6:
	.long	-8388608
	.align 4
.LC7:
	.long	2139095040
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC11:
	.long	0
	.long	1083179008
	.align 8
.LC32:
	.long	-350469331
	.long	1057634018
	.align 8
.LC33:
	.long	0
	.long	1076232192
	.align 8
.LC35:
	.long	0
	.long	1104006501
	.section	.rodata.cst4
	.align 4
.LC36:
	.long	1148846080
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <string.h> /* needed library to use strcmp function */
#include <hip/hip_runtime.h>

typedef struct {
    float posx;
    float posy;
    float range;
    float temp;
} heatsrc_t;

typedef struct {
    unsigned maxiter; /* maximum number of iterations */
    unsigned resolution; /* spatial resolution */
    int algorithm; /* 0=>Jacobi, 1=>Gauss */

    unsigned visres; /* visualization resolution */

    float *u, *uhelp;
    float *uvis;

    unsigned numsrcs; /* number of heat sources */
    heatsrc_t *heatsrcs;
} algoparam_t;

/* function declarations */
int read_input(FILE *infile, algoparam_t *param);
void print_params(algoparam_t *param);
int initialize(algoparam_t *param);
int finalize(algoparam_t *param);
void write_image(FILE * f, float *u, unsigned sizex, unsigned sizey);
int coarsen(float *uold, unsigned oldx, unsigned oldy, float *unew,
        unsigned newx, unsigned newy);

__device__ float dev_residual = 0.0;

__global__ void gpu_Heat(float *h, float *g, int N) {
    /* In this case, the stride is N */

    int i = blockIdx.y * blockDim.y + threadIdx.y;
    int j = blockIdx.x * blockDim.x + threadIdx.x;

    /* Assert if current thread belongs to first row or column of input matrix */
    bool is_first_row = threadIdx.y == 0 && blockIdx.y == 0;
    bool is_first_col = threadIdx.x == 0 && blockIdx.x == 0;

    if (i < N - 1 && j < N - 1 && !is_first_row && !is_first_col) {
        int pos = i * N + j;
        g[pos] = 0.25 * (h[pos - 1] + h[pos - N] + h[pos + 1] + h[pos + N]);
        float diff = g[pos] - h[pos];
        atomicAdd(&dev_residual, diff * diff);
    }
}

#define NB 8
#define min(a,b) ( ((a) < (b)) ? (a) : (b) )

float cpu_residual(float *u, float *utmp, unsigned sizex, unsigned sizey) {
    float diff, sum = 0.0;

    for (int i = 1; i < sizex - 1; i++)
        for (int j = 1; j < sizey - 1; j++) {
            diff = utmp[i * sizey + j] - u[i * sizey + j];
            sum += diff * diff;
        }
    return (sum);
}

float cpu_jacobi(float *u, float *utmp, unsigned sizex, unsigned sizey) {
    float diff, sum = 0.0;
    int nbx, bx, nby, by;

    nbx = NB;
    bx = sizex / nbx;
    nby = NB;
    by = sizey / nby;
    for (int ii = 0; ii < nbx; ii++)
        for (int jj = 0; jj < nby; jj++)
            for (int i = 1 + ii * bx; i <= min((ii+1)*bx, sizex-2); i++)
                for (int j = 1 + jj * by; j <= min((jj+1)*by, sizey-2); j++) {
                    utmp[i * sizey + j] = 0.25 * (u[i * sizey + (j - 1)] + /* left */
                            u[i * sizey + (j + 1)] + /* right */
                            u[(i - 1) * sizey + j] + /* top */
                            u[(i + 1) * sizey + j]); /* bottom */
                    diff = utmp[i * sizey + j] - u[i * sizey + j];
                    sum += diff * diff;
                }
    return (sum);
}

void usage(char *s) {
    fprintf(stderr, "Usage: %s <input file> -t threads -b blocks\n", s);
    fprintf(stderr,
            "       -t number of threads per block in each dimension (e.g. 16)\n");
}

int main(int argc, char *argv[]) {
    unsigned iter;
    FILE *infile, *resfile;
    char *resfilename;

    /* algorithmic parameters */
    algoparam_t param;
    int np;

    /* check arguments */
    if (argc < 4) {
        usage(argv[0]);
        return 1;
    }

    /* check input file */
    if (!(infile = fopen(argv[1], "r"))) {
        fprintf(stderr, "\nError: Cannot open \"%s\" for reading.\n\n",
                argv[1]);

        usage(argv[0]);
        return 1;
    }

    /* check result file */
    resfilename = "heat.ppm";

    if (!(resfile = fopen(resfilename, "w"))) {
        fprintf(stderr, "\nError: Cannot open \"%s\" for writing.\n\n",
                resfilename);
        usage(argv[0]);
        return 1;
    }

    /* check input */
    if (!read_input(infile, &param)) {
        fprintf(stderr, "\nError: Error parsing input file.\n\n");
        usage(argv[0]);
        return 1;
    }

    /* full size (param.resolution are only the inner points) */
    np = param.resolution + 2;

    int Grid_Dim, Block_Dim; /* Grid and Block structure values */
    if (strcmp(argv[2], "-t") == 0) {
        Block_Dim = atoi(argv[3]);
        Grid_Dim = np / Block_Dim + ((np % Block_Dim) != 0);
        ;
        if ((Block_Dim * Block_Dim) > 512) {
            printf("Error -- too many threads in block, try again\n");
            return 1;
        }
    } else {
        fprintf(stderr, "Usage: %s <input file> -t threads -b blocks\n",
                argv[0]);
        fprintf(stderr,
                "       -t number of threads per block in each dimension (e.g. 16)\n");
        return 0;
    }

    fprintf(stderr, "\nSolving Heat equation on the CPU and the GPU\n");
    fprintf(stderr, "--------------------------------------------\n");
    print_params(&param);

    fprintf(stdout,
            "\nExecution on CPU (sequential)\n-----------------------------\n");
    if (!initialize(&param)) {
        fprintf(stderr, "Error in Solver initialization.\n\n");
        return 1;
    }

    /* starting time */
    float elapsed_time_ms; /* which is applicable for asynchronous code also */
    hipEvent_t start, stop; /* using cuda events to measure time */
    hipEventCreate(&start); /* instrument code to measure start time */
    hipEventCreate(&stop);

    hipEventRecord(start, 0);
    hipEventSynchronize(start);

    iter = 0;
    float residual;
    while (1) {
        residual = cpu_jacobi(param.u, param.uhelp, np, np);
        float * tmp = param.u;
        param.u = param.uhelp;
        param.uhelp = tmp;

        iter++;

        /* solution good enough ? */
        if (residual < 0.00005)
            break;

        /* max. iteration reached ? (no limit with maxiter=0) */
        if (iter >= param.maxiter)
            break;
    }

    hipEventRecord(stop, 0); /* instrument code to measue end time */
    hipEventSynchronize(stop);
    hipEventElapsedTime(&elapsed_time_ms, start, stop);

    /* Flop count after iter iterations */
    float flop = iter * 11.0 * param.resolution * param.resolution;

    fprintf(stdout, "Time on CPU in ms.= %f ", elapsed_time_ms);
    fprintf(stdout, "(%3.3f GFlop => %6.2f MFlop/s)\n", flop / 1000000000.0,
            flop / elapsed_time_ms / 1000);
    fprintf(stdout, "Convergence to residual=%f: %d iterations\n", residual,
            iter);

    finalize(&param);

    fprintf(stdout, "\nExecution on GPU\n----------------\n");
    fprintf(stderr, "Number of threads per block in each dimension = %d\n",
            Block_Dim);
    fprintf(stderr, "Number of blocks per grid in each dimension   = %d\n",
            Grid_Dim);

    if (!initialize(&param)) {
        fprintf(stderr, "Error in Solver initialization.\n\n");
        return 1;
    }

    dim3 Grid(Grid_Dim, Grid_Dim);
    dim3 Block(Block_Dim, Block_Dim);

    /* starting time */
    hipEventRecord(start, 0);
    hipEventSynchronize(start);

    float *dev_u, *dev_uhelp;

    /* Allocation on GPU for matrices u and uhelp */
    size_t size = np * np * sizeof(float);
    hipMalloc(&dev_u, size);
    hipMalloc(&dev_uhelp, size);

    /* Copy initial values in u and uhelp from host to GPU */
    hipMemcpy(dev_u, param.u, size, hipMemcpyHostToDevice);
    hipMemcpy(dev_uhelp, param.uhelp, size, hipMemcpyHostToDevice);

    iter = 0;
    residual = 0.0;
    float residual_aux = 0.0, residual_acc;
    while (1) {
        if (iter > 0) {
            residual_aux = residual_acc;
        }
        gpu_Heat<<<Grid, Block>>>(dev_u, dev_uhelp, np);
        hipDeviceSynchronize(); /* wait for all threads to complete */

        /* residual is computed on host, we need to get from GPU values computed in u and uhelp */
        /* cudaMemcpy(param.u, dev_u, size, cudaMemcpyDeviceToHost); */
        /* cudaMemcpy(param.uhelp, dev_uhelp, size, cudaMemcpyDeviceToHost); */

        /* residual = cpu_residual (param.u, param.uhelp, np, np); */

        /* printf("Residual computation on GPU is ==> %f\n", residual); */

        /* Get the residual computation from global memory (on device)
         * and copy it into residual variable (host memory)
         */
        hipMemcpyFromSymbol(&residual_acc, HIP_SYMBOL(dev_residual), sizeof(float), 0, hipMemcpyDeviceToHost);
        /* printf("Acumulate Residual computation on GPU is ==> %f\n", residual_acc); */

        /* Update the value of residual */
        residual = residual_acc - residual_aux;
        printf("Residual computation on GPU is ==> %f\n", residual);

        float * tmp = dev_u;
        dev_u = dev_uhelp;
        dev_uhelp = tmp;

        iter++;

        /* solution good enough ? */
        if (residual < 0.00005)
            break;

        /* max. iteration reached ? (no limit with maxiter=0) */
        if (iter >= param.maxiter)
            break;
    }

    /* get result matrix from GPU */
    hipMemcpy(param.u, dev_u, size, hipMemcpyDeviceToHost);
    hipMemcpy(param.uhelp, dev_uhelp, size, hipMemcpyDeviceToHost);

    /* free memory used in GPU */
    hipFree(dev_u);
    hipFree(dev_uhelp);

    hipEventRecord( stop, 0 ); /* instrument code to measue end time */
    hipEventSynchronize(stop);
    hipEventElapsedTime(&elapsed_time_ms, start, stop);

    fprintf(stdout, "\nTime on GPU in ms. = %f ", elapsed_time_ms);
    fprintf(stdout, "(%3.3f GFlop => %6.2f MFlop/s)\n", flop / 1000000000.0,
            flop / elapsed_time_ms / 1000);
    fprintf(stdout, "Convergence to residual=%f: %d iterations\n", residual,
            iter);

    hipEventDestroy(start);
    hipEventDestroy(stop);

    /* for plot... */
    coarsen(param.u, np, np, param.uvis, param.visres + 2, param.visres + 2);

    write_image(resfile, param.uvis, param.visres + 2, param.visres + 2);

    finalize(&param);

    return 0;
}

/*
 * Initialize the iterative solver
 * - allocate memory for matrices
 * - set boundary conditions according to configuration
 */
int initialize(algoparam_t *param)

{
    int i, j;
    float dist;

    /* total number of points (including border) */
    const int np = param->resolution + 2;

    /* allocate memory */
    (param->u) = (float*) calloc(sizeof(float), np * np);
    (param->uhelp) = (float*) calloc(sizeof(float), np * np);
    (param->uvis) = (float*) calloc(sizeof(float),
            (param->visres + 2) * (param->visres + 2));

    if (!(param->u) || !(param->uhelp) || !(param->uvis)) {
        fprintf(stderr, "Error: Cannot allocate memory\n");
        return 0;
    }

    for (i = 0; i < param->numsrcs; i++) {
        /* top row */
        for (j = 0; j < np; j++) {
            dist = sqrt(
                    pow((float) j / (float) (np - 1) - param->heatsrcs[i].posx,
                            2) + pow(param->heatsrcs[i].posy, 2));

            if (dist <= param->heatsrcs[i].range) {
                (param->u)[j] += (param->heatsrcs[i].range - dist)
                        / param->heatsrcs[i].range * param->heatsrcs[i].temp;
            }
        }

        /* bottom row */
        for (j = 0; j < np; j++) {
            dist = sqrt(
                    pow((float) j / (float) (np - 1) - param->heatsrcs[i].posx,
                            2) + pow(1 - param->heatsrcs[i].posy, 2));

            if (dist <= param->heatsrcs[i].range) {
                (param->u)[(np - 1) * np + j] += (param->heatsrcs[i].range
                        - dist) / param->heatsrcs[i].range
                        * param->heatsrcs[i].temp;
            }
        }

        /* leftmost column */
        for (j = 1; j < np - 1; j++) {
            dist = sqrt(
                    pow(param->heatsrcs[i].posx, 2)
                            + pow(
                                    (float) j / (float) (np - 1)
                                            - param->heatsrcs[i].posy, 2));

            if (dist <= param->heatsrcs[i].range) {
                (param->u)[j * np] += (param->heatsrcs[i].range - dist)
                        / param->heatsrcs[i].range * param->heatsrcs[i].temp;
            }
        }

        /* rightmost column */
        for (j = 1; j < np - 1; j++) {
            dist = sqrt(
                    pow(1 - param->heatsrcs[i].posx, 2)
                            + pow(
                                    (float) j / (float) (np - 1)
                                            - param->heatsrcs[i].posy, 2));

            if (dist <= param->heatsrcs[i].range) {
                (param->u)[j * np + (np - 1)] += (param->heatsrcs[i].range
                        - dist) / param->heatsrcs[i].range
                        * param->heatsrcs[i].temp;
            }
        }
    }

    /* Copy u into uhelp */
    float *putmp, *pu;
    pu = param->u;
    putmp = param->uhelp;
    for (j = 0; j < np; j++)
        for (i = 0; i < np; i++)
            *putmp++ = *pu++;

    return 1;
}

/* free used memory */
int finalize(algoparam_t *param) {
    if (param->u) {
        free(param->u);
        param->u = 0;
    }

    if (param->uhelp) {
        free(param->uhelp);
        param->uhelp = 0;
    }

    if (param->uvis) {
        free(param->uvis);
        param->uvis = 0;
    }

    return 1;
}

/*
 * write the given temperature u matrix to rgb values
 * and write the resulting image to file f
 */
void write_image(FILE * f, float *u, unsigned sizex, unsigned sizey) {
    /* RGB table */
    unsigned char r[1024], g[1024], b[1024];
    int i, j, k;

    float min, max;

    j = 1023;

    /* prepare RGB table */
    for (i = 0; i < 256; i++) {
        r[j] = 255;
        g[j] = i;
        b[j] = 0;
        j--;
    }
    for (i = 0; i < 256; i++) {
        r[j] = 255 - i;
        g[j] = 255;
        b[j] = 0;
        j--;
    }
    for (i = 0; i < 256; i++) {
        r[j] = 0;
        g[j] = 255;
        b[j] = i;
        j--;
    }
    for (i = 0; i < 256; i++) {
        r[j] = 0;
        g[j] = 255 - i;
        b[j] = 255;
        j--;
    }

    min = DBL_MAX;
    max = -DBL_MAX;

    /* find minimum and maximum */
    for (i = 0; i < sizey; i++) {
        for (j = 0; j < sizex; j++) {
            if (u[i * sizex + j] > max)
                max = u[i * sizex + j];
            if (u[i * sizex + j] < min)
                min = u[i * sizex + j];
        }
    }

    fprintf(f, "P3\n");
    fprintf(f, "%u %u\n", sizex, sizey);
    fprintf(f, "%u\n", 255);

    for (i = 0; i < sizey; i++) {
        for (j = 0; j < sizex; j++) {
            k = (int) (1024.0 * (u[i * sizex + j] - min) / (max - min));
            fprintf(f, "%d %d %d  ", r[k], g[k], b[k]);
        }
        fprintf(f, "\n");
    }
}

int coarsen(float *uold, unsigned oldx, unsigned oldy, float *unew,
        unsigned newx, unsigned newy) {
    int i, j;

    int stepx;
    int stepy;
    int stopx = newx;
    int stopy = newy;

    if (oldx > newx)
        stepx = oldx / newx;
    else {
        stepx = 1;
        stopx = oldx;
    }
    if (oldy > newy)
        stepy = oldy / newy;
    else {
        stepy = 1;
        stopy = oldy;
    }

    /* NOTE: this only takes the top-left corner,
     * and doesnt' do any real coarsening
     */
    for (i = 0; i < stopy - 1; i++) {
        for (j = 0; j < stopx - 1; j++) {
            unew[i * newx + j] = uold[i * oldx * stepy + j * stepx];
        }
    }

    return 1;
}

#define BUFSIZE 100
int read_input(FILE *infile, algoparam_t *param) {
    int i, n;
    char buf[BUFSIZE];

    fgets(buf, BUFSIZE, infile);
    n = sscanf(buf, "%u", &(param->maxiter));
    if (n != 1)
        return 0;

    fgets(buf, BUFSIZE, infile);
    n = sscanf(buf, "%u", &(param->resolution));
    if (n != 1)
        return 0;

    param->visres = param->resolution;

    fgets(buf, BUFSIZE, infile);
    n = sscanf(buf, "%u", &(param->numsrcs));
    if (n != 1)
        return 0;

    (param->heatsrcs) = (heatsrc_t*) malloc(
            sizeof(heatsrc_t) * (param->numsrcs));

    for (i = 0; i < param->numsrcs; i++) {
        fgets(buf, BUFSIZE, infile);
        n = sscanf(buf, "%f %f %f %f", &(param->heatsrcs[i].posx),
                &(param->heatsrcs[i].posy), &(param->heatsrcs[i].range),
                &(param->heatsrcs[i].temp));

        if (n != 4)
            return 0;
    }

    return 1;
}

void print_params(algoparam_t *param) {
    int i;

    fprintf(stdout, "Iterations        : %u\n", param->maxiter);
    fprintf(stdout, "Resolution        : %u\n", param->resolution);
    fprintf(stdout, "Num. Heat sources : %u\n", param->numsrcs);

    for (i = 0; i < param->numsrcs; i++) {
        fprintf(stdout, "  %2d: (%2.2f, %2.2f) %2.2f %2.2f \n", i + 1,
                param->heatsrcs[i].posx, param->heatsrcs[i].posy,
                param->heatsrcs[i].range, param->heatsrcs[i].temp);
    }
}


	.text
	.file	"heatCUDA.hip"
	.globl	_Z23__device_stub__gpu_HeatPfS_i # -- Begin function _Z23__device_stub__gpu_HeatPfS_i
	.type	_Z23__device_stub__gpu_HeatPfS_i,@function
_Z23__device_stub__gpu_HeatPfS_i:       # @_Z23__device_stub__gpu_HeatPfS_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z8gpu_HeatPfS_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z23__device_stub__gpu_HeatPfS_i, .Lfunc_end0-_Z23__device_stub__gpu_HeatPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z12cpu_residualPfS_jj          # -- Begin function _Z12cpu_residualPfS_jj
	.type	_Z12cpu_residualPfS_jj,@function
_Z12cpu_residualPfS_jj:                 # @_Z12cpu_residualPfS_jj
	.cfi_startproc
# %bb.0:
                                        # kill: def $ecx killed $ecx def $rcx
	decl	%edx
	xorps	%xmm0, %xmm0
	cmpl	$2, %edx
	jb	.LBB1_5
# %bb.1:                                # %.preheader.lr.ph
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	leal	-1(%rcx), %eax
	leal	1(%rcx), %r8d
	leaq	-1(%rax), %r9
	xorps	%xmm0, %xmm0
	movl	$1, %r10d
.LBB1_2:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_6 Depth 2
	movq	%r9, %r11
	movl	%r8d, %ebx
	cmpl	$2, %eax
	jb	.LBB1_3
.LBB1_6:                                #   Parent Loop BB1_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ebx, %r14d
	movss	(%rsi,%r14,4), %xmm1            # xmm1 = mem[0],zero,zero,zero
	subss	(%rdi,%r14,4), %xmm1
	mulss	%xmm1, %xmm1
	addss	%xmm1, %xmm0
	incl	%ebx
	decq	%r11
	jne	.LBB1_6
.LBB1_3:                                # %._crit_edge
                                        #   in Loop: Header=BB1_2 Depth=1
	incl	%r10d
	addl	%ecx, %r8d
	cmpl	%edx, %r10d
	jne	.LBB1_2
# %bb.4:
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
.LBB1_5:                                # %._crit_edge23
	retq
.Lfunc_end1:
	.size	_Z12cpu_residualPfS_jj, .Lfunc_end1-_Z12cpu_residualPfS_jj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z10cpu_jacobiPfS_jj
.LCPI2_0:
	.long	0x3e800000                      # float 0.25
	.text
	.globl	_Z10cpu_jacobiPfS_jj
	.type	_Z10cpu_jacobiPfS_jj,@function
_Z10cpu_jacobiPfS_jj:                   # @_Z10cpu_jacobiPfS_jj
	.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
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
                                        # kill: def $ecx killed $ecx def $rcx
	movl	%edx, %eax
	shrl	$3, %eax
	movl	%ecx, %r8d
	shrl	$3, %r8d
	addl	$-2, %edx
	movl	%edx, -64(%rsp)                 # 4-byte Spill
	leal	-2(%rcx), %edx
	movl	%edx, -48(%rsp)                 # 4-byte Spill
	movl	%ecx, %edx
	movl	%eax, -68(%rsp)                 # 4-byte Spill
	imull	%eax, %edx
	movl	%edx, -72(%rsp)                 # 4-byte Spill
	leal	1(,%rcx,2), %edx
	xorps	%xmm0, %xmm0
	xorl	%r9d, %r9d
	movl	$1, %eax
	movss	.LCPI2_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	movl	%ecx, %r14d
	movq	%r8, -8(%rsp)                   # 8-byte Spill
.LBB2_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_2 Depth 2
                                        #       Child Loop BB2_10 Depth 3
                                        #         Child Loop BB2_12 Depth 4
	movl	%r9d, %r15d
	movl	%eax, %r10d
	movl	-68(%rsp), %eax                 # 4-byte Reload
	imull	%eax, %r15d
	incl	%r9d
	movq	%r9, -16(%rsp)                  # 8-byte Spill
	movl	%r9d, %r12d
	imull	%eax, %r12d
	movl	-64(%rsp), %eax                 # 4-byte Reload
	cmpl	%eax, %r12d
	cmovael	%eax, %r12d
	movl	%r10d, -56(%rsp)                # 4-byte Spill
	movl	%edx, -52(%rsp)                 # 4-byte Spill
	movl	%edx, %r9d
	movl	%r14d, -60(%rsp)                # 4-byte Spill
	xorl	%eax, %eax
	movq	%rax, -24(%rsp)                 # 8-byte Spill
	xorl	%eax, %eax
	movl	%r15d, -44(%rsp)                # 4-byte Spill
.LBB2_2:                                #   Parent Loop BB2_1 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB2_10 Depth 3
                                        #         Child Loop BB2_12 Depth 4
	cmpl	%r12d, %r15d
	jae	.LBB2_3
# %bb.9:                                # %.lr.ph78
                                        #   in Loop: Header=BB2_2 Depth=2
	movl	%eax, %ebx
	imull	%r8d, %ebx
	incl	%eax
	movl	%eax, -40(%rsp)                 # 4-byte Spill
	movl	%eax, %ebp
	imull	%r8d, %ebp
	movl	-48(%rsp), %eax                 # 4-byte Reload
	cmpl	%eax, %ebp
	cmovael	%eax, %ebp
	movl	%r10d, -28(%rsp)                # 4-byte Spill
	movl	%r10d, %edx
	movl	%r9d, -32(%rsp)                 # 4-byte Spill
	movl	%r14d, -36(%rsp)                # 4-byte Spill
	movl	%r15d, %r8d
.LBB2_10:                               #   Parent Loop BB2_1 Depth=1
                                        #     Parent Loop BB2_2 Depth=2
                                        # =>    This Loop Header: Depth=3
                                        #         Child Loop BB2_12 Depth 4
	cmpl	%ebp, %ebx
	jae	.LBB2_6
# %bb.11:                               # %.lr.ph
                                        #   in Loop: Header=BB2_10 Depth=3
	movl	%edx, %r13d
	movl	%r9d, %r11d
	movl	%r14d, %eax
	movq	-24(%rsp), %r10                 # 8-byte Reload
.LBB2_12:                               #   Parent Loop BB2_1 Depth=1
                                        #     Parent Loop BB2_2 Depth=2
                                        #       Parent Loop BB2_10 Depth=3
                                        # =>      This Inner Loop Header: Depth=4
	movl	%eax, %r15d
	movss	(%rdi,%r15,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	leal	2(%rax), %r15d
	addss	(%rdi,%r15,4), %xmm2
	movl	%r13d, %r15d
	addss	(%rdi,%r15,4), %xmm2
	movl	%r11d, %r15d
	addss	(%rdi,%r15,4), %xmm2
	mulss	%xmm1, %xmm2
	incl	%eax
	movss	%xmm2, (%rsi,%rax,4)
	subss	(%rdi,%rax,4), %xmm2
	mulss	%xmm2, %xmm2
	addss	%xmm2, %xmm0
	incq	%r10
	incl	%r11d
	incl	%r13d
	cmpq	%rbp, %r10
	jb	.LBB2_12
.LBB2_6:                                # %.loopexit
                                        #   in Loop: Header=BB2_10 Depth=3
	incl	%r8d
	addl	%ecx, %r14d
	addl	%ecx, %r9d
	addl	%ecx, %edx
	cmpl	%r12d, %r8d
	jb	.LBB2_10
# %bb.7:                                #   in Loop: Header=BB2_2 Depth=2
	movq	-8(%rsp), %r8                   # 8-byte Reload
	movl	-44(%rsp), %r15d                # 4-byte Reload
	movl	-28(%rsp), %r10d                # 4-byte Reload
	movl	-32(%rsp), %r9d                 # 4-byte Reload
	movl	-36(%rsp), %r14d                # 4-byte Reload
	movl	-40(%rsp), %eax                 # 4-byte Reload
	jmp	.LBB2_8
.LBB2_3:                                # %.._crit_edge_crit_edge
                                        #   in Loop: Header=BB2_2 Depth=2
	incl	%eax
.LBB2_8:                                # %._crit_edge
                                        #   in Loop: Header=BB2_2 Depth=2
	addq	%r8, -24(%rsp)                  # 8-byte Folded Spill
	addl	%r8d, %r14d
	addl	%r8d, %r9d
	addl	%r8d, %r10d
	cmpl	$8, %eax
	jne	.LBB2_2
# %bb.4:                                #   in Loop: Header=BB2_1 Depth=1
	movl	-72(%rsp), %eax                 # 4-byte Reload
	movl	-60(%rsp), %r14d                # 4-byte Reload
	addl	%eax, %r14d
	movl	-52(%rsp), %edx                 # 4-byte Reload
	addl	%eax, %edx
	movl	-56(%rsp), %r9d                 # 4-byte Reload
	addl	%eax, %r9d
	movl	%r9d, %eax
	movq	-16(%rsp), %r9                  # 8-byte Reload
	cmpl	$8, %r9d
	jne	.LBB2_1
# %bb.5:
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z10cpu_jacobiPfS_jj, .Lfunc_end2-_Z10cpu_jacobiPfS_jj
	.cfi_endproc
                                        # -- End function
	.globl	_Z5usagePc                      # -- Begin function _Z5usagePc
	.type	_Z5usagePc,@function
_Z5usagePc:                             # @_Z5usagePc
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movq	%rdi, %rdx
	movq	stderr(%rip), %rdi
	movl	$.L.str, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rcx
	movl	$.L.str.1, %edi
	movl	$66, %esi
	movl	$1, %edx
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	fwrite@PLT                      # TAILCALL
.Lfunc_end3:
	.size	_Z5usagePc, .Lfunc_end3-_Z5usagePc
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI4_0:
	.quad	0x3f0a36e2eb1c432d              # double 5.0000000000000002E-5
.LCPI4_1:
	.quad	0x4026000000000000              # double 11
.LCPI4_2:
	.quad	0x41cdcd6500000000              # double 1.0E+9
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0
.LCPI4_3:
	.long	0x447a0000                      # float 1000
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.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	$136, %rsp
	.cfi_def_cfa_offset 192
	.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, %r14
	cmpl	$3, %edi
	jle	.LBB4_11
# %bb.1:
	movq	8(%r14), %rdi
	movl	$.L.str.2, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB4_7
# %bb.2:
	movq	%rax, %r15
	movl	$.L.str.4, %edi
	movl	$.L.str.5, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB4_8
# %bb.3:
	movq	%rax, %rbx
	leaq	64(%rsp), %rsi
	movq	%r15, %rdi
	callq	_Z10read_inputP8_IO_FILEP11algoparam_t
	testl	%eax, %eax
	je	.LBB4_10
# %bb.4:
	movl	68(%rsp), %ebp
	movq	16(%r14), %rdi
	movl	$.L.str.8, %esi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB4_15
# %bb.5:
	addl	$2, %ebp
	movq	24(%r14), %rdi
	callq	atoi
	movl	%eax, %r15d
	movl	%ebp, %eax
	cltd
	idivl	%r15d
	movl	%eax, %r12d
	cmpl	$1, %edx
	sbbl	$-1, %r12d
	movl	%r15d, %eax
	imull	%r15d, %eax
	cmpl	$513, %eax                      # imm = 0x201
	jb	.LBB4_16
# %bb.6:
	movl	$.Lstr, %edi
	callq	puts@PLT
	jmp	.LBB4_13
.LBB4_7:
	movq	stderr(%rip), %rdi
	movq	8(%r14), %rdx
	movl	$.L.str.3, %esi
	jmp	.LBB4_9
.LBB4_8:
	movq	stderr(%rip), %rdi
	movl	$.L.str.6, %esi
	movl	$.L.str.4, %edx
.LBB4_9:
	xorl	%eax, %eax
	callq	fprintf
	jmp	.LBB4_11
.LBB4_10:
	movq	stderr(%rip), %rcx
	movl	$.L.str.7, %edi
	movl	$35, %esi
	movl	$1, %edx
	callq	fwrite@PLT
.LBB4_11:
	movq	(%r14), %rdx
	movq	stderr(%rip), %rdi
	movl	$.L.str, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rcx
	movl	$.L.str.1, %edi
	movl	$66, %esi
.LBB4_12:
	movl	$1, %edx
	callq	fwrite@PLT
.LBB4_13:
	movl	$1, %r15d
.LBB4_14:
	movl	%r15d, %eax
	addq	$136, %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
.LBB4_15:
	.cfi_def_cfa_offset 192
	movq	stderr(%rip), %rdi
	movq	(%r14), %rdx
	xorl	%r15d, %r15d
	movl	$.L.str, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rcx
	movl	$.L.str.1, %edi
	movl	$66, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	jmp	.LBB4_14
.LBB4_16:
	movq	stderr(%rip), %rcx
	movl	$.L.str.10, %edi
	movl	$46, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movq	stderr(%rip), %rcx
	movl	$.L.str.11, %edi
	movl	$45, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	leaq	64(%rsp), %r14
	movq	%r14, %rdi
	callq	_Z12print_paramsP11algoparam_t
	movq	stdout(%rip), %rcx
	movl	$.L.str.12, %edi
	movl	$61, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movq	%r14, %rdi
	callq	_Z10initializeP11algoparam_t
	testl	%eax, %eax
	jne	.LBB4_18
.LBB4_17:
	movq	stderr(%rip), %rcx
	movl	$.L.str.13, %edi
	movl	$33, %esi
	jmp	.LBB4_12
.LBB4_18:
	leaq	32(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	movq	%rsp, %rdi
	callq	hipEventCreate
	movq	(%r14), %rdi
	xorl	%r13d, %r13d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%r14), %rdi
	callq	hipEventSynchronize
	movq	80(%rsp), %rdi
	movq	88(%rsp), %rsi
.LBB4_19:                               # =>This Inner Loop Header: Depth=1
	movl	%ebp, %edx
	movl	%ebp, %ecx
	callq	_Z10cpu_jacobiPfS_jj
	movq	80(%rsp), %rsi
	movq	88(%rsp), %rdi
	movq	%rdi, 80(%rsp)
	movq	%rsi, 88(%rsp)
	incl	%r13d
	xorps	%xmm1, %xmm1
	cvtss2sd	%xmm0, %xmm1
	movsd	.LCPI4_0(%rip), %xmm0           # xmm0 = mem[0],zero
	ucomisd	%xmm1, %xmm0
	ja	.LBB4_21
# %bb.20:                               #   in Loop: Header=BB4_19 Depth=1
	cmpl	64(%rsp), %r13d
	jb	.LBB4_19
.LBB4_21:
	movq	(%rsp), %rdi
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	movsd	%xmm1, 56(%rsp)                 # 8-byte Spill
	callq	hipEventRecord
	movq	(%rsp), %rdi
	callq	hipEventSynchronize
	movq	32(%rsp), %rsi
	movq	(%rsp), %rdx
	leaq	12(%rsp), %rdi
	callq	hipEventElapsedTime
	movl	%r13d, %eax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	mulsd	.LCPI4_1(%rip), %xmm0
	leaq	64(%rsp), %rax
	movl	4(%rax), %eax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	mulsd	%xmm1, %xmm0
	mulsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	movss	%xmm0, 44(%rsp)                 # 4-byte Spill
	movq	stdout(%rip), %rdi
	leaq	12(%rsp), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rax), %xmm0
	movl	$.L.str.14, %esi
	movb	$1, %al
	callq	fprintf
	movss	44(%rsp), %xmm1                 # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	xorps	%xmm0, %xmm0
	cvtss2sd	%xmm1, %xmm0
	divsd	.LCPI4_2(%rip), %xmm0
	leaq	12(%rsp), %rax
	divss	(%rax), %xmm1
	movq	stdout(%rip), %rdi
	divss	.LCPI4_3(%rip), %xmm1
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.15, %esi
	movsd	%xmm0, 128(%rsp)                # 8-byte Spill
	movb	$2, %al
	callq	fprintf
	movq	stdout(%rip), %rdi
	movl	$.L.str.16, %esi
	movsd	56(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movl	%r13d, %edx
	movb	$1, %al
	callq	fprintf
	leaq	64(%rsp), %r13
	movq	%r13, %rdi
	callq	_Z8finalizeP11algoparam_t
	movq	stdout(%rip), %rcx
	movl	$.L.str.17, %edi
	movl	$35, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movq	stderr(%rip), %rdi
	movl	$.L.str.18, %esi
	movl	%r15d, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.19, %esi
	movl	%r12d, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	%r13, %rdi
	callq	_Z10initializeP11algoparam_t
	testl	%eax, %eax
	je	.LBB4_17
# %bb.22:
	movl	%r12d, %eax
	movq	%rax, %r12
	shlq	$32, %r12
	orq	%rax, %r12
	movl	%r15d, %eax
	movq	%rax, %r13
	shlq	$32, %r13
	orq	%rax, %r13
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	32(%rsp), %rdi
	callq	hipEventSynchronize
	movl	%ebp, %r15d
	imull	%r15d, %r15d
	shlq	$2, %r15
	leaq	24(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	16(%rsp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	24(%rsp), %rax
	movq	(%rax), %rdi
	movq	80(%rsp), %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	16(%rsp), %rax
	movq	(%rax), %rdi
	movq	88(%rsp), %rsi
	movq	%r15, 120(%rsp)                 # 8-byte Spill
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	xorpd	%xmm0, %xmm0
	movss	%xmm0, 48(%rsp)                 # 4-byte Spill
	leaq	52(%rsp), %r15
.LBB4_23:                               # =>This Inner Loop Header: Depth=1
	testl	%r14d, %r14d
	je	.LBB4_25
# %bb.24:                               #   in Loop: Header=BB4_23 Depth=1
	movss	52(%rsp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 48(%rsp)                 # 4-byte Spill
.LBB4_25:                               #   in Loop: Header=BB4_23 Depth=1
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_27
# %bb.26:                               #   in Loop: Header=BB4_23 Depth=1
	movq	24(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	%ebp, %edx
	callq	_Z23__device_stub__gpu_HeatPfS_i
.LBB4_27:                               #   in Loop: Header=BB4_23 Depth=1
	callq	hipDeviceSynchronize
	movl	$dev_residual, %esi
	movl	$4, %edx
	movq	%r15, %rdi
	xorl	%ecx, %ecx
	movl	$2, %r8d
	callq	hipMemcpyFromSymbol
	movss	52(%rsp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	subss	48(%rsp), %xmm0                 # 4-byte Folded Reload
	cvtss2sd	%xmm0, %xmm0
	movsd	%xmm0, 56(%rsp)                 # 8-byte Spill
	movl	$.L.str.20, %edi
	movb	$1, %al
	callq	printf
	movq	24(%rsp), %rax
	movq	16(%rsp), %rsi
	movq	%rsi, 24(%rsp)
	movq	%rax, 16(%rsp)
	incl	%r14d
	movsd	.LCPI4_0(%rip), %xmm0           # xmm0 = mem[0],zero
	ucomisd	56(%rsp), %xmm0                 # 8-byte Folded Reload
	ja	.LBB4_29
# %bb.28:                               #   in Loop: Header=BB4_23 Depth=1
	cmpl	64(%rsp), %r14d
	jb	.LBB4_23
.LBB4_29:
	leaq	64(%rsp), %r12
	movq	16(%r12), %rdi
	movq	120(%rsp), %r15                 # 8-byte Reload
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	24(%r12), %rdi
	movq	16(%rsp), %rsi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	24(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	xorl	%r15d, %r15d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	(%rsp), %rdi
	callq	hipEventSynchronize
	movq	32(%rsp), %rsi
	movq	(%rsp), %rdx
	leaq	12(%rsp), %r13
	movq	%r13, %rdi
	callq	hipEventElapsedTime
	movq	stdout(%rip), %rdi
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13), %xmm0
	movl	$.L.str.21, %esi
	movb	$1, %al
	callq	fprintf
	movss	44(%rsp), %xmm0                 # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	divss	(%r13), %xmm0
	movq	stdout(%rip), %rdi
	divss	.LCPI4_3(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm1
	movl	$.L.str.15, %esi
	movsd	128(%rsp), %xmm0                # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$2, %al
	callq	fprintf
	movq	stdout(%rip), %rdi
	movl	$.L.str.16, %esi
	movsd	56(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movl	%r14d, %edx
	movb	$1, %al
	callq	fprintf
	movq	32(%rsp), %rdi
	callq	hipEventDestroy
	movq	(%rsp), %rdi
	callq	hipEventDestroy
	movq	16(%r12), %rdi
	movq	32(%r12), %rcx
	movl	12(%r12), %r8d
	addl	$2, %r8d
	movl	%ebp, %esi
	movl	%ebp, %edx
	movl	%r8d, %r9d
	callq	_Z7coarsenPfjjS_jj
	movq	32(%r12), %rsi
	movl	12(%r12), %ecx
	addl	$2, %ecx
	movq	%rbx, %rdi
	movl	%ecx, %edx
	callq	_Z11write_imageP8_IO_FILEPfjj
	movq	%r12, %rdi
	callq	_Z8finalizeP11algoparam_t
	jmp	.LBB4_14
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z10read_inputP8_IO_FILEP11algoparam_t # -- Begin function _Z10read_inputP8_IO_FILEP11algoparam_t
	.type	_Z10read_inputP8_IO_FILEP11algoparam_t,@function
_Z10read_inputP8_IO_FILEP11algoparam_t: # @_Z10read_inputP8_IO_FILEP11algoparam_t
	.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	$120, %rsp
	.cfi_def_cfa_offset 176
	.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
	movq	%rdi, %r14
	leaq	16(%rsp), %r15
	movq	%r15, %rdi
	movl	$100, %esi
	movq	%r14, %rdx
	callq	fgets
	xorl	%ebp, %ebp
	movl	$.L.str.28, %esi
	movq	%r15, %rdi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	cmpl	$1, %eax
	jne	.LBB5_8
# %bb.1:
	leaq	16(%rsp), %r15
	movq	%r15, %rdi
	movl	$100, %esi
	movq	%r14, %rdx
	callq	fgets
	leaq	4(%rbx), %rdx
	xorl	%ebp, %ebp
	movl	$.L.str.28, %esi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	cmpl	$1, %eax
	jne	.LBB5_8
# %bb.2:
	movl	4(%rbx), %eax
	movl	%eax, 12(%rbx)
	leaq	16(%rsp), %r12
	movq	%r12, %rdi
	movl	$100, %esi
	movq	%r14, %rdx
	callq	fgets
	leaq	40(%rbx), %rdx
	xorl	%ebp, %ebp
	movl	$.L.str.28, %esi
	movq	%r12, %rdi
	movq	%rdx, 8(%rsp)                   # 8-byte Spill
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	cmpl	$1, %eax
	jne	.LBB5_8
# %bb.3:
	movl	40(%rbx), %r15d
	movq	%r15, %rdi
	shlq	$4, %rdi
	callq	malloc
	movq	%rax, 48(%rbx)
	movl	$1, %ebp
	testq	%r15, %r15
	je	.LBB5_8
# %bb.4:                                # %.lr.ph.preheader
	leaq	16(%rsp), %r12
	xorl	%r13d, %r13d
	xorl	%r15d, %r15d
.LBB5_6:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	movl	$100, %esi
	movq	%r14, %rdx
	callq	fgets
	movq	48(%rbx), %rax
	leaq	(%rax,%r13), %rdx
	leaq	(%rax,%r13), %rcx
	addq	$4, %rcx
	leaq	8(%rax,%r13), %r8
	leaq	(%rax,%r13), %r9
	addq	$12, %r9
	movl	$.L.str.29, %esi
	movq	%r12, %rdi
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	cmpl	$4, %eax
	jne	.LBB5_7
# %bb.5:                                #   in Loop: Header=BB5_6 Depth=1
	incq	%r15
	movq	8(%rsp), %rax                   # 8-byte Reload
	movl	(%rax), %eax
	addq	$16, %r13
	cmpq	%rax, %r15
	jb	.LBB5_6
	jmp	.LBB5_8
.LBB5_7:
	xorl	%ebp, %ebp
.LBB5_8:                                # %.loopexit
	movl	%ebp, %eax
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	_Z10read_inputP8_IO_FILEP11algoparam_t, .Lfunc_end5-_Z10read_inputP8_IO_FILEP11algoparam_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z12print_paramsP11algoparam_t  # -- Begin function _Z12print_paramsP11algoparam_t
	.type	_Z12print_paramsP11algoparam_t,@function
_Z12print_paramsP11algoparam_t:         # @_Z12print_paramsP11algoparam_t
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movq	stdout(%rip), %rdi
	movl	(%rbx), %edx
	movl	$.L.str.30, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stdout(%rip), %rdi
	movl	4(%rbx), %edx
	movl	$.L.str.31, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stdout(%rip), %rdi
	movl	40(%rbx), %edx
	movl	$.L.str.32, %esi
	xorl	%eax, %eax
	callq	fprintf
	cmpl	$0, 40(%rbx)
	je	.LBB6_3
# %bb.1:                                # %.lr.ph
	movl	$12, %r15d
	xorl	%r14d, %r14d
.LBB6_2:                                # =>This Inner Loop Header: Depth=1
	movq	stdout(%rip), %rdi
	incq	%r14
	movq	48(%rbx), %rax
	xorps	%xmm0, %xmm0
	cvtss2sd	-12(%rax,%r15), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	-8(%rax,%r15), %xmm1
	xorps	%xmm2, %xmm2
	cvtss2sd	-4(%rax,%r15), %xmm2
	xorps	%xmm3, %xmm3
	cvtss2sd	(%rax,%r15), %xmm3
	movl	$.L.str.33, %esi
	movl	%r14d, %edx
	movb	$4, %al
	callq	fprintf
	movl	40(%rbx), %eax
	addq	$16, %r15
	cmpq	%rax, %r14
	jb	.LBB6_2
.LBB6_3:                                # %._crit_edge
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end6:
	.size	_Z12print_paramsP11algoparam_t, .Lfunc_end6-_Z12print_paramsP11algoparam_t
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z10initializeP11algoparam_t
.LCPI7_0:
	.long	0x3f800000                      # float 1
	.text
	.globl	_Z10initializeP11algoparam_t
	.type	_Z10initializeP11algoparam_t,@function
_Z10initializeP11algoparam_t:           # @_Z10initializeP11algoparam_t
	.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	%rdi, %r15
	movl	4(%rdi), %r12d
	leal	2(%r12), %ebp
	movl	%ebp, %r14d
	imull	%r14d, %r14d
	movl	$4, %edi
	movq	%r14, %rsi
	callq	calloc
	movq	%rax, %rbx
	movq	%rax, 16(%r15)
	movl	$4, %edi
	movq	%r14, %rsi
	callq	calloc
	movq	%rax, %r14
	movq	%rax, 24(%r15)
	movl	12(%r15), %esi
	addl	$2, %esi
	imull	%esi, %esi
	movl	$4, %edi
	callq	calloc
	movq	%rax, 32(%r15)
	testq	%rbx, %rbx
	je	.LBB7_32
# %bb.1:
	testq	%r14, %r14
	je	.LBB7_32
# %bb.2:
	testq	%rax, %rax
	je	.LBB7_32
# %bb.3:                                # %.preheader151
	movl	40(%r15), %eax
	movl	%ebp, %ecx
	testq	%rax, %rax
	je	.LBB7_26
# %bb.4:                                # %.preheader150.lr.ph
	incl	%r12d
	cvtsi2ss	%r12d, %xmm0
	movl	%r12d, %edx
	imull	%ebp, %edx
	movslq	%edx, %rdx
	movslq	%ebp, %rdi
	movslq	%r12d, %r8
	leaq	(%rbx,%rdx,4), %rdx
	leaq	(,%rdi,4), %rsi
	leaq	(%rbx,%rdi,4), %r9
	movq	%r9, 16(%rsp)                   # 8-byte Spill
	shlq	$2, %r8
	leaq	(%r8,%rdi,4), %rdi
	addq	%rbx, %rdi
	movq	%rdi, 8(%rsp)                   # 8-byte Spill
	xorl	%r9d, %r9d
	movss	.LCPI7_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
.LBB7_5:                                # %.preheader150
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_7 Depth 2
                                        #     Child Loop BB7_12 Depth 2
                                        #     Child Loop BB7_17 Depth 2
                                        #     Child Loop BB7_22 Depth 2
	testl	%ebp, %ebp
	jle	.LBB7_15
# %bb.6:                                # %.lr.ph
                                        #   in Loop: Header=BB7_5 Depth=1
	movq	48(%r15), %r11
	movq	%r9, %r10
	shlq	$4, %r10
	leaq	(%r11,%r10), %rdi
	addq	$4, %rdi
	addq	%r10, %r11
	xorl	%r8d, %r8d
.LBB7_7:                                #   Parent Loop BB7_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm2, %xmm2
	cvtsi2ss	%r8d, %xmm2
	divss	%xmm0, %xmm2
	subss	(%r11), %xmm2
	cvtss2sd	%xmm2, %xmm2
	mulsd	%xmm2, %xmm2
	xorps	%xmm3, %xmm3
	cvtss2sd	(%rdi), %xmm3
	mulsd	%xmm3, %xmm3
	addsd	%xmm2, %xmm3
	xorps	%xmm2, %xmm2
	sqrtsd	%xmm3, %xmm2
	xorps	%xmm3, %xmm3
	cvtsd2ss	%xmm2, %xmm3
	movss	4(%rdi), %xmm2                  # xmm2 = mem[0],zero,zero,zero
	ucomiss	%xmm3, %xmm2
	jb	.LBB7_9
# %bb.8:                                #   in Loop: Header=BB7_7 Depth=2
	movaps	%xmm2, %xmm4
	subss	%xmm3, %xmm4
	divss	%xmm2, %xmm4
	mulss	8(%rdi), %xmm4
	addss	(%rbx,%r8,4), %xmm4
	movss	%xmm4, (%rbx,%r8,4)
.LBB7_9:                                #   in Loop: Header=BB7_7 Depth=2
	incq	%r8
	cmpq	%r8, %rcx
	jne	.LBB7_7
# %bb.10:                               # %.preheader149
                                        #   in Loop: Header=BB7_5 Depth=1
	testl	%ebp, %ebp
	jle	.LBB7_15
# %bb.11:                               # %.lr.ph154
                                        #   in Loop: Header=BB7_5 Depth=1
	movq	48(%r15), %rdi
	leaq	(%rdi,%r10), %r8
	addq	%r10, %rdi
	addq	$4, %rdi
	xorl	%r10d, %r10d
.LBB7_12:                               #   Parent Loop BB7_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm2, %xmm2
	cvtsi2ss	%r10d, %xmm2
	divss	%xmm0, %xmm2
	subss	(%r8), %xmm2
	cvtss2sd	%xmm2, %xmm2
	mulsd	%xmm2, %xmm2
	movaps	%xmm1, %xmm3
	subss	(%rdi), %xmm3
	cvtss2sd	%xmm3, %xmm3
	mulsd	%xmm3, %xmm3
	addsd	%xmm2, %xmm3
	xorps	%xmm2, %xmm2
	sqrtsd	%xmm3, %xmm2
	xorps	%xmm3, %xmm3
	cvtsd2ss	%xmm2, %xmm3
	movss	4(%rdi), %xmm2                  # xmm2 = mem[0],zero,zero,zero
	ucomiss	%xmm3, %xmm2
	jb	.LBB7_14
# %bb.13:                               #   in Loop: Header=BB7_12 Depth=2
	movaps	%xmm2, %xmm4
	subss	%xmm3, %xmm4
	divss	%xmm2, %xmm4
	mulss	8(%rdi), %xmm4
	addss	(%rdx,%r10,4), %xmm4
	movss	%xmm4, (%rdx,%r10,4)
.LBB7_14:                               #   in Loop: Header=BB7_12 Depth=2
	incq	%r10
	cmpq	%r10, %rcx
	jne	.LBB7_12
.LBB7_15:                               # %.preheader148
                                        #   in Loop: Header=BB7_5 Depth=1
	cmpl	$2, %r12d
	jl	.LBB7_25
# %bb.16:                               # %.lr.ph156
                                        #   in Loop: Header=BB7_5 Depth=1
	movq	48(%r15), %r11
	movq	%r9, %r10
	shlq	$4, %r10
	leaq	(%r11,%r10), %r13
	addq	$4, %r13
	addq	%r10, %r11
	movl	$1, %r8d
	movq	16(%rsp), %rdi                  # 8-byte Reload
.LBB7_17:                               #   Parent Loop BB7_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm2, %xmm2
	cvtss2sd	(%r11), %xmm2
	mulsd	%xmm2, %xmm2
	xorps	%xmm3, %xmm3
	cvtsi2ss	%r8d, %xmm3
	divss	%xmm0, %xmm3
	subss	(%r13), %xmm3
	cvtss2sd	%xmm3, %xmm3
	mulsd	%xmm3, %xmm3
	addsd	%xmm2, %xmm3
	xorps	%xmm2, %xmm2
	sqrtsd	%xmm3, %xmm2
	xorps	%xmm3, %xmm3
	cvtsd2ss	%xmm2, %xmm3
	movss	4(%r13), %xmm2                  # xmm2 = mem[0],zero,zero,zero
	ucomiss	%xmm3, %xmm2
	jb	.LBB7_19
# %bb.18:                               #   in Loop: Header=BB7_17 Depth=2
	movaps	%xmm2, %xmm4
	subss	%xmm3, %xmm4
	divss	%xmm2, %xmm4
	mulss	8(%r13), %xmm4
	addss	(%rdi), %xmm4
	movss	%xmm4, (%rdi)
.LBB7_19:                               #   in Loop: Header=BB7_17 Depth=2
	incq	%r8
	addq	%rsi, %rdi
	cmpq	%r8, %r12
	jne	.LBB7_17
# %bb.20:                               # %.preheader147
                                        #   in Loop: Header=BB7_5 Depth=1
	cmpl	$2, %r12d
	jl	.LBB7_25
# %bb.21:                               # %.lr.ph158
                                        #   in Loop: Header=BB7_5 Depth=1
	movq	48(%r15), %rdi
	leaq	(%rdi,%r10), %r11
	addq	%rdi, %r10
	addq	$4, %r10
	movl	$1, %r13d
	movq	8(%rsp), %r8                    # 8-byte Reload
.LBB7_22:                               #   Parent Loop BB7_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movaps	%xmm1, %xmm2
	subss	(%r11), %xmm2
	cvtss2sd	%xmm2, %xmm2
	mulsd	%xmm2, %xmm2
	xorps	%xmm3, %xmm3
	cvtsi2ss	%r13d, %xmm3
	divss	%xmm0, %xmm3
	subss	(%r10), %xmm3
	cvtss2sd	%xmm3, %xmm3
	mulsd	%xmm3, %xmm3
	addsd	%xmm2, %xmm3
	xorps	%xmm2, %xmm2
	sqrtsd	%xmm3, %xmm2
	xorps	%xmm3, %xmm3
	cvtsd2ss	%xmm2, %xmm3
	movss	4(%r10), %xmm2                  # xmm2 = mem[0],zero,zero,zero
	ucomiss	%xmm3, %xmm2
	jb	.LBB7_24
# %bb.23:                               #   in Loop: Header=BB7_22 Depth=2
	movaps	%xmm2, %xmm4
	subss	%xmm3, %xmm4
	divss	%xmm2, %xmm4
	mulss	8(%r10), %xmm4
	addss	(%r8), %xmm4
	movss	%xmm4, (%r8)
.LBB7_24:                               #   in Loop: Header=BB7_22 Depth=2
	incq	%r13
	addq	%rsi, %r8
	cmpq	%r13, %r12
	jne	.LBB7_22
.LBB7_25:                               # %._crit_edge
                                        #   in Loop: Header=BB7_5 Depth=1
	incq	%r9
	cmpq	%rax, %r9
	jne	.LBB7_5
.LBB7_26:                               # %._crit_edge160
	movl	$1, %eax
	testl	%ebp, %ebp
	jle	.LBB7_31
# %bb.27:                               # %.lr.ph164.preheader.preheader
	xorl	%edx, %edx
.LBB7_28:                               # %.lr.ph164.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB7_29 Depth 2
	xorl	%edi, %edi
	xorl	%esi, %esi
.LBB7_29:                               # %.lr.ph164
                                        #   Parent Loop BB7_28 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rbx,%rdi,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%r14,%rdi,4)
	addq	$-4, %rsi
	incq	%rdi
	cmpl	%edi, %ecx
	jne	.LBB7_29
# %bb.30:                               # %._crit_edge165
                                        #   in Loop: Header=BB7_28 Depth=1
	incl	%edx
	subq	%rsi, %rbx
	subq	%rsi, %r14
	cmpl	%ebp, %edx
	jne	.LBB7_28
.LBB7_31:                               # %.loopexit
	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
.LBB7_32:
	.cfi_def_cfa_offset 80
	movq	stderr(%rip), %rcx
	movl	$.L.str.22, %edi
	movl	$30, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	xorl	%eax, %eax
	jmp	.LBB7_31
.Lfunc_end7:
	.size	_Z10initializeP11algoparam_t, .Lfunc_end7-_Z10initializeP11algoparam_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z8finalizeP11algoparam_t       # -- Begin function _Z8finalizeP11algoparam_t
	.type	_Z8finalizeP11algoparam_t,@function
_Z8finalizeP11algoparam_t:              # @_Z8finalizeP11algoparam_t
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	movq	16(%rdi), %rdi
	testq	%rdi, %rdi
	je	.LBB8_2
# %bb.1:
	callq	free
	movq	$0, 16(%rbx)
.LBB8_2:
	movq	24(%rbx), %rdi
	testq	%rdi, %rdi
	je	.LBB8_4
# %bb.3:
	callq	free
	movq	$0, 24(%rbx)
.LBB8_4:
	movq	32(%rbx), %rdi
	testq	%rdi, %rdi
	je	.LBB8_6
# %bb.5:
	callq	free
	movq	$0, 32(%rbx)
.LBB8_6:
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end8:
	.size	_Z8finalizeP11algoparam_t, .Lfunc_end8-_Z8finalizeP11algoparam_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z7coarsenPfjjS_jj              # -- Begin function _Z7coarsenPfjjS_jj
	.type	_Z7coarsenPfjjS_jj,@function
_Z7coarsenPfjjS_jj:                     # @_Z7coarsenPfjjS_jj
	.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
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %r11d
	movl	$1, %r10d
	movl	%esi, %ebx
	cmpl	%r8d, %esi
	jbe	.LBB9_2
# %bb.1:
	movl	%esi, %eax
	xorl	%edx, %edx
	divl	%r8d
	movl	%eax, %r10d
	movl	%r8d, %ebx
.LBB9_2:
	movl	$1, %eax
	cmpl	%r9d, %r11d
	jbe	.LBB9_3
# %bb.4:
	movl	%r11d, %eax
	xorl	%edx, %edx
	divl	%r9d
	jmp	.LBB9_5
.LBB9_3:
	movl	%r11d, %r9d
.LBB9_5:
	cmpl	$2, %r9d
	jl	.LBB9_11
# %bb.6:                                # %.preheader.lr.ph
	leal	-1(%rbx), %edx
	imull	%esi, %eax
	addl	$-2, %r9d
	xorl	%esi, %esi
	xorl	%r11d, %r11d
	xorl	%r14d, %r14d
.LBB9_7:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB9_9 Depth 2
	cmpl	$2, %ebx
	jl	.LBB9_10
# %bb.8:                                # %.lr.ph
                                        #   in Loop: Header=BB9_7 Depth=1
	movq	%rdx, %r15
	movl	%esi, %ebp
	movl	%r11d, %r12d
.LBB9_9:                                #   Parent Loop BB9_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ebp, %r13d
	movss	(%rdi,%r13,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movl	%r12d, %r13d
	movss	%xmm0, (%rcx,%r13,4)
	incl	%r12d
	addl	%r10d, %ebp
	decq	%r15
	jne	.LBB9_9
.LBB9_10:                               # %._crit_edge
                                        #   in Loop: Header=BB9_7 Depth=1
	leal	1(%r14), %ebp
	addl	%r8d, %r11d
	addl	%eax, %esi
	cmpl	%r9d, %r14d
	movl	%ebp, %r14d
	jne	.LBB9_7
.LBB9_11:                               # %._crit_edge39
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end9:
	.size	_Z7coarsenPfjjS_jj, .Lfunc_end9-_Z7coarsenPfjjS_jj
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z11write_imageP8_IO_FILEPfjj
.LCPI10_0:
	.long	0xff800000                      # float -Inf
.LCPI10_1:
	.long	0x7f800000                      # float +Inf
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI10_2:
	.quad	0x4090000000000000              # double 1024
	.text
	.globl	_Z11write_imageP8_IO_FILEPfjj
	.type	_Z11write_imageP8_IO_FILEPfjj,@function
_Z11write_imageP8_IO_FILEPfjj:          # @_Z11write_imageP8_IO_FILEPfjj
	.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	$3112, %rsp                     # imm = 0xC28
	.cfi_def_cfa_offset 3168
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %ebp
	movl	%edx, 4(%rsp)                   # 4-byte Spill
	movq	%rsi, %r14
	movq	%rdi, %r15
	movl	$768, %r13d                     # imm = 0x300
	leaq	32(%rsp), %rax
	leaq	(%rax,%r13), %rdi
	movl	$256, %edx                      # imm = 0x100
	movl	$255, %esi
	callq	memset@PLT
	leaq	1056(%rsp), %r12
	addq	%r12, %r13
	xorl	%ebx, %ebx
	movl	$256, %edx                      # imm = 0x100
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	leaq	3103(%rsp), %rax
.LBB10_1:                               # =>This Inner Loop Header: Depth=1
	movb	%bl, (%rax)
	incl	%ebx
	decq	%rax
	cmpl	$256, %ebx                      # imm = 0x100
	jne	.LBB10_1
# %bb.2:                                # %.preheader95.preheader
	movl	$512, %ebx                      # imm = 0x200
	leaq	2080(%rsp), %r13
	leaq	(%rbx,%r13), %rdi
	movl	$256, %edx                      # imm = 0x100
	movl	$255, %esi
	callq	memset@PLT
	addq	%rbx, %r12
	movl	$256, %edx                      # imm = 0x100
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	memset@PLT
	movl	$256, %eax                      # imm = 0x100
	leaq	799(%rsp), %rcx
.LBB10_3:                               # %.preheader95
                                        # =>This Inner Loop Header: Depth=1
	decl	%eax
	movb	%al, (%rcx)
	decq	%rcx
	testl	%eax, %eax
	jne	.LBB10_3
# %bb.4:                                # %.preheader94.preheader
	movl	$256, %r12d                     # imm = 0x100
	leaq	32(%rsp), %rdi
	addq	%r12, %rdi
	xorl	%ebx, %ebx
	movl	$256, %edx                      # imm = 0x100
	xorl	%esi, %esi
	callq	memset@PLT
	addq	%r12, %r13
	movl	$256, %edx                      # imm = 0x100
	movq	%r13, %rdi
	movl	$255, %esi
	callq	memset@PLT
	leaq	1567(%rsp), %rax
.LBB10_5:                               # %.preheader94
                                        # =>This Inner Loop Header: Depth=1
	movb	%bl, (%rax)
	incl	%ebx
	decq	%rax
	cmpl	$256, %ebx                      # imm = 0x100
	jne	.LBB10_5
# %bb.6:                                # %.preheader93.preheader
	leaq	32(%rsp), %rdi
	movl	$256, %edx                      # imm = 0x100
	xorl	%esi, %esi
	callq	memset@PLT
	leaq	1056(%rsp), %rdi
	movl	$256, %edx                      # imm = 0x100
	movl	$255, %esi
	callq	memset@PLT
	movl	$255, %eax
	movl	$256, %ecx                      # imm = 0x100
	movl	4(%rsp), %r12d                  # 4-byte Reload
.LBB10_7:                               # %.preheader93
                                        # =>This Inner Loop Header: Depth=1
	movb	%al, 2080(%rsp,%rax)
	decq	%rax
	decl	%ecx
	jne	.LBB10_7
# %bb.8:                                # %.preheader92
	movl	%r12d, %eax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	testl	%ebp, %ebp
	je	.LBB10_9
# %bb.10:                               # %.preheader91.lr.ph
	movss	.LCPI10_1(%rip), %xmm1          # xmm1 = mem[0],zero,zero,zero
	movss	.LCPI10_0(%rip), %xmm0          # xmm0 = mem[0],zero,zero,zero
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB10_11:                              # %.preheader91
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_14 Depth 2
	testl	%r12d, %r12d
	je	.LBB10_12
# %bb.13:                               # %.lr.ph
                                        #   in Loop: Header=BB10_11 Depth=1
	movq	24(%rsp), %rdx                  # 8-byte Reload
	movl	%eax, %esi
.LBB10_14:                              #   Parent Loop BB10_11 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%esi, %edi
	movss	(%r14,%rdi,4), %xmm2            # xmm2 = mem[0],zero,zero,zero
	movaps	%xmm2, %xmm3
	maxss	%xmm0, %xmm3
	minss	%xmm1, %xmm2
	incl	%esi
	movaps	%xmm3, %xmm0
	movaps	%xmm2, %xmm1
	decq	%rdx
	jne	.LBB10_14
	jmp	.LBB10_15
.LBB10_12:                              #   in Loop: Header=BB10_11 Depth=1
	movaps	%xmm1, %xmm2
	movaps	%xmm0, %xmm3
.LBB10_15:                              # %._crit_edge
                                        #   in Loop: Header=BB10_11 Depth=1
	incl	%ecx
	addl	%r12d, %eax
	movaps	%xmm3, %xmm0
	movaps	%xmm2, %xmm1
	cmpl	%ebp, %ecx
	jne	.LBB10_11
	jmp	.LBB10_16
.LBB10_9:
	movss	.LCPI10_0(%rip), %xmm3          # xmm3 = mem[0],zero,zero,zero
	movss	.LCPI10_1(%rip), %xmm2          # xmm2 = mem[0],zero,zero,zero
.LBB10_16:                              # %._crit_edge111
	movss	%xmm3, 8(%rsp)                  # 4-byte Spill
	movss	%xmm2, (%rsp)                   # 4-byte Spill
	movl	$.L.str.23, %edi
	movl	$3, %esi
	movl	$1, %edx
	movq	%r15, %rcx
	callq	fwrite@PLT
	movl	$.L.str.24, %esi
	movq	%r15, %rdi
	movl	%r12d, %edx
	movl	%ebp, %ecx
	xorl	%eax, %eax
	callq	fprintf
	movl	$.L.str.25, %esi
	movq	%r15, %rdi
	movl	$255, %edx
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebp, 20(%rsp)                  # 4-byte Spill
	testl	%ebp, %ebp
	je	.LBB10_22
# %bb.17:                               # %.preheader.lr.ph
	movss	8(%rsp), %xmm0                  # 4-byte Reload
                                        # xmm0 = mem[0],zero,zero,zero
	subss	(%rsp), %xmm0                   # 4-byte Folded Reload
	cvtss2sd	%xmm0, %xmm0
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	xorl	%ebp, %ebp
	xorl	%ebx, %ebx
.LBB10_18:                              # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_20 Depth 2
	testl	%r12d, %r12d
	movss	(%rsp), %xmm1                   # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	movsd	8(%rsp), %xmm2                  # 8-byte Reload
                                        # xmm2 = mem[0],zero
	movsd	.LCPI10_2(%rip), %xmm3          # xmm3 = mem[0],zero
	je	.LBB10_21
# %bb.19:                               # %.lr.ph115
                                        #   in Loop: Header=BB10_18 Depth=1
	movq	24(%rsp), %r12                  # 8-byte Reload
	movl	%ebp, %r13d
.LBB10_20:                              #   Parent Loop BB10_18 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%r13d, %eax
	movss	(%r14,%rax,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	subss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	mulsd	%xmm3, %xmm0
	divsd	%xmm2, %xmm0
	cvttsd2si	%xmm0, %eax
	cltq
	movzbl	32(%rsp,%rax), %edx
	movzbl	2080(%rsp,%rax), %ecx
	movzbl	1056(%rsp,%rax), %r8d
	movl	$.L.str.26, %esi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	fprintf
	movsd	.LCPI10_2(%rip), %xmm3          # xmm3 = mem[0],zero
	movsd	8(%rsp), %xmm2                  # 8-byte Reload
                                        # xmm2 = mem[0],zero
	movss	(%rsp), %xmm1                   # 4-byte Reload
                                        # xmm1 = mem[0],zero,zero,zero
	incl	%r13d
	decq	%r12
	jne	.LBB10_20
.LBB10_21:                              # %._crit_edge116
                                        #   in Loop: Header=BB10_18 Depth=1
	movl	$10, %edi
	movq	%r15, %rsi
	callq	fputc@PLT
	incl	%ebx
	movl	4(%rsp), %r12d                  # 4-byte Reload
	addl	%r12d, %ebp
	cmpl	20(%rsp), %ebx                  # 4-byte Folded Reload
	jne	.LBB10_18
.LBB10_22:                              # %._crit_edge118
	addq	$3112, %rsp                     # imm = 0xC28
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end10:
	.size	_Z11write_imageP8_IO_FILEPfjj, .Lfunc_end10-_Z11write_imageP8_IO_FILEPfjj
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB11_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB11_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8gpu_HeatPfS_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$0, (%rsp)
	movl	$dev_residual, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movl	$4, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end11:
	.size	__hip_module_ctor, .Lfunc_end11-__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	.LBB12_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
.LBB12_2:
	retq
.Lfunc_end12:
	.size	__hip_module_dtor, .Lfunc_end12-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	dev_residual,@object            # @dev_residual
	.local	dev_residual
	.comm	dev_residual,4,4
	.type	_Z8gpu_HeatPfS_i,@object        # @_Z8gpu_HeatPfS_i
	.section	.rodata,"a",@progbits
	.globl	_Z8gpu_HeatPfS_i
	.p2align	3, 0x0
_Z8gpu_HeatPfS_i:
	.quad	_Z23__device_stub__gpu_HeatPfS_i
	.size	_Z8gpu_HeatPfS_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Usage: %s <input file> -t threads -b blocks\n"
	.size	.L.str, 45

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"       -t number of threads per block in each dimension (e.g. 16)\n"
	.size	.L.str.1, 67

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"\nError: Cannot open \"%s\" for reading.\n\n"
	.size	.L.str.3, 40

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"heat.ppm"
	.size	.L.str.4, 9

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"\nError: Cannot open \"%s\" for writing.\n\n"
	.size	.L.str.6, 40

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"\nError: Error parsing input file.\n\n"
	.size	.L.str.7, 36

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"-t"
	.size	.L.str.8, 3

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"\nSolving Heat equation on the CPU and the GPU\n"
	.size	.L.str.10, 47

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"--------------------------------------------\n"
	.size	.L.str.11, 46

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"\nExecution on CPU (sequential)\n-----------------------------\n"
	.size	.L.str.12, 62

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Error in Solver initialization.\n\n"
	.size	.L.str.13, 34

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Time on CPU in ms.= %f "
	.size	.L.str.14, 24

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"(%3.3f GFlop => %6.2f MFlop/s)\n"
	.size	.L.str.15, 32

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Convergence to residual=%f: %d iterations\n"
	.size	.L.str.16, 43

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"\nExecution on GPU\n----------------\n"
	.size	.L.str.17, 36

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Number of threads per block in each dimension = %d\n"
	.size	.L.str.18, 52

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"Number of blocks per grid in each dimension   = %d\n"
	.size	.L.str.19, 52

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"Residual computation on GPU is ==> %f\n"
	.size	.L.str.20, 39

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"\nTime on GPU in ms. = %f "
	.size	.L.str.21, 26

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"Error: Cannot allocate memory\n"
	.size	.L.str.22, 31

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"P3\n"
	.size	.L.str.23, 4

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"%u %u\n"
	.size	.L.str.24, 7

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"%u\n"
	.size	.L.str.25, 4

	.type	.L.str.26,@object               # @.str.26
.L.str.26:
	.asciz	"%d %d %d  "
	.size	.L.str.26, 11

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"%u"
	.size	.L.str.28, 3

	.type	.L.str.29,@object               # @.str.29
.L.str.29:
	.asciz	"%f %f %f %f"
	.size	.L.str.29, 12

	.type	.L.str.30,@object               # @.str.30
.L.str.30:
	.asciz	"Iterations        : %u\n"
	.size	.L.str.30, 24

	.type	.L.str.31,@object               # @.str.31
.L.str.31:
	.asciz	"Resolution        : %u\n"
	.size	.L.str.31, 24

	.type	.L.str.32,@object               # @.str.32
.L.str.32:
	.asciz	"Num. Heat sources : %u\n"
	.size	.L.str.32, 24

	.type	.L.str.33,@object               # @.str.33
.L.str.33:
	.asciz	"  %2d: (%2.2f, %2.2f) %2.2f %2.2f \n"
	.size	.L.str.33, 36

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z8gpu_HeatPfS_i"
	.size	.L__unnamed_1, 17

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"dev_residual"
	.size	.L__unnamed_2, 13

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Error -- too many threads in block, try again"
	.size	.Lstr, 46

	.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 _Z23__device_stub__gpu_HeatPfS_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym dev_residual
	.addrsig_sym _Z8gpu_HeatPfS_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z8gpu_HeatPfS_i        ; -- Begin function _Z8gpu_HeatPfS_i
	.globl	_Z8gpu_HeatPfS_i
	.p2align	8
	.type	_Z8gpu_HeatPfS_i,@function
_Z8gpu_HeatPfS_i:                       ; @_Z8gpu_HeatPfS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b32 s4, s[0:1], 0x10
	v_bfe_u32 v3, v0, 10, 10
	v_and_b32_e32 v4, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[0:1], null, s15, s3, v[3:4]
	v_mad_u64_u32 v[1:2], null, s14, s2, v[4:5]
	v_or_b32_e32 v2, s15, v3
	v_or_b32_e32 v3, s14, v4
	s_add_i32 s3, s4, -1
	v_cmp_ne_u32_e32 vcc_lo, 0, v2
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_max_i32_e32 v4, v0, v1
	v_cmp_ne_u32_e64 s2, 0, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cmp_gt_i32_e64 s3, s3, v4
	s_and_b32 s2, vcc_lo, s2
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_6
; %bb.1:
	v_mad_u64_u32 v[2:3], null, v0, s4, v[1:2]
	s_load_b128 s[8:11], s[0:1], 0x0
	s_ashr_i32 s5, s4, 31
	s_mov_b32 s2, exec_lo
	s_lshl_b64 s[0:1], s[4:5], 2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_subrev_nc_u32_e32 v0, s4, v2
	v_ashrrev_i32_e32 v3, 31, v2
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v4, vcc_lo, s8, v2
	v_add_co_ci_u32_e32 v5, vcc_lo, s9, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v0, vcc_lo, s8, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s9, v1, vcc_lo
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v6, vcc_lo, v4, s0
	v_add_co_ci_u32_e32 v7, vcc_lo, s1, v5, vcc_lo
	s_clause 0x3
	global_load_b32 v8, v[4:5], off offset:-4
	global_load_b32 v0, v[0:1], off
	global_load_b32 v1, v[6:7], off
	global_load_b32 v6, v[4:5], off offset:4
	s_waitcnt vmcnt(2)
	v_add_f32_e32 v0, v8, v0
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v0, v0, v6
	v_add_f32_e32 v6, v0, v1
	v_add_co_u32 v0, vcc_lo, s10, v2
	v_add_co_ci_u32_e32 v1, vcc_lo, s11, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3)
	v_mul_f32_e32 v2, 0x3e800000, v6
	global_store_b32 v[0:1], v2, off
	global_load_b32 v0, v[4:5], off
	v_bfrev_b32_e32 v2, 1
	s_waitcnt vmcnt(0)
	v_fma_f32 v0, 0x3e800000, v6, -v0
	s_delay_alu instid0(VALU_DEP_1)
	v_mul_f32_e32 v0, v0, v0
.LBB0_2:                                ; %ComputeLoop
                                        ; =>This Inner Loop Header: Depth=1
	s_ctz_i32_b32 s0, s2
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_readlane_b32 s1, v0, s0
	s_lshl_b32 s0, 1, s0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_not1_b32 s2, s2, s0
	s_cmp_lg_u32 s2, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f32_e32 v2, s1, v2
	s_cbranch_scc1 .LBB0_2
; %bb.3:                                ; %ComputeEnd
	v_mbcnt_lo_u32_b32 v0, exec_lo, 0
	s_mov_b32 s2, 0
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v0
	s_xor_b32 s0, exec_lo, s0
	s_cbranch_execz .LBB0_6
; %bb.4:
	v_mov_b32_e32 v3, 0
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, dev_residual@rel32@lo+4
	s_addc_u32 s1, s1, dev_residual@rel32@hi+12
	global_load_b32 v1, v3, s[0:1]
.LBB0_5:                                ; %atomicrmw.start
                                        ; =>This Inner Loop Header: Depth=1
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v0, v1, v2
	global_atomic_cmpswap_b32 v0, v3, v[0:1], s[0:1] glc
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, v0, v1
	v_mov_b32_e32 v1, v0
	s_or_b32 s2, vcc_lo, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB0_5
.LBB0_6:                                ; %Flow44
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8gpu_HeatPfS_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.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 9
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z8gpu_HeatPfS_i, .Lfunc_end0-_Z8gpu_HeatPfS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 548
; NumSgprs: 18
; NumVgprs: 9
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 9
; 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
	.protected	dev_residual            ; @dev_residual
	.type	dev_residual,@object
	.section	.bss,"aw",@nobits
	.globl	dev_residual
	.p2align	2, 0x0
dev_residual:
	.long	0x00000000                      ; float 0
	.size	dev_residual, 4

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.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 dev_residual
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8gpu_HeatPfS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8gpu_HeatPfS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     9
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
