
#include <stdio.h>
#include <iostream>
#include <unistd.h>
#include <sys/time.h>
#include <sys/time.h>

// Shorthand for formatting usage options
#define fpe(msg) fprintf(stderr, "\t%s\n", msg);

#define HANDLE_ERROR(err)  ( HandleError( err, __FILE__, __LINE__ ) )
#define MAX_THREADS (65536 * 1024)


/**
 * DEFINED VALUES HERE
 */

#define TILE_WIDTH 8
#define TILE_HEIGHT 8

using namespace std;

void HandleError(cudaError_t err, const char *file, int line) {
    //
    // Handle and report on CUDA errors.
    //
    if (err != cudaSuccess) {
        printf("%s in %s at line %d\n", cudaGetErrorString(err), file, line);

        exit(EXIT_FAILURE);
    }
}

void checkCUDAError(const char *msg, bool exitOnError) {
    //
    // Check cuda error and print result if appropriate.
    //
    cudaError_t err = cudaGetLastError();

    if (cudaSuccess != err) {
        fprintf(stderr, "Cuda error: %s: %s.\n", msg, cudaGetErrorString(err));
        if (exitOnError) {
            exit(-1);
        }
    }
}

void cleanupCuda(void) {
    //
    // Clean up CUDA resources.
    //

    //
    // Explicitly cleans up all runtime-related resources associated with the
    // calling host thread.
    //
    HANDLE_ERROR(
        cudaThreadExit()
    );
}

struct Args {
    bool debug;
    bool sequential;
    bool blocked;
    bool overlapped;
    // Data attributes
    int size, dimensions, alloc_size, thread_dim;
    int xSize, ySize, zSize;
    int xBlockSize, yBlockSize, zBlockSize, tBlockSize;
    // Run attributes
    int grid_size, block_count, thread_count, iterations;
};


void usage(char *prog_name, string msg) {
    if (msg.size() > 0) {
        fputs(msg.c_str(), stderr);
    }

    fprintf(stderr, "%s\n", prog_name);
    fprintf(stderr, "Options are:\n");
    fpe("-n<size> Set data size (default: 1024)");
    fpe("-d<dims> Set number of data dimensions (1, 2, or 3) (default: 2)");
    fpe("-g<size> Set grid size");
    fpe("-b<num>  Set block count");
    fpe("-t<num>  Set thread count");
    fpe("-i<iter> Number of iterations to perform (default: 1000)");
    fpe("-x<size> X Dimension");
    fpe("-y<size> Y Dimension");
    fpe("-z<size> Z Dimension");
    fpe("-T<size> T Dimension");
    fpe("-S       Execute sequential, CPU version");
    fpe("-B       Execute blocked sequential, CPU version");
    fpe("-O       Execute sequential overlapped tiling, CPU version");
    fpe("-D       Print debug info");
    fpe("-h       Print usage info (this message)");
    exit(EXIT_FAILURE);
}

Args parse_arguments(int argc, char *argv[]) {
    Args args = Args();

    int opt;
    // Parse args
    while ((opt = getopt(argc, argv, "n:d:g:j:b:t:i:x:y:z:T:hSBOD")) != -1) {
        switch (opt) {
            case 'D':
                args.debug = true;
                break;
            case 'S':
                args.sequential = true;
                break;
            case 'B':
                args.blocked = true;
                break;
            case 'O':
                args.overlapped = true;
                break;
            case 'n':
                args.size = atoi(optarg);
                break;
            case 'd':
                args.dimensions = atoi(optarg);
               break;
            case 'g':
                args.grid_size = atoi(optarg);
                break;
            case 'j':
                args.thread_dim = atoi(optarg);
                break;
            case 'b':
                args.block_count = atoi(optarg);
                break;
            case 't':
                args.thread_count = atoi(optarg);
                break;
            case 'i':
                args.iterations = atoi(optarg);
                break;
            case 'x':
                args.xBlockSize = atoi(optarg);
                break;
            case 'X':
                args.xSize = atoi(optarg);
                break;
            case 'y':
                args.yBlockSize = atoi(optarg);
                break;
            case 'Y':
                args.ySize = atoi(optarg);
                break;
            case 'z':
                args.zBlockSize = atoi(optarg);
                break;
            case 'Z':
                args.zSize = atoi(optarg);
                break;
            case 'T':
                args.tBlockSize = atoi(optarg);
                break;
            case 'h':
                usage(argv[0], "");
                break;
            default:
                usage(argv[0], "Unrecognized option\n");
        }
    }

    // check sizes
    if (args.size <= 0) {
        cout << "Data size must be larger than 0" << endl;
        exit(EXIT_FAILURE);
    }

    if (args.dimensions <= 0 || args.dimensions >= 4) {
        cerr << "Data must be 1, 2, or 3 dimensions" << endl;
        exit(EXIT_FAILURE);
    }

    // Calculations
    if (args.dimensions == 1) {
        args.alloc_size = args.size;
    } else if (args.dimensions == 2) {
        args.alloc_size = args.size * args.size;
    } else {
        args.alloc_size = args.size * args.size * args.size;
    }

    if (args.thread_count > 0) {
        args.block_count = args.alloc_size / args.thread_count;
    } else if (args.block_count > 0) {
        args.thread_count = args.alloc_size / args.block_count;
    } else {
        args.thread_count = 16;
        args.block_count = args.alloc_size / args.thread_count;
    }

    return args;
}

typedef struct {
    int dimensions;
    int height;
    int width;
    int depth;
    float* elements;
} Matrix;

Matrix initialize_matrix(int dimensions, int width, int height = 1, int depth = 1) {
    Matrix data;

    if (dimensions == 1 && width > 1) {
        data.width = width;
        data.height = 1;
        data.depth = 1;
        data.elements = (float *) malloc(width * sizeof(float));

        data.elements[0] = 1.0;
        data.elements[width - 1] = 1.0;
    } else if (dimensions == 2 && width > 1 && height > 1) {
        data.width = width;
        data.height = height;
        data.depth = 1;
        data.elements = (float *) malloc(width * height * sizeof(float));

        for (int y = 0; y < height; y += height - 1) {
            for (int x = 0; x < width; x++) {
                data.elements[y * width + x] = 1.0;
            }
        }

        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x += width - 1) {
                data.elements[y * width + x] = 1.0;
            }
        }
    } else if (dimensions == 3 && width > 1 && height > 1 && depth > 1) {
        data.width = width;
        data.height = height;
        data.depth = depth;
        data.elements = (float *) malloc(width * height * depth * sizeof(float));

        for (int z = 0; z < depth; z++) {
            // X = 0 & N planes
            for (int y = 0; y < height; y++) {
                for (int x = 0; x < width; x += width - 1) {
                    data.elements[z * width * height + y * width + x] = 1.0;
                }
            }

            // Y = 0 & N planes
            for (int y = 0; y < height; y += height - 1) {
                for (int x = 0; x < width; x++) {
                    data.elements[z * width * height + y * width + x] = 1.0;
                }
            }
        }

        // Z = 0 & N planes
        for (int z = 0; z < depth; z += depth - 1) {
            for (int y = 0; y < height; y++) {
                for (int x = 0; x < width; x++) {
                    data.elements[z * width * height + y * width + x] = 1.0;
                }
            }
        }
    } else {
        // Bad data
    }

    return data;
}
//
// Cached plane algorithm that calculates all the results for the thread plane from 0 to the end of the
// block of global data.
//
__global__ void cached_plane(Matrix data, Matrix result, int z_size) {
    int threadDep = threadIdx.z;
    int threadRow = threadIdx.y;
    int threadCol = threadIdx.x;
    int blockDep = blockIdx.z;
    int blockRow = blockIdx.y;
    int blockCol = blockIdx.x;

    int x = blockCol * blockDim.x + threadCol;
    int y = blockRow * blockDim.y + threadRow;
	int z = blockDep * blockDim.z + threadDep;

    int xySurface = data.width * data.height;
    int yTemp = y * data.width;

	int zTemp, index, xPrev, xNext, yPrev, yNext, zPrev, zNext; 

	float newValue;
    
    while(z < z_size){
		zTemp = z * xySurface;
		index = x + yTemp + zTemp; // x + y * data.width + z * data.width * data.height;
		xPrev = (x - 1) + yTemp + zTemp; // (x-1) + y * data.width + z * data.width * data.height;
		xNext = (x + 1) + yTemp + zTemp; // (x+1) + y * data.width + z * data.width * data.height;
		yPrev = x + yTemp - data.width + zTemp; // x + (y-1) * data.width + z * data.width * data.height;
		yNext = x + yTemp + data.width + zTemp; // x + (y+1) * data.width + z * data.width * data.height;
		zPrev = x + yTemp + zTemp - xySurface; // x + y * data.width + (z-1) * data.width * data.height;
		zNext = x + yTemp + zTemp + xySurface; // x + y * data.width + (z+1) * data.width * data.height;
		if (x > 0 && x < data.width - 1 && y > 0 && y < data.height - 1 && z > 0 && z < data.depth - 1) {
			newValue =
			(
				data.elements[index] +
				data.elements[xPrev] +
				data.elements[xNext] +
				data.elements[yPrev] +
				data.elements[yNext] + 
				data.elements[zPrev] +
				data.elements[zNext]
				) / 7;
			__syncthreads();
			result.elements[index] = newValue;
		} else {
        // Edge or beyond, do not change.
           __syncthreads();
		}
		z += 1;
    }
}

//
// Allocate the data arrays and copy the data arrays we need for the Jacobi to
// the GPU
//
void jacobi_naive(Args args, Matrix A, Matrix B) {
    Matrix deviceA, deviceB;
    deviceA.width = A.width;
    deviceA.height = A.height;
    deviceA.depth = A.depth;
    deviceA.dimensions = A.dimensions;

    deviceB.width = B.width;
    deviceB.height = B.height;
    deviceB.depth = B.depth;
    deviceB.dimensions = B.dimensions;
    
    int threadx_dim = TILE_WIDTH;
    int thready_dim = TILE_HEIGHT;
	int blockx_dim = args.size/threadx_dim;
	int blocky_dim = args.size/thready_dim;
    size_t sizeA = A.width * A.height * A.depth * sizeof(float);
    size_t sizeB = B.width * B.height * B.depth * sizeof(float);

    cudaMalloc((void **) &deviceA.elements, sizeA);
    cudaMalloc((void **) &deviceB.elements, sizeB);

    cudaMemcpy(deviceA.elements, A.elements, sizeA, cudaMemcpyHostToDevice);

    int  z_size = args.size;
    dim3 blocks(blockx_dim, blocky_dim, 1);
    dim3 threads( threadx_dim, thready_dim, 1);
	for (int t = 0; t < args.iterations; t++) {
	   cached_plane<<<blocks, threads>>>(deviceA, deviceB, z_size);
	   swap(deviceA, deviceB);
    }

    cudaMemcpy(B.elements, deviceA.elements, sizeA, cudaMemcpyDeviceToHost);
}

void print_data(float *data, int size, int dimensions) {
    if (size > 17) {
        cerr << "Data too big to print\n" << endl;
        return;
    }

    if (dimensions == 1) {
        for (int x = 0; x < size; x++) {
            printf("%.3f ", data[x]);
        }
    } else if (dimensions == 2) {
        for (int y = 0; y < size; y++) {
            for (int x = 0; x < size; x++) {
                printf("%.3f ", data[y * size + x]);
            }
            cout << endl;
        }
    } else if (dimensions == 3) {
        for (int z = 0; z < size; z++) {
            for (int y = 0; y < size; y++) {
                for (int x = 0; x < size; x++) {
                    printf("%.3f ", data[z * size * size + y * size + x]);
                }
                cout << endl;
            }
            cout << endl;
        }
    }
    cout << endl << endl;
}

int main(int argc, char *argv[]) {
    Args args = parse_arguments(argc, argv);
    float runtime;
    struct timeval start, end;
    Matrix A, B;

    A = initialize_matrix(args.dimensions, args.size, args.size, args.size);
    B = initialize_matrix(args.dimensions, args.size, args.size, args.size);

    gettimeofday( &start, NULL ); 
    jacobi_naive(args, A, B);
    gettimeofday( &end, NULL ); 
    runtime = ( ( end.tv_sec  - start.tv_sec ) * 1000.0 ) + ( ( end.tv_usec - start.tv_usec ) / 1000.0 );
    printf( "Processing Time: %4.4f milliseconds\n", runtime );
	if (args.debug) { print_data(B.elements, args.size, args.dimensions); }
	
}

	.file	"tmpxft_00239cfd_00000000-6_cached_plane.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3660:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3660:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s in %s at line %d\n"
	.text
	.globl	_Z11HandleError9cudaErrorPKci
	.type	_Z11HandleError9cudaErrorPKci, @function
