#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>

#ifndef THREADS_PER_BLOCK
#define THREADS_PER_BLOCK 1024
#endif

#define VERBOSE
#define CUDA_ERROR_CHECK
#define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ )

inline void __cudaSafeCall( cudaError err, const char *file, const int line )
{
        #ifdef CUDA_ERROR_CHECK
    if ( cudaSuccess != err )
    {
	fprintf( stderr, "cudaSafeCall() failed at %s:%i : %s\n",
		 file, line, cudaGetErrorString( err ) );
	exit( -1 );
    }
        #endif

    return;
}

#define NDIMS 2

__global__ void kernel1(float *dranks, int *dlinks, int *dlink_counts, float *dlink_weights, int nLinks, int start, int end, int GPUN)
{
    int id = blockIdx.x * blockDim.x + threadIdx.x;
    if (start <= id && id <= end) {
	dlink_weights[id-start] = dranks[dlinks[id*NDIMS+0]-1] / (float) dlink_counts[dlinks[id*NDIMS+0]-1];	
    }
}

__global__ void kernel2(float *dranks, int *dlinks, float *dlink_weights, int nDocs, int nLinks, int start, int end, int GPUN)
{
    int id = blockIdx.x * blockDim.x + threadIdx.x;
    if (start <= id && id <= end) {
	float new_rank = 0.0f;
	// look for links pointing to this document
	for (int l = 0; l < nLinks; l++) {
	    int dst = dlinks[l*NDIMS+1] - 1;
	    if (dst == id) {
		new_rank += dlink_weights[l];
	    }
	}
	dranks[id-start] = new_rank;
    }
}

extern "C" {
    
    void prCUDA1(float* ranks, int *links, int *link_counts, float *link_weights, long nDocs, long nLinks, long start, long end, long GPUN) {
	float *dranks, *dlink_weights;
	int *dlinks, *dlink_counts;
	if (GPUN > 0) {
	    assert(end - start + 1 == GPUN);
#ifdef VERBOSE
	    printf("In prCUDA1\n");
	    printf("\t GPUN: %d\n", GPUN);
	    printf("\t range: %d..%d\n", start, end);
#endif		
	    CudaSafeCall(cudaMalloc(&dranks, sizeof(float) * nDocs));
	    CudaSafeCall(cudaMalloc(&dlinks, sizeof(int) * nLinks * 2));
	    CudaSafeCall(cudaMalloc(&dlink_counts, sizeof(int) * nDocs));
	    CudaSafeCall(cudaMalloc(&dlink_weights, sizeof(float) * nLinks));
	    
	    CudaSafeCall(cudaMemcpy(dranks, ranks, sizeof(float) * nDocs, cudaMemcpyHostToDevice));
	    CudaSafeCall(cudaMemcpy(dlinks, links, sizeof(int) * nLinks * 2, cudaMemcpyHostToDevice));
	    CudaSafeCall(cudaMemcpy(dlink_counts, link_counts, sizeof(int) * nDocs, cudaMemcpyHostToDevice));
	    
	    kernel1<<<ceil(((float)nLinks)/THREADS_PER_BLOCK), THREADS_PER_BLOCK>>>(dranks, dlinks, dlink_counts, dlink_weights, nLinks, start, end, GPUN);
	    
	    CudaSafeCall(cudaDeviceSynchronize());
	    CudaSafeCall(cudaMemcpy(link_weights + start, dlink_weights, sizeof(float) * GPUN, cudaMemcpyDeviceToHost));

	    CudaSafeCall(cudaFree(dranks));
	    CudaSafeCall(cudaFree(dlinks));
	    CudaSafeCall(cudaFree(dlink_counts));
	    CudaSafeCall(cudaFree(dlink_weights));
	}
    }
    
    void prCUDA2(float* ranks, int *links, float *link_weights, long nDocs, long nLinks, long start, long end, long GPUN) {
	float *dranks, *dlink_weights;
	int *dlinks;
	if (GPUN > 0) {
	    assert(end - start + 1 == GPUN);
#ifdef VERBOSE
	    printf("In prCUDA2\n");
	    printf("\t GPUN: %d\n", GPUN);
	    printf("\t range: %d..%d\n", start, end);
#endif			
	    CudaSafeCall(cudaMalloc(&dranks, sizeof(float) * GPUN));
	    CudaSafeCall(cudaMalloc(&dlinks, sizeof(int) * nLinks * 2));
	    CudaSafeCall(cudaMalloc(&dlink_weights, sizeof(float) * nLinks));
	    
	    CudaSafeCall(cudaMemcpy(dlinks, links, sizeof(int) * nLinks * 2, cudaMemcpyHostToDevice));
	    CudaSafeCall(cudaMemcpy(dlink_weights, link_weights, sizeof(float) * nLinks, cudaMemcpyHostToDevice));
	    
	    kernel2<<<ceil(((float)nDocs)/THREADS_PER_BLOCK), THREADS_PER_BLOCK>>>(dranks, dlinks, dlink_weights, nDocs, nLinks, start, end, GPUN);
	    
	    CudaSafeCall(cudaDeviceSynchronize());	    
	    CudaSafeCall(cudaMemcpy(ranks + start, dranks, sizeof(float) * GPUN, cudaMemcpyDeviceToHost));
	    
	    CudaSafeCall(cudaFree(dranks));
	    CudaSafeCall(cudaFree(dlinks));
	    CudaSafeCall(cudaFree(dlink_weights));
	}
    }
}

	.file	"tmpxft_0021924d_00000000-6_pagerank.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata._Z14__cudaSafeCall9cudaErrorPKci.str1.1,"aMS",@progbits,1
