#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>

#define INFINITE 1000000000
int* distance_host;
int* distance_dev;


__global__ void FW1(int *distance_dev, int r, int vertexPadded){

    int i = r * blockDim.x + threadIdx.y;
    int j = r * blockDim.x + threadIdx.x;
    int offset = i * vertexPadded;

    extern __shared__ int dist[];
    dist[threadIdx.y * blockDim.x + threadIdx.x] = distance_dev[ offset + j ];
    __syncthreads();

    for(int k=0; k<blockDim.x; ++k){
        dist[ threadIdx.y * blockDim.x + threadIdx.x ] = min(dist[ threadIdx.y * blockDim.x + threadIdx.x ], dist[ threadIdx.y * blockDim.x + k ] + dist[ k * blockDim.x + threadIdx.x ]);
        __syncthreads();
    }
    distance_dev[ offset + j ] = dist[threadIdx.y * blockDim.x + threadIdx.x];
}


__global__ void FW2(int *distance_dev, int r, int vertexPadded, int total_round){

    int block_i, block_j;
    if(blockIdx.y == 0){
        block_i = r;
        block_j = (blockIdx.x + r + 1) % total_round;
    }else{
        block_j = r;
        block_i = (blockIdx.x + r + 1) % total_round;
    }

    int i = block_i * blockDim.x + threadIdx.y;
    int j = block_j * blockDim.x + threadIdx.x;
    int offset = i * vertexPadded;
    int index = threadIdx.y * blockDim.x + threadIdx.x;
    int blockSize_squard = blockDim.x * blockDim.x;


    extern __shared__ int dist[];
    dist[index] = distance_dev[offset + j];
    dist[blockSize_squard + index] = distance_dev[offset + threadIdx.x + r * blockDim.x];
    dist[2*blockSize_squard + index] = distance_dev[(threadIdx.y + r * blockDim.x) * vertexPadded + j ];
    __syncthreads();

    
    for (int k = 0; k < blockDim.x; k++) {
        int ik = threadIdx.y * blockDim.x + blockSize_squard + k;
        int kj = k * blockDim.x + 2 * blockSize_squard + threadIdx.x;
        dist[index] = min(dist[index], dist[ik] + dist[kj]);
        __syncthreads();
    }
    distance_dev[offset + j] = dist[index];
}


__global__ void FW3(int *distance_dev, int r, int vertexPadded, int total_round){

    int block_i = (r + blockIdx.y + 1) % total_round;
    int block_j = (r + blockIdx.x + 1) % total_round;

    int i = block_i * blockDim.x + threadIdx.y;
    int j = block_j * blockDim.x + threadIdx.x;
    int offset = i * vertexPadded;

    int index = threadIdx.y * blockDim.x + threadIdx.x;
    int blockSize_squard = blockDim.x * blockDim.x;

    extern __shared__ int dist[];
    dist[index] = distance_dev[offset + j]; //block(i,j)
    dist[blockSize_squard + index] = distance_dev[offset + threadIdx.x + r * blockDim.x]; //block(i,r)
    dist[2*blockSize_squard + index] = distance_dev[(threadIdx.y + r * blockDim.x) * vertexPadded + j ]; //block(r,j)
    __syncthreads();

    
    for (int k = 0; k < blockDim.x; k++) {
        int ik = threadIdx.y * blockDim.x + blockSize_squard + k;
        int kj = k * blockDim.x + 2 * blockSize_squard + threadIdx.x;
        dist[index] = min(dist[index], dist[ik] + dist[kj]);
        __syncthreads();
    }
    distance_dev[offset + j] = dist[index];
}

void block_FW(int blockSize, int vertexNum, int vertexPadded) {
    int round = vertexPadded / blockSize;
    dim3 block(blockSize, blockSize);
    dim3 grid2(round-1, 2);
    dim3 grid3(round-1, round-1);
    cudaMalloc(&distance_dev, sizeof(int) * vertexPadded * vertexPadded);
    cudaMemcpy(distance_dev, distance_host, sizeof(int) * vertexPadded * vertexPadded, cudaMemcpyHostToDevice);

	for (int r = 0; r < round; ++r) {
        FW1<<< 1, block, blockSize * blockSize * sizeof(int) >>>(distance_dev, r, vertexPadded);
        FW2<<< grid2, block, 3 * blockSize * blockSize * sizeof(int) >>>(distance_dev, r, vertexPadded, round);
        FW3<<< grid3, block, 3 * blockSize * blockSize * sizeof(int) >>>(distance_dev, r, vertexPadded, round);
    }
    cudaMemcpy(distance_host, distance_dev, sizeof(int) * vertexPadded * vertexPadded, cudaMemcpyDeviceToHost);
}


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

    //get number of threads per block
    cudaSetDevice(0);
    cudaDeviceProp prop;
    cudaGetDeviceProperties(&prop, 0);
    int ThreadsPerBlock = (int) sqrt(prop.maxThreadsPerBlock);
    int blockSize = ThreadsPerBlock;
    
    //read input file
    std::ifstream inputFile(argv[1], std::ios::in | std::ios::binary);
    unsigned vertexNum, edgeNum;
    inputFile.read((char*)&vertexNum, 4);
    inputFile.read((char*)&edgeNum, 4);

    //calculate block number, vertex number in a block
    if(vertexNum < blockSize) blockSize = vertexNum;
    int blockNum = ceil( 1.0 * vertexNum / blockSize);
    int vertexPadded = blockSize * blockNum;


    //Allocate memory (pinned)
    cudaMallocHost(&distance_host, sizeof(int) * vertexPadded * vertexPadded);

    for(unsigned i=0; i<vertexPadded; ++i){
        for(unsigned j=0; j<vertexPadded; ++j){
            if( i>=vertexNum || j>=vertexNum) distance_host[ i * vertexPadded + j ] = INFINITE;
            else if( i == j) distance_host[ i * vertexPadded + j ] = 0;
            else distance_host[ i * vertexPadded + j ] = INFINITE;
        }
    }

    int source, destination, weight;
    while( inputFile.read((char*)&source, 4) ){
        inputFile.read((char*)&destination, 4);
        inputFile.read((char*)&weight, 4);
        distance_host[ source * vertexPadded + destination ] = weight;
    }
    inputFile.close();


    block_FW(blockSize, vertexNum, vertexPadded);

    
    //write answer to output file
    std::ofstream outputFile(argv[2], std::ios::out | std::ios::binary);
    for(int i=0; i<vertexNum; ++i){
        for(int j=0; j<vertexNum; ++j){
            outputFile.write( (char*)&distance_host[ i * vertexPadded + j ], 4);
        }
    }
    outputFile.close();
    
    cudaFree(distance_host);
    cudaFree(distance_dev);
    return 0;
}
	.file	"tmpxft_0025cda4_00000000-6_apsp.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4009:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4009:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z24__device_stub__Z3FW1PiiiPiii
	.type	_Z24__device_stub__Z3FW1PiiiPiii, @function