_Z11HandleError9cudaErrorPKci:
.LFB3648:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movl	%edx, 12(%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r8d
	movq	%rbx, %rcx
	movl	$2, %edi
	movq	%rax, %rdx
	leaq	.LC0(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	ret
	.cfi_endproc
.LFE3648:
	.size	_Z11HandleError9cudaErrorPKci, .-_Z11HandleError9cudaErrorPKci
	.section	.rodata.str1.1
.LC1:
	.string	"Cuda error: %s: %s.\n"
	.text
	.globl	_Z14checkCUDAErrorPKcb
	.type	_Z14checkCUDAErrorPKcb, @function
_Z14checkCUDAErrorPKcb:
.LFB3649:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%esi, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 32
	call	cudaGetLastError@PLT
	testl	%eax, %eax
	je	.L8
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movq	%rbp, %rcx
	leaq	.LC1(%rip), %rdx
	movq	%rax, %r8
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	testb	%bl, %bl
	je	.L8
	orl	$-1, %edi
	call	exit@PLT
.L8:
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3649:
	.size	_Z14checkCUDAErrorPKcb, .-_Z14checkCUDAErrorPKcb
	.section	.rodata.str1.1
.LC2:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/SudoBoyar/csc5593-gpu-project/master/Jacobi/cached_plane.cu"
	.text
	.globl	_Z11cleanupCudav
	.type	_Z11cleanupCudav, @function
_Z11cleanupCudav:
.LFB3650:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	cudaThreadExit@PLT
	movl	$58, %edx
	leaq	.LC2(%rip), %rsi
	popq	%rcx
	.cfi_def_cfa_offset 8
	movl	%eax, %edi
	jmp	_Z11HandleError9cudaErrorPKci
	.cfi_endproc
.LFE3650:
	.size	_Z11cleanupCudav, .-_Z11cleanupCudav
	.section	.rodata.str1.1
.LC3:
	.string	"%s\n"
.LC4:
	.string	"Options are:\n"
.LC5:
	.string	"-n<size> Set data size (default: 1024)"
.LC6:
	.string	"\t%s\n"
.LC7:
	.string	"-d<dims> Set number of data dimensions (1, 2, or 3) (default: 2)"
.LC8:
	.string	"-g<size> Set grid size"
.LC9:
	.string	"-b<num>  Set block count"
.LC10:
	.string	"-t<num>  Set thread count"
.LC11:
	.string	"-i<iter> Number of iterations to perform (default: 1000)"
.LC12:
	.string	"-x<size> X Dimension"
.LC13:
	.string	"-y<size> Y Dimension"
.LC14:
	.string	"-z<size> Z Dimension"
.LC15:
	.string	"-T<size> T Dimension"
.LC16:
	.string	"-S       Execute sequential, CPU version"
.LC17:
	.string	"-B       Execute blocked sequential, CPU version"
.LC18:
	.string	"-O       Execute sequential overlapped tiling, CPU version"
.LC19:
	.string	"-D       Print debug info"
.LC20:
	.string	"-h       Print usage info (this message)"
	.text
	.globl	_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
	.type	_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE, @function
_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE:
.LFB3651:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	cmpq	$0, 8(%rsi)
	movq	%rdi, %rbx
	je	.L17
	movq	%rsi, %rax
	movq	stderr(%rip), %rsi
	movq	(%rax), %rdi
	call	fputs@PLT
.L17:
	movq	stderr(%rip), %rdi
	movq	%rbx, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC3(%rip), %rdx
	leaq	.LC6(%rip), %rbx
	call	__fprintf_chk@PLT
	movq	stderr(%rip), %rdi
	leaq	.LC4(%rip), %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC5(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC7(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC8(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC9(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC10(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC11(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC12(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC13(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC14(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC15(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC16(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC17(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC18(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC19(%rip), %rcx
	call	__fprintf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC20(%rip), %rcx
	call	__fprintf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
	.cfi_endproc
.LFE3651:
	.size	_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE, .-_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
	.globl	_Z17initialize_matrixiiii
	.type	_Z17initialize_matrixiiii, @function
_Z17initialize_matrixiiii:
.LFB3653:
	.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
	movl	%r8d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%ecx, %r12d
	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
	movslq	%edx, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	cmpl	$1, %ebx
	setg	%al
	cmpl	$1, %esi
	jne	.L20
	testb	%al, %al
	je	.L20
	movl	%ebx, 8(%rdi)
	salq	$2, %rbx
	movl	$1, 4(%rdi)
	movl	$1, 12(%rdi)
	movq	%rbx, %rdi
	call	malloc@PLT
	movss	.LC21(%rip), %xmm0
	movq	%rax, 16(%rbp)
	movss	%xmm0, (%rax)
	movss	%xmm0, -4(%rax,%rbx)
	jmp	.L19
.L20:
	cmpl	$1, %r12d
	setg	%dl
	cmpl	$2, %esi
	jne	.L22
	testb	%dl, %al
	je	.L22
	movl	%ebx, %edi
	movl	%ebx, 8(%rbp)
	imull	%r12d, %edi
	movl	%r12d, 4(%rbp)
	movl	$1, 12(%rbp)
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	leal	-1(%r12), %edi
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	movl	%edi, %r9d
	movq	%rax, 16(%rbp)
	movss	.LC21(%rip), %xmm0
	imull	%ebx, %r9d
.L23:
	movslq	%ecx, %rdx
	leaq	(%rax,%rdx,4), %r8
	xorl	%edx, %edx
.L26:
	cmpl	%edx, %ebx
	jle	.L71
	movss	%xmm0, (%r8,%rdx,4)
	incq	%rdx
	jmp	.L26
.L71:
	addl	%edi, %esi
	addl	%r9d, %ecx
	cmpl	%esi, %r12d
	jg	.L23
	movslq	%ebx, %rdx
	movss	.LC21(%rip), %xmm0
	xorl	%esi, %esi
	xorl	%edi, %edi
	leaq	-4(,%rdx,4), %r8
	leal	-1(%rbx), %r9d
.L25:
	movslq	%esi, %rdx
	leaq	(%rax,%rdx,4), %rcx
	xorl	%edx, %edx
.L29:
	cmpl	%ebx, %edx
	jge	.L72
	movss	%xmm0, (%rcx)
	addl	%r9d, %edx
	addq	%r8, %rcx
	jmp	.L29
.L72:
	incl	%edi
	addl	%ebx, %esi
	cmpl	%edi, %r12d
	jg	.L25
	jmp	.L19
.L22:
	cmpl	$3, %esi
	jne	.L19
	testb	%al, %al
	je	.L19
	cmpl	$1, %r13d
	jle	.L19
	testb	%dl, %dl
	je	.L19
	movl	%ebx, %r14d
	movl	%ebx, 8(%rbp)
	imull	%r12d, %r14d
	movl	%r12d, 4(%rbp)
	movl	%r13d, 12(%rbp)
	movl	%r14d, %edi
	imull	%r13d, %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	leal	-1(%r12), %r8d
	movslq	%ebx, %rdx
	xorl	%edi, %edi
	movl	%r8d, %ecx
	movq	%rax, 16(%rbp)
	leal	-1(%rbx), %r10d
	movss	.LC21(%rip), %xmm0
	imull	%ebx, %ecx
	leaq	-4(,%rdx,4), %r9
	xorl	%edx, %edx
	movl	%ecx, 12(%rsp)
.L30:
	movl	%edx, %esi
	xorl	%ecx, %ecx
.L38:
	movslq	%esi, %r11
	leaq	(%rax,%r11,4), %r15
	xorl	%r11d, %r11d
.L33:
	cmpl	%ebx, %r11d
	jge	.L73
	movss	%xmm0, (%r15)
	addl	%r10d, %r11d
	addq	%r9, %r15
	jmp	.L33
.L73:
	incl	%ecx
	addl	%ebx, %esi
	cmpl	%ecx, %r12d
	jg	.L38
	movl	%edx, %esi
	xorl	%r11d, %r11d
.L32:
	movslq	%esi, %rcx
	leaq	(%rax,%rcx,4), %r15
	xorl	%ecx, %ecx
.L36:
	cmpl	%ecx, %ebx
	jle	.L74
	movss	%xmm0, (%r15,%rcx,4)
	incq	%rcx
	jmp	.L36
.L74:
	movl	12(%rsp), %ecx
	addl	%r8d, %r11d
	addl	%ecx, %esi
	cmpl	%r11d, %r12d
	jg	.L32
	incl	%edi
	addl	%r14d, %edx
	cmpl	%edi, %r13d
	jg	.L30
	leal	-1(%r13), %r10d
	movss	.LC21(%rip), %xmm0
	xorl	%edi, %edi
	xorl	%r8d, %r8d
	movl	%r10d, %r9d
	imull	%r12d, %r9d
	imull	%ebx, %r9d
.L37:
	movl	%edi, %esi
	xorl	%ecx, %ecx
.L42:
	movslq	%esi, %rdx
	leaq	(%rax,%rdx,4), %r11
	xorl	%edx, %edx
.L41:
	cmpl	%edx, %ebx
	jle	.L75
	movss	%xmm0, (%r11,%rdx,4)
	incq	%rdx
	jmp	.L41
.L75:
	incl	%ecx
	addl	%ebx, %esi
	cmpl	%ecx, %r12d
	jg	.L42
	addl	%r10d, %r8d
	addl	%r9d, %edi
	cmpl	%r8d, %r13d
	jg	.L37
.L19:
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	movq	%rbp, %rax
	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
.LFE3653:
	.size	_Z17initialize_matrixiiii, .-_Z17initialize_matrixiiii
	.section	.rodata.str1.1
.LC22:
	.string	"Data too big to print\n"
.LC23:
	.string	"%.3f "
	.text
	.globl	_Z10print_dataPfii
	.type	_Z10print_dataPfii, @function
_Z10print_dataPfii:
.LFB3656:
	.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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	cmpl	$17, %esi
	jle	.L77
	leaq	.LC22(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	jmp	.L96
.L77:
	movq	%rdi, %rbx
	movl	%esi, %ebp
	cmpl	$1, %edx
	jne	.L94
	xorl	%r12d, %r12d
	leaq	.LC23(%rip), %r13
.L78:
	cmpl	%r12d, %ebp
	jle	.L81
	movq	%r13, %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	(%rbx,%r12,4), %xmm0
	call	__printf_chk@PLT
	incq	%r12
	jmp	.L78
.L94:
	cmpl	$2, %edx
	jne	.L82
	movslq	%esi, %r13
	xorl	%r12d, %r12d
	leaq	.LC23(%rip), %r14
	salq	$2, %r13
.L83:
	cmpl	%ebp, %r12d
	jge	.L81
	leaq	0(%r13,%rbx), %r15
.L84:
	cvtss2sd	(%rbx), %xmm0
	movq	%r14, %rsi
	movl	$2, %edi
	movb	$1, %al
	call	__printf_chk@PLT
	addq	$4, %rbx
	cmpq	%r15, %rbx
	jne	.L84
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	incl	%r12d
	call	_ZNSolsEPFRSoS_E@PLT
	jmp	.L83
.L82:
	cmpl	$3, %edx
	jne	.L81
	movl	%esi, %eax
	movslq	%esi, %r15
	xorl	%r13d, %r13d
	imull	%esi, %eax
	cltq
	salq	$2, %rax
	movq	%rax, 16(%rsp)
	leaq	0(,%r15,4), %rax
	movq	%rax, 8(%rsp)
.L86:
	cmpl	%ebp, %r13d
	jge	.L81
	movq	%rbx, %r12
	xorl	%r14d, %r14d
.L89:
	movq	8(%rsp), %rax
	movq	%r12, %rdx
	addq	%rax, %r12
.L87:
	movl	$2, %edi
	movb	$1, %al
	leaq	.LC23(%rip), %rsi
	movq	%rdx, 24(%rsp)
	cvtss2sd	(%rdx), %xmm0
	call	__printf_chk@PLT
	movq	24(%rsp), %rdx
	addq	$4, %rdx
	cmpq	%r12, %rdx
	jne	.L87
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	incq	%r14
	call	_ZNSolsEPFRSoS_E@PLT
	cmpq	%r15, %r14
	leaq	_ZSt4cout(%rip), %rdi
	jne	.L89
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	incl	%r13d
	call	_ZNSolsEPFRSoS_E@PLT
	movq	16(%rsp), %rax
	addq	%rax, %rbx
	jmp	.L86
.L81:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZNSolsEPFRSoS_E@PLT
.L96:
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	movq	%rax, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_ZNSolsEPFRSoS_E@PLT
	.cfi_endproc
.LFE3656:
	.size	_Z10print_dataPfii, .-_Z10print_dataPfii
	.globl	_Z40__device_stub__Z12cached_plane6MatrixS_iR6MatrixS0_i
	.type	_Z40__device_stub__Z12cached_plane6MatrixS_iR6MatrixS0_i, @function
_Z40__device_stub__Z12cached_plane6MatrixS_iR6MatrixS0_i:
.LFB3682:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movl	%edx, 12(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rax
	movq	%rdi, 80(%rsp)
	leaq	32(%rsp), %rdi
	movq	%rsi, 88(%rsp)
	leaq	44(%rsp), %rsi
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movl	$1, 40(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L97
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z12cached_plane6MatrixS_i(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 144
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L97:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L99
	call	__stack_chk_fail@PLT
.L99:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3682:
	.size	_Z40__device_stub__Z12cached_plane6MatrixS_iR6MatrixS0_i, .-_Z40__device_stub__Z12cached_plane6MatrixS_iR6MatrixS0_i
	.globl	_Z12cached_plane6MatrixS_i
	.type	_Z12cached_plane6MatrixS_i, @function
_Z12cached_plane6MatrixS_i:
.LFB3683:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	%edi, %edx
	leaq	40(%rsp), %rsi
	leaq	16(%rsp), %rdi
	call	_Z40__device_stub__Z12cached_plane6MatrixS_iR6MatrixS0_i
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3683:
	.size	_Z12cached_plane6MatrixS_i, .-_Z12cached_plane6MatrixS_i
	.globl	_Z12jacobi_naive4Args6MatrixS0_
	.type	_Z12jacobi_naive4Args6MatrixS0_, @function
_Z12jacobi_naive4Args6MatrixS0_:
.LFB3654:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	addq	$-128, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	movl	244(%rsp), %edx
	movl	248(%rsp), %ebx
	leaq	40(%rsp), %rdi
	movl	252(%rsp), %eax
	movl	240(%rsp), %ecx
	movl	%ebx, 32(%rsp)
	imull	%edx, %ebx
	movl	272(%rsp), %ebp
	movl	276(%rsp), %r13d
	movl	268(%rsp), %r14d
	movl	%ecx, 24(%rsp)
	movl	264(%rsp), %ecx
	movl	%edx, 28(%rsp)
	imull	%eax, %ebx
	movl	%ebp, 56(%rsp)
	movl	180(%rsp), %r12d
	movl	%ecx, 48(%rsp)
	movl	%r13d, 60(%rsp)
	movslq	%ebx, %rbx
	movl	%eax, 36(%rsp)
	salq	$2, %rbx
	movl	%r14d, 52(%rsp)
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	movl	%ebp, %esi
	leaq	64(%rsp), %rdi
	xorl	%ebp, %ebp
	imull	%r14d, %esi
	imull	%r13d, %esi
	leaq	96(%rsp), %r13
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movq	256(%rsp), %rsi
	movq	40(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	%r12d, %eax
	movl	$8, %ecx
	movl	$1, 8(%rsp)
	cltd
	movl	$1, 20(%rsp)
	idivl	%ecx
	movl	%eax, (%rsp)
	movl	%eax, 4(%rsp)
	movabsq	$34359738376, %rax
	movq	%rax, 12(%rsp)
.L104:
	cmpl	%ebp, 236(%rsp)
	jle	.L109
	movl	20(%rsp), %ecx
	movq	12(%rsp), %rdx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movq	(%rsp), %rdi
	movl	8(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L105
	movq	40(%rsp), %rax
	movups	24(%rsp), %xmm0
	movl	%r12d, %edx
	movq	%r13, %rsi
	movups	48(%rsp), %xmm1
	leaq	72(%rsp), %rdi
	movq	%rax, 88(%rsp)
	movq	64(%rsp), %rax
	movups	%xmm0, 72(%rsp)
	movq	%rax, 112(%rsp)
	movups	%xmm1, 96(%rsp)
	call	_Z40__device_stub__Z12cached_plane6MatrixS_iR6MatrixS0_i
.L105:
	movups	48(%rsp), %xmm2
	movq	40(%rsp), %rax
	incl	%ebp
	movq	24(%rsp), %rcx
	movq	32(%rsp), %rdx
	movq	64(%rsp), %rsi
	movups	%xmm2, 24(%rsp)
	movq	%rcx, 48(%rsp)
	movq	%rsi, 40(%rsp)
	movq	%rdx, 56(%rsp)
	movq	%rax, 64(%rsp)
	jmp	.L104
.L109:
	movq	40(%rsp), %rsi
	movq	280(%rsp), %rdi
	movl	$2, %ecx
	movq	%rbx, %rdx
	call	cudaMemcpy@PLT
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L107
	call	__stack_chk_fail@PLT
.L107:
	subq	$-128, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3654:
	.size	_Z12jacobi_naive4Args6MatrixS0_, .-_Z12jacobi_naive4Args6MatrixS0_
	.section	.rodata.str1.1
.LC24:
	.string	"_Z12cached_plane6MatrixS_i"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3685:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC24(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z12cached_plane6MatrixS_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3685:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.str1.1,"aMS",@progbits,1
.LC25:
	.string	"basic_string: construction from null is not valid"
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IS3_EEPKcRKS3_,comdat
	.align 2
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, @function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_:
.LFB3986:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	16(%rdi), %rax
	movq	%rax, (%rdi)
	testq	%rsi, %rsi
	jne	.L113
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L118
	leaq	.LC25(%rip), %rdi
	call	_ZSt19__throw_logic_errorPKc@PLT
.L113:
	movq	%rdi, %rbx
	movq	%rsi, %rdi
	movq	%rsi, %rbp
	call	strlen@PLT
	movq	%rax, (%rsp)
	leaq	0(%rbp,%rax), %r12
	cmpq	$15, %rax
	jbe	.L115
	movq	%rsp, %rsi
	xorl	%edx, %edx
	movq	%rbx, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm@PLT
	movq	%rax, (%rbx)
	movq	(%rsp), %rax
	movq	%rax, 16(%rbx)
.L115:
	movq	(%rbx), %rdi
	movq	%r12, %rdx
	movq	%rbp, %rsi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_S_copy_charsEPcPKcS7_@PLT
	movq	(%rsp), %rax
	movq	(%rbx), %rdx
	movq	%rax, 8(%rbx)
	movb	$0, (%rdx,%rax)
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	je	.L116
.L118:
	call	__stack_chk_fail@PLT
.L116:
	addq	$16, %rsp
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3986:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_, .-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
	.set	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_
	.section	.rodata.str1.1
.LC26:
	.string	""
.LC27:
	.string	"Unrecognized option\n"
.LC28:
	.string	"n:d:g:j:b:t:i:x:y:z:T:hSBOD"
.LC29:
	.string	"Data size must be larger than 0"
.LC30:
	.string	"Data must be 1, 2, or 3 dimensions"
	.text
	.globl	_Z15parse_argumentsiPPc
	.type	_Z15parse_argumentsiPPc, @function
_Z15parse_argumentsiPPc:
.LFB3652:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA3652
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	$16, %ecx
	leaq	.LC28(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rdx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rdi, %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	rep stosl
.L120:
	movq	%r13, %rdx
	movq	%rbp, %rsi
	movl	%r12d, %edi
	call	getopt@PLT
	cmpl	$-1, %eax
	je	.L169
	subl	$66, %eax
	cmpl	$56, %eax
	ja	.L121
	leaq	.L123(%rip), %rdx
	movslq	(%rdx,%rax,4), %rax
	addq	%rdx, %rax
	notrack jmp	*%rax
	.section	.rodata
	.align 4
	.align 4
.L123:
	.long	.L141-.L123
	.long	.L121-.L123
	.long	.L140-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L139-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L138-.L123
	.long	.L137-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L136-.L123
	.long	.L135-.L123
	.long	.L134-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L133-.L123
	.long	.L121-.L123
	.long	.L132-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L131-.L123
	.long	.L130-.L123
	.long	.L129-.L123
	.long	.L128-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L127-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L126-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L121-.L123
	.long	.L125-.L123
	.long	.L124-.L123
	.long	.L122-.L123
	.text
.L140:
	movb	$1, (%rbx)
	jmp	.L120
.L138:
	movb	$1, 1(%rbx)
	jmp	.L120
.L141:
	movb	$1, 2(%rbx)
	jmp	.L120
.L139:
	movb	$1, 3(%rbx)
	jmp	.L120
.L127:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 4(%rbx)
	jmp	.L120
.L132:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 8(%rbx)
	jmp	.L120
.L131:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 48(%rbx)
	jmp	.L120
.L128:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 16(%rbx)
	jmp	.L120
.L133:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 52(%rbx)
	jmp	.L120
.L126:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 56(%rbx)
	jmp	.L120
.L129:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 60(%rbx)
	jmp	.L120
.L125:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 32(%rbx)
	jmp	.L120
.L136:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 20(%rbx)
	jmp	.L120
.L124:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 36(%rbx)
	jmp	.L120
.L135:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 24(%rbx)
	jmp	.L120
.L122:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 40(%rbx)
	jmp	.L120
.L134:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 28(%rbx)
	jmp	.L120
.L137:
	movq	optarg(%rip), %rdi
	call	atoi@PLT
	movl	%eax, 44(%rbx)
	jmp	.L120
.L130:
	leaq	8(%rsp), %r12
	leaq	7(%rsp), %rdx
	leaq	.LC26(%rip), %rsi
	movq	%r12, %rdi
.LEHB0:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE0:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L166
	movq	0(%rbp), %rdi
	movq	%r12, %rsi
.LEHB1:
	call	_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LEHE1:
.L121:
	leaq	8(%rsp), %r12
	leaq	7(%rsp), %rdx
	leaq	.LC27(%rip), %rsi
	movq	%r12, %rdi
.LEHB2:
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEPKcRKS3_
.LEHE2:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L166
	movq	0(%rbp), %rdi
	movq	%r12, %rsi
.LEHB3:
	call	_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LEHE3:
.L169:
	movl	4(%rbx), %eax
	leaq	.LC29(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	testl	%eax, %eax
	jle	.L167
	movl	8(%rbx), %edx
	leal	-1(%rdx), %ecx
	cmpl	$2, %ecx
	jbe	.L147
	leaq	.LC30(%rip), %rsi
	leaq	_ZSt4cerr(%rip), %rdi
.L167:
.LEHB4:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E@PLT
	movl	$1, %edi
	call	exit@PLT
.L147:
	cmpl	$1, %edx
	je	.L148
	movl	%eax, %ecx
	imull	%eax, %ecx
	imull	%ecx, %eax
	cmpl	$2, %edx
	jne	.L148
	movl	%ecx, %eax
.L148:
	movl	56(%rbx), %ecx
	movl	%eax, 12(%rbx)
	testl	%ecx, %ecx
	jle	.L149
	cltd
	idivl	%ecx
	jmp	.L164
.L149:
	movl	52(%rbx), %ecx
	testl	%ecx, %ecx
	jle	.L151
	cltd
	idivl	%ecx
	movl	%eax, 56(%rbx)
	jmp	.L119
.L151:
	movl	$16, 56(%rbx)
	sarl	$4, %eax
.L164:
	movl	%eax, 52(%rbx)
	jmp	.L119
.L158:
	endbr64
	jmp	.L168
.L159:
	endbr64
.L168:
	movq	%rax, %rbx
.L154:
	movq	%r12, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L166
	movq	%rbx, %rdi
	call	_Unwind_Resume@PLT
.LEHE4:
.L119:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L156
.L166:
	call	__stack_chk_fail@PLT
.L156:
	addq	$56, %rsp
	.cfi_def_cfa_offset 40
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3652:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA3652:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE3652-.LLSDACSB3652
.LLSDACSB3652:
	.uleb128 .LEHB0-.LFB3652
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB3652
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L158-.LFB3652
	.uleb128 0
	.uleb128 .LEHB2-.LFB3652
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB3-.LFB3652
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L159-.LFB3652
	.uleb128 0
	.uleb128 .LEHB4-.LFB3652
	.uleb128 .LEHE4-.LEHB4
	.uleb128 0
	.uleb128 0
.LLSDACSE3652:
	.text
	.size	_Z15parse_argumentsiPPc, .-_Z15parse_argumentsiPPc
	.section	.rodata.str1.1
.LC32:
	.string	"Processing Time: %4.4f milliseconds\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB3657:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rsi, %rdx
	movl	%edi, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$160, %rsp
	.cfi_def_cfa_offset 192
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	leaq	88(%rsp), %r12
	movq	%r12, %rdi
	call	_Z15parse_argumentsiPPc
	movl	92(%rsp), %ebx
	movl	96(%rsp), %ebp
	leaq	40(%rsp), %rdi
	movl	%ebx, %r8d
	movl	%ebx, %ecx
	movl	%ebx, %edx
	movl	%ebp, %esi
	call	_Z17initialize_matrixiiii
	movl	%ebx, %r8d
	movl	%ebx, %edx
	leaq	64(%rsp), %rdi
	movl	%ebx, %ecx
	movl	%ebp, %esi
	call	_Z17initialize_matrixiiii
	leaq	8(%rsp), %rdi
	xorl	%esi, %esi
	call	gettimeofday@PLT
	subq	$112, %rsp
	.cfi_def_cfa_offset 304
	movl	$16, %ecx
	movq	%r12, %rsi
	movq	192(%rsp), %rax
	movups	176(%rsp), %xmm3
	movq	%rsp, %rdi
	movups	152(%rsp), %xmm4
	movq	%rax, 104(%rsp)
	movq	168(%rsp), %rax
	movups	%xmm3, 88(%rsp)
	movups	%xmm4, 64(%rsp)
	movq	%rax, 80(%rsp)
	rep movsl
	call	_Z12jacobi_naive4Args6MatrixS0_
	addq	$112, %rsp
	.cfi_def_cfa_offset 192
	xorl	%esi, %esi
	leaq	24(%rsp), %rdi
	call	gettimeofday@PLT
	movq	24(%rsp), %rax
	subq	8(%rsp), %rax
	leaq	.LC32(%rip), %rsi
	cvtsi2sdq	%rax, %xmm0
	movq	32(%rsp), %rax
	subq	16(%rsp), %rax
	movl	$2, %edi
	cvtsi2sdq	%rax, %xmm1
	movsd	.LC31(%rip), %xmm2
	movb	$1, %al
	mulsd	%xmm2, %xmm0
	divsd	%xmm2, %xmm1
	addsd	%xmm1, %xmm0
	cvtsd2ss	%xmm0, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	cmpb	$0, 88(%rsp)
	je	.L171
	movq	80(%rsp), %rdi
	movl	%ebp, %edx
	movl	%ebx, %esi
	call	_Z10print_dataPfii
.L171:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L172
	call	__stack_chk_fail@PLT
.L172:
	addq	$160, %rsp
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3657:
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC21:
	.long	1065353216
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC31:
	.long	0
	.long	1083129856
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:



#include <hip/hip_runtime.h>
#include <stdio.h>
#include <iostream>
#include <unistd.h>
#include <sys/time.h>
#include <sys/time.h>

// Shorthand for formatting usage options
#define fpe(msg) fprintf(stderr, "\t%s\n", msg);

#define HANDLE_ERROR(err)  ( HandleError( err, __FILE__, __LINE__ ) )
#define MAX_THREADS (65536 * 1024)


/**
 * DEFINED VALUES HERE
 */

#define TILE_WIDTH 8
#define TILE_HEIGHT 8

using namespace std;

void HandleError(hipError_t err, const char *file, int line) {
    //
    // Handle and report on CUDA errors.
    //
    if (err != hipSuccess) {
        printf("%s in %s at line %d\n", hipGetErrorString(err), file, line);

        exit(EXIT_FAILURE);
    }
}

void checkCUDAError(const char *msg, bool exitOnError) {
    //
    // Check cuda error and print result if appropriate.
    //
    hipError_t err = hipGetLastError();

    if (hipSuccess != err) {
        fprintf(stderr, "Cuda error: %s: %s.\n", msg, hipGetErrorString(err));
        if (exitOnError) {
            exit(-1);
        }
    }
}

void cleanupCuda(void) {
    //
    // Clean up CUDA resources.
    //

    //
    // Explicitly cleans up all runtime-related resources associated with the
    // calling host thread.
    //
    HANDLE_ERROR(
        hipDeviceReset()
    );
}

struct Args {
    bool debug;
    bool sequential;
    bool blocked;
    bool overlapped;
    // Data attributes
    int size, dimensions, alloc_size, thread_dim;
    int xSize, ySize, zSize;
    int xBlockSize, yBlockSize, zBlockSize, tBlockSize;
    // Run attributes
    int grid_size, block_count, thread_count, iterations;
};


void usage(char *prog_name, string msg) {
    if (msg.size() > 0) {
        fputs(msg.c_str(), stderr);
    }

    fprintf(stderr, "%s\n", prog_name);
    fprintf(stderr, "Options are:\n");
    fpe("-n<size> Set data size (default: 1024)");
    fpe("-d<dims> Set number of data dimensions (1, 2, or 3) (default: 2)");
    fpe("-g<size> Set grid size");
    fpe("-b<num>  Set block count");
    fpe("-t<num>  Set thread count");
    fpe("-i<iter> Number of iterations to perform (default: 1000)");
    fpe("-x<size> X Dimension");
    fpe("-y<size> Y Dimension");
    fpe("-z<size> Z Dimension");
    fpe("-T<size> T Dimension");
    fpe("-S       Execute sequential, CPU version");
    fpe("-B       Execute blocked sequential, CPU version");
    fpe("-O       Execute sequential overlapped tiling, CPU version");
    fpe("-D       Print debug info");
    fpe("-h       Print usage info (this message)");
    exit(EXIT_FAILURE);
}

Args parse_arguments(int argc, char *argv[]) {
    Args args = Args();

    int opt;
    // Parse args
    while ((opt = getopt(argc, argv, "n:d:g:j:b:t:i:x:y:z:T:hSBOD")) != -1) {
        switch (opt) {
            case 'D':
                args.debug = true;
                break;
            case 'S':
                args.sequential = true;
                break;
            case 'B':
                args.blocked = true;
                break;
            case 'O':
                args.overlapped = true;
                break;
            case 'n':
                args.size = atoi(optarg);
                break;
            case 'd':
                args.dimensions = atoi(optarg);
               break;
            case 'g':
                args.grid_size = atoi(optarg);
                break;
            case 'j':
                args.thread_dim = atoi(optarg);
                break;
            case 'b':
                args.block_count = atoi(optarg);
                break;
            case 't':
                args.thread_count = atoi(optarg);
                break;
            case 'i':
                args.iterations = atoi(optarg);
                break;
            case 'x':
                args.xBlockSize = atoi(optarg);
                break;
            case 'X':
                args.xSize = atoi(optarg);
                break;
            case 'y':
                args.yBlockSize = atoi(optarg);
                break;
            case 'Y':
                args.ySize = atoi(optarg);
                break;
            case 'z':
                args.zBlockSize = atoi(optarg);
                break;
            case 'Z':
                args.zSize = atoi(optarg);
                break;
            case 'T':
                args.tBlockSize = atoi(optarg);
                break;
            case 'h':
                usage(argv[0], "");
                break;
            default:
                usage(argv[0], "Unrecognized option\n");
        }
    }

    // check sizes
    if (args.size <= 0) {
        cout << "Data size must be larger than 0" << endl;
        exit(EXIT_FAILURE);
    }

    if (args.dimensions <= 0 || args.dimensions >= 4) {
        cerr << "Data must be 1, 2, or 3 dimensions" << endl;
        exit(EXIT_FAILURE);
    }

    // Calculations
    if (args.dimensions == 1) {
        args.alloc_size = args.size;
    } else if (args.dimensions == 2) {
        args.alloc_size = args.size * args.size;
    } else {
        args.alloc_size = args.size * args.size * args.size;
    }

    if (args.thread_count > 0) {
        args.block_count = args.alloc_size / args.thread_count;
    } else if (args.block_count > 0) {
        args.thread_count = args.alloc_size / args.block_count;
    } else {
        args.thread_count = 16;
        args.block_count = args.alloc_size / args.thread_count;
    }

    return args;
}

typedef struct {
    int dimensions;
    int height;
    int width;
    int depth;
    float* elements;
} Matrix;

Matrix initialize_matrix(int dimensions, int width, int height = 1, int depth = 1) {
    Matrix data;

    if (dimensions == 1 && width > 1) {
        data.width = width;
        data.height = 1;
        data.depth = 1;
        data.elements = (float *) malloc(width * sizeof(float));

        data.elements[0] = 1.0;
        data.elements[width - 1] = 1.0;
    } else if (dimensions == 2 && width > 1 && height > 1) {
        data.width = width;
        data.height = height;
        data.depth = 1;
        data.elements = (float *) malloc(width * height * sizeof(float));

        for (int y = 0; y < height; y += height - 1) {
            for (int x = 0; x < width; x++) {
                data.elements[y * width + x] = 1.0;
            }
        }

        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x += width - 1) {
                data.elements[y * width + x] = 1.0;
            }
        }
    } else if (dimensions == 3 && width > 1 && height > 1 && depth > 1) {
        data.width = width;
        data.height = height;
        data.depth = depth;
        data.elements = (float *) malloc(width * height * depth * sizeof(float));

        for (int z = 0; z < depth; z++) {
            // X = 0 & N planes
            for (int y = 0; y < height; y++) {
                for (int x = 0; x < width; x += width - 1) {
                    data.elements[z * width * height + y * width + x] = 1.0;
                }
            }

            // Y = 0 & N planes
            for (int y = 0; y < height; y += height - 1) {
                for (int x = 0; x < width; x++) {
                    data.elements[z * width * height + y * width + x] = 1.0;
                }
            }
        }

        // Z = 0 & N planes
        for (int z = 0; z < depth; z += depth - 1) {
            for (int y = 0; y < height; y++) {
                for (int x = 0; x < width; x++) {
                    data.elements[z * width * height + y * width + x] = 1.0;
                }
            }
        }
    } else {
        // Bad data
    }

    return data;
}
//
// Cached plane algorithm that calculates all the results for the thread plane from 0 to the end of the
// block of global data.
//
__global__ void cached_plane(Matrix data, Matrix result, int z_size) {
    int threadDep = threadIdx.z;
    int threadRow = threadIdx.y;
    int threadCol = threadIdx.x;
    int blockDep = blockIdx.z;
    int blockRow = blockIdx.y;
    int blockCol = blockIdx.x;

    int x = blockCol * blockDim.x + threadCol;
    int y = blockRow * blockDim.y + threadRow;
	int z = blockDep * blockDim.z + threadDep;

    int xySurface = data.width * data.height;
    int yTemp = y * data.width;

	int zTemp, index, xPrev, xNext, yPrev, yNext, zPrev, zNext; 

	float newValue;
    
    while(z < z_size){
		zTemp = z * xySurface;
		index = x + yTemp + zTemp; // x + y * data.width + z * data.width * data.height;
		xPrev = (x - 1) + yTemp + zTemp; // (x-1) + y * data.width + z * data.width * data.height;
		xNext = (x + 1) + yTemp + zTemp; // (x+1) + y * data.width + z * data.width * data.height;
		yPrev = x + yTemp - data.width + zTemp; // x + (y-1) * data.width + z * data.width * data.height;
		yNext = x + yTemp + data.width + zTemp; // x + (y+1) * data.width + z * data.width * data.height;
		zPrev = x + yTemp + zTemp - xySurface; // x + y * data.width + (z-1) * data.width * data.height;
		zNext = x + yTemp + zTemp + xySurface; // x + y * data.width + (z+1) * data.width * data.height;
		if (x > 0 && x < data.width - 1 && y > 0 && y < data.height - 1 && z > 0 && z < data.depth - 1) {
			newValue =
			(
				data.elements[index] +
				data.elements[xPrev] +
				data.elements[xNext] +
				data.elements[yPrev] +
				data.elements[yNext] + 
				data.elements[zPrev] +
				data.elements[zNext]
				) / 7;
			__syncthreads();
			result.elements[index] = newValue;
		} else {
        // Edge or beyond, do not change.
           __syncthreads();
		}
		z += 1;
    }
}

//
// Allocate the data arrays and copy the data arrays we need for the Jacobi to
// the GPU
//
void jacobi_naive(Args args, Matrix A, Matrix B) {
    Matrix deviceA, deviceB;
    deviceA.width = A.width;
    deviceA.height = A.height;
    deviceA.depth = A.depth;
    deviceA.dimensions = A.dimensions;

    deviceB.width = B.width;
    deviceB.height = B.height;
    deviceB.depth = B.depth;
    deviceB.dimensions = B.dimensions;
    
    int threadx_dim = TILE_WIDTH;
    int thready_dim = TILE_HEIGHT;
	int blockx_dim = args.size/threadx_dim;
	int blocky_dim = args.size/thready_dim;
    size_t sizeA = A.width * A.height * A.depth * sizeof(float);
    size_t sizeB = B.width * B.height * B.depth * sizeof(float);

    hipMalloc((void **) &deviceA.elements, sizeA);
    hipMalloc((void **) &deviceB.elements, sizeB);

    hipMemcpy(deviceA.elements, A.elements, sizeA, hipMemcpyHostToDevice);

    int  z_size = args.size;
    dim3 blocks(blockx_dim, blocky_dim, 1);
    dim3 threads( threadx_dim, thready_dim, 1);
	for (int t = 0; t < args.iterations; t++) {
	   cached_plane<<<blocks, threads>>>(deviceA, deviceB, z_size);
	   swap(deviceA, deviceB);
    }

    hipMemcpy(B.elements, deviceA.elements, sizeA, hipMemcpyDeviceToHost);
}

void print_data(float *data, int size, int dimensions) {
    if (size > 17) {
        cerr << "Data too big to print\n" << endl;
        return;
    }

    if (dimensions == 1) {
        for (int x = 0; x < size; x++) {
            printf("%.3f ", data[x]);
        }
    } else if (dimensions == 2) {
        for (int y = 0; y < size; y++) {
            for (int x = 0; x < size; x++) {
                printf("%.3f ", data[y * size + x]);
            }
            cout << endl;
        }
    } else if (dimensions == 3) {
        for (int z = 0; z < size; z++) {
            for (int y = 0; y < size; y++) {
                for (int x = 0; x < size; x++) {
                    printf("%.3f ", data[z * size * size + y * size + x]);
                }
                cout << endl;
            }
            cout << endl;
        }
    }
    cout << endl << endl;
}

int main(int argc, char *argv[]) {
    Args args = parse_arguments(argc, argv);
    float runtime;
    struct timeval start, end;
    Matrix A, B;

    A = initialize_matrix(args.dimensions, args.size, args.size, args.size);
    B = initialize_matrix(args.dimensions, args.size, args.size, args.size);

    gettimeofday( &start, NULL ); 
    jacobi_naive(args, A, B);
    gettimeofday( &end, NULL ); 
    runtime = ( ( end.tv_sec  - start.tv_sec ) * 1000.0 ) + ( ( end.tv_usec - start.tv_usec ) / 1000.0 );
    printf( "Processing Time: %4.4f milliseconds\n", runtime );
	if (args.debug) { print_data(B.elements, args.size, args.dimensions); }
	
}

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

                                        # End of file scope inline assembly
	.globl	_Z11HandleError10hipError_tPKci # -- Begin function _Z11HandleError10hipError_tPKci
	.type	_Z11HandleError10hipError_tPKci,@function
_Z11HandleError10hipError_tPKci:        # @_Z11HandleError10hipError_tPKci
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	jne	.LBB0_2
# %bb.1:
	retq
.LBB0_2:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	%edx, %ebx
	movq	%rsi, %r14
	callq	hipGetErrorString
	movl	$.L.str, %edi
	movq	%rax, %rsi
	movq	%r14, %rdx
	movl	%ebx, %ecx
	xorl	%eax, %eax
	callq	printf
	movl	$1, %edi
	callq	exit
.Lfunc_end0:
	.size	_Z11HandleError10hipError_tPKci, .Lfunc_end0-_Z11HandleError10hipError_tPKci
	.cfi_endproc
                                        # -- End function
	.globl	_Z14checkCUDAErrorPKcb          # -- Begin function _Z14checkCUDAErrorPKcb
	.type	_Z14checkCUDAErrorPKcb,@function
_Z14checkCUDAErrorPKcb:                 # @_Z14checkCUDAErrorPKcb
	.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
	movl	%esi, %ebx
	movq	%rdi, %r14
	callq	hipGetLastError
	testl	%eax, %eax
	jne	.LBB1_1
.LBB1_2:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.LBB1_1:
	.cfi_def_cfa_offset 32
	movq	stderr(%rip), %r15
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.1, %esi
	movq	%r15, %rdi
	movq	%r14, %rdx
	movq	%rax, %rcx
	xorl	%eax, %eax
	callq	fprintf
	testb	%bl, %bl
	je	.LBB1_2
# %bb.3:
	movl	$-1, %edi
	callq	exit
.Lfunc_end1:
	.size	_Z14checkCUDAErrorPKcb, .Lfunc_end1-_Z14checkCUDAErrorPKcb
	.cfi_endproc
                                        # -- End function
	.globl	_Z11cleanupCudav                # -- Begin function _Z11cleanupCudav
	.type	_Z11cleanupCudav,@function
_Z11cleanupCudav:                       # @_Z11cleanupCudav
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	hipDeviceReset
	movl	$.L.str.2, %esi
	movl	%eax, %edi
	movl	$62, %edx
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	_Z11HandleError10hipError_tPKci # TAILCALL
.Lfunc_end2:
	.size	_Z11cleanupCudav, .Lfunc_end2-_Z11cleanupCudav
	.cfi_endproc
                                        # -- End function
	.globl	_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE # -- Begin function _Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
	.type	_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE,@function
_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE: # @_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movq	%rdi, %rbx
	cmpq	$0, 8(%rsi)
	je	.LBB3_2
# %bb.1:
	movq	(%rsi), %rdi
	movq	stderr(%rip), %rsi
	callq	fputs
.LBB3_2:
	movq	stderr(%rip), %rdi
	movl	$.L.str.3, %esi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rcx
	movl	$.L.str.4, %edi
	movl	$13, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.6, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.7, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.8, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.9, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.10, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.11, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.12, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.13, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.14, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.15, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.16, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.17, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.18, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.19, %edx
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	$.L.str.5, %esi
	movl	$.L.str.20, %edx
	xorl	%eax, %eax
	callq	fprintf
	movl	$1, %edi
	callq	exit
.Lfunc_end3:
	.size	_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE, .Lfunc_end3-_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
	.cfi_endproc
                                        # -- End function
	.globl	_Z15parse_argumentsiPPc         # -- Begin function _Z15parse_argumentsiPPc
	.type	_Z15parse_argumentsiPPc,@function
_Z15parse_argumentsiPPc:                # @_Z15parse_argumentsiPPc
	.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	$152, %rsp
	.cfi_def_cfa_offset 208
	.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	%rdx, %r13
	movl	%esi, %r15d
	movq	%rdi, %rbx
	xorps	%xmm0, %xmm0
	movups	%xmm0, (%rdi)
	leaq	56(%rdi), %rax
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	leaq	52(%rdi), %rax
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movl	4(%rdi), %r14d
	movb	3(%rdi), %al
	movb	%al, 14(%rsp)                   # 1-byte Spill
	movb	1(%rdi), %al
	movb	%al, 15(%rsp)                   # 1-byte Spill
	movb	2(%rdi), %r12b
	xorl	%eax, %eax
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	movl	$0, 52(%rsp)                    # 4-byte Folded Spill
	movl	$0, 48(%rsp)                    # 4-byte Folded Spill
	movl	$0, 56(%rsp)                    # 4-byte Folded Spill
	movl	$0, 60(%rsp)                    # 4-byte Folded Spill
	movl	$0, 44(%rsp)                    # 4-byte Folded Spill
	movl	$0, 40(%rsp)                    # 4-byte Folded Spill
	movl	$0, 36(%rsp)                    # 4-byte Folded Spill
	movl	$0, 32(%rsp)                    # 4-byte Folded Spill
	movl	$0, 28(%rsp)                    # 4-byte Folded Spill
	movl	$0, 24(%rsp)                    # 4-byte Folded Spill
	movl	$0, 20(%rsp)                    # 4-byte Folded Spill
	movl	$0, 16(%rsp)                    # 4-byte Folded Spill
	xorl	%ecx, %ecx
.LBB4_1:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
                                        # =>This Inner Loop Header: Depth=1
	movl	%ecx, %ebp
	movl	$.L.str.21, %edx
	movl	%r15d, %edi
	movq	%r13, %rsi
	callq	getopt
                                        # kill: def $eax killed $eax def $rax
	cmpl	$78, %eax
	jle	.LBB4_2
# %bb.6:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
                                        #   in Loop: Header=BB4_1 Depth=1
	leal	-83(%rax), %ecx
	cmpl	$39, %ecx
	ja	.LBB4_7
# %bb.9:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
                                        #   in Loop: Header=BB4_1 Depth=1
	jmpq	*.LJTI4_0(,%rcx,8)
.LBB4_10:                               #   in Loop: Header=BB4_1 Depth=1
	movb	$1, 15(%rsp)                    # 1-byte Folded Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_2:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
                                        #   in Loop: Header=BB4_1 Depth=1
	cmpl	$66, %eax
	je	.LBB4_11
# %bb.3:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
                                        #   in Loop: Header=BB4_1 Depth=1
	movb	$1, %cl
	cmpl	$68, %eax
	je	.LBB4_1
	jmp	.LBB4_4
.LBB4_11:                               #   in Loop: Header=BB4_1 Depth=1
	movb	$1, %r12b
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_7:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
                                        #   in Loop: Header=BB4_1 Depth=1
	cmpl	$79, %eax
	jne	.LBB4_5
# %bb.8:                                #   in Loop: Header=BB4_1 Depth=1
	movb	$1, 14(%rsp)                    # 1-byte Folded Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_23:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 24(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_21:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 32(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_12:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, %r14d
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_18:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 44(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_13:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
                                        # kill: def $eax killed $eax def $rax
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_16:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 56(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_24:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 20(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_22:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 28(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_15:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 48(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_20:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 36(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_25:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 16(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_19:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 40(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_14:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 52(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_17:                               #   in Loop: Header=BB4_1 Depth=1
	movq	optarg(%rip), %rdi
	callq	atoi
	movl	%eax, 60(%rsp)                  # 4-byte Spill
	movl	%ebp, %ecx
	jmp	.LBB4_1
.LBB4_4:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit
	cmpl	$-1, %eax
	jne	.LBB4_5
# %bb.28:
	movl	%r14d, 4(%rbx)
	movb	14(%rsp), %al                   # 1-byte Reload
	movb	%al, 3(%rbx)
	movb	%r12b, 2(%rbx)
	movb	15(%rsp), %al                   # 1-byte Reload
	movb	%al, 1(%rbx)
	movl	16(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 44(%rbx)
	movl	20(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 28(%rbx)
	movl	24(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 40(%rbx)
	movl	28(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 24(%rbx)
	movl	32(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 36(%rbx)
	movl	36(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 20(%rbx)
	movl	40(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 32(%rbx)
	movl	44(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 60(%rbx)
	movl	60(%rsp), %esi                  # 4-byte Reload
	movl	%esi, 56(%rbx)
	movl	56(%rsp), %edx                  # 4-byte Reload
	movl	%edx, 52(%rbx)
	movl	48(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 16(%rbx)
	movl	52(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 48(%rbx)
	movq	64(%rsp), %rdi                  # 8-byte Reload
	movl	%edi, 8(%rbx)
	movb	%bpl, (%rbx)
	testl	%r14d, %r14d
	jle	.LBB4_29
# %bb.31:
	leal	-4(%rdi), %eax
	cmpl	$-4, %eax
	movq	80(%rsp), %rcx                  # 8-byte Reload
	jbe	.LBB4_32
# %bb.33:
	cmpl	$1, %edi
	je	.LBB4_37
# %bb.34:
	cmpl	$2, %edi
	jne	.LBB4_36
# %bb.35:
	imull	%r14d, %r14d
	jmp	.LBB4_37
.LBB4_36:
	movl	%r14d, %eax
	imull	%r14d, %eax
	imull	%eax, %r14d
.LBB4_37:
	movl	%r14d, 12(%rbx)
	testl	%esi, %esi
	jg	.LBB4_41
# %bb.38:
	testl	%edx, %edx
	jle	.LBB4_40
# %bb.39:
	movl	%edx, %esi
	movq	72(%rsp), %rcx                  # 8-byte Reload
	jmp	.LBB4_41
.LBB4_40:
	movq	72(%rsp), %rax                  # 8-byte Reload
	movl	$16, (%rax)
	movl	$16, %esi
.LBB4_41:
	movl	%r14d, %eax
	cltd
	idivl	%esi
	movl	%eax, (%rcx)
	movq	%rbx, %rax
	addq	$152, %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_5:                                # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.exit23
	.cfi_def_cfa_offset 208
	movl	%r14d, 4(%rbx)
	movb	14(%rsp), %al                   # 1-byte Reload
	movb	%al, 3(%rbx)
	movb	%r12b, 2(%rbx)
	movb	15(%rsp), %al                   # 1-byte Reload
	movb	%al, 1(%rbx)
	movl	16(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 44(%rbx)
	movl	20(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 28(%rbx)
	movl	24(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 40(%rbx)
	movl	28(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 24(%rbx)
	movl	32(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 36(%rbx)
	movl	36(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 20(%rbx)
	movl	40(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 32(%rbx)
	movl	44(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 60(%rbx)
	movl	60(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 56(%rbx)
	movl	56(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 52(%rbx)
	movl	48(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 16(%rbx)
	movl	52(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 48(%rbx)
	movq	64(%rsp), %rax                  # 8-byte Reload
	movl	%eax, 8(%rbx)
	movb	%bpl, (%rbx)
	movq	(%r13), %rbx
	leaq	104(%rsp), %rax
	movq	%rax, -16(%rax)
	leaq	88(%rsp), %r14
	movl	$.L.str.23, %esi
	movl	$.L.str.23+20, %edx
	jmp	.LBB4_27
.LBB4_26:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.exit
	movl	%r14d, 4(%rbx)
	movb	14(%rsp), %al                   # 1-byte Reload
	movb	%al, 3(%rbx)
	movb	%r12b, 2(%rbx)
	movb	15(%rsp), %al                   # 1-byte Reload
	movb	%al, 1(%rbx)
	movl	16(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 44(%rbx)
	movl	20(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 28(%rbx)
	movl	24(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 40(%rbx)
	movl	28(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 24(%rbx)
	movl	32(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 36(%rbx)
	movl	36(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 20(%rbx)
	movl	40(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 32(%rbx)
	movl	44(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 60(%rbx)
	movl	60(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 56(%rbx)
	movl	56(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 52(%rbx)
	movl	48(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 16(%rbx)
	movl	52(%rsp), %eax                  # 4-byte Reload
	movl	%eax, 48(%rbx)
	movq	64(%rsp), %rax                  # 8-byte Reload
	movl	%eax, 8(%rbx)
	movb	%bpl, (%rbx)
	movq	(%r13), %rbx
	leaq	136(%rsp), %rax
	movq	%rax, -16(%rax)
	leaq	120(%rsp), %r14
	movl	$.L.str.22, %esi
	movl	$.L.str.22, %edx
.LBB4_27:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_.exit
	movq	%r14, %rdi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_Z5usagePcNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
.LBB4_29:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.24, %esi
	jmp	.LBB4_30
.LBB4_32:
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.25, %esi
.LBB4_30:
	callq	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
	movq	%rax, %rdi
	callq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
	movl	$1, %edi
	callq	exit
.Lfunc_end4:
	.size	_Z15parse_argumentsiPPc, .Lfunc_end4-_Z15parse_argumentsiPPc
	.cfi_endproc
	.section	.rodata,"a",@progbits
	.p2align	3, 0x0
.LJTI4_0:
	.quad	.LBB4_10
	.quad	.LBB4_25
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_20
	.quad	.LBB4_22
	.quad	.LBB4_24
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_16
	.quad	.LBB4_5
	.quad	.LBB4_13
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_14
	.quad	.LBB4_26
	.quad	.LBB4_18
	.quad	.LBB4_15
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_12
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_17
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_5
	.quad	.LBB4_19
	.quad	.LBB4_21
	.quad	.LBB4_23
                                        # -- End function
	.text
	.globl	_Z17initialize_matrixiiii       # -- Begin function _Z17initialize_matrixiiii
	.type	_Z17initialize_matrixiiii,@function
_Z17initialize_matrixiiii:              # @_Z17initialize_matrixiiii
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%r8d, %r12d
	movl	%ecx, %r15d
	movl	%edx, %r14d
	movq	%rdi, %rbx
	movl	%edx, %r13d
	cmpl	$1, %esi
	jne	.LBB5_3
# %bb.1:
	cmpl	$2, %r14d
	jl	.LBB5_3
# %bb.2:
	movl	%r14d, 8(%rbx)
	movl	$1, %eax
	movl	%eax, 4(%rbx)
	movl	%eax, 12(%rbx)
	leaq	(,%r13,4), %rdi
	callq	malloc
	movq	%rax, 16(%rbx)
	movl	$1065353216, %ecx               # imm = 0x3F800000
	movl	%ecx, (%rax)
	movl	%ecx, -4(%rax,%r13,4)
	jmp	.LBB5_37
.LBB5_3:
	cmpl	$2, %esi
	jne	.LBB5_16
# %bb.4:
	cmpl	$2, %r14d
	jl	.LBB5_16
# %bb.5:
	cmpl	$2, %r15d
	jl	.LBB5_16
# %bb.6:
	movl	%r14d, 8(%rbx)
	movl	%r15d, 4(%rbx)
	movl	$1, 12(%rbx)
	movl	%r15d, %eax
	imull	%r14d, %eax
	movslq	%eax, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, 16(%rbx)
	leal	-1(%r15), %edx
	movl	%r15d, %ecx
	movq	%r13, %rsi
	imulq	%rdx, %rsi
	shlq	$2, %rsi
	xorl	%edi, %edi
	movq	%rax, %r8
.LBB5_7:                                # %.lr.ph141
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_8 Depth 2
	xorl	%r9d, %r9d
.LBB5_8:                                #   Parent Loop BB5_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$1065353216, (%r8,%r9,4)        # imm = 0x3F800000
	incq	%r9
	cmpq	%r9, %r13
	jne	.LBB5_8
# %bb.9:                                # %._crit_edge142
                                        #   in Loop: Header=BB5_7 Depth=1
	addq	%rdx, %rdi
	addq	%rsi, %r8
	cmpq	%rcx, %rdi
	jb	.LBB5_7
# %bb.10:                               # %.preheader116
	testl	%r15d, %r15d
	jle	.LBB5_37
# %bb.11:                               # %.preheader.lr.ph
	leal	-1(%r14), %edx
	movslq	%edx, %rdx
	leaq	(,%r13,4), %rsi
	xorl	%edi, %edi
.LBB5_12:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_14 Depth 2
	testl	%r14d, %r14d
	jle	.LBB5_15
# %bb.13:                               # %.lr.ph145
                                        #   in Loop: Header=BB5_12 Depth=1
	xorl	%r8d, %r8d
.LBB5_14:                               #   Parent Loop BB5_12 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$1065353216, (%rax,%r8,4)       # imm = 0x3F800000
	addq	%rdx, %r8
	cmpq	%r13, %r8
	jl	.LBB5_14
.LBB5_15:                               # %._crit_edge146
                                        #   in Loop: Header=BB5_12 Depth=1
	incq	%rdi
	addq	%rsi, %rax
	cmpq	%rcx, %rdi
	jne	.LBB5_12
	jmp	.LBB5_37
.LBB5_16:
	cmpl	$2, %r15d
	jl	.LBB5_37
# %bb.17:
	cmpl	$2, %r14d
	jl	.LBB5_37
# %bb.18:
	cmpl	$3, %esi
	jne	.LBB5_37
# %bb.19:
	cmpl	$2, %r12d
	jl	.LBB5_37
# %bb.20:
	movl	%r14d, 8(%rbx)
	movl	%r15d, 4(%rbx)
	movl	%r12d, 12(%rbx)
	movl	%r15d, %ebp
	imull	%r14d, %ebp
	movl	%ebp, %eax
	imull	%r12d, %eax
	movslq	%eax, %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rbx, (%rsp)                    # 8-byte Spill
	movq	%rax, 16(%rbx)
	leal	-1(%r14), %ecx
	leal	-1(%r15), %edx
	movl	%r14d, %esi
	imull	%edx, %esi
	xorl	%edi, %edi
	xorl	%r8d, %r8d
.LBB5_21:                               # %.preheader123.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_22 Depth 2
                                        #       Child Loop BB5_23 Depth 3
                                        #     Child Loop BB5_26 Depth 2
                                        #       Child Loop BB5_27 Depth 3
	movq	%rdi, %r9
	xorl	%r10d, %r10d
.LBB5_22:                               # %.lr.ph
                                        #   Parent Loop BB5_21 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB5_23 Depth 3
	xorl	%r11d, %r11d
.LBB5_23:                               #   Parent Loop BB5_21 Depth=1
                                        #     Parent Loop BB5_22 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	leal	(%r9,%r11), %ebx
	movslq	%ebx, %rbx
	movl	$1065353216, (%rax,%rbx,4)      # imm = 0x3F800000
	addq	%rcx, %r11
	cmpq	%r13, %r11
	jl	.LBB5_23
# %bb.24:                               # %._crit_edge
                                        #   in Loop: Header=BB5_22 Depth=2
	incl	%r10d
	addq	%r13, %r9
	cmpl	%r15d, %r10d
	jne	.LBB5_22
# %bb.25:                               # %.preheader122.lr.ph
                                        #   in Loop: Header=BB5_21 Depth=1
	xorl	%r9d, %r9d
	movq	%rdi, %r10
.LBB5_26:                               # %.lr.ph129
                                        #   Parent Loop BB5_21 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB5_27 Depth 3
	xorl	%r11d, %r11d
.LBB5_27:                               #   Parent Loop BB5_21 Depth=1
                                        #     Parent Loop BB5_26 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	leal	(%r10,%r11), %ebx
	movslq	%ebx, %rbx
	movl	$1065353216, (%rax,%rbx,4)      # imm = 0x3F800000
	incq	%r11
	cmpq	%r11, %r13
	jne	.LBB5_27
# %bb.28:                               # %._crit_edge130
                                        #   in Loop: Header=BB5_26 Depth=2
	addl	%edx, %r9d
	addq	%rsi, %r10
	cmpl	%r15d, %r9d
	jl	.LBB5_26
# %bb.29:                               # %._crit_edge132
                                        #   in Loop: Header=BB5_21 Depth=1
	incl	%r8d
	addq	%rbp, %rdi
	cmpl	%r12d, %r8d
	jne	.LBB5_21
# %bb.30:                               # %.preheader120
	testl	%r12d, %r12d
	movq	(%rsp), %rbx                    # 8-byte Reload
	jle	.LBB5_37
# %bb.31:                               # %.preheader119.lr.ph
	leal	-1(%r12), %ecx
	imull	%ecx, %ebp
	xorl	%edx, %edx
	xorl	%esi, %esi
.LBB5_32:                               # %.preheader119
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB5_34 Depth 2
                                        #       Child Loop BB5_38 Depth 3
	testl	%r15d, %r15d
	jle	.LBB5_36
# %bb.33:                               # %.preheader118.lr.ph
                                        #   in Loop: Header=BB5_32 Depth=1
	xorl	%edi, %edi
	movl	%edx, %r8d
.LBB5_34:                               # %.preheader118
                                        #   Parent Loop BB5_32 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB5_38 Depth 3
	movq	%r13, %r9
	movl	%r8d, %r10d
	testl	%r13d, %r13d
	jle	.LBB5_35
.LBB5_38:                               #   Parent Loop BB5_32 Depth=1
                                        #     Parent Loop BB5_34 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	movslq	%r10d, %r10
	movl	$1065353216, (%rax,%r10,4)      # imm = 0x3F800000
	incl	%r10d
	decq	%r9
	jne	.LBB5_38
.LBB5_35:                               # %._crit_edge136
                                        #   in Loop: Header=BB5_34 Depth=2
	incl	%edi
	addl	%r14d, %r8d
	cmpl	%r15d, %edi
	jne	.LBB5_34
.LBB5_36:                               # %._crit_edge138
                                        #   in Loop: Header=BB5_32 Depth=1
	addl	%ecx, %esi
	addl	%ebp, %edx
	cmpl	%r12d, %esi
	jl	.LBB5_32
.LBB5_37:                               # %.loopexit
	movq	%rbx, %rax
	addq	$8, %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	_Z17initialize_matrixiiii, .Lfunc_end5-_Z17initialize_matrixiiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__cached_plane6MatrixS_i # -- Begin function _Z27__device_stub__cached_plane6MatrixS_i
	.type	_Z27__device_stub__cached_plane6MatrixS_i,@function
_Z27__device_stub__cached_plane6MatrixS_i: # @_Z27__device_stub__cached_plane6MatrixS_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	$96, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	144(%rsp), %rcx
	leaq	64(%rsp), %rbx
	movq	%rcx, (%rbx)
	leaq	168(%rsp), %rcx
	movq	%rcx, 8(%rbx)
	movq	%rax, 16(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%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	$_Z12cached_plane6MatrixS_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$112, %rsp
	.cfi_adjust_cfa_offset -112
	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_end6:
	.size	_Z27__device_stub__cached_plane6MatrixS_i, .Lfunc_end6-_Z27__device_stub__cached_plane6MatrixS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z12jacobi_naive4Args6MatrixS0_ # -- Begin function _Z12jacobi_naive4Args6MatrixS0_
	.type	_Z12jacobi_naive4Args6MatrixS0_,@function
_Z12jacobi_naive4Args6MatrixS0_:        # @_Z12jacobi_naive4Args6MatrixS0_
	.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
	leaq	280(%rsp), %r9
	movl	264(%rsp), %eax
	leaq	64(%rsp), %r15
	movl	%eax, -8(%r15)
	movl	256(%rsp), %ecx
	movl	260(%rsp), %edx
	movl	%edx, -12(%r15)
	movl	268(%rsp), %esi
	movl	%esi, -4(%r15)
	movl	%ecx, -16(%r15)
	movl	8(%r9), %ecx
	leaq	96(%rsp), %r12
	movl	%ecx, -8(%r12)
	movl	(%r9), %edi
	movl	4(%r9), %r8d
	movl	%r8d, -12(%r12)
	movl	12(%r9), %r9d
	movl	%r9d, -4(%r12)
	movl	%edi, -16(%r12)
	movl	196(%rsp), %ebx
	leal	7(%rbx), %ebp
	testl	%ebx, %ebx
	cmovnsl	%ebx, %ebp
	imull	%eax, %edx
	imull	%esi, %edx
	movslq	%edx, %r14
	shlq	$2, %r14
	imull	%ecx, %r8d
	imull	%r9d, %r8d
	movslq	%r8d, %r13
	shlq	$2, %r13
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	%r12, %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	movq	(%r15), %rdi
	movq	272(%rsp), %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	252(%rsp), %r13d
	testl	%r13d, %r13d
	jle	.LBB7_5
# %bb.1:
	sarl	$3, %ebp
	movq	%rbp, %r15
	shlq	$32, %r15
	orq	%rbp, %r15
	movabsq	$34359738376, %r12              # imm = 0x800000008
.LBB7_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	movl	$1, %esi
	movq	%r12, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_4
# %bb.3:                                #   in Loop: Header=BB7_2 Depth=1
	movq	96(%rsp), %rax
	movq	%rax, 40(%rsp)
	movups	80(%rsp), %xmm0
	movups	%xmm0, 24(%rsp)
	movq	64(%rsp), %rax
	movq	%rax, 16(%rsp)
	movups	48(%rsp), %xmm0
	movups	%xmm0, (%rsp)
	movl	%ebx, %edi
	callq	_Z27__device_stub__cached_plane6MatrixS_i
.LBB7_4:                                #   in Loop: Header=BB7_2 Depth=1
	movq	64(%rsp), %rax
	movaps	48(%rsp), %xmm0
	movaps	80(%rsp), %xmm1
	movaps	%xmm1, 48(%rsp)
	movq	96(%rsp), %rcx
	movq	%rcx, 64(%rsp)
	movaps	%xmm0, 80(%rsp)
	movq	%rax, 96(%rsp)
	decl	%r13d
	jne	.LBB7_2
.LBB7_5:                                # %._crit_edge
	leaq	280(%rsp), %rax
	movq	16(%rax), %rdi
	movq	64(%rsp), %rsi
	movq	%r14, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	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
.Lfunc_end7:
	.size	_Z12jacobi_naive4Args6MatrixS0_, .Lfunc_end7-_Z12jacobi_naive4Args6MatrixS0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z10print_dataPfii              # -- Begin function _Z10print_dataPfii
	.type	_Z10print_dataPfii,@function
_Z10print_dataPfii:                     # @_Z10print_dataPfii
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.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, 8(%rsp)                   # 8-byte Spill
	cmpl	$18, %esi
	jl	.LBB8_2
# %bb.1:
	movl	$_ZSt4cerr, %ebx
	movl	$_ZSt4cerr, %edi
	movl	$.L.str.26, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB8_21
.LBB8_2:
	movl	%esi, %ebp
	cmpl	$1, %edx
	je	.LBB8_17
# %bb.3:
	cmpl	$2, %edx
	je	.LBB8_12
# %bb.4:
	cmpl	$3, %edx
	jne	.LBB8_20
# %bb.5:                                # %.preheader46
	testl	%ebp, %ebp
	jle	.LBB8_20
# %bb.6:                                # %.preheader45.lr.ph
	movl	%ebp, %r14d
	movl	%ebp, %eax
	imull	%ebp, %eax
	movl	%eax, 20(%rsp)                  # 4-byte Spill
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB8_7:                                # %.preheader44.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_8 Depth 2
                                        #       Child Loop BB8_9 Depth 3
	movq	%rcx, 24(%rsp)                  # 8-byte Spill
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movl	%eax, %r12d
	xorl	%r15d, %r15d
.LBB8_8:                                # %.preheader44
                                        #   Parent Loop BB8_7 Depth=1
                                        # =>  This Loop Header: Depth=2
                                        #       Child Loop BB8_9 Depth 3
	movslq	%r12d, %rax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r13
	xorl	%ebx, %ebx
.LBB8_9:                                #   Parent Loop BB8_7 Depth=1
                                        #     Parent Loop BB8_8 Depth=2
                                        # =>    This Inner Loop Header: Depth=3
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r13,%rbx,4), %xmm0
	movl	$.L.str.27, %edi
	movb	$1, %al
	callq	printf
	incq	%rbx
	cmpq	%rbx, %r14
	jne	.LBB8_9
# %bb.10:                               # %._crit_edge
                                        #   in Loop: Header=BB8_8 Depth=2
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%r15
	addl	%ebp, %r12d
	cmpq	%r14, %r15
	jne	.LBB8_8
# %bb.11:                               # %._crit_edge50
                                        #   in Loop: Header=BB8_7 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	24(%rsp), %rcx                  # 8-byte Reload
	incq	%rcx
	movq	32(%rsp), %rax                  # 8-byte Reload
	addl	20(%rsp), %eax                  # 4-byte Folded Reload
	cmpq	%r14, %rcx
	jne	.LBB8_7
	jmp	.LBB8_20
.LBB8_12:                               # %.preheader42
	testl	%ebp, %ebp
	jle	.LBB8_20
# %bb.13:                               # %.preheader41.lr.ph
	movl	%ebp, %r14d
	xorl	%ebx, %ebx
	xorl	%r13d, %r13d
.LBB8_14:                               # %.lr.ph53
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB8_15 Depth 2
	movl	%ebx, %eax
	movq	8(%rsp), %rcx                   # 8-byte Reload
	leaq	(%rcx,%rax,4), %r12
	xorl	%r15d, %r15d
.LBB8_15:                               #   Parent Loop BB8_14 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r12,%r15,4), %xmm0
	movl	$.L.str.27, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB8_15
# %bb.16:                               # %._crit_edge54
                                        #   in Loop: Header=BB8_14 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	movl	$_ZSt4cout, %eax
	addq	%rax, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incq	%r13
	addl	%ebp, %ebx
	cmpq	%r14, %r13
	jne	.LBB8_14
	jmp	.LBB8_20
.LBB8_17:                               # %.preheader
	testl	%ebp, %ebp
	jle	.LBB8_20
# %bb.18:                               # %.lr.ph57.preheader
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
.LBB8_19:                               # %.lr.ph57
                                        # =>This Inner Loop Header: Depth=1
	movq	8(%rsp), %rax                   # 8-byte Reload
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rax,%r15,4), %xmm0
	movl	$.L.str.27, %edi
	movb	$1, %al
	callq	printf
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB8_19
.LBB8_20:                               # %.loopexit
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %ecx
	movq	-24(%rax), %rdi
	addq	%rcx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	%rax, %rbx
.LBB8_21:
	movq	(%rbx), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%rbx, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_ZNSo5flushEv                   # TAILCALL
.Lfunc_end8:
	.size	_Z10print_dataPfii, .Lfunc_end8-_Z10print_dataPfii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI9_0:
	.quad	0x408f400000000000              # double 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	$264, %rsp                      # imm = 0x108
	.cfi_def_cfa_offset 320
	.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, %rdx
	movl	%edi, %esi
	leaq	200(%rsp), %r14
	movq	%r14, %rdi
	callq	_Z15parse_argumentsiPPc
	movl	4(%r14), %ebp
	movl	8(%r14), %ebx
	leaq	176(%rsp), %r13
	movq	%r13, %rdi
	movl	%ebx, %esi
	movl	%ebp, %edx
	movl	%ebp, %ecx
	movl	%ebp, %r8d
	callq	_Z17initialize_matrixiiii
	leaq	136(%rsp), %r15
	movq	%r15, %rdi
	movl	%ebx, %esi
	movl	%ebp, %edx
	movl	%ebp, %ecx
	movl	%ebp, %r8d
	callq	_Z17initialize_matrixiiii
	movups	(%r15), %xmm0
	movaps	%xmm0, 112(%rsp)
	movq	16(%r15), %r15
	leaq	136(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	%r15, 128(%rsp)
	movq	%r15, 104(%rsp)
	movaps	112(%rsp), %xmm0
	movups	%xmm0, 88(%rsp)
	movq	16(%r13), %rax
	movq	%rax, 80(%rsp)
	movups	(%r13), %xmm0
	movups	%xmm0, 64(%rsp)
	movups	(%r14), %xmm0
	movups	16(%r14), %xmm1
	movups	32(%r14), %xmm2
	movups	48(%r14), %xmm3
	movups	%xmm3, 48(%rsp)
	movups	%xmm2, 32(%rsp)
	movups	%xmm1, 16(%rsp)
	movups	%xmm0, (%rsp)
	callq	_Z12jacobi_naive4Args6MatrixS0_
	leaq	160(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r13), %rax
	subq	(%r12), %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	movq	8(%r13), %rax
	movsd	.LCPI9_0(%rip), %xmm1           # xmm1 = mem[0],zero
	subq	8(%r12), %rax
	mulsd	%xmm1, %xmm0
	xorps	%xmm2, %xmm2
	cvtsi2sd	%rax, %xmm2
	divsd	%xmm1, %xmm2
	addsd	%xmm0, %xmm2
	xorps	%xmm0, %xmm0
	cvtsd2ss	%xmm2, %xmm0
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.28, %edi
	movb	$1, %al
	callq	printf
	cmpb	$0, (%r14)
	je	.LBB9_2
# %bb.1:
	movq	%r15, %rdi
	movl	%ebp, %esi
	movl	%ebx, %edx
	callq	_Z10print_dataPfii
.LBB9_2:
	xorl	%eax, %eax
	addq	$264, %rsp                      # imm = 0x108
	.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_end9:
	.size	main, .Lfunc_end9-main
	.cfi_endproc
                                        # -- End function
	.section	.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,"axG",@progbits,_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,comdat
	.weak	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag # -- Begin function _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.p2align	1, 0x90
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag,@function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag: # @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r14
	movq	%rsi, %r15
	movq	%rdi, %rbx
	subq	%rsi, %r14
	movq	%r14, (%rsp)
	cmpq	$15, %r14
	jbe	.LBB10_1
# %bb.2:
	movq	%rsp, %r12
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERmm
	movq	%rax, (%rbx)
	movq	(%r12), %rcx
	movq	%rcx, 16(%rbx)
	jmp	.LBB10_3
.LBB10_1:                               # %._crit_edge
	movq	(%rbx), %rax
.LBB10_3:
	testq	%r14, %r14
	je	.LBB10_7
# %bb.4:
	cmpq	$1, %r14
	jne	.LBB10_6
# %bb.5:
	movb	(%r15), %cl
	movb	%cl, (%rax)
	jmp	.LBB10_7
.LBB10_6:
	movq	%rax, %rdi
	movq	%r15, %rsi
	movq	%r14, %rdx
	callq	memcpy@PLT
.LBB10_7:                               # %_ZZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tagEN6_GuardD2Ev.exit
	movq	(%rsp), %rax
	movq	%rax, 8(%rbx)
	movq	(%rbx), %rcx
	movb	$0, (%rcx,%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end10:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag, .Lfunc_end10-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPKcEEvT_S8_St20forward_iterator_tag
	.cfi_endproc
                                        # -- End function
	.text
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB11_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB11_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12cached_plane6MatrixS_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_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	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"%s in %s at line %d\n"
	.size	.L.str, 21

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"Cuda error: %s: %s.\n"
	.size	.L.str.1, 21

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/SudoBoyar/csc5593-gpu-project/master/Jacobi/cached_plane.hip"
	.size	.L.str.2, 123

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Options are:\n"
	.size	.L.str.4, 14

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"\t%s\n"
	.size	.L.str.5, 5

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"-n<size> Set data size (default: 1024)"
	.size	.L.str.6, 39

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"-d<dims> Set number of data dimensions (1, 2, or 3) (default: 2)"
	.size	.L.str.7, 65

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"-g<size> Set grid size"
	.size	.L.str.8, 23

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"-b<num>  Set block count"
	.size	.L.str.9, 25

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"-t<num>  Set thread count"
	.size	.L.str.10, 26

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"-i<iter> Number of iterations to perform (default: 1000)"
	.size	.L.str.11, 57

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"-x<size> X Dimension"
	.size	.L.str.12, 21

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"-y<size> Y Dimension"
	.size	.L.str.13, 21

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"-z<size> Z Dimension"
	.size	.L.str.14, 21

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"-T<size> T Dimension"
	.size	.L.str.15, 21

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"-S       Execute sequential, CPU version"
	.size	.L.str.16, 41

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"-B       Execute blocked sequential, CPU version"
	.size	.L.str.17, 49

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"-O       Execute sequential overlapped tiling, CPU version"
	.size	.L.str.18, 59

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"-D       Print debug info"
	.size	.L.str.19, 26

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"-h       Print usage info (this message)"
	.size	.L.str.20, 41

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"n:d:g:j:b:t:i:x:y:z:T:hSBOD"
	.size	.L.str.21, 28

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.zero	1
	.size	.L.str.22, 1

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"Unrecognized option\n"
	.size	.L.str.23, 21

	.type	.L.str.24,@object               # @.str.24
.L.str.24:
	.asciz	"Data size must be larger than 0"
	.size	.L.str.24, 32

	.type	.L.str.25,@object               # @.str.25
.L.str.25:
	.asciz	"Data must be 1, 2, or 3 dimensions"
	.size	.L.str.25, 35

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

	.type	.L.str.26,@object               # @.str.26
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.26:
	.asciz	"Data too big to print\n"
	.size	.L.str.26, 23

	.type	.L.str.27,@object               # @.str.27
.L.str.27:
	.asciz	"%.3f "
	.size	.L.str.27, 6

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"Processing Time: %4.4f milliseconds\n"
	.size	.L.str.28, 37

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12cached_plane6MatrixS_i"
	.size	.L__unnamed_1, 27

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

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

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12cached_plane6MatrixS_i ; -- Begin function _Z12cached_plane6MatrixS_i
	.globl	_Z12cached_plane6MatrixS_i
	.p2align	8
	.type	_Z12cached_plane6MatrixS_i,@function
_Z12cached_plane6MatrixS_i:             ; @_Z12cached_plane6MatrixS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x48
	s_load_b32 s10, s[0:1], 0x30
	v_bfe_u32 v3, v0, 20, 10
	s_add_u32 s2, s0, 56
	s_addc_u32 s3, s1, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[3:4]
	s_mov_b32 s4, exec_lo
	v_cmpx_gt_i32_e64 s10, v1
	s_cbranch_execz .LBB0_9
; %bb.1:                                ; %.lr.ph
	s_load_b64 s[8:9], s[0:1], 0x4
	s_load_b32 s7, s[2:3], 0xc
	s_clause 0x2
	s_load_b32 s12, s[0:1], 0xc
	s_load_b64 s[2:3], s[0:1], 0x10
	s_load_b64 s[4:5], s[0:1], 0x28
	v_bfe_u32 v2, v0, 10, 10
	v_and_b32_e32 v5, 0x3ff, v0
	v_add_nc_u32_e32 v0, -1, v1
	s_mov_b32 s11, 0
	s_waitcnt lgkmcnt(0)
	v_mul_lo_u32 v3, s8, v1
	s_lshr_b32 s0, s7, 16
	s_and_b32 s1, s7, 0xffff
	v_mul_lo_u32 v0, s8, v0
	s_mul_i32 s13, s13, s1
	s_mul_i32 s14, s14, s0
	v_add_nc_u32_e32 v4, s13, v5
	v_add_nc_u32_e32 v6, s14, v2
	v_add3_u32 v3, v2, v3, s14
	s_add_i32 s7, s9, -1
	s_mul_i32 s6, s9, s8
	v_add3_u32 v0, v2, v0, s14
	v_cmp_gt_i32_e32 vcc_lo, s7, v4
	v_min_i32_e32 v4, v6, v4
	v_mul_lo_u32 v7, s9, v3
	v_add_nc_u32_e32 v8, -1, v3
	v_mad_u64_u32 v[2:3], null, s9, v0, v[5:6]
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_cmp_lt_i32_e64 s1, 0, v4
	s_add_i32 s8, s8, -1
	v_mad_u64_u32 v[3:4], null, s9, v8, v[5:6]
	v_cmp_gt_i32_e64 s0, s8, v6
	v_add_nc_u32_e32 v0, v5, v7
	v_add3_u32 v4, v7, s9, v5
	s_ashr_i32 s7, s6, 31
	s_add_i32 s12, s12, -1
	s_and_b32 s14, s1, vcc_lo
	s_lshl_b64 s[8:9], s[6:7], 2
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	s_mov_b32 s1, -1
	s_and_saveexec_b32 s7, s14
	s_cbranch_execz .LBB0_6
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	v_cmp_lt_i32_e32 vcc_lo, 0, v1
	v_cmp_gt_i32_e64 s1, s12, v1
	s_and_b32 s15, s0, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	s_and_b32 s1, s15, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s15, s1
	s_cbranch_execz .LBB0_5
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u32_e32 v5, s13, v0
	v_add_nc_u32_e32 v11, s13, v3
	v_add_nc_u32_e32 v13, s13, v4
	v_add_nc_u32_e32 v15, s13, v2
	s_delay_alu instid0(VALU_DEP_4)
	v_add_nc_u32_e32 v7, -1, v5
	v_ashrrev_i32_e32 v6, 31, v5
	v_add_nc_u32_e32 v9, 1, v5
	v_ashrrev_i32_e32 v12, 31, v11
	v_ashrrev_i32_e32 v14, 31, v13
	v_ashrrev_i32_e32 v8, 31, v7
	v_lshlrev_b64 v[5:6], 2, v[5:6]
	v_ashrrev_i32_e32 v10, 31, v9
	v_lshlrev_b64 v[11:12], 2, v[11:12]
	v_ashrrev_i32_e32 v16, 31, v15
	v_lshlrev_b64 v[7:8], 2, v[7:8]
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_2) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[9:10], 2, v[9:10]
	v_add_co_u32 v17, vcc_lo, s2, v5
	v_add_co_ci_u32_e32 v18, vcc_lo, s3, v6, vcc_lo
	v_add_co_u32 v7, vcc_lo, s2, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v8, vcc_lo
	v_add_co_u32 v9, vcc_lo, s2, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, s3, v10, vcc_lo
	s_clause 0x2
	global_load_b32 v19, v[17:18], off
	global_load_b32 v20, v[7:8], off
	global_load_b32 v21, v[9:10], off
	v_lshlrev_b64 v[7:8], 2, v[13:14]
	v_add_co_u32 v9, vcc_lo, s2, v11
	v_add_co_ci_u32_e32 v10, vcc_lo, s3, v12, vcc_lo
	v_lshlrev_b64 v[11:12], 2, v[15:16]
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_u32 v7, vcc_lo, s2, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v8, vcc_lo
	s_clause 0x1
	global_load_b32 v13, v[9:10], off
	global_load_b32 v14, v[7:8], off
	v_add_co_u32 v7, vcc_lo, s2, v11
	v_add_co_ci_u32_e32 v8, vcc_lo, s3, v12, vcc_lo
	v_add_co_u32 v9, vcc_lo, v17, s8
	v_add_co_ci_u32_e32 v10, vcc_lo, s9, v18, vcc_lo
	s_clause 0x1
	global_load_b32 v7, v[7:8], off
	global_load_b32 v8, v[9:10], off
	s_waitcnt vmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	v_add_f32_e32 v9, v19, v20
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v9, v9, v21
	v_add_f32_e32 v9, v9, v13
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v9, v9, v14
	v_add_f32_e32 v7, v9, v7
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f32_e32 v7, v7, v8
	v_div_scale_f32 v8, null, 0x40e00000, 0x40e00000, v7
	v_div_scale_f32 v11, vcc_lo, v7, 0x40e00000, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v9, v8
	s_waitcnt_depctr 0xfff
	v_fma_f32 v10, -v8, v9, 1.0
	v_fmac_f32_e32 v9, v10, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f32_e32 v10, v11, v9
	v_fma_f32 v12, -v8, v10, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v10, v12, v9
	v_fma_f32 v8, -v8, v10, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_div_fmas_f32 v8, v8, v9, v10
	v_add_co_u32 v5, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s5, v6, vcc_lo
	v_div_fixup_f32 v7, v8, 0x40e00000, v7
	global_store_b32 v[5:6], v7, off
.LBB0_5:                                ; %Flow87
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s15
	s_xor_b32 s1, s1, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_not1_b32 s1, s1, exec_lo
.LBB0_6:                                ; %Flow
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s7
	s_and_saveexec_b32 s7, s1
	s_cbranch_execz .LBB0_8
; %bb.7:                                ;   in Loop: Header=BB0_2 Depth=1
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
.LBB0_8:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s7
	v_add_nc_u32_e32 v1, 1, v1
	v_add_nc_u32_e32 v0, s6, v0
	v_add_nc_u32_e32 v4, s6, v4
	v_add_nc_u32_e32 v3, s6, v3
	v_add_nc_u32_e32 v2, s6, v2
	v_cmp_le_i32_e32 vcc_lo, s10, v1
	s_or_b32 s11, vcc_lo, s11
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s11
	s_cbranch_execnz .LBB0_2
.LBB0_9:                                ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12cached_plane6MatrixS_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 312
		.amdhsa_user_sgpr_count 13
		.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 1
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 2
		.amdhsa_next_free_vgpr 22
		.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	_Z12cached_plane6MatrixS_i, .Lfunc_end0-_Z12cached_plane6MatrixS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 892
; NumSgprs: 18
; NumVgprs: 22
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 22
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 13
; 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: 1
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 2
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .offset:         0
        .size:           24
        .value_kind:     by_value
      - .offset:         24
        .size:           24
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         60
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         64
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         68
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         70
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         72
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         74
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         76
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         78
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         112
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         120
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 312
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12cached_plane6MatrixS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12cached_plane6MatrixS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     22
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