.LC0:
	.string	"cudaSafeCall() failed at %s:%i : %s\n"
	.section	.text._Z14__cudaSafeCall9cudaErrorPKci,"axG",@progbits,_Z14__cudaSafeCall9cudaErrorPKci,comdat
	.weak	_Z14__cudaSafeCall9cudaErrorPKci
	.type	_Z14__cudaSafeCall9cudaErrorPKci, @function
_Z14__cudaSafeCall9cudaErrorPKci:
.LFB2027:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movl	%edx, 12(%rsp)
	call	cudaGetErrorString@PLT
	movq	stderr(%rip), %rdi
	movq	%rbx, %rcx
	movl	12(%rsp), %r8d
	movq	%rax, %r9
	leaq	.LC0(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	orl	$-1, %edi
	call	exit@PLT
.L2:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z14__cudaSafeCall9cudaErrorPKci, .-_Z14__cudaSafeCall9cudaErrorPKci
	.text
	.globl	_Z37__device_stub__Z7kernel1PfPiS0_S_iiiiPfPiS0_S_iiii
	.type	_Z37__device_stub__Z7kernel1PfPiS0_S_iiiiPfPiS0_S_iiii, @function
_Z37__device_stub__Z7kernel1PfPiS0_S_iiiiPfPiS0_S_iiii:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 12(%rsp)
	movl	%r9d, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	208(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	216(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L8
	pushq	64(%rsp)
	.cfi_def_cfa_offset 216
	leaq	_Z7kernel1PfPiS0_S_iiii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 224
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L8:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z37__device_stub__Z7kernel1PfPiS0_S_iiiiPfPiS0_S_iiii, .-_Z37__device_stub__Z7kernel1PfPiS0_S_iiiiPfPiS0_S_iiii
	.globl	_Z7kernel1PfPiS0_S_iiii
	.type	_Z7kernel1PfPiS0_S_iiii, @function
_Z7kernel1PfPiS0_S_iiii:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z7kernel1PfPiS0_S_iiiiPfPiS0_S_iiii
	.cfi_endproc
.LFE2055:
	.size	_Z7kernel1PfPiS0_S_iiii, .-_Z7kernel1PfPiS0_S_iiii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"In prCUDA1\n"
.LC2:
	.string	"\t GPUN: %d\n"
.LC3:
	.string	"\t range: %d..%d\n"
.LC4:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/ahayashi/chapel-gpu/master/apps/pagerank/pagerank.cu"
	.text
	.globl	prCUDA1
	.type	prCUDA1, @function
prCUDA1:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdx, 8(%rsp)
	movq	160(%rsp), %rbx
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	testq	%rbx, %rbx
	jle	.L13
	movq	%rdi, %r14
	movq	%rsi, %r13
	movl	$2, %edi
	movq	%r9, %rbp
	leaq	.LC1(%rip), %rsi
	movq	%r8, %r15
	movq	%rcx, %r12
	call	__printf_chk@PLT
	movq	%rbx, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	152(%rsp), %rcx
	movl	$2, %edi
	xorl	%eax, %eax
	movq	144(%rsp), %rdx
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	leaq	0(,%r15,4), %rax
	leaq	16(%rsp), %rdi
	movq	%rax, %rsi
	movq	%rax, (%rsp)
	leaq	0(,%rbp,8), %r15
	call	cudaMalloc@PLT
	movl	$66, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	leaq	32(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaMalloc@PLT
	movl	$67, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	(%rsp), %rsi
	leaq	40(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$68, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	leaq	0(,%rbp,4), %rsi
	leaq	24(%rsp), %rdi
	call	cudaMalloc@PLT
	movl	$69, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	(%rsp), %rdx
	movq	16(%rsp), %rdi
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$71, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	32(%rsp), %rdi
	movq	%r15, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$72, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	(%rsp), %rdx
	movq	8(%rsp), %rsi
	movl	$1, %ecx
	movq	40(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$73, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	cvtsi2ssq	%rbp, %xmm0
	mulss	.LC5(%rip), %xmm0
	call	ceilf@PLT
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	cvttss2siq	%xmm0, %rax
	salq	$10, %rdx
	movl	$1, %ecx
	movl	%eax, 48(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 52(%rsp)
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	pushq	%rbx
	.cfi_def_cfa_offset 152
	movl	160(%rsp), %eax
	movl	%ebp, %r8d
	pushq	%rax
	.cfi_def_cfa_offset 160
	movl	160(%rsp), %r9d
	movq	40(%rsp), %rcx
	movq	56(%rsp), %rdx
	movq	48(%rsp), %rsi
	movq	32(%rsp), %rdi
	call	_Z37__device_stub__Z7kernel1PfPiS0_S_iiiiPfPiS0_S_iiii
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L15:
	call	cudaDeviceSynchronize@PLT
	movl	$77, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	24(%rsp), %rsi
	movq	144(%rsp), %rax
	movl	$2, %ecx
	leaq	0(,%rbx,4), %rdx
	leaq	(%r12,%rax,4), %rdi
	call	cudaMemcpy@PLT
	movl	$78, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movl	$80, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movl	$81, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movl	$82, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movl	$83, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
.L13:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	prCUDA1, .-prCUDA1
	.globl	_Z35__device_stub__Z7kernel2PfPiS_iiiiiPfPiS_iiiii
	.type	_Z35__device_stub__Z7kernel2PfPiS_iiiiiPfPiS_iiiii, @function
_Z35__device_stub__Z7kernel2PfPiS_iiiiiPfPiS_iiiii:
.LFB2056:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movq	%rdi, 40(%rsp)
	leaq	72(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	84(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	56(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	64(%rsp), %rcx
	movl	%r8d, 16(%rsp)
	movl	%r9d, 12(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	208(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	216(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L18
	pushq	64(%rsp)
	.cfi_def_cfa_offset 216
	leaq	_Z7kernel2PfPiS_iiiii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 224
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L18:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z35__device_stub__Z7kernel2PfPiS_iiiiiPfPiS_iiiii, .-_Z35__device_stub__Z7kernel2PfPiS_iiiiiPfPiS_iiiii
	.globl	_Z7kernel2PfPiS_iiiii
	.type	_Z7kernel2PfPiS_iiiii, @function
_Z7kernel2PfPiS_iiiii:
.LFB2057:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z7kernel2PfPiS_iiiiiPfPiS_iiiii
	.cfi_endproc
.LFE2057:
	.size	_Z7kernel2PfPiS_iiiii, .-_Z7kernel2PfPiS_iiiii
	.section	.rodata.str1.1
.LC6:
	.string	"In prCUDA2\n"
	.text
	.globl	prCUDA2
	.type	prCUDA2, @function
prCUDA2:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%rsi, 16(%rsp)
	movq	168(%rsp), %r13
	movq	%rdx, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	testq	%r13, %r13
	jle	.L23
	leaq	.LC6(%rip), %rsi
	movq	%rdi, %r14
	movq	%r8, %r12
	movq	%r9, %rbp
	movl	$2, %edi
	movq	%rcx, %rbx
	leaq	0(,%r12,8), %r15
	call	__printf_chk@PLT
	movq	%r13, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	%rbp, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	movq	160(%rsp), %rcx
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	leaq	0(,%r13,4), %rax
	leaq	40(%rsp), %rdi
	movq	%rax, %rsi
	movq	%rax, (%rsp)
	call	cudaMalloc@PLT
	movl	$97, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	leaq	56(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaMalloc@PLT
	movl	$98, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	leaq	0(,%r12,4), %rax
	leaq	48(%rsp), %rdi
	movq	%rax, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	movl	$99, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	16(%rsp), %rsi
	movq	56(%rsp), %rdi
	movq	%r15, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movl	$101, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	8(%rsp), %rdx
	movq	24(%rsp), %rsi
	movl	$1, %ecx
	movq	48(%rsp), %rdi
	call	cudaMemcpy@PLT
	movl	$102, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	cvtsi2ssq	%rbx, %xmm0
	mulss	.LC5(%rip), %xmm0
	call	ceilf@PLT
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	cvttss2siq	%xmm0, %rax
	salq	$10, %rdx
	movl	$1, %ecx
	movl	%eax, 64(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	pushq	%r13
	.cfi_def_cfa_offset 168
	movl	168(%rsp), %eax
	movl	%ebp, %r9d
	movl	%r12d, %r8d
	movl	%ebx, %ecx
	pushq	%rax
	.cfi_def_cfa_offset 176
	movq	64(%rsp), %rdx
	movq	72(%rsp), %rsi
	movq	56(%rsp), %rdi
	call	_Z35__device_stub__Z7kernel2PfPiS_iiiiiPfPiS_iiiii
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L25:
	call	cudaDeviceSynchronize@PLT
	movl	$106, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	(%rsp), %rdx
	movq	40(%rsp), %rsi
	movl	$2, %ecx
	leaq	(%r14,%rbp,4), %rdi
	call	cudaMemcpy@PLT
	movl	$107, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movl	$109, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movl	$110, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
	movq	48(%rsp), %rdi
	call	cudaFree@PLT
	movl	$111, %edx
	leaq	.LC4(%rip), %rsi
	movl	%eax, %edi
	call	_Z14__cudaSafeCall9cudaErrorPKci
.L23:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	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
.LFE2029:
	.size	prCUDA2, .-prCUDA2
	.section	.rodata.str1.1
.LC7:
	.string	"_Z7kernel2PfPiS_iiiii"
.LC8:
	.string	"_Z7kernel1PfPiS0_S_iiii"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2059:
	.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	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z7kernel2PfPiS_iiiii(%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	.LC8(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z7kernel1PfPiS0_S_iiii(%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
.LFE2059:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC5:
	.long	981467136
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>

#ifndef THREADS_PER_BLOCK
#define THREADS_PER_BLOCK 1024
#endif

#define VERBOSE
#define CUDA_ERROR_CHECK
#define CudaSafeCall( err ) __cudaSafeCall( err, __FILE__, __LINE__ )

inline void __cudaSafeCall( hipError_t err, const char *file, const int line )
{
        #ifdef CUDA_ERROR_CHECK
    if ( hipSuccess != err )
    {
	fprintf( stderr, "cudaSafeCall() failed at %s:%i : %s\n",
		 file, line, hipGetErrorString( err ) );
	exit( -1 );
    }
        #endif

    return;
}

#define NDIMS 2

__global__ void kernel1(float *dranks, int *dlinks, int *dlink_counts, float *dlink_weights, int nLinks, int start, int end, int GPUN)
{
    int id = blockIdx.x * blockDim.x + threadIdx.x;
    if (start <= id && id <= end) {
	dlink_weights[id-start] = dranks[dlinks[id*NDIMS+0]-1] / (float) dlink_counts[dlinks[id*NDIMS+0]-1];	
    }
}

__global__ void kernel2(float *dranks, int *dlinks, float *dlink_weights, int nDocs, int nLinks, int start, int end, int GPUN)
{
    int id = blockIdx.x * blockDim.x + threadIdx.x;
    if (start <= id && id <= end) {
	float new_rank = 0.0f;
	// look for links pointing to this document
	for (int l = 0; l < nLinks; l++) {
	    int dst = dlinks[l*NDIMS+1] - 1;
	    if (dst == id) {
		new_rank += dlink_weights[l];
	    }
	}
	dranks[id-start] = new_rank;
    }
}

extern "C" {
    
    void prCUDA1(float* ranks, int *links, int *link_counts, float *link_weights, long nDocs, long nLinks, long start, long end, long GPUN) {
	float *dranks, *dlink_weights;
	int *dlinks, *dlink_counts;
	if (GPUN > 0) {
	    assert(end - start + 1 == GPUN);
#ifdef VERBOSE
	    printf("In prCUDA1\n");
	    printf("\t GPUN: %d\n", GPUN);
	    printf("\t range: %d..%d\n", start, end);
#endif		
	    CudaSafeCall(hipMalloc(&dranks, sizeof(float) * nDocs));
	    CudaSafeCall(hipMalloc(&dlinks, sizeof(int) * nLinks * 2));
	    CudaSafeCall(hipMalloc(&dlink_counts, sizeof(int) * nDocs));
	    CudaSafeCall(hipMalloc(&dlink_weights, sizeof(float) * nLinks));
	    
	    CudaSafeCall(hipMemcpy(dranks, ranks, sizeof(float) * nDocs, hipMemcpyHostToDevice));
	    CudaSafeCall(hipMemcpy(dlinks, links, sizeof(int) * nLinks * 2, hipMemcpyHostToDevice));
	    CudaSafeCall(hipMemcpy(dlink_counts, link_counts, sizeof(int) * nDocs, hipMemcpyHostToDevice));
	    
	    kernel1<<<ceil(((float)nLinks)/THREADS_PER_BLOCK), THREADS_PER_BLOCK>>>(dranks, dlinks, dlink_counts, dlink_weights, nLinks, start, end, GPUN);
	    
	    CudaSafeCall(hipDeviceSynchronize());
	    CudaSafeCall(hipMemcpy(link_weights + start, dlink_weights, sizeof(float) * GPUN, hipMemcpyDeviceToHost));

	    CudaSafeCall(hipFree(dranks));
	    CudaSafeCall(hipFree(dlinks));
	    CudaSafeCall(hipFree(dlink_counts));
	    CudaSafeCall(hipFree(dlink_weights));
	}
    }
    
    void prCUDA2(float* ranks, int *links, float *link_weights, long nDocs, long nLinks, long start, long end, long GPUN) {
	float *dranks, *dlink_weights;
	int *dlinks;
	if (GPUN > 0) {
	    assert(end - start + 1 == GPUN);
#ifdef VERBOSE
	    printf("In prCUDA2\n");
	    printf("\t GPUN: %d\n", GPUN);
	    printf("\t range: %d..%d\n", start, end);
#endif			
	    CudaSafeCall(hipMalloc(&dranks, sizeof(float) * GPUN));
	    CudaSafeCall(hipMalloc(&dlinks, sizeof(int) * nLinks * 2));
	    CudaSafeCall(hipMalloc(&dlink_weights, sizeof(float) * nLinks));
	    
	    CudaSafeCall(hipMemcpy(dlinks, links, sizeof(int) * nLinks * 2, hipMemcpyHostToDevice));
	    CudaSafeCall(hipMemcpy(dlink_weights, link_weights, sizeof(float) * nLinks, hipMemcpyHostToDevice));
	    
	    kernel2<<<ceil(((float)nDocs)/THREADS_PER_BLOCK), THREADS_PER_BLOCK>>>(dranks, dlinks, dlink_weights, nDocs, nLinks, start, end, GPUN);
	    
	    CudaSafeCall(hipDeviceSynchronize());	    
	    CudaSafeCall(hipMemcpy(ranks + start, dranks, sizeof(float) * GPUN, hipMemcpyDeviceToHost));
	    
	    CudaSafeCall(hipFree(dranks));
	    CudaSafeCall(hipFree(dlinks));
	    CudaSafeCall(hipFree(dlink_weights));
	}
    }
}

	.text
	.file	"pagerank.hip"
	.globl	_Z22__device_stub__kernel1PfPiS0_S_iiii # -- Begin function _Z22__device_stub__kernel1PfPiS0_S_iiii
	.type	_Z22__device_stub__kernel1PfPiS0_S_iiii,@function
_Z22__device_stub__kernel1PfPiS0_S_iiii: # @_Z22__device_stub__kernel1PfPiS0_S_iiii
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	32(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	12(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	8(%rsp), %r8
	movl	%r9d, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	216(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%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	$_Z7kernel1PfPiS0_S_iiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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	_Z22__device_stub__kernel1PfPiS0_S_iiii, .Lfunc_end0-_Z22__device_stub__kernel1PfPiS0_S_iiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__kernel2PfPiS_iiiii # -- Begin function _Z22__device_stub__kernel2PfPiS_iiiii
	.type	_Z22__device_stub__kernel2PfPiS_iiiii,@function
_Z22__device_stub__kernel2PfPiS_iiiii:  # @_Z22__device_stub__kernel2PfPiS_iiiii
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	56(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	48(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	40(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	20(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	16(%rsp), %rcx
	movl	%r8d, (%rcx)
	leaq	12(%rsp), %r8
	movl	%r9d, (%r8)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%rbx)
	movq	%r8, 40(%rbx)
	leaq	208(%rsp), %rax
	movq	%rax, 48(%rbx)
	leaq	216(%rsp), %rax
	movq	%rax, 56(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%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	$_Z7kernel2PfPiS_iiiii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	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	_Z22__device_stub__kernel2PfPiS_iiiii, .Lfunc_end1-_Z22__device_stub__kernel2PfPiS_iiiii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function prCUDA1
.LCPI2_0:
	.long	0x3a800000                      # float 9.765625E-4
	.text
	.globl	prCUDA1
	.type	prCUDA1,@function
prCUDA1:                                # @prCUDA1
	.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	$56, %rsp
	.cfi_def_cfa_offset 112
	.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	128(%rsp), %rbx
	testq	%rbx, %rbx
	jle	.LBB2_30
# %bb.1:
	movq	%r9, %r12
	movq	%r8, %rbp
	movq	%rdi, %r14
	movq	%rsi, 48(%rsp)                  # 8-byte Spill
	movq	%rdx, 40(%rsp)                  # 8-byte Spill
	movq	%rcx, 32(%rsp)                  # 8-byte Spill
	movq	120(%rsp), %r15
	movq	112(%rsp), %r13
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.L.str.1, %edi
	movq	%rbx, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.2, %edi
	movq	%r13, %rsi
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	printf
	shlq	$2, %rbp
	leaq	24(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_2
# %bb.4:                                # %_Z14__cudaSafeCall10hipError_tPKci.exit
	leaq	(,%r12,8), %r13
	leaq	8(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_5
# %bb.6:                                # %_Z14__cudaSafeCall10hipError_tPKci.exit24
	movq	%rsp, %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_7
# %bb.8:                                # %_Z14__cudaSafeCall10hipError_tPKci.exit26
	leaq	(,%r12,4), %rsi
	leaq	16(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB2_9
# %bb.10:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit28
	movq	24(%rsp), %rdi
	movq	%r14, %rsi
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_11
# %bb.12:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit30
	movq	8(%rsp), %rdi
	movq	48(%rsp), %rsi                  # 8-byte Reload
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_13
# %bb.14:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit32
	movq	(%rsp), %rdi
	movq	40(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_15
# %bb.16:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit34
	cvtsi2ss	%r12, %xmm0
	mulss	.LCPI2_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %rax
	movl	%eax, %edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$1024, %rdx                     # imm = 0x400
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movq	112(%rsp), %r14
	jne	.LBB2_18
# %bb.17:
	movq	24(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
	movq	16(%rsp), %rcx
	movl	%r12d, %r8d
	movl	%r14d, %r9d
	pushq	%rbx
	.cfi_adjust_cfa_offset 8
	pushq	128(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z22__device_stub__kernel1PfPiS0_S_iiii
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB2_18:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB2_19
# %bb.20:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit36
	movq	32(%rsp), %rax                  # 8-byte Reload
	leaq	(%rax,%r14,4), %rdi
	movq	16(%rsp), %rsi
	shlq	$2, %rbx
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB2_21
# %bb.22:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit38
	movq	24(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_23
# %bb.24:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit40
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_25
# %bb.26:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit42
	movq	(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_27
# %bb.28:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit44
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB2_29
.LBB2_30:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit46
	addq	$56, %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
.LBB2_2:
	.cfi_def_cfa_offset 112
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$68, %ecx
	jmp	.LBB2_3
.LBB2_5:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$69, %ecx
	jmp	.LBB2_3
.LBB2_7:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$70, %ecx
	jmp	.LBB2_3
.LBB2_9:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$71, %ecx
	jmp	.LBB2_3
.LBB2_11:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$73, %ecx
	jmp	.LBB2_3
.LBB2_13:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$74, %ecx
	jmp	.LBB2_3
.LBB2_15:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$75, %ecx
	jmp	.LBB2_3
.LBB2_19:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$79, %ecx
	jmp	.LBB2_3
.LBB2_21:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$80, %ecx
	jmp	.LBB2_3
.LBB2_23:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$82, %ecx
	jmp	.LBB2_3
.LBB2_25:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$83, %ecx
	jmp	.LBB2_3
.LBB2_27:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$84, %ecx
	jmp	.LBB2_3
.LBB2_29:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$85, %ecx
.LBB2_3:
	movq	%rax, %r8
	xorl	%eax, %eax
	callq	fprintf
	movl	$-1, %edi
	callq	exit
.Lfunc_end2:
	.size	prCUDA1, .Lfunc_end2-prCUDA1
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function prCUDA2
.LCPI3_0:
	.long	0x3a800000                      # float 9.765625E-4
	.text
	.globl	prCUDA2
	.type	prCUDA2,@function
prCUDA2:                                # @prCUDA2
	.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
	movq	136(%rsp), %rbp
	testq	%rbp, %rbp
	jle	.LBB3_24
# %bb.1:
	movq	%rdi, %r12
	movq	%rsi, 64(%rsp)                  # 8-byte Spill
	movq	%rdx, 48(%rsp)                  # 8-byte Spill
	movq	%r8, %r13
	movq	%rcx, 56(%rsp)                  # 8-byte Spill
	movq	%r9, %r15
	movq	128(%rsp), %rbx
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.L.str.1, %edi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.2, %edi
	movq	%r15, %r14
	movq	%r15, %rsi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	printf
	leaq	(,%rbp,4), %rbx
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_2
# %bb.4:                                # %_Z14__cudaSafeCall10hipError_tPKci.exit
	movq	%rbx, 32(%rsp)                  # 8-byte Spill
	movq	%r12, 40(%rsp)                  # 8-byte Spill
	movq	%r13, %r15
	leaq	(,%r13,8), %rbp
	leaq	8(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_5
# %bb.6:                                # %_Z14__cudaSafeCall10hipError_tPKci.exit22
	leaq	(,%r15,4), %r12
	leaq	16(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB3_7
# %bb.8:                                # %_Z14__cudaSafeCall10hipError_tPKci.exit24
	movq	%r14, %rbx
	movq	8(%rsp), %rdi
	movq	64(%rsp), %rsi                  # 8-byte Reload
	movq	%rbp, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_9
# %bb.10:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit26
	movq	16(%rsp), %rdi
	movq	48(%rsp), %rsi                  # 8-byte Reload
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	movq	56(%rsp), %r12                  # 8-byte Reload
	movq	136(%rsp), %r13
	jne	.LBB3_11
# %bb.12:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit28
	cvtsi2ss	%r12, %xmm0
	mulss	.LCPI3_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %rax
	movl	%eax, %edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$1024, %rdx                     # imm = 0x400
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	movq	40(%rsp), %r14                  # 8-byte Reload
	jne	.LBB3_14
# %bb.13:
	movq	24(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	16(%rsp), %rdx
	movl	%r12d, %ecx
	movl	%r15d, %r8d
	movl	%ebx, %r9d
	pushq	%r13
	.cfi_adjust_cfa_offset 8
	pushq	136(%rsp)
	.cfi_adjust_cfa_offset 8
	callq	_Z22__device_stub__kernel2PfPiS_iiiii
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
.LBB3_14:
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	jne	.LBB3_15
# %bb.16:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit30
	leaq	(%r14,%rbx,4), %rdi
	movq	24(%rsp), %rsi
	movq	32(%rsp), %rdx                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB3_17
# %bb.18:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit32
	movq	24(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB3_19
# %bb.20:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit34
	movq	8(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB3_21
# %bb.22:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit36
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB3_23
.LBB3_24:                               # %_Z14__cudaSafeCall10hipError_tPKci.exit38
	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
.LBB3_2:
	.cfi_def_cfa_offset 128
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$99, %ecx
	jmp	.LBB3_3
.LBB3_5:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$100, %ecx
	jmp	.LBB3_3
.LBB3_7:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$101, %ecx
	jmp	.LBB3_3
.LBB3_9:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$103, %ecx
	jmp	.LBB3_3
.LBB3_11:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$104, %ecx
	jmp	.LBB3_3
.LBB3_15:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$108, %ecx
	jmp	.LBB3_3
.LBB3_17:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$109, %ecx
	jmp	.LBB3_3
.LBB3_19:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$111, %ecx
	jmp	.LBB3_3
.LBB3_21:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$112, %ecx
	jmp	.LBB3_3
.LBB3_23:
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.5, %esi
	movl	$.L.str.3, %edx
	movq	%rbx, %rdi
	movl	$113, %ecx
.LBB3_3:
	movq	%rax, %r8
	xorl	%eax, %eax
	callq	fprintf
	movl	$-1, %edi
	callq	exit
.Lfunc_end3:
	.size	prCUDA2, .Lfunc_end3-prCUDA2
	.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	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7kernel1PfPiS0_S_iiii, %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	$_Z7kernel2PfPiS_iiiii, %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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z7kernel1PfPiS0_S_iiii,@object # @_Z7kernel1PfPiS0_S_iiii
	.section	.rodata,"a",@progbits
	.globl	_Z7kernel1PfPiS0_S_iiii
	.p2align	3, 0x0
_Z7kernel1PfPiS0_S_iiii:
	.quad	_Z22__device_stub__kernel1PfPiS0_S_iiii
	.size	_Z7kernel1PfPiS0_S_iiii, 8

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

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"\t GPUN: %d\n"
	.size	.L.str.1, 12

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"\t range: %d..%d\n"
	.size	.L.str.2, 17

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/ahayashi/chapel-gpu/master/apps/pagerank/pagerank.hip"
	.size	.L.str.3, 116

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"cudaSafeCall() failed at %s:%i : %s\n"
	.size	.L.str.5, 37

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z7kernel1PfPiS0_S_iiii"
	.size	.L__unnamed_1, 24

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z7kernel2PfPiS_iiiii"
	.size	.L__unnamed_2, 22

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"In prCUDA1"
	.size	.Lstr, 11

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"In prCUDA2"
	.size	.Lstr.1, 11

	.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 _Z22__device_stub__kernel1PfPiS0_S_iiii
	.addrsig_sym _Z22__device_stub__kernel2PfPiS_iiiii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z7kernel1PfPiS0_S_iiii
	.addrsig_sym _Z7kernel2PfPiS_iiiii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7kernel1PfPiS0_S_iiii ; -- Begin function _Z7kernel1PfPiS0_S_iiii
	.globl	_Z7kernel1PfPiS0_S_iiii
	.p2align	8
	.type	_Z7kernel1PfPiS0_S_iiii,@function
_Z7kernel1PfPiS0_S_iiii:                ; @_Z7kernel1PfPiS0_S_iiii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x3c
	s_load_b64 s[8:9], s[0:1], 0x24
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	v_cmp_le_i32_e32 vcc_lo, s8, v1
	v_cmp_ge_i32_e64 s2, s9, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB0_2
; %bb.1:
	s_load_b256 s[0:7], s[0:1], 0x0
	v_lshlrev_b32_e32 v2, 1, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v3, 31, v2
	v_lshlrev_b64 v[2:3], 2, v[2:3]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v2, vcc_lo, s2, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo
	global_load_b32 v2, v[2:3], off
	s_waitcnt vmcnt(0)
	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 v4, vcc_lo, s4, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s5, v3, vcc_lo
	v_add_co_u32 v2, vcc_lo, s0, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s1, v3, vcc_lo
	global_load_b32 v0, v[4:5], off offset:-4
	global_load_b32 v2, v[2:3], off offset:-4
	s_waitcnt vmcnt(1)
	v_cvt_f32_i32_e32 v3, v0
	s_waitcnt vmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_div_scale_f32 v4, null, v3, v3, v2
	v_div_scale_f32 v6, vcc_lo, v2, v3, v2
	v_rcp_f32_e32 v5, v4
	s_waitcnt_depctr 0xfff
	v_fma_f32 v0, -v4, v5, 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fmac_f32_e32 v5, v0, v5
	v_mul_f32_e32 v7, v6, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v0, -v4, v7, v6
	v_fmac_f32_e32 v7, v0, v5
	v_subrev_nc_u32_e32 v0, s8, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_fma_f32 v4, -v4, v7, v6
	v_ashrrev_i32_e32 v1, 31, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_fmas_f32 v4, v4, v5, v7
	v_lshlrev_b64 v[0:1], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_div_fixup_f32 v2, v4, v3, v2
	v_add_co_u32 v0, vcc_lo, s6, v0
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7kernel1PfPiS0_S_iiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 304
		.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 8
		.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	_Z7kernel1PfPiS0_S_iiii, .Lfunc_end0-_Z7kernel1PfPiS0_S_iiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 356
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; Occupancy: 16
; WaveLimiterHint : 1
; 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	_Z7kernel2PfPiS_iiiii   ; -- Begin function _Z7kernel2PfPiS_iiiii
	.globl	_Z7kernel2PfPiS_iiiii
	.p2align	8
	.type	_Z7kernel2PfPiS_iiiii,@function
_Z7kernel2PfPiS_iiiii:                  ; @_Z7kernel2PfPiS_iiiii
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x3c
	s_load_b128 s[4:7], s[0:1], 0x1c
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	v_cmp_le_i32_e32 vcc_lo, s5, v1
	v_cmp_ge_i32_e64 s2, s6, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_saveexec_b32 s3, s2
	s_cbranch_execz .LBB1_7
; %bb.1:                                ; %.preheader
	s_clause 0x1
	s_load_b128 s[8:11], s[0:1], 0x0
	s_load_b64 s[0:1], s[0:1], 0x10
	v_mov_b32_e32 v0, 0
	s_cmp_lt_i32 s4, 1
	s_cbranch_scc1 .LBB1_6
; %bb.2:                                ; %.lr.ph.preheader
	s_waitcnt lgkmcnt(0)
	s_add_u32 s2, s10, 4
	s_addc_u32 s3, s11, 0
.LBB1_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b32 s6, s[2:3], 0x0
	s_waitcnt lgkmcnt(0)
	s_add_i32 s6, s6, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	v_cmp_eq_u32_e32 vcc_lo, s6, v1
	s_and_saveexec_b32 s6, vcc_lo
	s_cbranch_execz .LBB1_5
; %bb.4:                                ;   in Loop: Header=BB1_3 Depth=1
	s_load_b32 s7, s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v0, s7, v0
.LBB1_5:                                ;   in Loop: Header=BB1_3 Depth=1
	s_or_b32 exec_lo, exec_lo, s6
	s_add_i32 s4, s4, -1
	s_add_u32 s2, s2, 8
	s_addc_u32 s3, s3, 0
	s_add_u32 s0, s0, 4
	s_addc_u32 s1, s1, 0
	s_cmp_eq_u32 s4, 0
	s_cbranch_scc0 .LBB1_3
.LBB1_6:                                ; %Flow46
	v_subrev_nc_u32_e32 v1, s5, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v1, vcc_lo, s8, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s9, v2, vcc_lo
	global_store_b32 v[1:2], v0, off
.LBB1_7:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7kernel2PfPiS_iiiii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 304
		.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 3
		.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	_Z7kernel2PfPiS_iiiii, .Lfunc_end1-_Z7kernel2PfPiS_iiiii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 256
; NumSgprs: 18
; NumVgprs: 3
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 3
; 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
	.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
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         36
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         44
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         52
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         60
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         62
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         64
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         66
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         68
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         70
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         112
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 304
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7kernel1PfPiS0_S_iiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7kernel1PfPiS0_S_iiii.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
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .offset:         28
        .size:           4
        .value_kind:     by_value
      - .offset:         32
        .size:           4
        .value_kind:     by_value
      - .offset:         36
        .size:           4
        .value_kind:     by_value
      - .offset:         40
        .size:           4
        .value_kind:     by_value
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         52
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         56
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         60
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         62
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         64
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         66
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         68
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         70
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         104
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         112
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 304
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7kernel2PfPiS_iiiii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7kernel2PfPiS_iiiii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     3
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