_Z24__device_stub__Z3FW1PiiiPiii:
.LFB4031:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	32(%rsp), %rdi
	movl	%esi, 4(%rsp)
	leaq	44(%rsp), %rsi
	movl	%edx, (%rsp)
	leaq	16(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	24(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z3FW1Piii(%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
.L2:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4031:
	.size	_Z24__device_stub__Z3FW1PiiiPiii, .-_Z24__device_stub__Z3FW1PiiiPiii
	.globl	_Z3FW1Piii
	.type	_Z3FW1Piii, @function
_Z3FW1Piii:
.LFB4032:
	.cfi_startproc
	endbr64
	jmp	_Z24__device_stub__Z3FW1PiiiPiii
	.cfi_endproc
.LFE4032:
	.size	_Z3FW1Piii, .-_Z3FW1Piii
	.globl	_Z25__device_stub__Z3FW2PiiiiPiiii
	.type	_Z25__device_stub__Z3FW2PiiiiPiiii, @function
_Z25__device_stub__Z3FW2PiiiiPiiii:
.LFB4033:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 16(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 12(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z3FW2Piiii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L8:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4033:
	.size	_Z25__device_stub__Z3FW2PiiiiPiiii, .-_Z25__device_stub__Z3FW2PiiiiPiiii
	.globl	_Z3FW2Piiii
	.type	_Z3FW2Piiii, @function
_Z3FW2Piiii:
.LFB4034:
	.cfi_startproc
	endbr64
	jmp	_Z25__device_stub__Z3FW2PiiiiPiiii
	.cfi_endproc
.LFE4034:
	.size	_Z3FW2Piiii, .-_Z3FW2Piiii
	.globl	_Z25__device_stub__Z3FW3PiiiiPiiii
	.type	_Z25__device_stub__Z3FW3PiiiiPiiii, @function
_Z25__device_stub__Z3FW3PiiiiPiiii:
.LFB4035:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movl	%esi, 20(%rsp)
	leaq	68(%rsp), %rsi
	movl	%edx, 16(%rsp)
	leaq	40(%rsp), %rdx
	movl	%ecx, 12(%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L13
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z3FW3Piiii(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L13:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4035:
	.size	_Z25__device_stub__Z3FW3PiiiiPiiii, .-_Z25__device_stub__Z3FW3PiiiiPiiii
	.globl	_Z3FW3Piiii
	.type	_Z3FW3Piiii, @function
_Z3FW3Piiii:
.LFB4036:
	.cfi_startproc
	endbr64
	jmp	_Z25__device_stub__Z3FW3PiiiiPiiii
	.cfi_endproc
.LFE4036:
	.size	_Z3FW3Piiii, .-_Z3FW3Piiii
	.globl	_Z8block_FWiii
	.type	_Z8block_FWiii, @function
_Z8block_FWiii:
.LFB4005:
	.cfi_startproc
	endbr64
	movl	%edx, %eax
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$2147483649, %esi
	movabsq	$4294967297, %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	addq	%rsi, %rsi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edx, %ebp
	cltd
	idivl	%edi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movl	%edi, %ebx
	imull	%ebx, %ebx
	movl	%edi, 16(%rsp)
	movl	%edi, 20(%rsp)
	leaq	distance_dev(%rip), %rdi
	movq	%rsi, 32(%rsp)
	movslq	%ebx, %r14
	movl	$1, 24(%rsp)
	leal	(%rbx,%rbx,2), %ebx
	movl	$1, 48(%rsp)
	movslq	%ebx, %rbx
	salq	$2, %r14
	salq	$2, %rbx
	movl	%eax, %r13d
	decl	%eax
	movl	%eax, 28(%rsp)
	movl	%eax, 40(%rsp)
	movl	%eax, 44(%rsp)
	movslq	%ebp, %rax
	imulq	%rax, %rax
	salq	$2, %rax
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movq	8(%rsp), %rdx
	movl	$1, %ecx
	movq	distance_host(%rip), %rsi
	movq	distance_dev(%rip), %rdi
	call	cudaMemcpy@PLT
.L19:
	cmpl	%r13d, %r12d
	jge	.L25
	movl	24(%rsp), %ecx
	movq	16(%rsp), %rdx
	xorl	%r9d, %r9d
	movq	%r14, %r8
	movq	%r15, %rdi
	movl	$1, %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L20
	movq	distance_dev(%rip), %rdi
	movl	%ebp, %edx
	movl	%r12d, %esi
	call	_Z24__device_stub__Z3FW1PiiiPiii
.L20:
	movl	24(%rsp), %ecx
	movq	16(%rsp), %rdx
	xorl	%r9d, %r9d
	movq	%rbx, %r8
	movq	28(%rsp), %rdi
	movl	36(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	movq	distance_dev(%rip), %rdi
	movl	%r13d, %ecx
	movl	%ebp, %edx
	movl	%r12d, %esi
	call	_Z25__device_stub__Z3FW2PiiiiPiiii
.L21:
	movl	24(%rsp), %ecx
	movq	16(%rsp), %rdx
	xorl	%r9d, %r9d
	movq	%rbx, %r8
	movq	40(%rsp), %rdi
	movl	48(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L22
	movq	distance_dev(%rip), %rdi
	movl	%r13d, %ecx
	movl	%ebp, %edx
	movl	%r12d, %esi
	call	_Z25__device_stub__Z3FW3PiiiiPiiii
.L22:
	incl	%r12d
	jmp	.L19
.L25:
	movq	8(%rsp), %rdx
	movq	distance_dev(%rip), %rsi
	movl	$2, %ecx
	movq	distance_host(%rip), %rdi
	addq	$72, %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
	jmp	cudaMemcpy@PLT
	.cfi_endproc
.LFE4005:
	.size	_Z8block_FWiii, .-_Z8block_FWiii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z3FW3Piiii"
.LC1:
	.string	"_Z3FW2Piiii"
.LC2:
	.string	"_Z3FW1Piii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4038:
	.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	_Z3FW3Piiii(%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	_Z3FW2Piiii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC2(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z3FW1Piii(%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
.LFE4038:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB4006:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4006
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%edi, %edi
	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
	subq	$2120, %rsp
	.cfi_def_cfa_offset 2176
	movq	%fs:40, %rax
	movq	%rax, 2104(%rsp)
	xorl	%eax, %eax
.LEHB0:
	call	cudaSetDevice@PLT
	leaq	1072(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaGetDeviceProperties_v2@PLT
	cvtsi2sdl	1392(%rsp), %xmm0
	call	sqrt@PLT
	movq	8(%r12), %rsi
	movl	$12, %edx
	leaq	552(%rsp), %rax
	movq	%rax, %rdi
	cvttsd2sil	%xmm0, %ebp
	movq	%rax, 8(%rsp)
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE0:
	movq	8(%rsp), %rdi
	leaq	20(%rsp), %rsi
	movl	$4, %edx
.LEHB1:
	call	_ZNSi4readEPcl@PLT
	movq	8(%rsp), %rdi
	leaq	24(%rsp), %rsi
	movl	$4, %edx
	call	_ZNSi4readEPcl@PLT
	movl	20(%rsp), %eax
	cmpl	%eax, %ebp
	cvtsi2sdq	%rax, %xmm0
	cmova	%eax, %ebp
	cvtsi2sdl	%ebp, %xmm1
	divsd	%xmm1, %xmm0
	call	ceil@PLT
	xorl	%edx, %edx
	leaq	distance_host(%rip), %rdi
	cvttsd2sil	%xmm0, %ebx
	imull	%ebp, %ebx
	movslq	%ebx, %rsi
	imulq	%rsi, %rsi
	salq	$2, %rsi
	call	cudaHostAlloc@PLT
	movq	distance_host(%rip), %rdi
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	xorl	%r9d, %r9d
	movl	$1000000000, %r8d
.L32:
	cmpl	%ebx, %edx
	je	.L55
	xorl	%eax, %eax
.L34:
	leal	(%rax,%rcx), %esi
	cmpl	%eax, %edx
	movl	%eax, %r11d
	leaq	(%rdi,%rsi,4), %r10
	cmovnb	%edx, %r11d
	movl	$1000000000, %esi
	cmpl	20(%rsp), %r11d
	jnb	.L33
	cmpl	%eax, %edx
	movl	%r8d, %esi
	cmove	%r9d, %esi
.L33:
	incl	%eax
	movl	%esi, (%r10)
	cmpl	%ebx, %eax
	jne	.L34
	incl	%edx
	addl	%ebx, %ecx
	jmp	.L32
.L55:
	leaq	28(%rsp), %r13
.L35:
	movq	8(%rsp), %rdi
	movl	$4, %edx
	movq	%r13, %rsi
	call	_ZNSi4readEPcl@PLT
	movq	(%rax), %rdx
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	jne	.L56
	movq	8(%rsp), %rdi
	leaq	32(%rsp), %rsi
	movl	$4, %edx
	call	_ZNSi4readEPcl@PLT
	movq	8(%rsp), %rdi
	leaq	36(%rsp), %rsi
	movl	$4, %edx
	call	_ZNSi4readEPcl@PLT
	movl	28(%rsp), %eax
	movl	36(%rsp), %ecx
	movq	distance_host(%rip), %rdx
	imull	%ebx, %eax
	addl	32(%rsp), %eax
	cltq
	movl	%ecx, (%rdx,%rax,4)
	jmp	.L35
.L56:
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv@PLT
	movl	20(%rsp), %esi
	movl	%ebx, %edx
	movl	%ebp, %edi
	call	_Z8block_FWiii
	leaq	40(%rsp), %rbp
	movq	16(%r12), %rsi
	movl	$20, %edx
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@PLT
.LEHE1:
	xorl	%r14d, %r14d
	xorl	%r15d, %r15d
.L37:
	cmpl	20(%rsp), %r15d
	jnb	.L39
	movslq	%r14d, %r12
	xorl	%r13d, %r13d
	salq	$2, %r12
.L40:
	cmpl	20(%rsp), %r13d
	jnb	.L57
	movq	distance_host(%rip), %rsi
	movl	$4, %edx
	movq	%rbp, %rdi
	addq	%r12, %rsi
.LEHB2:
	call	_ZNSo5writeEPKcl@PLT
	incl	%r13d
	addq	$4, %r12
	jmp	.L40
.L57:
	incl	%r15d
	addl	%ebx, %r14d
	jmp	.L37
.L39:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
	movq	distance_host(%rip), %rdi
	call	cudaFree@PLT
	movq	distance_dev(%rip), %rdi
	call	cudaFree@PLT
.LEHE2:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	2104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L44
	jmp	.L53
.L50:
	endbr64
	movq	%rax, %rbx
.L41:
	movq	%rbp, %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L42
.L49:
	endbr64
	movq	%rax, %rbx
.L42:
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	2104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L53
	movq	%rbx, %rdi
.LEHB3:
	call	_Unwind_Resume@PLT
.LEHE3:
.L53:
	call	__stack_chk_fail@PLT
.L44:
	addq	$2120, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4006:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4006:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4006-.LLSDACSB4006
.LLSDACSB4006:
	.uleb128 .LEHB0-.LFB4006
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB4006
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L49-.LFB4006
	.uleb128 0
	.uleb128 .LEHB2-.LFB4006
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L50-.LFB4006
	.uleb128 0
	.uleb128 .LEHB3-.LFB4006
	.uleb128 .LEHE3-.LEHB3
	.uleb128 0
	.uleb128 0
.LLSDACSE4006:
	.section	.text.startup
	.size	main, .-main
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	distance_dev
	.bss
	.align 8
	.type	distance_dev, @object
	.size	distance_dev, 8
distance_dev:
	.zero	8
	.globl	distance_host
	.align 8
	.type	distance_host, @object
	.size	distance_host, 8
distance_host:
	.zero	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 <iomanip>
#include <fstream>
#include <cmath>

#define INFINITE 1000000000
int* distance_host;
int* distance_dev;


__global__ void FW1(int *distance_dev, int r, int vertexPadded){

    int i = r * blockDim.x + threadIdx.y;
    int j = r * blockDim.x + threadIdx.x;
    int offset = i * vertexPadded;

    extern __shared__ int dist[];
    dist[threadIdx.y * blockDim.x + threadIdx.x] = distance_dev[ offset + j ];
    __syncthreads();

    for(int k=0; k<blockDim.x; ++k){
        dist[ threadIdx.y * blockDim.x + threadIdx.x ] = min(dist[ threadIdx.y * blockDim.x + threadIdx.x ], dist[ threadIdx.y * blockDim.x + k ] + dist[ k * blockDim.x + threadIdx.x ]);
        __syncthreads();
    }
    distance_dev[ offset + j ] = dist[threadIdx.y * blockDim.x + threadIdx.x];
}


__global__ void FW2(int *distance_dev, int r, int vertexPadded, int total_round){

    int block_i, block_j;
    if(blockIdx.y == 0){
        block_i = r;
        block_j = (blockIdx.x + r + 1) % total_round;
    }else{
        block_j = r;
        block_i = (blockIdx.x + r + 1) % total_round;
    }

    int i = block_i * blockDim.x + threadIdx.y;
    int j = block_j * blockDim.x + threadIdx.x;
    int offset = i * vertexPadded;
    int index = threadIdx.y * blockDim.x + threadIdx.x;
    int blockSize_squard = blockDim.x * blockDim.x;


    extern __shared__ int dist[];
    dist[index] = distance_dev[offset + j];
    dist[blockSize_squard + index] = distance_dev[offset + threadIdx.x + r * blockDim.x];
    dist[2*blockSize_squard + index] = distance_dev[(threadIdx.y + r * blockDim.x) * vertexPadded + j ];
    __syncthreads();

    
    for (int k = 0; k < blockDim.x; k++) {
        int ik = threadIdx.y * blockDim.x + blockSize_squard + k;
        int kj = k * blockDim.x + 2 * blockSize_squard + threadIdx.x;
        dist[index] = min(dist[index], dist[ik] + dist[kj]);
        __syncthreads();
    }
    distance_dev[offset + j] = dist[index];
}


__global__ void FW3(int *distance_dev, int r, int vertexPadded, int total_round){

    int block_i = (r + blockIdx.y + 1) % total_round;
    int block_j = (r + blockIdx.x + 1) % total_round;

    int i = block_i * blockDim.x + threadIdx.y;
    int j = block_j * blockDim.x + threadIdx.x;
    int offset = i * vertexPadded;

    int index = threadIdx.y * blockDim.x + threadIdx.x;
    int blockSize_squard = blockDim.x * blockDim.x;

    extern __shared__ int dist[];
    dist[index] = distance_dev[offset + j]; //block(i,j)
    dist[blockSize_squard + index] = distance_dev[offset + threadIdx.x + r * blockDim.x]; //block(i,r)
    dist[2*blockSize_squard + index] = distance_dev[(threadIdx.y + r * blockDim.x) * vertexPadded + j ]; //block(r,j)
    __syncthreads();

    
    for (int k = 0; k < blockDim.x; k++) {
        int ik = threadIdx.y * blockDim.x + blockSize_squard + k;
        int kj = k * blockDim.x + 2 * blockSize_squard + threadIdx.x;
        dist[index] = min(dist[index], dist[ik] + dist[kj]);
        __syncthreads();
    }
    distance_dev[offset + j] = dist[index];
}

void block_FW(int blockSize, int vertexNum, int vertexPadded) {
    int round = vertexPadded / blockSize;
    dim3 block(blockSize, blockSize);
    dim3 grid2(round-1, 2);
    dim3 grid3(round-1, round-1);
    hipMalloc(&distance_dev, sizeof(int) * vertexPadded * vertexPadded);
    hipMemcpy(distance_dev, distance_host, sizeof(int) * vertexPadded * vertexPadded, hipMemcpyHostToDevice);

	for (int r = 0; r < round; ++r) {
        FW1<<< 1, block, blockSize * blockSize * sizeof(int) >>>(distance_dev, r, vertexPadded);
        FW2<<< grid2, block, 3 * blockSize * blockSize * sizeof(int) >>>(distance_dev, r, vertexPadded, round);
        FW3<<< grid3, block, 3 * blockSize * blockSize * sizeof(int) >>>(distance_dev, r, vertexPadded, round);
    }
    hipMemcpy(distance_host, distance_dev, sizeof(int) * vertexPadded * vertexPadded, hipMemcpyDeviceToHost);
}


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

    //get number of threads per block
    hipSetDevice(0);
    hipDeviceProp_t prop;
    hipGetDeviceProperties(&prop, 0);
    int ThreadsPerBlock = (int) sqrt(prop.maxThreadsPerBlock);
    int blockSize = ThreadsPerBlock;
    
    //read input file
    std::ifstream inputFile(argv[1], std::ios::in | std::ios::binary);
    unsigned vertexNum, edgeNum;
    inputFile.read((char*)&vertexNum, 4);
    inputFile.read((char*)&edgeNum, 4);

    //calculate block number, vertex number in a block
    if(vertexNum < blockSize) blockSize = vertexNum;
    int blockNum = ceil( 1.0 * vertexNum / blockSize);
    int vertexPadded = blockSize * blockNum;


    //Allocate memory (pinned)
    hipHostMalloc(&distance_host, sizeof(int) * vertexPadded * vertexPadded, hipHostMallocDefault);

    for(unsigned i=0; i<vertexPadded; ++i){
        for(unsigned j=0; j<vertexPadded; ++j){
            if( i>=vertexNum || j>=vertexNum) distance_host[ i * vertexPadded + j ] = INFINITE;
            else if( i == j) distance_host[ i * vertexPadded + j ] = 0;
            else distance_host[ i * vertexPadded + j ] = INFINITE;
        }
    }

    int source, destination, weight;
    while( inputFile.read((char*)&source, 4) ){
        inputFile.read((char*)&destination, 4);
        inputFile.read((char*)&weight, 4);
        distance_host[ source * vertexPadded + destination ] = weight;
    }
    inputFile.close();


    block_FW(blockSize, vertexNum, vertexPadded);

    
    //write answer to output file
    std::ofstream outputFile(argv[2], std::ios::out | std::ios::binary);
    for(int i=0; i<vertexNum; ++i){
        for(int j=0; j<vertexNum; ++j){
            outputFile.write( (char*)&distance_host[ i * vertexPadded + j ], 4);
        }
    }
    outputFile.close();
    
    hipFree(distance_host);
    hipFree(distance_dev);
    return 0;
}
	.text
	.file	"apsp.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z18__device_stub__FW1Piii      # -- Begin function _Z18__device_stub__FW1Piii
	.type	_Z18__device_stub__FW1Piii,@function
_Z18__device_stub__FW1Piii:             # @_Z18__device_stub__FW1Piii
	.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	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	movq	%rsp, %rsi
	movl	%edx, (%rsi)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%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	$_Z3FW1Piii, %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_end0:
	.size	_Z18__device_stub__FW1Piii, .Lfunc_end0-_Z18__device_stub__FW1Piii
	.cfi_endproc
                                        # -- End function
	.globl	_Z18__device_stub__FW2Piiii     # -- Begin function _Z18__device_stub__FW2Piiii
	.type	_Z18__device_stub__FW2Piiii,@function
_Z18__device_stub__FW2Piiii:            # @_Z18__device_stub__FW2Piiii
	.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	20(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	16(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	12(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z3FW2Piiii, %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	_Z18__device_stub__FW2Piiii, .Lfunc_end1-_Z18__device_stub__FW2Piiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z18__device_stub__FW3Piiii     # -- Begin function _Z18__device_stub__FW3Piiii
	.type	_Z18__device_stub__FW3Piiii,@function
_Z18__device_stub__FW3Piiii:            # @_Z18__device_stub__FW3Piiii
	.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	20(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	16(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	12(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	32(%rsp), %r12
	leaq	24(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z3FW3Piiii, %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_end2:
	.size	_Z18__device_stub__FW3Piiii, .Lfunc_end2-_Z18__device_stub__FW3Piiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z8block_FWiii                  # -- Begin function _Z8block_FWiii
	.type	_Z8block_FWiii,@function
_Z8block_FWiii:                         # @_Z8block_FWiii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ecx
	movl	%edi, %ebx
	movl	%edx, %eax
	cltd
	idivl	%edi
	movl	%eax, %r15d
	movl	%ecx, 4(%rsp)                   # 4-byte Spill
	movslq	%ecx, %r14
	imulq	%r14, %r14
	shlq	$2, %r14
	movl	$distance_dev, %edi
	movq	%r14, %rsi
	callq	hipMalloc
	movq	distance_dev(%rip), %rdi
	movq	distance_host(%rip), %rsi
	movq	%r14, 8(%rsp)                   # 8-byte Spill
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%r15d, %r15d
	jle	.LBB3_9
# %bb.1:                                # %.lr.ph
	movl	%ebx, %eax
	movq	%rax, %r13
	shlq	$32, %r13
	orq	%rax, %r13
	leal	-1(%r15), %r14d
	movq	%r14, %rbp
	shlq	$32, %rbp
	orq	%r14, %rbp
	btsq	$33, %r14
	imull	%ebx, %ebx
	leaq	(,%rbx,4), %rax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	leal	(%rbx,%rbx,2), %eax
	movslq	%eax, %rbx
	shlq	$2, %rbx
	xorl	%r12d, %r12d
.LBB3_2:                                # =>This Inner Loop Header: Depth=1
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	movq	16(%rsp), %r8                   # 8-byte Reload
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_4
# %bb.3:                                #   in Loop: Header=BB3_2 Depth=1
	movq	distance_dev(%rip), %rdi
	movl	%r12d, %esi
	movl	4(%rsp), %edx                   # 4-byte Reload
	callq	_Z18__device_stub__FW1Piii
.LBB3_4:                                #   in Loop: Header=BB3_2 Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	movq	%rbx, %r8
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_6
# %bb.5:                                #   in Loop: Header=BB3_2 Depth=1
	movq	distance_dev(%rip), %rdi
	movl	%r12d, %esi
	movl	4(%rsp), %edx                   # 4-byte Reload
	movl	%r15d, %ecx
	callq	_Z18__device_stub__FW2Piiii
.LBB3_6:                                #   in Loop: Header=BB3_2 Depth=1
	movq	%rbp, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	movq	%rbx, %r8
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_8
# %bb.7:                                #   in Loop: Header=BB3_2 Depth=1
	movq	distance_dev(%rip), %rdi
	movl	%r12d, %esi
	movl	4(%rsp), %edx                   # 4-byte Reload
	movl	%r15d, %ecx
	callq	_Z18__device_stub__FW3Piiii
.LBB3_8:                                #   in Loop: Header=BB3_2 Depth=1
	incl	%r12d
	cmpl	%r12d, %r15d
	jne	.LBB3_2
.LBB3_9:                                # %._crit_edge
	movq	distance_host(%rip), %rdi
	movq	distance_dev(%rip), %rsi
	movq	8(%rsp), %rdx                   # 8-byte Reload
	movl	$2, %ecx
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	hipMemcpy                       # TAILCALL
.Lfunc_end3:
	.size	_Z8block_FWiii, .Lfunc_end3-_Z8block_FWiii
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
.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	$2552, %rsp                     # imm = 0x9F8
	.cfi_def_cfa_offset 2608
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %r14
	xorl	%edi, %edi
	callq	hipSetDevice
	leaq	1080(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	hipGetDevicePropertiesR0600
	cvtsi2sdl	320(%rbx), %xmm0
	xorpd	%xmm1, %xmm1
	ucomisd	%xmm1, %xmm0
	jb	.LBB4_2
# %bb.1:
	sqrtsd	%xmm0, %xmm0
	jmp	.LBB4_3
.LBB4_2:                                # %call.sqrt
	callq	sqrt
.LBB4_3:                                # %.split
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	movq	%r14, 32(%rsp)                  # 8-byte Spill
	movq	8(%r14), %rsi
	leaq	560(%rsp), %rbx
	movq	%rbx, %rdi
	movl	$12, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
.Ltmp0:
	leaq	4(%rsp), %rsi
	movl	$4, %edx
	movq	%rbx, %rdi
	callq	_ZNSi4readEPcl
.Ltmp1:
# %bb.4:
.Ltmp2:
	leaq	560(%rsp), %rdi
	leaq	44(%rsp), %rsi
	movl	$4, %edx
	callq	_ZNSi4readEPcl
.Ltmp3:
# %bb.5:
	cvttsd2si	8(%rsp), %ebx           # 8-byte Folded Reload
	movl	4(%rsp), %eax
	cmpl	%ebx, %eax
	cmovbl	%eax, %ebx
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sd	%ebx, %xmm1
	divsd	%xmm1, %xmm0
	callq	ceil@PLT
	cvttsd2si	%xmm0, %r14d
	movl	%ebx, 8(%rsp)                   # 4-byte Spill
	imull	%ebx, %r14d
	movslq	%r14d, %rbp
	movq	%rbp, %rsi
	imulq	%rbp, %rsi
	shlq	$2, %rsi
.Ltmp5:
	movl	$distance_host, %edi
	xorl	%edx, %edx
	callq	hipHostMalloc
.Ltmp6:
# %bb.6:                                # %_ZL13hipHostMallocIiE10hipError_tPPT_mj.exit.preheader
	testl	%r14d, %r14d
	je	.LBB4_16
# %bb.7:                                # %.preheader63.preheader
	movl	%r14d, %eax
	xorl	%ecx, %ecx
	xorl	%edx, %edx
.LBB4_8:                                # %.preheader63
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_9 Depth 2
	movq	distance_host(%rip), %rsi
	movl	%r14d, %edi
	imull	%edx, %edi
	addl	%edx, %edi
	xorl	%r8d, %r8d
.LBB4_9:                                #   Parent Loop BB4_8 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	4(%rsp), %r9d
	cmpq	%r9, %rdx
	jae	.LBB4_13
# %bb.10:                               #   in Loop: Header=BB4_9 Depth=2
	cmpq	%r9, %r8
	jae	.LBB4_13
# %bb.11:                               #   in Loop: Header=BB4_9 Depth=2
	cmpq	%r8, %rdx
	jne	.LBB4_13
# %bb.12:                               #   in Loop: Header=BB4_9 Depth=2
	movl	$0, (%rsi,%rdi,4)
	jmp	.LBB4_14
.LBB4_13:                               #   in Loop: Header=BB4_9 Depth=2
	leal	(%rcx,%r8), %r9d
	movl	$1000000000, (%rsi,%r9,4)       # imm = 0x3B9ACA00
.LBB4_14:                               #   in Loop: Header=BB4_9 Depth=2
	incq	%r8
	cmpq	%r8, %rax
	jne	.LBB4_9
# %bb.15:                               # %_ZL13hipHostMallocIiE10hipError_tPPT_mj.exit
                                        #   in Loop: Header=BB4_8 Depth=1
	incq	%rdx
	addq	%rax, %rcx
	cmpq	%rax, %rdx
	jne	.LBB4_8
.LBB4_16:                               # %_ZL13hipHostMallocIiE10hipError_tPPT_mj.exit._crit_edge
	leaq	560(%rsp), %r15
	leaq	28(%rsp), %r12
	leaq	24(%rsp), %r13
	leaq	20(%rsp), %rbx
.LBB4_17:                               # =>This Inner Loop Header: Depth=1
.Ltmp8:
	movl	$4, %edx
	movq	%r15, %rdi
	movq	%r12, %rsi
	callq	_ZNSi4readEPcl
.Ltmp9:
# %bb.18:                               #   in Loop: Header=BB4_17 Depth=1
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	jne	.LBB4_22
# %bb.19:                               #   in Loop: Header=BB4_17 Depth=1
.Ltmp28:
	movl	$4, %edx
	movq	%r15, %rdi
	movq	%r13, %rsi
	callq	_ZNSi4readEPcl
.Ltmp29:
# %bb.20:                               #   in Loop: Header=BB4_17 Depth=1
.Ltmp30:
	movl	$4, %edx
	movq	%r15, %rdi
	movq	%rbx, %rsi
	callq	_ZNSi4readEPcl
.Ltmp31:
# %bb.21:                               #   in Loop: Header=BB4_17 Depth=1
	movl	20(%rsp), %eax
	movq	distance_host(%rip), %rcx
	movslq	28(%rsp), %rdx
	imulq	%rbp, %rdx
	movslq	24(%rsp), %rsi
	addq	%rdx, %rsi
	movl	%eax, (%rcx,%rsi,4)
	jmp	.LBB4_17
.LBB4_22:
.Ltmp10:
	leaq	560(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv
.Ltmp11:
# %bb.23:
.Ltmp12:
	movl	8(%rsp), %edi                   # 4-byte Reload
	movl	%r14d, %edx
	callq	_Z8block_FWiii
.Ltmp13:
# %bb.24:
	movq	32(%rsp), %rax                  # 8-byte Reload
	movq	16(%rax), %rsi
.Ltmp15:
	leaq	48(%rsp), %rdi
	movl	$20, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode
.Ltmp16:
# %bb.25:                               # %.preheader62
	cmpl	$0, 4(%rsp)
	je	.LBB4_31
# %bb.26:                               # %.lr.ph.preheader
	shlq	$2, %rbp
	xorl	%r14d, %r14d
	leaq	48(%rsp), %rbx
	xorl	%r15d, %r15d
.LBB4_27:                               # %.lr.ph
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_28 Depth 2
	xorl	%r12d, %r12d
	movq	%r14, %r13
.LBB4_28:                               #   Parent Loop BB4_27 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	distance_host(%rip), %rsi
	addq	%r13, %rsi
.Ltmp18:
	movl	$4, %edx
	movq	%rbx, %rdi
	callq	_ZNSo5writeEPKcl
.Ltmp19:
# %bb.29:                               #   in Loop: Header=BB4_28 Depth=2
	movl	4(%rsp), %eax
	addq	$4, %r13
	incl	%r12d
	cmpl	%r12d, %eax
	ja	.LBB4_28
# %bb.30:                               # %._crit_edge
                                        #   in Loop: Header=BB4_27 Depth=1
	incq	%r15
	addq	%rbp, %r14
	cmpl	%r15d, %eax
	ja	.LBB4_27
.LBB4_31:                               # %._crit_edge68
.Ltmp21:
	leaq	48(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp22:
# %bb.32:
	movq	distance_host(%rip), %rdi
.Ltmp23:
	callq	hipFree
.Ltmp24:
# %bb.33:
	movq	distance_dev(%rip), %rdi
.Ltmp25:
	callq	hipFree
.Ltmp26:
# %bb.34:
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rax
	leaq	56(%rsp), %rdi
	movq	%rax, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %rcx
	movq	-24(%rax), %rax
	movq	%rcx, 48(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	296(%rsp), %rdi
	callq	_ZNSt8ios_baseD2Ev
	leaq	560(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	xorl	%eax, %eax
	addq	$2552, %rsp                     # imm = 0x9F8
	.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_35:
	.cfi_def_cfa_offset 2608
.Ltmp17:
	jmp	.LBB4_37
.LBB4_36:
.Ltmp7:
	jmp	.LBB4_37
.LBB4_38:                               # %.loopexit.split-lp
.Ltmp14:
	jmp	.LBB4_37
.LBB4_39:
.Ltmp4:
	jmp	.LBB4_37
.LBB4_40:
.Ltmp27:
	jmp	.LBB4_43
.LBB4_41:                               # %.loopexit
.Ltmp32:
.LBB4_37:
	movq	%rax, %rbx
	jmp	.LBB4_44
.LBB4_42:
.Ltmp20:
.LBB4_43:
	movq	%rax, %rbx
	leaq	48(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
.LBB4_44:
	leaq	560(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table4:
.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 .Ltmp3-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp3
	.uleb128 .Ltmp4-.Lfunc_begin0           #     jumps to .Ltmp4
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp5-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp5
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp5-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp6-.Ltmp5                  #   Call between .Ltmp5 and .Ltmp6
	.uleb128 .Ltmp7-.Lfunc_begin0           #     jumps to .Ltmp7
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp8-.Lfunc_begin0           # >> Call Site 5 <<
	.uleb128 .Ltmp31-.Ltmp8                 #   Call between .Ltmp8 and .Ltmp31
	.uleb128 .Ltmp32-.Lfunc_begin0          #     jumps to .Ltmp32
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp10-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp13-.Ltmp10                #   Call between .Ltmp10 and .Ltmp13
	.uleb128 .Ltmp14-.Lfunc_begin0          #     jumps to .Ltmp14
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp15-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp16-.Ltmp15                #   Call between .Ltmp15 and .Ltmp16
	.uleb128 .Ltmp17-.Lfunc_begin0          #     jumps to .Ltmp17
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp18-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp19-.Ltmp18                #   Call between .Ltmp18 and .Ltmp19
	.uleb128 .Ltmp20-.Lfunc_begin0          #     jumps to .Ltmp20
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp21-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp26-.Ltmp21                #   Call between .Ltmp21 and .Ltmp26
	.uleb128 .Ltmp27-.Lfunc_begin0          #     jumps to .Ltmp27
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp26-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Lfunc_end4-.Ltmp26            #   Call between .Ltmp26 and .Lfunc_end4
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- 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:
	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	$_Z3FW1Piii, %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	$_Z3FW2Piiii, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z3FW3Piiii, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %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	distance_host,@object           # @distance_host
	.bss
	.globl	distance_host
	.p2align	3, 0x0
distance_host:
	.quad	0
	.size	distance_host, 8

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

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

	.type	_Z3FW2Piiii,@object             # @_Z3FW2Piiii
	.globl	_Z3FW2Piiii
	.p2align	3, 0x0
_Z3FW2Piiii:
	.quad	_Z18__device_stub__FW2Piiii
	.size	_Z3FW2Piiii, 8

	.type	_Z3FW3Piiii,@object             # @_Z3FW3Piiii
	.globl	_Z3FW3Piiii
	.p2align	3, 0x0
_Z3FW3Piiii:
	.quad	_Z18__device_stub__FW3Piiii
	.size	_Z3FW3Piiii, 8

	.type	.L__unnamed_1,@object           # @0
	.section	.rodata.str1.1,"aMS",@progbits,1
.L__unnamed_1:
	.asciz	"_Z3FW1Piii"
	.size	.L__unnamed_1, 11

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z3FW2Piiii"
	.size	.L__unnamed_2, 12

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z3FW3Piiii"
	.size	.L__unnamed_3, 12

	.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 _Z18__device_stub__FW1Piii
	.addrsig_sym _Z18__device_stub__FW2Piiii
	.addrsig_sym _Z18__device_stub__FW3Piiii
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym distance_host
	.addrsig_sym distance_dev
	.addrsig_sym _Z3FW1Piii
	.addrsig_sym _Z3FW2Piiii
	.addrsig_sym _Z3FW3Piiii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z3FW1Piii              ; -- Begin function _Z3FW1Piii
	.globl	_Z3FW1Piii
	.p2align	8
	.type	_Z3FW1Piii,@function
_Z3FW1Piii:                             ; @_Z3FW1Piii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x1c
	s_load_b128 s[4:7], s[0:1], 0x0
	v_bfe_u32 v3, v0, 10, 10
	v_and_b32_e32 v4, 0x3ff, v0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s1, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_mul_i32 s0, s1, s6
	v_mad_u32_u24 v2, v3, s1, v4
	v_add_nc_u32_e32 v1, s0, v3
	s_cmp_eq_u32 s1, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_lshl_add_u32 v2, v2, 2, 0
	v_mul_lo_u32 v1, v1, s7
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add3_u32 v0, s0, v4, v1
	s_mov_b32 s0, 0
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	v_add_co_u32 v0, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
	global_load_b32 v5, v[0:1], off
	s_waitcnt vmcnt(0)
	ds_store_b32 v2, v5
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB0_3
; %bb.1:                                ; %.lr.ph.preheader
	v_mul_u32_u24_e32 v5, s1, v3
	v_lshl_add_u32 v3, v4, 2, 0
	s_lshl_b32 s1, s1, 2
	s_delay_alu instid0(VALU_DEP_2)
	v_lshl_add_u32 v4, v5, 2, 0
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_add_nc_u32_e32 v5, s0, v4
	s_add_i32 s0, s0, 4
	ds_load_b32 v6, v3
	ds_load_b32 v7, v2
	ds_load_b32 v5, v5
	v_add_nc_u32_e32 v3, s1, v3
	s_cmp_eq_u32 s1, s0
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v5, v6, v5
	s_delay_alu instid0(VALU_DEP_1)
	v_min_i32_e32 v5, v7, v5
	ds_store_b32 v2, v5
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB0_2
.LBB0_3:                                ; %._crit_edge
	ds_load_b32 v2, v2
	s_waitcnt lgkmcnt(0)
	global_store_b32 v[0:1], v2, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z3FW1Piii
		.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 1
		.amdhsa_next_free_vgpr 8
		.amdhsa_next_free_sgpr 8
		.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	_Z3FW1Piii, .Lfunc_end0-_Z3FW1Piii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 328
; NumSgprs: 10
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 10
; NumVGPRsForWavesPerEU: 8
; 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: 1
	.text
	.protected	_Z3FW2Piiii             ; -- Begin function _Z3FW2Piiii
	.globl	_Z3FW2Piiii
	.p2align	8
	.type	_Z3FW2Piiii,@function
_Z3FW2Piiii:                            ; @_Z3FW2Piiii
; %bb.0:
	s_load_b128 s[4:7], s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	v_cvt_f32_u32_e32 v1, s6
	s_sub_i32 s3, 0, s6
	s_add_i32 s7, s14, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_add_i32 s7, s7, 1
	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 s2, v1
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v0, 0x3ff, v0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s3, s3, s2
	s_mul_hi_u32 s3, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	s_add_i32 s2, s2, s3
	s_load_b32 s3, s[0:1], 0x24
	s_mul_hi_u32 s2, s7, s2
	s_load_b64 s[0:1], s[0:1], 0x0
	s_mul_i32 s2, s2, s6
	s_sub_i32 s2, s7, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_sub_i32 s7, s2, s6
	s_cmp_ge_u32 s2, s6
	s_cselect_b32 s2, s7, s2
	s_sub_i32 s7, s2, s6
	s_cmp_ge_u32 s2, s6
	s_cselect_b32 s2, s7, s2
	s_cmp_eq_u32 s15, 0
	s_cselect_b32 s6, s2, s4
	s_cselect_b32 s7, s4, s2
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
	v_mad_u64_u32 v[2:3], null, s7, s2, v[1:2]
	v_mad_u64_u32 v[3:4], null, s6, s2, v[0:1]
	v_mov_b32_e32 v4, 0
	s_mul_i32 s3, s2, s4
	v_add_nc_u32_e32 v7, s3, v1
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_lo_u32 v2, v2, s5
	v_mad_u64_u32 v[5:6], null, v7, s5, v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_dual_mov_b32 v6, v4 :: v_dual_add_nc_u32 v7, v2, v3
	v_add3_u32 v3, s3, v0, v2
	v_ashrrev_i32_e32 v8, 31, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_lshlrev_b64 v[2:3], 2, v[3:4]
	v_lshlrev_b64 v[4:5], 2, v[5:6]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[6:7], 2, v[7:8]
	v_add_co_u32 v8, vcc_lo, s0, v2
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_ci_u32_e32 v9, vcc_lo, s1, v3, vcc_lo
	v_add_co_u32 v2, vcc_lo, s0, v6
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v7, vcc_lo
	v_add_co_u32 v4, vcc_lo, s0, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	s_clause 0x2
	global_load_b32 v6, v[2:3], off
	global_load_b32 v7, v[8:9], off
	global_load_b32 v5, v[4:5], off
	v_mad_u32_u24 v4, v1, s2, v0
	s_mul_i32 s1, s2, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	s_lshl_b32 s0, s1, 2
	s_cmp_eq_u32 s2, 0
	v_lshl_add_u32 v4, v4, 2, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v8, s0, v4
	v_add_nc_u32_e32 v9, s0, v8
	s_mov_b32 s0, 0
	s_waitcnt vmcnt(2)
	ds_store_b32 v4, v6
	s_waitcnt vmcnt(1)
	ds_store_b32 v8, v7
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v5
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB1_3
; %bb.1:                                ; %.lr.ph
	v_mul_u32_u24_e32 v1, s2, v1
	v_lshlrev_b32_e32 v0, 2, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_nc_u32_e32 v1, s1, v1
	s_lshl_b32 s1, s1, 3
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	v_add3_u32 v0, 0, s1, v0
	s_lshl_b32 s1, s2, 2
	s_delay_alu instid0(VALU_DEP_2)
	v_lshl_add_u32 v1, v1, 2, 0
.LBB1_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_add_nc_u32_e32 v5, s0, v1
	s_add_i32 s0, s0, 4
	ds_load_b32 v6, v0
	ds_load_b32 v7, v4
	ds_load_b32 v5, v5
	v_add_nc_u32_e32 v0, s1, v0
	s_cmp_eq_u32 s1, s0
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v5, v6, v5
	s_delay_alu instid0(VALU_DEP_1)
	v_min_i32_e32 v5, v7, v5
	ds_store_b32 v4, v5
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB1_2
.LBB1_3:                                ; %._crit_edge
	ds_load_b32 v0, v4
	s_waitcnt lgkmcnt(0)
	global_store_b32 v[2:3], v0, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z3FW2Piiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 10
		.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_end1:
	.size	_Z3FW2Piiii, .Lfunc_end1-_Z3FW2Piiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 628
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.protected	_Z3FW3Piiii             ; -- Begin function _Z3FW3Piiii
	.globl	_Z3FW3Piiii
	.p2align	8
	.type	_Z3FW3Piiii,@function
_Z3FW3Piiii:                            ; @_Z3FW3Piiii
; %bb.0:
	s_load_b128 s[4:7], s[0:1], 0x8
	s_waitcnt lgkmcnt(0)
	v_cvt_f32_u32_e32 v1, s6
	s_sub_i32 s3, 0, s6
	s_add_i32 s7, s4, 1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_add_i32 s8, s7, s15
	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 s2, v1
	v_bfe_u32 v1, v0, 10, 10
	v_and_b32_e32 v0, 0x3ff, v0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s3, s3, s2
	s_mul_hi_u32 s3, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s2, s2, s3
	s_mul_hi_u32 s3, s8, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s3, s3, s6
	s_sub_i32 s3, s8, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_sub_i32 s8, s3, s6
	s_cmp_ge_u32 s3, s6
	s_cselect_b32 s3, s8, s3
	s_load_b32 s8, s[0:1], 0x24
	s_sub_i32 s9, s3, s6
	s_cmp_ge_u32 s3, s6
	s_load_b64 s[0:1], s[0:1], 0x0
	s_cselect_b32 s3, s9, s3
	s_add_i32 s7, s7, s14
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_hi_u32 s2, s7, s2
	s_mul_i32 s2, s2, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_sub_i32 s2, s7, s2
	s_sub_i32 s7, s2, s6
	s_cmp_ge_u32 s2, s6
	s_cselect_b32 s2, s7, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	s_sub_i32 s7, s2, s6
	s_cmp_ge_u32 s2, s6
	s_cselect_b32 s6, s7, s2
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s8, 0xffff
	v_mad_u64_u32 v[2:3], null, s3, s2, v[1:2]
	v_mad_u64_u32 v[3:4], null, s6, s2, v[0:1]
	v_mov_b32_e32 v4, 0
	s_mul_i32 s3, s2, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_nc_u32_e32 v7, s3, v1
	v_mul_lo_u32 v2, v2, s5
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[5:6], null, v7, s5, v[3:4]
	v_dual_mov_b32 v6, v4 :: v_dual_add_nc_u32 v7, v2, v3
	v_add3_u32 v3, s3, v0, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v8, 31, v7
	v_lshlrev_b64 v[2:3], 2, v[3:4]
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_lshlrev_b64 v[4:5], 2, v[5:6]
	v_lshlrev_b64 v[6:7], 2, v[7:8]
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v8, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v9, vcc_lo, s1, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_add_co_u32 v2, vcc_lo, s0, v6
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v7, vcc_lo
	v_add_co_u32 v4, vcc_lo, s0, v4
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	s_clause 0x2
	global_load_b32 v6, v[2:3], off
	global_load_b32 v7, v[8:9], off
	global_load_b32 v5, v[4:5], off
	v_mad_u32_u24 v4, v1, s2, v0
	s_mul_i32 s1, s2, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	s_lshl_b32 s0, s1, 2
	s_cmp_eq_u32 s2, 0
	v_lshl_add_u32 v4, v4, 2, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v8, s0, v4
	v_add_nc_u32_e32 v9, s0, v8
	s_mov_b32 s0, 0
	s_waitcnt vmcnt(2)
	ds_store_b32 v4, v6
	s_waitcnt vmcnt(1)
	ds_store_b32 v8, v7
	s_waitcnt vmcnt(0)
	ds_store_b32 v9, v5
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB2_3
; %bb.1:                                ; %.lr.ph
	v_mul_u32_u24_e32 v1, s2, v1
	v_lshlrev_b32_e32 v0, 2, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_nc_u32_e32 v1, s1, v1
	s_lshl_b32 s1, s1, 3
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	v_add3_u32 v0, 0, s1, v0
	s_lshl_b32 s1, s2, 2
	s_delay_alu instid0(VALU_DEP_2)
	v_lshl_add_u32 v1, v1, 2, 0
.LBB2_2:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_add_nc_u32_e32 v5, s0, v1
	s_add_i32 s0, s0, 4
	ds_load_b32 v6, v0
	ds_load_b32 v7, v4
	ds_load_b32 v5, v5
	v_add_nc_u32_e32 v0, s1, v0
	s_cmp_eq_u32 s1, s0
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v5, v6, v5
	s_delay_alu instid0(VALU_DEP_1)
	v_min_i32_e32 v5, v7, v5
	ds_store_b32 v4, v5
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc0 .LBB2_2
.LBB2_3:                                ; %._crit_edge
	ds_load_b32 v0, v4
	s_waitcnt lgkmcnt(0)
	global_store_b32 v[2:3], v0, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z3FW3Piiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 14
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 10
		.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_end2:
	.size	_Z3FW3Piiii, .Lfunc_end2-_Z3FW3Piiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 668
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .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
      - .offset:         136
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .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:           _Z3FW1Piii
    .private_segment_fixed_size: 0
    .sgpr_count:     10
    .sgpr_spill_count: 0
    .symbol:         _Z3FW1Piii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
      - .offset:         144
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .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:           _Z3FW2Piiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z3FW2Piiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
      - .offset:         144
        .size:           4
        .value_kind:     hidden_dynamic_lds_size
    .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:           _Z3FW3Piiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z3FW3Piiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
