#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <limits>
#include <algorithm>

using namespace std;

const int BLOCK_SIZE = 512;


#define idx(i,j,lda) ( (j) + ((i)*(lda)) )

class mySet
{
private:
	int size = 4000;
	bool N[4000];
	int cnt = 4000;
	
public:
	__device__ mySet(){}
	
	__device__ void init(int s)
	{
		this->cnt = s;
		for (int i = 0; i < s; i++)
		{
			N[i] = true;
		}
	}

	__device__ bool contains(int x)
	{
		return N[x];
	}

	__device__ void insert(int x)
	{
		if (N[x] == true)
			return;
		N[x] = true;
		cnt++;
	}

	__device__ void erase(int x)
	{
		if (N[x] == true)
		{
			N[x] = false;
			cnt--;
		}
	}

	__device__ bool empty()
	{
		return (cnt == 0);
	}

 	__device__ int getCount()
 	{
  	 	return cnt;
  	}
};



__device__ int getGlobalIdx_1D_1D()
{
	return blockIdx.x *blockDim.x + threadIdx.x;
}

__device__ int getGlobalIdx_1D_2D()
{
	return blockIdx.x * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;
}

__device__ int getGlobalIdx_2D_2D()
{
	int blockId = blockIdx.x + blockIdx.y * gridDim.x;
	int threadId = blockId * (blockDim.x * blockDim.y)
		+ (threadIdx.y * blockDim.x) + threadIdx.x;
	return threadId;
}

__device__ int getGlobalIdx_2D_1D()
{
	int blockId   = blockIdx.y * gridDim.x + blockIdx.x;			 	
	int threadId = blockId * blockDim.x + threadIdx.x; 
	return threadId;
}
__device__ int getGlobalIdx_3D_3D()
{
	int blockId = blockIdx.x + blockIdx.y * gridDim.x
		+ gridDim.x * gridDim.y * blockIdx.z;
	int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z)
		+ (threadIdx.z * (blockDim.x * blockDim.y))
		+ (threadIdx.y * blockDim.x) + threadIdx.x;
	return threadId;
}
//zdroj: http://cs.calvin.edu/courses/cs/374/CUDA/CUDA-Thread-Indexing-Cheatsheet.pdf


__global__ void prepareArray(int vertexCnt, int* d)
{
	int threads = gridDim.x * gridDim.y * gridDim.z * blockDim.x * blockDim.y * blockDim.z;
  	int cycleCnt = (vertexCnt / threads > 0 ? vertexCnt / threads : 1);
	for (int cycle = 0; cycle < cycleCnt; cycle++)
	{
		int s = (blockIdx.x * blockDim.x + threadIdx.x) + threads * cycle; // pozice na radku
		if(s >= vertexCnt) 
			return;

		for (int i = 0; i < vertexCnt; i++)
		{
			d[vertexCnt *i+s] = INT_MAX / 2;
		}
	}
}

__global__ void dijsktra( int* __restrict__ edgeMatrix, int vertexCnt, int* d)
{
	int threads = gridDim.x * gridDim.y * gridDim.z * blockDim.x * blockDim.y * blockDim.z;
  	int cycleCnt = (vertexCnt / threads > 0 ? vertexCnt / threads : 1);
	for (int cycle = 0; cycle < cycleCnt; cycle++)
	{
		int s = (blockIdx.x * blockDim.x + threadIdx.x) + threads * cycle; // pozice na radku
		if(s >= vertexCnt) 
			return;
			
		mySet N;
		
		N.init(vertexCnt);

		d[s*vertexCnt + s] = 0;
		while (!N.empty())
		{
			int localMin = INT_MAX;

			int cnt = N.getCount();
			int u = 0;
			int j = 0;
			for (int i = 0; i < vertexCnt && j < cnt; i++)
			{
				if (!N.contains(i)) continue;
				if (localMin > d[vertexCnt *i+s])
				{
					localMin = d[vertexCnt *i+s];
					u = i;
				}
				j++;
			}
			N.erase(u);

			for (int i = 0; i < vertexCnt; i++)
			{
				if (i == u || !N.contains(i)) continue;

				if (edgeMatrix[u + i*vertexCnt] > 0)
				{
					int alt = d[vertexCnt *u+s] + edgeMatrix[u + i*vertexCnt];
					atomicMin((d + vertexCnt * i + s), alt);
				}
			}
		}
	}
}



int *readMatrix(const char *path, int &n)
{
	ifstream iFile;
	iFile.open(path);
	if (!iFile.is_open())
		return NULL;

	string line;
	getline(iFile, line);
	n = atoi(line.c_str());
	int *matrix = new int[n * n];
  
	int i;
	for (i = 0; getline(iFile, line); i++)
	{
		size_t endpos = line.find_last_not_of(" \t\r\n");
		if (string::npos != endpos)
			line = line.substr(0, endpos + 1);

		for (int j = 0; j < n; j++)
		{
			size_t pos = line.find_first_of(" ");
			matrix[idx(i,j,n)] = stoi(line, &pos, 10);
			line = line.substr(pos);
			
		}
	}
	iFile.close();
	return matrix;

}

void writeMatrix(const char *path, int n, int *matrix)
{
	ofstream oFile;
	oFile.open(path, fstream::trunc | fstream::out);
	if (oFile.is_open())
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
			{
				oFile << matrix[idx(i, j, n)] << (j + 1 < n ? " " : "\n");
			}
		}
	}
	oFile.close();
}

int main(int argc, const char* argv[])
{
	if (argc < 3 || argc > 4)
	{
		cout << "Program takes 2 or 3 parameters (matrix and thread count and optional output file)!\n";
		return 1;
	}

    int threadCnt = atoi(argv[2]);
	
    int stc = 0;
    int *matrix = readMatrix(argv[1], stc);
    // reading input file
    if (matrix == NULL){
         cout << "File doesn't exists" << endl;
         cout << argv[1] << endl;
         return 1;
    }
	cudaEvent_t start, stop;
	float elapsedTime;



	cudaEventCreate(&start);
	cudaEventCreate(&stop);
	cudaEventRecord(start, 0);


	int *cumatrix; 
	int *d;
	cudaMalloc((void **)&cumatrix, stc * stc * sizeof(int));
	cudaMemcpy(cumatrix, matrix,  stc * stc * sizeof(int), cudaMemcpyHostToDevice);
	cudaMalloc((void **)&d, stc * stc * sizeof(int));

	prepareArray<<<stc / BLOCK_SIZE, BLOCK_SIZE>>>(stc, d);
    cudaError_t code = cudaThreadSynchronize();  
	if (code != cudaSuccess)
	{
		fprintf(stdout, "GPUassert: %s \n", cudaGetErrorString(code));
	}

   	dijsktra<<<stc / BLOCK_SIZE, BLOCK_SIZE>>>(cumatrix, stc, d);
    code = cudaThreadSynchronize();  
	if (code != cudaSuccess)
	{
		fprintf(stdout, "GPUassert: %s \n", cudaGetErrorString(code));
	}
  
	int *outM = new int[stc*stc];

  	cudaMemcpy(outM, d,  stc * stc * sizeof(int), cudaMemcpyDeviceToHost);
	cudaEventRecord(stop, 0);
	cudaEventSynchronize(stop);
	cudaEventElapsedTime(&elapsedTime, start, stop);
	cout << "Time: " << elapsedTime << endl;
	if (argc == 4)
	{
		cout << "Writing results...\n";
		writeMatrix(argv[3], stc, outM);
	}
	cudaFree(cumatrix);
  	cudaFree(d);
  	delete [] matrix;
  	delete [] outM;

	cout << "\nDone\n";
    return 0;
}

	.file	"tmpxft_0039eeab_00000000-6_dijks.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4043:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4043:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_.isra.0, @function
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_.isra.0:
.LFB4807:
	.cfi_startproc
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdi, %rbp
	movq	%rsi, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	call	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv@PLT
	testb	%al, %al
	je	.L3
	cmpq	%rbp, %rbx
	je	.L4
	movq	8(%rbx), %rdx
	testq	%rdx, %rdx
	je	.L5
	movq	(%rbx), %rsi
	movq	0(%rbp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_S_copyEPcPKcm@PLT
.L5:
	movq	8(%rbx), %rax
	movq	0(%rbp), %rdx
	movq	%rax, 8(%rbp)
	movb	$0, (%rdx,%rax)
	jmp	.L4
.L3:
	movq	%rbp, %rdi
	call	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv@PLT
	movl	%eax, %edx
	xorl	%eax, %eax
	testb	%dl, %dl
	jne	.L6
	movq	0(%rbp), %rax
	movq	16(%rbp), %r12
.L6:
	movq	(%rbx), %rdx
	movq	%rdx, 0(%rbp)
	movq	8(%rbx), %rdx
	movq	%rdx, 8(%rbp)
	movq	16(%rbx), %rdx
	movq	%rdx, 16(%rbp)
	testq	%rax, %rax
	je	.L7
	movq	%rax, (%rbx)
	movq	%r12, 16(%rbx)
	jmp	.L4
.L7:
	leaq	16(%rbx), %rax
	movq	%rax, (%rbx)
.L4:
	xorl	%eax, %eax
	movq	%rax, 8(%rbx)
	movq	(%rbx), %rax
	movb	$0, (%rax)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4807:
	.size	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_.isra.0, .-_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_.isra.0
	.globl	_Z18getGlobalIdx_1D_1Dv
	.type	_Z18getGlobalIdx_1D_1Dv, @function
_Z18getGlobalIdx_1D_1Dv:
.LFB4029:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE4029:
	.size	_Z18getGlobalIdx_1D_1Dv, .-_Z18getGlobalIdx_1D_1Dv
	.globl	_Z18getGlobalIdx_1D_2Dv
	.type	_Z18getGlobalIdx_1D_2Dv, @function
_Z18getGlobalIdx_1D_2Dv:
.LFB4800:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z18getGlobalIdx_1D_1Dv
	.cfi_endproc
.LFE4800:
	.size	_Z18getGlobalIdx_1D_2Dv, .-_Z18getGlobalIdx_1D_2Dv
	.globl	_Z18getGlobalIdx_2D_2Dv
	.type	_Z18getGlobalIdx_2D_2Dv, @function
_Z18getGlobalIdx_2D_2Dv:
.LFB4802:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z18getGlobalIdx_1D_1Dv
	.cfi_endproc
.LFE4802:
	.size	_Z18getGlobalIdx_2D_2Dv, .-_Z18getGlobalIdx_2D_2Dv
	.globl	_Z18getGlobalIdx_2D_1Dv
	.type	_Z18getGlobalIdx_2D_1Dv, @function
_Z18getGlobalIdx_2D_1Dv:
.LFB4804:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z18getGlobalIdx_1D_1Dv
	.cfi_endproc
.LFE4804:
	.size	_Z18getGlobalIdx_2D_1Dv, .-_Z18getGlobalIdx_2D_1Dv
	.globl	_Z18getGlobalIdx_3D_3Dv
	.type	_Z18getGlobalIdx_3D_3Dv, @function
_Z18getGlobalIdx_3D_3Dv:
.LFB4806:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z18getGlobalIdx_1D_1Dv
	.cfi_endproc
.LFE4806:
	.size	_Z18getGlobalIdx_3D_3Dv, .-_Z18getGlobalIdx_3D_3Dv
	.globl	_Z33__device_stub__Z12prepareArrayiPiiPi
	.type	_Z33__device_stub__Z12prepareArrayiPiiPi, @function
_Z33__device_stub__Z12prepareArrayiPiiPi:
.LFB4065:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movl	%edi, 12(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L24
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z12prepareArrayiPi(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L24:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4065:
	.size	_Z33__device_stub__Z12prepareArrayiPiiPi, .-_Z33__device_stub__Z12prepareArrayiPiiPi
	.globl	_Z12prepareArrayiPi
	.type	_Z12prepareArrayiPi, @function
_Z12prepareArrayiPi:
.LFB4066:
	.cfi_startproc
	endbr64
	jmp	_Z33__device_stub__Z12prepareArrayiPiiPi
	.cfi_endproc
.LFE4066:
	.size	_Z12prepareArrayiPi, .-_Z12prepareArrayiPi
	.globl	_Z30__device_stub__Z8dijsktraPiiS_PiiS_
	.type	_Z30__device_stub__Z8dijsktraPiiS_PiiS_, @function
_Z30__device_stub__Z8dijsktraPiiS_PiiS_:
.LFB4067:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movl	%esi, 12(%rsp)
	leaq	40(%rsp), %rcx
	leaq	60(%rsp), %rsi
	movq	%rdx, (%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movq	%rdi, 24(%rsp)
	leaq	48(%rsp), %rdi
	movq	%rax, 96(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 104(%rsp)
	movq	%rsp, %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movl	$1, 56(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z8dijsktraPiiS_(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L29:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4067:
	.size	_Z30__device_stub__Z8dijsktraPiiS_PiiS_, .-_Z30__device_stub__Z8dijsktraPiiS_PiiS_
	.globl	_Z8dijsktraPiiS_
	.type	_Z8dijsktraPiiS_, @function
_Z8dijsktraPiiS_:
.LFB4068:
	.cfi_startproc
	endbr64
	jmp	_Z30__device_stub__Z8dijsktraPiiS_PiiS_
	.cfi_endproc
.LFE4068:
	.size	_Z8dijsktraPiiS_, .-_Z8dijsktraPiiS_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z8dijsktraPiiS_"
.LC1:
	.string	"_Z12prepareArrayiPi"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4070:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z8dijsktraPiiS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC1(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12prepareArrayiPi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE4070:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text._ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev,"axG",@progbits,_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD5Ev,comdat
	.align 2
	.weak	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev
	.type	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev, @function
_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev:
.LFB4149:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rdi, %rbx
	call	__errno_location@PLT
	cmpl	$0, (%rax)
	jne	.L36
	movl	(%rbx), %edx
	movl	%edx, (%rax)
.L36:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4149:
	.size	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev, .-_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev
	.weak	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev
	.set	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev,_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD2Ev
	.section	.rodata.str1.1
.LC2:
	.string	" \t\r\n"
.LC3:
	.string	" "
.LC4:
	.string	"stoi"
	.text
	.globl	_Z10readMatrixPKcRi
	.type	_Z10readMatrixPKcRi, @function
_Z10readMatrixPKcRi:
.LFB4034:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4034
	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
	movq	%rsi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rdi, %rbx
	subq	$664, %rsp
	.cfi_def_cfa_offset 720
	movq	%fs:40, %rax
	movq	%rax, 648(%rsp)
	xorl	%eax, %eax
	leaq	128(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
.LEHB0:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE0:
	movq	16(%rsp), %rdi
	movl	$8, %edx
	movq	%rbx, %rsi
.LEHB1:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
.LEHE1:
	leaq	248(%rsp), %rdi
	call	_ZNKSt12__basic_fileIcE7is_openEv@PLT
	testb	%al, %al
	je	.L57
	leaq	64(%rsp), %rax
	movq	16(%rsp), %rdi
	xorl	%edx, %edx
	movb	$0, 80(%rsp)
	movq	%rax, 8(%rsp)
	movq	8(%rsp), %rsi
	leaq	80(%rsp), %rax
	movq	%rax, 64(%rsp)
	movq	%rdx, 72(%rsp)
.LEHB2:
	call	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
	movq	64(%rsp), %rdi
	call	atoi@PLT
	movl	%eax, (%r12)
	imull	%eax, %eax
	movslq	%eax, %rdi
	salq	$2, %rdi
	call	_Znam@PLT
	movq	%rax, %rbp
	xorl	%r13d, %r13d
.L41:
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdi
	call	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE@PLT
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	movl	32(%rax,%rdx), %ebx
	andl	$5, %ebx
	jne	.L69
	movq	8(%rsp), %rdi
	orq	$-1, %rdx
	leaq	.LC2(%rip), %rsi
	call	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE16find_last_not_ofEPKcm@PLT
	cmpq	$-1, %rax
	je	.L43
	leaq	96(%rsp), %r14
	movq	8(%rsp), %rsi
	leaq	1(%rax), %rcx
	xorl	%edx, %edx
	movq	%r14, %rdi
	call	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm@PLT
	movq	8(%rsp), %rdi
	movq	%r14, %rsi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_.isra.0
	movq	%r14, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L43
.L52:
	movq	8(%rsp), %rdi
	xorl	%edx, %edx
	leaq	.LC3(%rip), %rsi
	call	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13find_first_ofEPKcm@PLT
	movl	(%r12), %eax
	movq	64(%rsp), %r14
	imull	%r13d, %eax
	addl	%ebx, %eax
	cltq
	leaq	0(%rbp,%rax,4), %r15
	call	__errno_location@PLT
	movl	$10, %edx
	leaq	56(%rsp), %rsi
	movq	%r14, %rdi
	movq	%rax, %rcx
	movl	(%rax), %eax
	movq	%rcx, 32(%rsp)
	movl	%eax, 52(%rsp)
	xorl	%eax, %eax
	movl	%eax, (%rcx)
	call	__isoc23_strtol@PLT
	movq	56(%rsp), %rdx
	leaq	52(%rsp), %rcx
	movq	%rcx, 24(%rsp)
	movq	32(%rsp), %rcx
	cmpq	%rdx, %r14
	je	.L70
	cmpl	$34, (%rcx)
	je	.L48
	movl	$2147483648, %ecx
	movl	$4294967295, %esi
	movq	%rdx, 40(%rsp)
	addq	%rax, %rcx
	movq	%rax, 32(%rsp)
	cmpq	%rcx, %rsi
	jb	.L48
	movq	24(%rsp), %rdi
	call	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev
	movq	32(%rsp), %rax
	movq	40(%rsp), %rdx
	orq	$-1, %rcx
	movq	8(%rsp), %rsi
	movl	%eax, (%r15)
	leaq	96(%rsp), %r15
	subq	%r14, %rdx
	movq	%r15, %rdi
	call	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm@PLT
.LEHE2:
	movq	8(%rsp), %rdi
	movq	%r15, %rsi
	incl	%ebx
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_.isra.0
	movq	%r15, %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
.L43:
	cmpl	%ebx, (%r12)
	jg	.L52
	jmp	.L71
.L70:
	movq	648(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L66
	leaq	.LC4(%rip), %rdi
.LEHB3:
	call	_ZSt24__throw_invalid_argumentPKc@PLT
.L48:
	movq	648(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L66
	leaq	.LC4(%rip), %rdi
	call	_ZSt20__throw_out_of_rangePKc@PLT
.LEHE3:
.L61:
	endbr64
	movq	%rax, %rbx
.L50:
	movq	24(%rsp), %rdi
	call	_ZZN9__gnu_cxx6__stoaIlicJiEEET0_PFT_PKT1_PPS3_DpT2_EPKcS5_PmS9_EN11_Save_errnoD1Ev
	jmp	.L51
.L71:
	incl	%r13d
	jmp	.L41
.L69:
	movq	16(%rsp), %rdi
.LEHB4:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv@PLT
.LEHE4:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L40
.L57:
	xorl	%ebp, %ebp
.L40:
	movq	16(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	648(%rsp), %rax
	subq	%fs:40, %rax
	je	.L56
	jmp	.L66
.L60:
	endbr64
	movq	%rax, %rbx
.L51:
	movq	8(%rsp), %rdi
	call	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_disposeEv@PLT
	jmp	.L54
.L59:
	endbr64
	movq	%rax, %rbx
.L54:
	movq	16(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	648(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L66
	movq	%rbx, %rdi
.LEHB5:
	call	_Unwind_Resume@PLT
.LEHE5:
.L66:
	call	__stack_chk_fail@PLT
.L56:
	addq	$664, %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
.LFE4034:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4034:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4034-.LLSDACSB4034
.LLSDACSB4034:
	.uleb128 .LEHB0-.LFB4034
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB4034
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L59-.LFB4034
	.uleb128 0
	.uleb128 .LEHB2-.LFB4034
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L60-.LFB4034
	.uleb128 0
	.uleb128 .LEHB3-.LFB4034
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L61-.LFB4034
	.uleb128 0
	.uleb128 .LEHB4-.LFB4034
	.uleb128 .LEHE4-.LEHB4
	.uleb128 .L60-.LFB4034
	.uleb128 0
	.uleb128 .LEHB5-.LFB4034
	.uleb128 .LEHE5-.LEHB5
	.uleb128 0
	.uleb128 0
.LLSDACSE4034:
	.text
	.size	_Z10readMatrixPKcRi, .-_Z10readMatrixPKcRi
	.section	.rodata.str1.1
.LC5:
	.string	"\n"
	.text
	.globl	_Z11writeMatrixPKciPi
	.type	_Z11writeMatrixPKciPi, @function
_Z11writeMatrixPKciPi:
.LFB4039:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4039
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%esi, %ebx
	subq	$552, %rsp
	.cfi_def_cfa_offset 608
	movq	%rdx, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 536(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, (%rsp)
.LEHB6:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE6:
	movq	(%rsp), %rdi
	movl	$48, %edx
	movq	%rbp, %rsi
.LEHB7:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	leaq	136(%rsp), %rdi
	call	_ZNKSt12__basic_fileIcE7is_openEv@PLT
	testb	%al, %al
	je	.L73
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
	movslq	%ebx, %r15
.L74:
	cmpl	%ebx, %r13d
	jge	.L73
	movq	8(%rsp), %rcx
	movslq	%r12d, %rax
	xorl	%ebp, %ebp
	leaq	(%rcx,%rax,4), %r14
.L76:
	movl	(%r14,%rbp,4), %esi
	movq	(%rsp), %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	leal	1(%rbp), %eax
	leaq	.LC3(%rip), %rsi
	cmpl	%eax, %ebx
	leaq	.LC5(%rip), %rax
	cmovle	%rax, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	incq	%rbp
	cmpq	%r15, %rbp
	jne	.L76
	incl	%r13d
	addl	%ebx, %r12d
	jmp	.L74
.L73:
	movq	(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
.LEHE7:
	movq	(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	536(%rsp), %rax
	subq	%fs:40, %rax
	je	.L79
	jmp	.L86
.L81:
	endbr64
	movq	%rax, %rbx
.L77:
	movq	(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	536(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L86
	movq	%rbx, %rdi
.LEHB8:
	call	_Unwind_Resume@PLT
.LEHE8:
.L86:
	call	__stack_chk_fail@PLT
.L79:
	addq	$552, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4039:
	.section	.gcc_except_table
.LLSDA4039:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4039-.LLSDACSB4039
.LLSDACSB4039:
	.uleb128 .LEHB6-.LFB4039
	.uleb128 .LEHE6-.LEHB6
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB7-.LFB4039
	.uleb128 .LEHE7-.LEHB7
	.uleb128 .L81-.LFB4039
	.uleb128 0
	.uleb128 .LEHB8-.LFB4039
	.uleb128 .LEHE8-.LEHB8
	.uleb128 0
	.uleb128 0
.LLSDACSE4039:
	.text
	.size	_Z11writeMatrixPKciPi, .-_Z11writeMatrixPKciPi
	.section	.rodata.str1.1
.LC6:
	.string	"Program takes 2 or 3 parameters (matrix and thread count and optional output file)!\n"
.LC7:
	.string	"File doesn't exists"
.LC8:
	.string	"GPUassert: %s \n"
.LC9:
	.string	"Time: "
.LC10:
	.string	"Writing results...\n"
.LC11:
	.string	"\nDone\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB4040:
	.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
	leaq	_ZSt4cout(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leal	-3(%rdi), %eax
	cmpl	$1, %eax
	jbe	.L89
	leaq	.LC6(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	jmp	.L90
.L89:
	movq	%rsi, %r14
	movl	%edi, %r15d
	leaq	28(%rsp), %rsi
	xorl	%eax, %eax
	movq	8(%r14), %rdi
	movl	%eax, 28(%rsp)
	call	_Z10readMatrixPKcRi
	movq	%rax, %r13
	testq	%rax, %rax
	jne	.L91
	leaq	.LC7(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movq	8(%r14), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
.L90:
	movl	$1, %eax
	jmp	.L88
.L91:
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	28(%rsp), %ebx
	leaq	48(%rsp), %rdi
	movl	%ebx, %eax
	imull	%ebx, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdx
	movq	48(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	8(%rsp), %rsi
	leaq	56(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	%ebx, %eax
	movl	$512, %esi
	xorl	%r9d, %r9d
	cltd
	movl	$8388609, %ecx
	xorl	%r8d, %r8d
	movl	$1, 84(%rsp)
	idivl	%esi
	salq	$9, %rcx
	movq	%rcx, 76(%rsp)
	movq	%rcx, %rdx
	movl	$1, %ecx
	movl	%eax, 64(%rsp)
	movl	%eax, %r12d
	movabsq	$4294967297, %rax
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L93
	movq	56(%rsp), %rsi
	movl	%ebx, %edi
	call	_Z33__device_stub__Z12prepareArrayiPiiPi
.L93:
	call	cudaThreadSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L94
	call	cudaGetErrorString@PLT
	movq	stdout(%rip), %rdi
	movl	$2, %esi
	leaq	.LC8(%rip), %rdx
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L94:
	movl	%r12d, 64(%rsp)
	movl	$8388609, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	salq	$9, %rdx
	movl	$1, %ecx
	movl	$1, 84(%rsp)
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	movq	%rdx, 76(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L95
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rdi
	movl	%ebx, %esi
	call	_Z30__device_stub__Z8dijsktraPiiS_PiiS_
.L95:
	call	cudaThreadSynchronize@PLT
	movl	%eax, %edi
	testl	%eax, %eax
	je	.L96
	call	cudaGetErrorString@PLT
	movq	stdout(%rip), %rdi
	movl	$2, %esi
	leaq	.LC8(%rip), %rdx
	movq	%rax, %rcx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
.L96:
	movq	8(%rsp), %rdi
	call	_Znam@PLT
	movq	8(%rsp), %rdx
	movq	56(%rsp), %rsi
	movl	$2, %ecx
	movq	%rax, %rdi
	movq	%rax, %r12
	call	cudaMemcpy@PLT
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	76(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	leaq	.LC9(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	76(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	cmpl	$4, %r15d
	jne	.L97
	leaq	.LC10(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	24(%r14), %rdi
	movq	%r12, %rdx
	movl	%ebx, %esi
	call	_Z11writeMatrixPKciPi
.L97:
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	%r13, %rdi
	call	_ZdaPv@PLT
	movq	%r12, %rdi
	call	_ZdaPv@PLT
	leaq	.LC11(%rip), %rsi
	movq	%rbp, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	xorl	%eax, %eax
.L88:
	movq	88(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L98
	call	__stack_chk_fail@PLT
.L98:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4040:
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <limits>
#include <algorithm>

using namespace std;

const int BLOCK_SIZE = 512;


#define idx(i,j,lda) ( (j) + ((i)*(lda)) )

class mySet
{
private:
	int size = 4000;
	bool N[4000];
	int cnt = 4000;
	
public:
	__device__ mySet(){}
	
	__device__ void init(int s)
	{
		this->cnt = s;
		for (int i = 0; i < s; i++)
		{
			N[i] = true;
		}
	}

	__device__ bool contains(int x)
	{
		return N[x];
	}

	__device__ void insert(int x)
	{
		if (N[x] == true)
			return;
		N[x] = true;
		cnt++;
	}

	__device__ void erase(int x)
	{
		if (N[x] == true)
		{
			N[x] = false;
			cnt--;
		}
	}

	__device__ bool empty()
	{
		return (cnt == 0);
	}

 	__device__ int getCount()
 	{
  	 	return cnt;
  	}
};



__device__ int getGlobalIdx_1D_1D()
{
	return blockIdx.x *blockDim.x + threadIdx.x;
}

__device__ int getGlobalIdx_1D_2D()
{
	return blockIdx.x * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;
}

__device__ int getGlobalIdx_2D_2D()
{
	int blockId = blockIdx.x + blockIdx.y * gridDim.x;
	int threadId = blockId * (blockDim.x * blockDim.y)
		+ (threadIdx.y * blockDim.x) + threadIdx.x;
	return threadId;
}

__device__ int getGlobalIdx_2D_1D()
{
	int blockId   = blockIdx.y * gridDim.x + blockIdx.x;			 	
	int threadId = blockId * blockDim.x + threadIdx.x; 
	return threadId;
}
__device__ int getGlobalIdx_3D_3D()
{
	int blockId = blockIdx.x + blockIdx.y * gridDim.x
		+ gridDim.x * gridDim.y * blockIdx.z;
	int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z)
		+ (threadIdx.z * (blockDim.x * blockDim.y))
		+ (threadIdx.y * blockDim.x) + threadIdx.x;
	return threadId;
}
//zdroj: http://cs.calvin.edu/courses/cs/374/CUDA/CUDA-Thread-Indexing-Cheatsheet.pdf


__global__ void prepareArray(int vertexCnt, int* d)
{
	int threads = gridDim.x * gridDim.y * gridDim.z * blockDim.x * blockDim.y * blockDim.z;
  	int cycleCnt = (vertexCnt / threads > 0 ? vertexCnt / threads : 1);
	for (int cycle = 0; cycle < cycleCnt; cycle++)
	{
		int s = (blockIdx.x * blockDim.x + threadIdx.x) + threads * cycle; // pozice na radku
		if(s >= vertexCnt) 
			return;

		for (int i = 0; i < vertexCnt; i++)
		{
			d[vertexCnt *i+s] = INT_MAX / 2;
		}
	}
}

__global__ void dijsktra( int* __restrict__ edgeMatrix, int vertexCnt, int* d)
{
	int threads = gridDim.x * gridDim.y * gridDim.z * blockDim.x * blockDim.y * blockDim.z;
  	int cycleCnt = (vertexCnt / threads > 0 ? vertexCnt / threads : 1);
	for (int cycle = 0; cycle < cycleCnt; cycle++)
	{
		int s = (blockIdx.x * blockDim.x + threadIdx.x) + threads * cycle; // pozice na radku
		if(s >= vertexCnt) 
			return;
			
		mySet N;
		
		N.init(vertexCnt);

		d[s*vertexCnt + s] = 0;
		while (!N.empty())
		{
			int localMin = INT_MAX;

			int cnt = N.getCount();
			int u = 0;
			int j = 0;
			for (int i = 0; i < vertexCnt && j < cnt; i++)
			{
				if (!N.contains(i)) continue;
				if (localMin > d[vertexCnt *i+s])
				{
					localMin = d[vertexCnt *i+s];
					u = i;
				}
				j++;
			}
			N.erase(u);

			for (int i = 0; i < vertexCnt; i++)
			{
				if (i == u || !N.contains(i)) continue;

				if (edgeMatrix[u + i*vertexCnt] > 0)
				{
					int alt = d[vertexCnt *u+s] + edgeMatrix[u + i*vertexCnt];
					atomicMin((d + vertexCnt * i + s), alt);
				}
			}
		}
	}
}



int *readMatrix(const char *path, int &n)
{
	ifstream iFile;
	iFile.open(path);
	if (!iFile.is_open())
		return NULL;

	string line;
	getline(iFile, line);
	n = atoi(line.c_str());
	int *matrix = new int[n * n];
  
	int i;
	for (i = 0; getline(iFile, line); i++)
	{
		size_t endpos = line.find_last_not_of(" \t\r\n");
		if (string::npos != endpos)
			line = line.substr(0, endpos + 1);

		for (int j = 0; j < n; j++)
		{
			size_t pos = line.find_first_of(" ");
			matrix[idx(i,j,n)] = stoi(line, &pos, 10);
			line = line.substr(pos);
			
		}
	}
	iFile.close();
	return matrix;

}

void writeMatrix(const char *path, int n, int *matrix)
{
	ofstream oFile;
	oFile.open(path, fstream::trunc | fstream::out);
	if (oFile.is_open())
	{
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n; j++)
			{
				oFile << matrix[idx(i, j, n)] << (j + 1 < n ? " " : "\n");
			}
		}
	}
	oFile.close();
}

int main(int argc, const char* argv[])
{
	if (argc < 3 || argc > 4)
	{
		cout << "Program takes 2 or 3 parameters (matrix and thread count and optional output file)!\n";
		return 1;
	}

    int threadCnt = atoi(argv[2]);
	
    int stc = 0;
    int *matrix = readMatrix(argv[1], stc);
    // reading input file
    if (matrix == NULL){
         cout << "File doesn't exists" << endl;
         cout << argv[1] << endl;
         return 1;
    }
	hipEvent_t start, stop;
	float elapsedTime;



	hipEventCreate(&start);
	hipEventCreate(&stop);
	hipEventRecord(start, 0);


	int *cumatrix; 
	int *d;
	hipMalloc((void **)&cumatrix, stc * stc * sizeof(int));
	hipMemcpy(cumatrix, matrix,  stc * stc * sizeof(int), hipMemcpyHostToDevice);
	hipMalloc((void **)&d, stc * stc * sizeof(int));

	prepareArray<<<stc / BLOCK_SIZE, BLOCK_SIZE>>>(stc, d);
    hipError_t code = hipDeviceSynchronize();  
	if (code != hipSuccess)
	{
		fprintf(stdout, "GPUassert: %s \n", hipGetErrorString(code));
	}

   	dijsktra<<<stc / BLOCK_SIZE, BLOCK_SIZE>>>(cumatrix, stc, d);
    code = hipDeviceSynchronize();  
	if (code != hipSuccess)
	{
		fprintf(stdout, "GPUassert: %s \n", hipGetErrorString(code));
	}
  
	int *outM = new int[stc*stc];

  	hipMemcpy(outM, d,  stc * stc * sizeof(int), hipMemcpyDeviceToHost);
	hipEventRecord(stop, 0);
	hipEventSynchronize(stop);
	hipEventElapsedTime(&elapsedTime, start, stop);
	cout << "Time: " << elapsedTime << endl;
	if (argc == 4)
	{
		cout << "Writing results...\n";
		writeMatrix(argv[3], stc, outM);
	}
	hipFree(cumatrix);
  	hipFree(d);
  	delete [] matrix;
  	delete [] outM;

	cout << "\nDone\n";
    return 0;
}

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

                                        # End of file scope inline assembly
	.globl	_Z27__device_stub__prepareArrayiPi # -- Begin function _Z27__device_stub__prepareArrayiPi
	.type	_Z27__device_stub__prepareArrayiPi,@function
_Z27__device_stub__prepareArrayiPi:     # @_Z27__device_stub__prepareArrayiPi
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	4(%rsp), %rax
	movl	%edi, (%rax)
	leaq	24(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%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	$_Z12prepareArrayiPi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z27__device_stub__prepareArrayiPi, .Lfunc_end0-_Z27__device_stub__prepareArrayiPi
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__dijsktraPiiS_ # -- Begin function _Z23__device_stub__dijsktraPiiS_
	.type	_Z23__device_stub__dijsktraPiiS_,@function
_Z23__device_stub__dijsktraPiiS_:       # @_Z23__device_stub__dijsktraPiiS_
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	12(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	32(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z8dijsktraPiiS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z23__device_stub__dijsktraPiiS_, .Lfunc_end1-_Z23__device_stub__dijsktraPiiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z10readMatrixPKcRi             # -- Begin function _Z10readMatrixPKcRi
	.type	_Z10readMatrixPKcRi,@function
_Z10readMatrixPKcRi:                    # @_Z10readMatrixPKcRi
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$616, %rsp                      # imm = 0x268
	.cfi_def_cfa_offset 672
	.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, %r13
	movq	%rdi, %r15
	leaq	96(%rsp), %r14
	movq	%r14, %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev
.Ltmp0:
	movq	%r14, %rdi
	movq	%r15, %rsi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp1:
# %bb.1:
	leaq	216(%rsp), %rdi
	callq	_ZNKSt12__basic_fileIcE7is_openEv
	testb	%al, %al
	je	.LBB2_2
# %bb.4:
	leaq	40(%rsp), %r15
	movq	%r15, -16(%r15)
	movq	$0, -8(%r15)
	movb	$0, (%r15)
	movq	96(%rsp), %rax
	addq	-24(%rax), %r14
.Ltmp3:
	movq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp4:
# %bb.5:                                # %.noexc
.Ltmp5:
	movsbl	%al, %edx
	leaq	96(%rsp), %rbx
	leaq	24(%rsp), %rsi
	movq	%rbx, %rdi
	callq	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_
.Ltmp6:
# %bb.6:                                # %_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE.exit
	movq	24(%rsp), %rdi
	callq	atoi
                                        # kill: def $eax killed $eax def $rax
	movl	%eax, (%r13)
	imull	%eax, %eax
	leaq	(,%rax,4), %rdi
.Ltmp8:
	callq	_Znam
.Ltmp9:
# %bb.7:                                # %.preheader
	movq	%rax, %r15
	xorl	%eax, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	leaq	24(%rsp), %rbp
.LBB2_8:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_17 Depth 2
	leaq	56(%rsp), %r14
	movq	96(%rsp), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
.Ltmp11:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp12:
# %bb.9:                                # %.noexc34
                                        #   in Loop: Header=BB2_8 Depth=1
.Ltmp13:
	movsbl	%al, %edx
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	callq	_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EES4_
.Ltmp14:
# %bb.10:                               #   in Loop: Header=BB2_8 Depth=1
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	jne	.LBB2_39
# %bb.11:                               #   in Loop: Header=BB2_8 Depth=1
	movl	$.L.str, %esi
	movl	$4, %ecx
	movq	%rbp, %rdi
	movq	$-1, %rdx
	callq	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE16find_last_not_ofEPKcmm
	cmpq	$-1, %rax
	je	.LBB2_15
# %bb.12:                               #   in Loop: Header=BB2_8 Depth=1
	incq	%rax
.Ltmp19:
	movq	%r14, %rdi
	movq	%rbp, %rsi
	xorl	%edx, %edx
	movq	%rax, %rcx
	callq	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm
.Ltmp20:
# %bb.13:                               #   in Loop: Header=BB2_8 Depth=1
	movq	%rbp, %rdi
	movq	%r14, %rsi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_
	movq	56(%rsp), %rdi
	leaq	72(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB2_15
# %bb.14:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i
                                        #   in Loop: Header=BB2_8 Depth=1
	callq	_ZdlPv
.LBB2_15:                               #   in Loop: Header=BB2_8 Depth=1
	cmpl	$0, (%r13)
	jle	.LBB2_37
# %bb.16:                               # %.lr.ph.preheader
                                        #   in Loop: Header=BB2_8 Depth=1
	movslq	16(%rsp), %rax                  # 4-byte Folded Reload
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	xorl	%ebx, %ebx
.LBB2_17:                               # %.lr.ph
                                        #   Parent Loop BB2_8 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r15, %r14
	movl	$.L.str.1, %esi
	movl	$1, %ecx
	movq	%rbp, %r12
	movq	%rbp, %rdi
	xorl	%edx, %edx
	callq	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13find_first_ofEPKcmm
	movq	24(%rsp), %r15
	callq	__errno_location
	movq	%rax, %rbp
	movl	(%rax), %eax
	movl	%eax, 12(%rsp)                  # 4-byte Spill
	movl	$0, (%rbp)
	movq	%r15, %rdi
	leaq	56(%rsp), %rsi
	movl	$10, %edx
	callq	__isoc23_strtol
	movq	56(%rsp), %rdx
	subq	%r15, %rdx
	je	.LBB2_18
# %bb.27:                               #   in Loop: Header=BB2_17 Depth=2
	movslq	%eax, %rcx
	cmpq	%rax, %rcx
	jne	.LBB2_29
# %bb.28:                               #   in Loop: Header=BB2_17 Depth=2
	movl	(%rbp), %ecx
	cmpl	$34, %ecx
	je	.LBB2_29
# %bb.31:                               #   in Loop: Header=BB2_17 Depth=2
	testl	%ecx, %ecx
	jne	.LBB2_33
# %bb.32:                               #   in Loop: Header=BB2_17 Depth=2
	movl	12(%rsp), %ecx                  # 4-byte Reload
	movl	%ecx, (%rbp)
.LBB2_33:                               #   in Loop: Header=BB2_17 Depth=2
	movslq	(%r13), %rcx
	imulq	88(%rsp), %rcx                  # 8-byte Folded Reload
	addq	%rbx, %rcx
	movq	%r14, %r15
	movl	%eax, (%r14,%rcx,4)
.Ltmp22:
	leaq	56(%rsp), %r14
	movq	%r14, %rdi
	movq	%r12, %rbp
	movq	%r12, %rsi
	movq	$-1, %rcx
	callq	_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6substrEmm
.Ltmp23:
# %bb.34:                               #   in Loop: Header=BB2_17 Depth=2
	movq	%rbp, %rdi
	movq	%r14, %rsi
	callq	_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEOS4_
	movq	56(%rsp), %rdi
	leaq	72(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB2_36
# %bb.35:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i37
                                        #   in Loop: Header=BB2_17 Depth=2
	callq	_ZdlPv
.LBB2_36:                               # %_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev.exit39
                                        #   in Loop: Header=BB2_17 Depth=2
	incq	%rbx
	cmpl	(%r13), %ebx
	jl	.LBB2_17
.LBB2_37:                               # %._crit_edge
                                        #   in Loop: Header=BB2_8 Depth=1
	movq	16(%rsp), %rax                  # 8-byte Reload
	incl	%eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	leaq	96(%rsp), %rbx
	jmp	.LBB2_8
.LBB2_2:
	xorl	%r15d, %r15d
	jmp	.LBB2_3
.LBB2_39:
.Ltmp16:
	leaq	96(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv
.Ltmp17:
# %bb.40:
	movq	24(%rsp), %rdi
	leaq	40(%rsp), %rax
	cmpq	%rax, %rdi
	je	.LBB2_3
# %bb.41:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i40
	callq	_ZdlPv
.LBB2_3:
	leaq	96(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%r15, %rax
	addq	$616, %rsp                      # imm = 0x268
	.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
.LBB2_18:
	.cfi_def_cfa_offset 672
.Ltmp27:
	movl	$.L.str.9, %edi
	callq	_ZSt24__throw_invalid_argumentPKc
.Ltmp28:
# %bb.24:
.LBB2_29:                               # %.critedge.i.i
.Ltmp25:
	movl	$.L.str.9, %edi
	callq	_ZSt20__throw_out_of_rangePKc
.Ltmp26:
# %bb.30:
.LBB2_22:                               # %.loopexit.split-lp
.Ltmp18:
	jmp	.LBB2_20
.LBB2_19:
.Ltmp10:
	jmp	.LBB2_20
.LBB2_42:
.Ltmp7:
	movq	%rax, %rbx
	jmp	.LBB2_43
.LBB2_45:
.Ltmp2:
	movq	%rax, %rbx
	jmp	.LBB2_46
.LBB2_23:
.Ltmp21:
	jmp	.LBB2_20
.LBB2_21:                               # %.loopexit
.Ltmp15:
	jmp	.LBB2_20
.LBB2_38:
.Ltmp24:
.LBB2_20:                               # %.body
	movq	%rax, %rbx
	leaq	40(%rsp), %r15
	jmp	.LBB2_43
.LBB2_25:
.Ltmp29:
	movq	%rax, %rbx
	cmpl	$0, (%rbp)
	leaq	40(%rsp), %r15
	jne	.LBB2_43
# %bb.26:
	movl	12(%rsp), %eax                  # 4-byte Reload
	movl	%eax, (%rbp)
.LBB2_43:                               # %.body
	movq	24(%rsp), %rdi
	cmpq	%r15, %rdi
	je	.LBB2_46
# %bb.44:                               # %_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv.exit.i.i43
	callq	_ZdlPv
.LBB2_46:
	leaq	96(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end2:
	.size	_Z10readMatrixPKcRi, .Lfunc_end2-_Z10readMatrixPKcRi
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table2:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp6-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp6
	.uleb128 .Ltmp7-.Lfunc_begin0           #     jumps to .Ltmp7
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp8-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp9-.Ltmp8                  #   Call between .Ltmp8 and .Ltmp9
	.uleb128 .Ltmp10-.Lfunc_begin0          #     jumps to .Ltmp10
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp11-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp14-.Ltmp11                #   Call between .Ltmp11 and .Ltmp14
	.uleb128 .Ltmp15-.Lfunc_begin0          #     jumps to .Ltmp15
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp19-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp20-.Ltmp19                #   Call between .Ltmp19 and .Ltmp20
	.uleb128 .Ltmp21-.Lfunc_begin0          #     jumps to .Ltmp21
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp22-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp23-.Ltmp22                #   Call between .Ltmp22 and .Ltmp23
	.uleb128 .Ltmp24-.Lfunc_begin0          #     jumps to .Ltmp24
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp16-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp17-.Ltmp16                #   Call between .Ltmp16 and .Ltmp17
	.uleb128 .Ltmp18-.Lfunc_begin0          #     jumps to .Ltmp18
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp27-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp26-.Ltmp27                #   Call between .Ltmp27 and .Ltmp26
	.uleb128 .Ltmp29-.Lfunc_begin0          #     jumps to .Ltmp29
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp26-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Lfunc_end2-.Ltmp26            #   Call between .Ltmp26 and .Lfunc_end2
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	_Z11writeMatrixPKciPi           # -- Begin function _Z11writeMatrixPKciPi
	.type	_Z11writeMatrixPKciPi,@function
_Z11writeMatrixPKciPi:                  # @_Z11writeMatrixPKciPi
.Lfunc_begin1:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception1
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$536, %rsp                      # imm = 0x218
	.cfi_def_cfa_offset 592
	.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, %rbx
	movl	%esi, %ebp
	movq	%rdi, %r14
	leaq	24(%rsp), %r15
	movq	%r15, %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev
.Ltmp30:
	movq	%r15, %rdi
	movq	%r14, %rsi
	movl	$48, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp31:
# %bb.1:
	leaq	136(%rsp), %rdi
	callq	_ZNKSt12__basic_fileIcE7is_openEv
	testb	%al, %al
	je	.LBB3_7
# %bb.2:
	testl	%ebp, %ebp
	jle	.LBB3_7
# %bb.3:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit.preheader.preheader
	movl	%ebp, %r15d
	leaq	(,%r15,4), %rax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movq	%r15, %r13
	negq	%r13
	xorl	%eax, %eax
	leaq	24(%rsp), %r14
	movl	$.L.str.1, %r12d
.LBB3_4:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_5 Depth 2
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movl	$1, %ebp
.LBB3_5:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
                                        #   Parent Loop BB3_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r13, %rax
	addq	%rbp, %rax
	cmpq	$1, %rax
	je	.LBB3_6
# %bb.9:                                #   in Loop: Header=BB3_5 Depth=2
	movl	-4(%rbx,%rbp,4), %esi
.Ltmp32:
	movq	%r14, %rdi
	callq	_ZNSolsEi
.Ltmp33:
# %bb.10:                               #   in Loop: Header=BB3_5 Depth=2
	cmpq	%r15, %rbp
	movl	$.L.str.2, %esi
	cmovbq	%r12, %rsi
	incq	%rbp
.Ltmp34:
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp35:
	jmp	.LBB3_5
.LBB3_6:                                #   in Loop: Header=BB3_4 Depth=1
	movq	16(%rsp), %rax                  # 8-byte Reload
	incq	%rax
	addq	8(%rsp), %rbx                   # 8-byte Folded Reload
	cmpq	%r15, %rax
	jne	.LBB3_4
.LBB3_7:                                # %.loopexit
.Ltmp37:
	leaq	24(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp38:
# %bb.8:
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax
	leaq	32(%rsp), %rdi
	movq	%rax, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %rcx
	movq	-24(%rax), %rax
	movq	%rcx, 24(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	272(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	addq	$536, %rsp                      # imm = 0x218
	.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
.LBB3_12:
	.cfi_def_cfa_offset 592
.Ltmp39:
	jmp	.LBB3_13
.LBB3_11:
.Ltmp36:
.LBB3_13:
	movq	%rax, %rbx
	leaq	24(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end3:
	.size	_Z11writeMatrixPKciPi, .Lfunc_end3-_Z11writeMatrixPKciPi
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table3:
.Lexception1:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end1-.Lcst_begin1
.Lcst_begin1:
	.uleb128 .Lfunc_begin1-.Lfunc_begin1    # >> Call Site 1 <<
	.uleb128 .Ltmp30-.Lfunc_begin1          #   Call between .Lfunc_begin1 and .Ltmp30
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp30-.Lfunc_begin1          # >> Call Site 2 <<
	.uleb128 .Ltmp31-.Ltmp30                #   Call between .Ltmp30 and .Ltmp31
	.uleb128 .Ltmp39-.Lfunc_begin1          #     jumps to .Ltmp39
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp32-.Lfunc_begin1          # >> Call Site 3 <<
	.uleb128 .Ltmp35-.Ltmp32                #   Call between .Ltmp32 and .Ltmp35
	.uleb128 .Ltmp36-.Lfunc_begin1          #     jumps to .Ltmp36
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp37-.Lfunc_begin1          # >> Call Site 4 <<
	.uleb128 .Ltmp38-.Ltmp37                #   Call between .Ltmp37 and .Ltmp38
	.uleb128 .Ltmp39-.Lfunc_begin1          #     jumps to .Ltmp39
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp38-.Lfunc_begin1          # >> Call Site 5 <<
	.uleb128 .Lfunc_end3-.Ltmp38            #   Call between .Ltmp38 and .Lfunc_end3
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end1:
	.p2align	2, 0x0
                                        # -- End function
	.text
	.globl	main                            # -- Begin function 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	$72, %rsp
	.cfi_def_cfa_offset 128
	.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	%edi, %r15d
	leal	-5(%r15), %eax
	cmpl	$-3, %eax
	ja	.LBB4_2
# %bb.1:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$84, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB4_18
.LBB4_2:
	movq	%rsi, %rbx
	leaq	28(%rsp), %rsi
	movl	$0, (%rsi)
	movq	8(%rbx), %rdi
	callq	_Z10readMatrixPKcRi
	testq	%rax, %rax
	je	.LBB4_14
# %bb.3:
	movq	%rax, %r14
	movq	%rbx, 40(%rsp)                  # 8-byte Spill
	movabsq	$4294967808, %rbx               # imm = 0x100000200
	leaq	56(%rsp), %r12
	movq	%r12, %rdi
	callq	hipEventCreate
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r12), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	28(%rsp), %r12d
	movl	%r12d, %r13d
	imull	%r13d, %r13d
	shlq	$2, %r13
	leaq	32(%rsp), %rbp
	movq	%rbp, %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	movq	(%rbp), %rdi
	movq	%r14, %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	8(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	leal	511(%r12), %eax
	testl	%r12d, %r12d
	cmovnsl	%r12d, %eax
	sarl	$9, %eax
	leaq	(%rax,%rbx), %rbp
	addq	$-512, %rbp                     # imm = 0xFE00
	movq	%rbp, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_5
# %bb.4:
	movq	8(%rsp), %rsi
	movl	%r12d, %edi
	callq	_Z27__device_stub__prepareArrayiPi
.LBB4_5:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	movq	%r14, 48(%rsp)                  # 8-byte Spill
	je	.LBB4_7
# %bb.6:
	movq	stdout(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movq	%r14, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
.LBB4_7:
	movq	%rbp, %rdi
	movl	$1, %esi
	movabsq	$4294967808, %rdx               # imm = 0x100000200
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_9
# %bb.8:
	movq	32(%rsp), %rdi
	movq	8(%rsp), %rdx
	movl	%r12d, %esi
	callq	_Z23__device_stub__dijsktraPiiS_
.LBB4_9:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	je	.LBB4_11
# %bb.10:
	movq	stdout(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movq	%r14, %rdi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	fprintf
.LBB4_11:
	movq	%r13, %rdi
	callq	_Znam
	movq	%rax, %rbp
	movq	8(%rsp), %rsi
	movq	%rax, %rdi
	movq	%r13, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	16(%rsp), %rdi
	xorl	%r13d, %r13d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	16(%rsp), %rdi
	callq	hipEventSynchronize
	movq	56(%rsp), %rsi
	movq	16(%rsp), %rdx
	leaq	68(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventElapsedTime
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$6, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	cvtss2sd	(%r14), %xmm0
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	cmpl	$4, %r15d
	jne	.LBB4_13
# %bb.12:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.7, %esi
	movl	$19, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	40(%rsp), %rax                  # 8-byte Reload
	movq	24(%rax), %rdi
	movl	%r12d, %esi
	movq	%rbp, %rdx
	callq	_Z11writeMatrixPKciPi
.LBB4_13:
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	48(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	%rbp, %rdi
	callq	_ZdaPv
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$6, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB4_19
.LBB4_14:
	movl	$_ZSt4cout, %r14d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$19, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	8(%rbx), %rbx
	testq	%rbx, %rbx
	je	.LBB4_16
# %bb.15:
	movq	%rbx, %rdi
	callq	strlen
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB4_17
.LBB4_16:
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cout(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB4_17:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	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
.LBB4_18:
	movl	$1, %r13d
.LBB4_19:
	movl	%r13d, %eax
	addq	$72, %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_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12prepareArrayiPi, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8dijsktraPiiS_, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__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	.LBB6_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
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z12prepareArrayiPi,@object     # @_Z12prepareArrayiPi
	.section	.rodata,"a",@progbits
	.globl	_Z12prepareArrayiPi
	.p2align	3, 0x0
_Z12prepareArrayiPi:
	.quad	_Z27__device_stub__prepareArrayiPi
	.size	_Z12prepareArrayiPi, 8

	.type	_Z8dijsktraPiiS_,@object        # @_Z8dijsktraPiiS_
	.globl	_Z8dijsktraPiiS_
	.p2align	3, 0x0
_Z8dijsktraPiiS_:
	.quad	_Z23__device_stub__dijsktraPiiS_
	.size	_Z8dijsktraPiiS_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	" \t\r\n"
	.size	.L.str, 5

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

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Program takes 2 or 3 parameters (matrix and thread count and optional output file)!\n"
	.size	.L.str.3, 85

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"File doesn't exists"
	.size	.L.str.4, 20

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

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Time: "
	.size	.L.str.6, 7

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Writing results...\n"
	.size	.L.str.7, 20

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

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12prepareArrayiPi"
	.size	.L__unnamed_1, 20

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z8dijsktraPiiS_"
	.size	.L__unnamed_2, 17

	.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 _Z27__device_stub__prepareArrayiPi
	.addrsig_sym _Z23__device_stub__dijsktraPiiS_
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z12prepareArrayiPi
	.addrsig_sym _Z8dijsktraPiiS_
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12prepareArrayiPi     ; -- Begin function _Z12prepareArrayiPi
	.globl	_Z12prepareArrayiPi
	.p2align	8
	.type	_Z12prepareArrayiPi,@function
_Z12prepareArrayiPi:                    ; @_Z12prepareArrayiPi
; %bb.0:
	s_clause 0x3
	s_load_b128 s[4:7], s[0:1], 0x8
	s_load_b64 s[2:3], s[0:1], 0x18
	s_load_b32 s8, s[0:1], 0x20
	s_load_b32 s0, s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s6, s7, s6
	s_and_b32 s9, s3, 0xffff
	s_mul_i32 s2, s6, s2
	s_lshr_b32 s3, s3, 16
	s_mul_i32 s2, s2, s9
	s_and_b32 s6, s8, 0xffff
	s_mul_i32 s2, s2, s3
	s_ashr_i32 s1, s0, 31
	s_mul_i32 s6, s2, s6
	s_add_i32 s10, s0, s1
	s_ashr_i32 s2, s6, 31
	s_xor_b32 s10, s10, s1
	s_add_i32 s3, s6, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	s_xor_b32 s3, s3, s2
	s_xor_b32 s2, s1, s2
	v_cvt_f32_u32_e32 v1, s3
	s_sub_i32 s8, 0, s3
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v1, v1
	v_readfirstlane_b32 s7, v1
	v_mad_u64_u32 v[1:2], null, s15, s9, v[0:1]
	v_bfrev_b32_e32 v0, -4
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s8, s8, s7
	s_mul_hi_u32 s8, s7, s8
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_mov_b32_e32 v2, v1
	s_add_i32 s7, s7, s8
	s_mul_hi_u32 s8, s10, s7
	s_mov_b32 s7, 0
	s_mul_i32 s11, s8, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_sub_i32 s10, s10, s11
	s_add_i32 s11, s8, 1
	s_sub_i32 s12, s10, s3
	s_cmp_ge_u32 s10, s3
	s_cselect_b32 s8, s11, s8
	s_cselect_b32 s9, s12, s10
	s_add_i32 s10, s8, 1
	s_cmp_ge_u32 s9, s3
	s_cselect_b32 s3, s10, s8
	v_cmp_gt_i64_e64 s8, s[0:1], 0
	s_xor_b32 s3, s3, s2
                                        ; implicit-def: $sgpr10
	s_delay_alu instid0(SALU_CYCLE_1)
	s_sub_i32 s9, s3, s2
	s_lshl_b64 s[2:3], s[0:1], 2
	s_max_i32 s1, s9, 1
	s_mov_b32 s9, 0
.LBB0_1:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_4 Depth 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[3:4], null, s9, s6, v[1:2]
	s_or_b32 s10, s10, exec_lo
	s_mov_b32 s11, exec_lo
	v_cmpx_gt_i32_e64 s0, v3
	s_cbranch_execz .LBB0_6
; %bb.2:                                ; %.preheader
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_and_not1_b32 vcc_lo, exec_lo, s8
	s_cbranch_vccnz .LBB0_5
; %bb.3:                                ; %.lr.ph.preheader
                                        ;   in Loop: Header=BB0_1 Depth=1
	v_ashrrev_i32_e32 v3, 31, v2
	s_mov_b32 s12, s0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[2:3]
	v_add_co_u32 v3, vcc_lo, s4, v3
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v4, vcc_lo, s5, v4, vcc_lo
.LBB0_4:                                ; %.lr.ph
                                        ;   Parent Loop BB0_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_store_b32 v[3:4], v0, off
	v_add_co_u32 v3, vcc_lo, v3, s2
	v_add_co_ci_u32_e32 v4, vcc_lo, s3, v4, vcc_lo
	s_add_i32 s12, s12, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s12, 0
	s_cbranch_scc1 .LBB0_4
.LBB0_5:                                ; %._crit_edge
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_add_i32 s9, s9, 1
	v_add_nc_u32_e32 v2, s6, v2
	s_cmp_eq_u32 s9, s1
	s_cselect_b32 s12, -1, 0
	s_and_not1_b32 s10, s10, exec_lo
	s_and_b32 s12, s12, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s10, s10, s12
.LBB0_6:                                ; %Flow47
                                        ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s11
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s11, exec_lo, s10
	s_or_b32 s7, s11, s7
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s7
	s_cbranch_execnz .LBB0_1
; %bb.7:                                ; %.critedge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12prepareArrayiPi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.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 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 5
		.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	_Z12prepareArrayiPi, .Lfunc_end0-_Z12prepareArrayiPi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 452
; NumSgprs: 18
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 5
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z8dijsktraPiiS_        ; -- Begin function _Z8dijsktraPiiS_
	.globl	_Z8dijsktraPiiS_
	.p2align	8
	.type	_Z8dijsktraPiiS_,@function
_Z8dijsktraPiiS_:                       ; @_Z8dijsktraPiiS_
; %bb.0:
	s_clause 0x4
	s_load_b128 s[4:7], s[0:1], 0x10
	s_load_b64 s[2:3], s[0:1], 0x20
	s_load_b32 s8, s[0:1], 0x28
	s_load_b32 s9, s[0:1], 0x8
	s_load_b64 s[0:1], s[0:1], 0x0
	s_mov_b32 s16, 0
                                        ; implicit-def: $sgpr17
	v_mov_b32_e32 v4, 0
	s_waitcnt lgkmcnt(0)
	s_mul_i32 s6, s7, s6
	s_and_b32 s7, s3, 0xffff
	s_mul_i32 s2, s6, s2
	s_lshr_b32 s3, s3, 16
	s_mul_i32 s2, s2, s7
	s_and_b32 s6, s8, 0xffff
	s_mul_i32 s8, s2, s3
	s_ashr_i32 s11, s9, 31
	s_mul_i32 s8, s8, s6
	s_add_i32 s12, s9, s11
	s_ashr_i32 s2, s8, 31
	s_xor_b32 s12, s12, s11
	s_add_i32 s3, s8, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	s_xor_b32 s3, s3, s2
	s_xor_b32 s2, s11, s2
	v_cvt_f32_u32_e32 v1, s3
	s_sub_i32 s10, 0, s3
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v1, v1
	v_readfirstlane_b32 s6, v1
	v_mad_u64_u32 v[1:2], null, s15, s7, v[0:1]
	v_mov_b32_e32 v0, 1
	s_mov_b32 s15, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s10, s10, s6
	s_mul_hi_u32 s10, s6, s10
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s6, s6, s10
	s_mul_hi_u32 s6, s12, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_mul_i32 s10, s6, s3
	s_add_i32 s11, s6, 1
	s_sub_i32 s10, s12, s10
	s_sub_i32 s12, s10, s3
	s_cmp_ge_u32 s10, s3
	s_cselect_b32 s6, s11, s6
	s_cselect_b32 s10, s12, s10
	s_add_i32 s11, s6, 1
	s_cmp_ge_u32 s10, s3
	s_mov_b32 s3, 0
	s_cselect_b32 s6, s11, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_xor_b32 s6, s6, s2
	s_sub_i32 s2, s6, s2
	s_cmp_gt_i32 s9, 0
	s_cselect_b32 s10, -1, 0
	s_add_i32 s11, s9, 1
	s_max_i32 s12, s2, 1
	s_cmp_lg_u32 s9, 0
	s_cselect_b32 s13, -1, 0
	s_add_i32 s14, 4, 4
.LBB1_1:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB1_3 Depth 2
                                        ;     Child Loop BB1_6 Depth 2
                                        ;       Child Loop BB1_8 Depth 3
                                        ;       Child Loop BB1_16 Depth 3
	v_mad_u64_u32 v[2:3], null, s16, s8, v[1:2]
	s_or_b32 s17, s17, exec_lo
	s_mov_b32 s18, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s9, v2
	s_cbranch_execz .LBB1_24
; %bb.2:                                ;   in Loop: Header=BB1_1 Depth=1
	s_and_not1_b32 vcc_lo, exec_lo, s10
	s_mov_b32 s2, s9
	s_mov_b32 s6, s14
	s_cbranch_vccnz .LBB1_4
.LBB1_3:                                ; %.lr.ph.i
                                        ;   Parent Loop BB1_1 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_add_i32 s2, s2, -1
	scratch_store_b8 off, v0, s6
	s_add_i32 s6, s6, 1
	s_cmp_lg_u32 s2, 0
	s_cbranch_scc1 .LBB1_3
.LBB1_4:                                ; %_ZN5mySet4initEi.exit
                                        ;   in Loop: Header=BB1_1 Depth=1
	v_mul_lo_u32 v5, v2, s11
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v6, 31, v5
	v_lshlrev_b64 v[5:6], 2, v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v5, vcc_lo, s4, v5
	v_add_co_ci_u32_e32 v6, vcc_lo, s5, v6, vcc_lo
	s_and_not1_b32 vcc_lo, exec_lo, s13
	global_store_b32 v[5:6], v4, off
	s_cbranch_vccnz .LBB1_23
; %bb.5:                                ; %.preheader.lr.ph
                                        ;   in Loop: Header=BB1_1 Depth=1
	v_ashrrev_i32_e32 v3, 31, v2
	v_mov_b32_e32 v7, s9
	s_mov_b32 s19, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	v_add_co_u32 v5, vcc_lo, s4, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v6, vcc_lo, s5, v3, vcc_lo
.LBB1_6:                                ; %.preheader
                                        ;   Parent Loop BB1_1 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB1_8 Depth 3
                                        ;       Child Loop BB1_16 Depth 3
	v_cmp_lt_i32_e32 vcc_lo, 0, v7
	v_mov_b32_e32 v8, 0
	s_and_b32 s6, s10, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_saveexec_b32 s2, s6
	s_cbranch_execz .LBB1_12
; %bb.7:                                ; %.lr.ph.preheader
                                        ;   in Loop: Header=BB1_6 Depth=2
	v_mov_b32_e32 v2, 0
	v_bfrev_b32_e32 v3, -2
	v_mov_b32_e32 v8, 0
	s_mov_b32 s20, 0
	s_mov_b32 s6, 0
	s_mov_b32 s21, 0
.LBB1_8:                                ; %.lr.ph
                                        ;   Parent Loop BB1_1 Depth=1
                                        ;     Parent Loop BB1_6 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_i32 s7, s14, s21
	s_mov_b32 s22, exec_lo
	scratch_load_u8 v9, off, s7
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u16_e32 0, v9
	s_cbranch_execz .LBB1_10
; %bb.9:                                ;   in Loop: Header=BB1_8 Depth=3
	s_ashr_i32 s7, s6, 31
	v_add_nc_u32_e32 v2, 1, v2
	s_lshl_b64 s[24:25], s[6:7], 2
	s_delay_alu instid0(SALU_CYCLE_1)
	v_add_co_u32 v9, vcc_lo, v5, s24
	v_add_co_ci_u32_e32 v10, vcc_lo, s25, v6, vcc_lo
	global_load_b32 v9, v[9:10], off
	s_waitcnt vmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, v3, v9
	v_min_i32_e32 v3, v3, v9
	v_cndmask_b32_e64 v8, v8, s21, vcc_lo
.LBB1_10:                               ;   in Loop: Header=BB1_8 Depth=3
	s_or_b32 exec_lo, exec_lo, s22
	s_add_i32 s21, s21, 1
	v_cmp_ge_i32_e32 vcc_lo, v2, v7
	s_cmp_ge_i32 s21, s9
	s_cselect_b32 s7, -1, 0
	s_add_i32 s6, s6, s9
	s_or_b32 s7, s7, vcc_lo
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s7, exec_lo, s7
	s_or_b32 s20, s7, s20
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s20
	s_cbranch_execnz .LBB1_8
; %bb.11:                               ; %Flow114
                                        ;   in Loop: Header=BB1_6 Depth=2
	s_or_b32 exec_lo, exec_lo, s20
.LBB1_12:                               ; %Flow115
                                        ;   in Loop: Header=BB1_6 Depth=2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 exec_lo, exec_lo, s2
	v_add3_u32 v2, 4, v8, 4
	s_mov_b32 s2, exec_lo
	scratch_load_u8 v3, v2, off
	s_waitcnt vmcnt(0)
	v_cmpx_ne_u16_e32 0, v3
	s_cbranch_execz .LBB1_14
; %bb.13:                               ;   in Loop: Header=BB1_6 Depth=2
	v_add_nc_u32_e32 v7, -1, v7
	scratch_store_b8 v2, v4, off
.LBB1_14:                               ; %_ZN5mySet5eraseEi.exit
                                        ;   in Loop: Header=BB1_6 Depth=2
	s_or_b32 exec_lo, exec_lo, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 vcc_lo, exec_lo, s10
	s_cbranch_vccnz .LBB1_21
; %bb.15:                               ; %.lr.ph92
                                        ;   in Loop: Header=BB1_6 Depth=2
	v_mul_lo_u32 v2, v8, s9
	s_mov_b32 s2, 0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_mov_b32 s6, s2
	v_ashrrev_i32_e32 v3, 31, v2
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	v_add_co_u32 v2, vcc_lo, v5, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, v6, v3, vcc_lo
.LBB1_16:                               ;   Parent Loop BB1_1 Depth=1
                                        ;     Parent Loop BB1_6 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	s_mov_b32 s7, exec_lo
	v_cmpx_ne_u32_e64 s6, v8
	s_cbranch_execz .LBB1_20
; %bb.17:                               ;   in Loop: Header=BB1_16 Depth=3
	s_add_i32 s20, s14, s6
	scratch_load_u8 v9, off, s20
	s_waitcnt vmcnt(0)
	v_cmp_ne_u16_e32 vcc_lo, 0, v9
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_20
; %bb.18:                               ;   in Loop: Header=BB1_16 Depth=3
	v_add_nc_u32_e32 v9, s2, v8
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v10, 31, v9
	v_lshlrev_b64 v[9:10], 2, v[9:10]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v9, vcc_lo, s0, v9
	v_add_co_ci_u32_e32 v10, vcc_lo, s1, v10, vcc_lo
	global_load_b32 v9, v[9:10], off
	s_waitcnt vmcnt(0)
	v_cmp_lt_i32_e32 vcc_lo, 0, v9
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB1_20
; %bb.19:                               ;   in Loop: Header=BB1_16 Depth=3
	global_load_b32 v10, v[2:3], off
	s_lshl_b64 s[20:21], s[2:3], 2
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v11, v10, v9
	v_add_co_u32 v9, vcc_lo, v5, s20
	v_add_co_ci_u32_e32 v10, vcc_lo, s21, v6, vcc_lo
	global_atomic_min_i32 v[9:10], v11, off
.LBB1_20:                               ;   in Loop: Header=BB1_16 Depth=3
	s_or_b32 exec_lo, exec_lo, s7
	s_add_i32 s6, s6, 1
	s_add_i32 s2, s2, s9
	s_cmp_eq_u32 s9, s6
	s_cbranch_scc0 .LBB1_16
.LBB1_21:                               ; %.loopexit
                                        ;   in Loop: Header=BB1_6 Depth=2
	v_cmp_eq_u32_e32 vcc_lo, 0, v7
	s_or_b32 s19, vcc_lo, s19
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s19
	s_cbranch_execnz .LBB1_6
; %bb.22:                               ; %Flow116
                                        ;   in Loop: Header=BB1_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s19
.LBB1_23:                               ; %._crit_edge93
                                        ;   in Loop: Header=BB1_1 Depth=1
	s_add_i32 s16, s16, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	s_cmp_eq_u32 s16, s12
	s_cselect_b32 s2, -1, 0
	s_and_not1_b32 s6, s17, exec_lo
	s_and_b32 s2, s2, exec_lo
	s_or_b32 s17, s6, s2
.LBB1_24:                               ; %Flow121
                                        ;   in Loop: Header=BB1_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s18
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, exec_lo, s17
	s_or_b32 s15, s2, s15
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s15
	s_cbranch_execnz .LBB1_1
; %bb.25:                               ; %.critedge
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8dijsktraPiiS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 4012
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.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 1
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 12
		.amdhsa_next_free_sgpr 26
		.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_end1:
	.size	_Z8dijsktraPiiS_, .Lfunc_end1-_Z8dijsktraPiiS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1020
; NumSgprs: 28
; NumVgprs: 12
; ScratchSize: 4012
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 28
; NumVGPRsForWavesPerEU: 12
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 1
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.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:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12prepareArrayiPi
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12prepareArrayiPi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .actual_access:  read_only
        .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8dijsktraPiiS_
    .private_segment_fixed_size: 4012
    .sgpr_count:     28
    .sgpr_spill_count: 0
    .symbol:         _Z8dijsktraPiiS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     12
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
