#include<bits/stdc++.h>
using namespace std;

#define MAX_VAL ((int)1e8)
#define cudaCatchError(error) { gpuAssert((error), __FILE__, __LINE__); }

// Catch Cuda errors
inline void gpuAssert(cudaError_t error, const char *file, int line,  bool abort = false)
{
    if (error != cudaSuccess)
    {
        printf("\n====== Cuda Error Code %i ======\n %s in CUDA %s\n", error, cudaGetErrorString(error));
        printf("\nIn file :%s\nOn line: %d", file, line);
        
        if(abort)
            exit(-1);
    }
}

__global__ void compute(int *d_r, int *d_c, int *d_depth, int *max_depth, int *Q1, int *Q2, int nodes){
    int idx = threadIdx.x;
    __shared__ int len1, len2, curr_depth;
    int i;
    
    for(i=idx; i<nodes; i+=1024){
        d_depth[i] = MAX_VAL;
    }
    if(idx == 0){
        d_depth[0] = 0;
        curr_depth = 0;
        len1 = 1;
        len2 = 0;
        Q1[0] = 0;
    }
    __syncthreads();

    while(len1){
        for(i=idx; i<len1; i+=1024){
            for(int j=d_r[Q1[i]]; j<d_r[Q1[i]+1]; j++){
                int v = d_c[j];
                if(atomicCAS(&d_depth[v], MAX_VAL, d_depth[Q1[i]]+1) == MAX_VAL){
                    int t = atomicAdd(&len2,1);
                    Q2[t] = v;  
                }
            }
        }
        __syncthreads();

        if(idx==0){
            for(i=0; i<len2; i++){
                Q1[i] = Q2[i];
            }
            len1 = len2;
            len2 = 0;
            curr_depth++;
        }
        __syncthreads();
    }

    max_depth[0] = curr_depth;
}

int main(int argc, char *argv[]){
    if(argc<2){
        cout << "Usage: " << argv[0] << " <graph_file_name>\n";
        return 0;
    }

    ifstream input;
    input.open(argv[1]);

    int nodes, edges, i;
    input >> nodes;
    input >> edges;

    // allocating host memory
    int *h_r = (int*)malloc((nodes+1)*sizeof(int));
    int *h_c = (int*)malloc(edges*2*sizeof(int));

    // reading inputs
    for(i=0; i<nodes+1; i++){
        input >> h_r[i];
    }
    for(i=0; i<edges*2; i++){
        input >> h_c[i];
    }
    
    // allocating device memory
    int *Q1, *Q2, *d_r, *d_c, *d_depth, *max_depth;
    cudaMalloc((void**)&Q1, nodes*sizeof(int));
    cudaMalloc((void**)&Q2, nodes*sizeof(int));
    cudaMalloc((void**)&d_r, (nodes+1)*sizeof(int));
    cudaMalloc((void**)&d_c, edges*2*sizeof(int));
    cudaMalloc((void**)&d_depth, nodes*sizeof(int));
    cudaMalloc((void**)&max_depth, sizeof(int));

    // copying data to device
    cudaMemcpy(d_r, h_r, (nodes+1)*sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy(d_c, h_c, edges*2*sizeof(int), cudaMemcpyHostToDevice);

    // timer
    cudaEvent_t start, stop;
	cudaEventCreate(&start);
	cudaEventCreate(&stop);

    cudaEventRecord(start);

    // kernel call
    printf("Starting Computation\n");
    compute <<<1, 1024>>> (d_r, d_c, d_depth, max_depth, Q1, Q2, nodes);
    cudaThreadSynchronize();
    printf("Finished Computation\n");

    // timer
    cudaEventRecord(stop);
	cudaEventSynchronize(stop);
	float milliseconds = 0;
	cudaEventElapsedTime(&milliseconds, start, stop);

	cout<<"Compute time in GPU: "<<milliseconds<<"ms"<<endl;

    // copying results to host
    int *result = (int *)malloc(sizeof(int));
    cudaCatchError(cudaMemcpy(result, max_depth, sizeof(int), cudaMemcpyDeviceToHost));

    printf("Depth : %d\n", result[0]-1);

    // solution check
    int *h_depth = (int*) malloc(nodes*sizeof(int));
	cudaMemcpy(h_depth, d_depth, nodes*sizeof(int), cudaMemcpyDeviceToHost);
	int *h_check_depth = (int*)malloc(nodes*sizeof(int));
	freopen(argv[2], "r", stdin);
    printf("malloc done\n");
    
    for(int i = 0; i < nodes; i++) {
		cin>>h_check_depth[i];
    }
    printf("Finished reading output file\n");
	bool flag = true;
	int count = 0;

    printf("Starting checking\n");
	for(int i = 0; i < nodes; i++) {
		if(h_depth[i] != h_check_depth[i]) {
            printf("Found %d, Expected %d\n",h_depth[i], h_check_depth[i]);
			flag = false;
			count++;
		}
    }
    printf("Finished checking\n");

	if(flag) {
		cout<<"Solution is correct!\n";
	}
	else {
		cout<<"Solution is incorrect!"<<endl;
		cout<<count<<" testcases failed.\n";
	}
    return 0;   
}
	.file	"tmpxft_0025a24f_00000000-6_parallel_BFS_work_efficient.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB10829:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE10829:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z37__device_stub__Z7computePiS_S_S_S_S_iPiS_S_S_S_S_i
	.type	_Z37__device_stub__Z7computePiS_S_S_S_S_iPiS_S_S_S_S_i, @function
_Z37__device_stub__Z7computePiS_S_S_S_S_iPiS_S_S_S_S_i:
.LFB10851:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movq	%rcx, 16(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%r9, (%rsp)
	movq	%fs:40, %rax
	movq	%rax, 168(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movl	$1, 72(%rsp)
	movq	%rax, 112(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 120(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 144(%rsp)
	movq	%rsp, %rax
	movq	%rax, 152(%rsp)
	leaq	192(%rsp), %rax
	movq	%rax, 160(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L2
	pushq	56(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z7computePiS_S_S_S_S_i(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 208
	movq	92(%rsp), %rcx
	movl	100(%rsp), %r8d
	movq	80(%rsp), %rsi
	movl	88(%rsp), %edx
	leaq	128(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L2:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L4
	call	__stack_chk_fail@PLT
.L4:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE10851:
	.size	_Z37__device_stub__Z7computePiS_S_S_S_S_iPiS_S_S_S_S_i, .-_Z37__device_stub__Z7computePiS_S_S_S_S_iPiS_S_S_S_S_i
	.globl	_Z7computePiS_S_S_S_S_i
	.type	_Z7computePiS_S_S_S_S_i, @function
_Z7computePiS_S_S_S_S_i:
.LFB10852:
	.cfi_startproc
	endbr64
	jmp	_Z37__device_stub__Z7computePiS_S_S_S_S_iPiS_S_S_S_S_i
	.cfi_endproc
.LFE10852:
	.size	_Z7computePiS_S_S_S_S_i, .-_Z7computePiS_S_S_S_S_i
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"_Z7computePiS_S_S_S_S_i"
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB10854:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z7computePiS_S_S_S_S_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE10854:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1
.LC1:
	.string	"Usage: "
.LC2:
	.string	" <graph_file_name>\n"
.LC3:
	.string	"Starting Computation\n"
.LC4:
	.string	"Finished Computation\n"
.LC6:
	.string	"Compute time in GPU: "
.LC7:
	.string	"ms"
.LC8:
	.string	"Depth : %d\n"
.LC9:
	.string	"\n====== Cuda Error Code %i ======\n %s in CUDA %s\n"
.LC10:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/vrn25/CUDA-Playground/master/BreadthFirstSearch/parallel_BFS_work_efficient.cu"
.LC11:
	.string	"\nIn file :%s\nOn line: %d"
.LC12:
	.string	"r"
.LC13:
	.string	"malloc done\n"
.LC14:
	.string	"Finished reading output file\n"
.LC15:
	.string	"Starting checking\n"
.LC16:
	.string	"Found %d, Expected %d\n"
.LC17:
	.string	"Finished checking\n"
.LC18:
	.string	"Solution is correct!\n"
.LC19:
	.string	"Solution is incorrect!"
.LC20:
	.string	" testcases failed.\n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB10826:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA10826
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%rsi, %rbx
	subq	$648, %rsp
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	decl	%edi
	jg	.L11
	leaq	.LC1(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
.LEHB0:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	(%rbx), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	jmp	.L12
.L11:
	leaq	-576(%rbp), %rax
	movq	%rax, %rdi
	movq	%rax, -680(%rbp)
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE0:
	movq	8(%rbx), %rsi
	movl	$8, %edx
	movq	-680(%rbp), %rdi
.LEHB1:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	movq	-680(%rbp), %rdi
	leaq	-672(%rbp), %rsi
	call	_ZNSirsERi@PLT
	movq	-680(%rbp), %rdi
	leaq	-668(%rbp), %rsi
	call	_ZNSirsERi@PLT
	movl	-672(%rbp), %eax
	xorl	%r13d, %r13d
	leal	1(%rax), %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %r12
	movl	-668(%rbp), %eax
	movq	%r12, %r14
	leal	(%rax,%rax), %edi
	movslq	%edi, %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %r15
.L13:
	cmpl	%r13d, -672(%rbp)
	jl	.L42
	movq	-680(%rbp), %rdi
	movq	%r14, %rsi
	call	_ZNSirsERi@PLT
	incl	%r13d
	addq	$4, %r14
	jmp	.L13
.L42:
	movq	%r15, %r14
	xorl	%r13d, %r13d
.L15:
	movl	-668(%rbp), %eax
	addl	%eax, %eax
	cmpl	%r13d, %eax
	jle	.L43
	movq	-680(%rbp), %rdi
	movq	%r14, %rsi
	call	_ZNSirsERi@PLT
	incl	%r13d
	addq	$4, %r14
	jmp	.L15
.L43:
	movslq	-672(%rbp), %rsi
	leaq	-664(%rbp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movslq	-672(%rbp), %rsi
	leaq	-656(%rbp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movl	-672(%rbp), %eax
	leaq	-648(%rbp), %rdi
	leal	1(%rax), %esi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movl	-668(%rbp), %eax
	leaq	-640(%rbp), %rdi
	leal	(%rax,%rax), %esi
	movslq	%esi, %rsi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	movslq	-672(%rbp), %rsi
	leaq	-632(%rbp), %rdi
	salq	$2, %rsi
	call	cudaMalloc@PLT
	leaq	-624(%rbp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movl	-672(%rbp), %eax
	movq	-648(%rbp), %rdi
	movl	$1, %ecx
	movq	%r12, %rsi
	leal	1(%rax), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	movl	-668(%rbp), %eax
	movq	-640(%rbp), %rdi
	movl	$1, %ecx
	movq	%r15, %rsi
	leal	(%rax,%rax), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	leaq	-616(%rbp), %rdi
	call	cudaEventCreate@PLT
	leaq	-608(%rbp), %rdi
	call	cudaEventCreate@PLT
	movq	-616(%rbp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$4194305, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	salq	$10, %rdx
	movl	$1, %esi
	movabsq	$4294967297, %rdi
	movl	$1, -580(%rbp)
	movq	%rdx, -588(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	je	.L17
.L19:
	call	cudaThreadSynchronize@PLT
	jmp	.L44
.L17:
	pushq	%rcx
	movl	-672(%rbp), %eax
	movq	-656(%rbp), %r9
	movq	-664(%rbp), %r8
	movq	-624(%rbp), %rcx
	movq	-632(%rbp), %rdx
	pushq	%rax
	movq	-640(%rbp), %rsi
	movq	-648(%rbp), %rdi
	.cfi_escape 0x2e,0x10
	call	_Z37__device_stub__Z7computePiS_S_S_S_S_iPiS_S_S_S_S_i
	popq	%rax
	popq	%rdx
	jmp	.L19
.L44:
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	.cfi_escape 0x2e,0
	call	__printf_chk@PLT
	movq	-608(%rbp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	-608(%rbp), %rdi
	call	cudaEventSynchronize@PLT
	movq	-608(%rbp), %rdx
	movq	-616(%rbp), %rsi
	leaq	-588(%rbp), %rdi
	movl	$0x00000000, -588(%rbp)
	call	cudaEventElapsedTime@PLT
	leaq	.LC6(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	cvtss2sd	-588(%rbp), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	leaq	.LC7(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	$4, %edi
	call	malloc@PLT
	movl	$2, %ecx
	movl	$4, %edx
	movq	-624(%rbp), %rsi
	movq	%rax, %rdi
	movq	%rax, %r12
	call	cudaMemcpy@PLT
	movl	%eax, %r15d
	testl	%eax, %eax
	jne	.L20
.L22:
	movl	(%r12), %edx
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	decl	%edx
	call	__printf_chk@PLT
	jmp	.L45
.L20:
	movl	%eax, %edi
	call	cudaGetErrorString@PLT
	movq	%rax, %rcx
	movl	%r15d, %edx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC9(%rip), %rsi
	call	__printf_chk@PLT
	movl	$124, %ecx
	leaq	.LC10(%rip), %rdx
	leaq	.LC11(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	jmp	.L22
.L45:
	movslq	-672(%rbp), %r12
	salq	$2, %r12
	movq	%r12, %rdi
	call	malloc@PLT
	movq	-632(%rbp), %rsi
	movl	$2, %ecx
	movq	%r12, %rdx
	movq	%rax, %rdi
	movq	%rax, -688(%rbp)
	call	cudaMemcpy@PLT
	movslq	-672(%rbp), %rdi
	salq	$2, %rdi
	call	malloc@PLT
	movq	16(%rbx), %rdi
	movq	stdin(%rip), %rdx
	leaq	.LC12(%rip), %rsi
	movq	%rax, %r12
	call	freopen@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r12, %r13
	xorl	%ebx, %ebx
	leaq	_ZSt3cin(%rip), %r14
.L23:
	cmpl	%ebx, -672(%rbp)
	jle	.L46
	movq	%r13, %rsi
	movq	%r14, %rdi
	call	_ZNSirsERi@PLT
	incl	%ebx
	addq	$4, %r13
	jmp	.L23
.L46:
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%ebx, %ebx
	xorl	%r13d, %r13d
	leaq	.LC16(%rip), %r15
	movb	$1, %r14b
.L25:
	cmpl	%ebx, -672(%rbp)
	jle	.L47
	movq	-688(%rbp), %rax
	movl	(%r12,%rbx,4), %ecx
	movl	(%rax,%rbx,4), %edx
	cmpl	%ecx, %edx
	je	.L26
	movq	%r15, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	incl	%r13d
	xorl	%r14d, %r14d
.L26:
	incq	%rbx
	jmp	.L25
.L47:
	leaq	.LC17(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	testb	%r14b, %r14b
	je	.L28
	leaq	.LC18(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
.L41:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	-576(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L12
.L28:
	leaq	.LC19(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	movl	%r13d, %esi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZNSolsEi@PLT
.LEHE1:
	movq	%rax, %rdi
	leaq	.LC20(%rip), %rsi
	jmp	.L41
.L12:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L32
	jmp	.L38
.L34:
	endbr64
	movq	%rax, %rbx
.L30:
	movq	-680(%rbp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L38
	movq	%rbx, %rdi
.LEHB2:
	call	_Unwind_Resume@PLT
.LEHE2:
.L38:
	call	__stack_chk_fail@PLT
.L32:
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10826:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA10826:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE10826-.LLSDACSB10826
.LLSDACSB10826:
	.uleb128 .LEHB0-.LFB10826
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB10826
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L34-.LFB10826
	.uleb128 0
	.uleb128 .LEHB2-.LFB10826
	.uleb128 .LEHE2-.LEHB2
	.uleb128 0
	.uleb128 0
.LLSDACSE10826:
	.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
	.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<bits/stdc++.h>
using namespace std;

#define MAX_VAL ((int)1e8)
#define cudaCatchError(error) { gpuAssert((error), __FILE__, __LINE__); }

// Catch Cuda errors
inline void gpuAssert(hipError_t error, const char *file, int line,  bool abort = false)
{
    if (error != hipSuccess)
    {
        printf("\n====== Cuda Error Code %i ======\n %s in CUDA %s\n", error, hipGetErrorString(error));
        printf("\nIn file :%s\nOn line: %d", file, line);
        
        if(abort)
            exit(-1);
    }
}

__global__ void compute(int *d_r, int *d_c, int *d_depth, int *max_depth, int *Q1, int *Q2, int nodes){
    int idx = threadIdx.x;
    __shared__ int len1, len2, curr_depth;
    int i;
    
    for(i=idx; i<nodes; i+=1024){
        d_depth[i] = MAX_VAL;
    }
    if(idx == 0){
        d_depth[0] = 0;
        curr_depth = 0;
        len1 = 1;
        len2 = 0;
        Q1[0] = 0;
    }
    __syncthreads();

    while(len1){
        for(i=idx; i<len1; i+=1024){
            for(int j=d_r[Q1[i]]; j<d_r[Q1[i]+1]; j++){
                int v = d_c[j];
                if(atomicCAS(&d_depth[v], MAX_VAL, d_depth[Q1[i]]+1) == MAX_VAL){
                    int t = atomicAdd(&len2,1);
                    Q2[t] = v;  
                }
            }
        }
        __syncthreads();

        if(idx==0){
            for(i=0; i<len2; i++){
                Q1[i] = Q2[i];
            }
            len1 = len2;
            len2 = 0;
            curr_depth++;
        }
        __syncthreads();
    }

    max_depth[0] = curr_depth;
}

int main(int argc, char *argv[]){
    if(argc<2){
        cout << "Usage: " << argv[0] << " <graph_file_name>\n";
        return 0;
    }

    ifstream input;
    input.open(argv[1]);

    int nodes, edges, i;
    input >> nodes;
    input >> edges;

    // allocating host memory
    int *h_r = (int*)malloc((nodes+1)*sizeof(int));
    int *h_c = (int*)malloc(edges*2*sizeof(int));

    // reading inputs
    for(i=0; i<nodes+1; i++){
        input >> h_r[i];
    }
    for(i=0; i<edges*2; i++){
        input >> h_c[i];
    }
    
    // allocating device memory
    int *Q1, *Q2, *d_r, *d_c, *d_depth, *max_depth;
    hipMalloc((void**)&Q1, nodes*sizeof(int));
    hipMalloc((void**)&Q2, nodes*sizeof(int));
    hipMalloc((void**)&d_r, (nodes+1)*sizeof(int));
    hipMalloc((void**)&d_c, edges*2*sizeof(int));
    hipMalloc((void**)&d_depth, nodes*sizeof(int));
    hipMalloc((void**)&max_depth, sizeof(int));

    // copying data to device
    hipMemcpy(d_r, h_r, (nodes+1)*sizeof(int), hipMemcpyHostToDevice);
    hipMemcpy(d_c, h_c, edges*2*sizeof(int), hipMemcpyHostToDevice);

    // timer
    hipEvent_t start, stop;
	hipEventCreate(&start);
	hipEventCreate(&stop);

    hipEventRecord(start);

    // kernel call
    printf("Starting Computation\n");
    compute <<<1, 1024>>> (d_r, d_c, d_depth, max_depth, Q1, Q2, nodes);
    hipDeviceSynchronize();
    printf("Finished Computation\n");

    // timer
    hipEventRecord(stop);
	hipEventSynchronize(stop);
	float milliseconds = 0;
	hipEventElapsedTime(&milliseconds, start, stop);

	cout<<"Compute time in GPU: "<<milliseconds<<"ms"<<endl;

    // copying results to host
    int *result = (int *)malloc(sizeof(int));
    cudaCatchError(hipMemcpy(result, max_depth, sizeof(int), hipMemcpyDeviceToHost));

    printf("Depth : %d\n", result[0]-1);

    // solution check
    int *h_depth = (int*) malloc(nodes*sizeof(int));
	hipMemcpy(h_depth, d_depth, nodes*sizeof(int), hipMemcpyDeviceToHost);
	int *h_check_depth = (int*)malloc(nodes*sizeof(int));
	freopen(argv[2], "r", stdin);
    printf("malloc done\n");
    
    for(int i = 0; i < nodes; i++) {
		cin>>h_check_depth[i];
    }
    printf("Finished reading output file\n");
	bool flag = true;
	int count = 0;

    printf("Starting checking\n");
	for(int i = 0; i < nodes; i++) {
		if(h_depth[i] != h_check_depth[i]) {
            printf("Found %d, Expected %d\n",h_depth[i], h_check_depth[i]);
			flag = false;
			count++;
		}
    }
    printf("Finished checking\n");

	if(flag) {
		cout<<"Solution is correct!\n";
	}
	else {
		cout<<"Solution is incorrect!"<<endl;
		cout<<count<<" testcases failed.\n";
	}
    return 0;   
}
	.text
	.file	"parallel_BFS_work_efficient.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z22__device_stub__computePiS_S_S_S_S_i # -- Begin function _Z22__device_stub__computePiS_S_S_S_S_i
	.type	_Z22__device_stub__computePiS_S_S_S_S_i,@function
_Z22__device_stub__computePiS_S_S_S_S_i: # @_Z22__device_stub__computePiS_S_S_S_S_i
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$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	24(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	16(%rsp), %r8
	movq	%r9, (%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	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z7computePiS_S_S_S_S_i, %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__computePiS_S_S_S_S_i, .Lfunc_end0-_Z22__device_stub__computePiS_S_S_S_S_i
	.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	$616, %rsp                      # imm = 0x268
	.cfi_def_cfa_offset 672
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	cmpl	$1, %edi
	jg	.LBB1_5
# %bb.1:
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$7, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%rbx), %rbx
	testq	%rbx, %rbx
	je	.LBB1_2
# %bb.3:
	movq	%rbx, %rdi
	callq	strlen
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB1_4
.LBB1_5:
	leaq	96(%rsp), %r14
	movq	%r14, %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev
	movq	8(%rbx), %rsi
.Ltmp0:
	movq	%r14, %rdi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp1:
# %bb.6:
.Ltmp3:
	movq	%rbx, 72(%rsp)                  # 8-byte Spill
	leaq	96(%rsp), %rdi
	leaq	8(%rsp), %rsi
	callq	_ZNSirsERi
.Ltmp4:
# %bb.7:
.Ltmp5:
	leaq	96(%rsp), %rdi
	leaq	12(%rsp), %rsi
	callq	_ZNSirsERi
.Ltmp6:
# %bb.8:
	movslq	8(%rsp), %rbp
	leaq	4(,%rbp,4), %rdi
	callq	malloc
	movq	%rax, %r15
	movslq	12(%rsp), %rbx
	leaq	(,%rbx,8), %rdi
	callq	malloc
	movq	%rax, %r14
	testq	%rbp, %rbp
	js	.LBB1_13
# %bb.9:                                # %.lr.ph.preheader
	movq	$-1, %rbx
	leaq	96(%rsp), %r12
	movq	%r15, %r13
.LBB1_10:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
.Ltmp8:
	movq	%r12, %rdi
	movq	%r13, %rsi
	callq	_ZNSirsERi
.Ltmp9:
# %bb.11:                               #   in Loop: Header=BB1_10 Depth=1
	movslq	8(%rsp), %rbp
	incq	%rbx
	addq	$4, %r13
	cmpq	%rbp, %rbx
	jl	.LBB1_10
# %bb.12:                               # %.preheader.loopexit
	movl	12(%rsp), %ebx
.LBB1_13:                               # %.preheader
	testl	%ebx, %ebx
	jle	.LBB1_18
# %bb.14:                               # %.lr.ph100.preheader
	xorl	%ebp, %ebp
	leaq	96(%rsp), %r12
	movq	%r14, %r13
.LBB1_15:                               # %.lr.ph100
                                        # =>This Inner Loop Header: Depth=1
.Ltmp11:
	movq	%r12, %rdi
	movq	%r13, %rsi
	callq	_ZNSirsERi
.Ltmp12:
# %bb.16:                               #   in Loop: Header=BB1_15 Depth=1
	incq	%rbp
	movslq	12(%rsp), %rax
	addq	%rax, %rax
	addq	$4, %r13
	cmpq	%rax, %rbp
	jl	.LBB1_15
# %bb.17:                               # %._crit_edge.loopexit
	movl	8(%rsp), %ebp
.LBB1_18:                               # %._crit_edge
	movslq	%ebp, %rsi
	shlq	$2, %rsi
.Ltmp14:
	leaq	88(%rsp), %rdi
	callq	hipMalloc
.Ltmp15:
# %bb.19:
	movslq	8(%rsp), %rsi
	shlq	$2, %rsi
.Ltmp16:
	leaq	80(%rsp), %rdi
	callq	hipMalloc
.Ltmp17:
# %bb.20:
	movslq	8(%rsp), %rax
	leaq	4(,%rax,4), %rsi
.Ltmp18:
	leaq	64(%rsp), %rdi
	callq	hipMalloc
.Ltmp19:
# %bb.21:
	movslq	12(%rsp), %rsi
	shlq	$3, %rsi
.Ltmp20:
	leaq	56(%rsp), %rdi
	callq	hipMalloc
.Ltmp21:
# %bb.22:
	movslq	8(%rsp), %rsi
	shlq	$2, %rsi
.Ltmp22:
	leaq	48(%rsp), %rdi
	callq	hipMalloc
.Ltmp23:
# %bb.23:
.Ltmp24:
	leaq	40(%rsp), %rdi
	movl	$4, %esi
	callq	hipMalloc
.Ltmp25:
# %bb.24:
	movq	64(%rsp), %rdi
	movslq	8(%rsp), %rax
	leaq	4(,%rax,4), %rdx
.Ltmp26:
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp27:
# %bb.25:
	movq	56(%rsp), %rdi
	movslq	12(%rsp), %rdx
	shlq	$3, %rdx
.Ltmp28:
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp29:
# %bb.26:
.Ltmp31:
	leaq	32(%rsp), %rdi
	callq	hipEventCreate
.Ltmp32:
# %bb.27:
.Ltmp33:
	leaq	16(%rsp), %rdi
	callq	hipEventCreate
.Ltmp34:
# %bb.28:
	movq	32(%rsp), %rdi
.Ltmp35:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp36:
# %bb.29:
	movl	$.Lstr, %edi
	callq	puts@PLT
.Ltmp37:
	movabsq	$4294967297, %rdi               # imm = 0x100000001
	movabsq	$4294968320, %rdx               # imm = 0x100000400
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
.Ltmp38:
# %bb.30:
	testl	%eax, %eax
	jne	.LBB1_32
# %bb.31:
	movq	64(%rsp), %rdi
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rcx
	movq	88(%rsp), %r8
	movq	80(%rsp), %r9
	movl	8(%rsp), %eax
.Ltmp39:
	movl	%eax, (%rsp)
	callq	_Z22__device_stub__computePiS_S_S_S_S_i
.Ltmp40:
.LBB1_32:
.Ltmp41:
	callq	hipDeviceSynchronize
.Ltmp42:
# %bb.33:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movq	16(%rsp), %rdi
.Ltmp43:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp44:
# %bb.34:
	movq	16(%rsp), %rdi
.Ltmp45:
	callq	hipEventSynchronize
.Ltmp46:
# %bb.35:
	leaq	28(%rsp), %rdi
	movl	$0, (%rdi)
	movq	32(%rsp), %rsi
	movq	16(%rsp), %rdx
.Ltmp48:
	callq	hipEventElapsedTime
.Ltmp49:
# %bb.36:
.Ltmp50:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$21, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp51:
# %bb.37:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit76
	cvtss2sd	28(%rsp), %xmm0
.Ltmp52:
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp53:
# %bb.38:                               # %_ZNSolsEf.exit
.Ltmp54:
	movq	%rax, %r14
	movl	$.L.str.5, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp55:
# %bb.39:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit77
	movq	(%r14), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
.Ltmp56:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp57:
# %bb.40:                               # %.noexc87
.Ltmp58:
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
.Ltmp59:
# %bb.41:                               # %.noexc88
.Ltmp60:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp61:
# %bb.42:                               # %_ZNSolsEPFRSoS_E.exit
	movl	$4, %edi
	callq	malloc
	movq	%rax, %r14
	movq	40(%rsp), %rsi
.Ltmp63:
	movl	$4, %edx
	movq	%rax, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp64:
# %bb.43:
	movl	%eax, %ebp
	testl	%eax, %eax
	je	.LBB1_46
# %bb.44:
.Ltmp65:
	movl	%ebp, %edi
	callq	hipGetErrorString
.Ltmp66:
# %bb.45:                               # %.noexc
	movl	$.L.str.17, %edi
	movl	%ebp, %esi
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.18, %edi
	movl	$.L.str.6, %esi
	movl	$126, %edx
	xorl	%eax, %eax
	callq	printf
.LBB1_46:                               # %_Z9gpuAssert10hipError_tPKcib.exit
	movl	(%r14), %esi
	decl	%esi
	movl	$.L.str.7, %edi
	xorl	%eax, %eax
	callq	printf
	movslq	8(%rsp), %r15
	shlq	$2, %r15
	movq	%r15, %rdi
	callq	malloc
	movq	%rax, %r14
	movq	48(%rsp), %rsi
.Ltmp68:
	movq	%rax, %rdi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp69:
# %bb.47:
	movslq	8(%rsp), %rdi
	shlq	$2, %rdi
	callq	malloc
	movq	%rax, %r15
	movq	72(%rsp), %rax                  # 8-byte Reload
	movq	16(%rax), %rdi
	movq	stdin(%rip), %rdx
.Ltmp71:
	movl	$.L.str.8, %esi
	callq	freopen
.Ltmp72:
# %bb.48:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	cmpl	$0, 8(%rsp)
	jle	.LBB1_52
# %bb.49:                               # %.lr.ph103.preheader
	xorl	%r12d, %r12d
	movq	%r15, %rbx
.LBB1_50:                               # %.lr.ph103
                                        # =>This Inner Loop Header: Depth=1
.Ltmp74:
	movl	$_ZSt3cin, %edi
	movq	%rbx, %rsi
	callq	_ZNSirsERi
.Ltmp75:
# %bb.51:                               #   in Loop: Header=BB1_50 Depth=1
	incq	%r12
	movslq	8(%rsp), %rax
	addq	$4, %rbx
	cmpq	%rax, %r12
	jl	.LBB1_50
.LBB1_52:                               # %._crit_edge104
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.LBB1_65
# %bb.53:                               # %.lr.ph109.preheader
	movb	$1, %bpl
	xorl	%r12d, %r12d
	xorl	%ebx, %ebx
.LBB1_54:                               # %.lr.ph109
                                        # =>This Inner Loop Header: Depth=1
	movl	(%r14,%r12,4), %esi
	movl	(%r15,%r12,4), %edx
	cmpl	%edx, %esi
	je	.LBB1_56
# %bb.55:                               #   in Loop: Header=BB1_54 Depth=1
	xorl	%ebp, %ebp
	movl	$.L.str.12, %edi
	xorl	%eax, %eax
	callq	printf
	incl	%ebx
	movl	8(%rsp), %eax
.LBB1_56:                               #   in Loop: Header=BB1_54 Depth=1
	incq	%r12
	movslq	%eax, %rcx
	cmpq	%rcx, %r12
	jl	.LBB1_54
# %bb.57:                               # %._crit_edge110
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	testb	$1, %bpl
	jne	.LBB1_58
# %bb.71:
.Ltmp77:
	movl	$_ZSt4cout, %r14d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.15, %esi
	movl	$22, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp78:
# %bb.72:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit82
	movq	_ZSt4cout(%rip), %rax
	addq	-24(%rax), %r14
.Ltmp79:
	movq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp80:
# %bb.73:                               # %.noexc90
.Ltmp81:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp82:
# %bb.74:                               # %.noexc91
.Ltmp83:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp84:
# %bb.75:                               # %_ZNSolsEPFRSoS_E.exit84
.Ltmp85:
	movl	$_ZSt4cout, %edi
	movl	%ebx, %esi
	callq	_ZNSolsEi
.Ltmp86:
# %bb.76:
	movq	%rax, %rdi
	movl	$19, %edx
	movl	$.L.str.16, %esi
	jmp	.LBB1_77
.LBB1_2:
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cout(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB1_4:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$19, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB1_79
.LBB1_65:                               # %._crit_edge110.thread
	movl	$.Lstr.5, %edi
	callq	puts@PLT
.LBB1_58:
	movl	$21, %edx
	movl	$.L.str.14, %esi
	movl	$_ZSt4cout, %edi
.LBB1_77:                               # %.invoke
.Ltmp87:
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp88:
# %bb.78:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit80
	leaq	96(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
.LBB1_79:
	xorl	%eax, %eax
	addq	$616, %rsp                      # imm = 0x268
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB1_68:
	.cfi_def_cfa_offset 672
.Ltmp73:
	jmp	.LBB1_81
.LBB1_67:
.Ltmp70:
	jmp	.LBB1_81
.LBB1_59:
.Ltmp2:
	jmp	.LBB1_81
.LBB1_66:
.Ltmp67:
	jmp	.LBB1_81
.LBB1_60:
.Ltmp7:
	jmp	.LBB1_81
.LBB1_70:
.Ltmp89:
	jmp	.LBB1_81
.LBB1_80:
.Ltmp62:
	jmp	.LBB1_81
.LBB1_64:
.Ltmp47:
	jmp	.LBB1_81
.LBB1_63:
.Ltmp30:
	jmp	.LBB1_81
.LBB1_69:
.Ltmp76:
	jmp	.LBB1_81
.LBB1_61:                               # %.loopexit
.Ltmp13:
	jmp	.LBB1_81
.LBB1_62:                               # %.loopexit.split-lp
.Ltmp10:
.LBB1_81:
	movq	%rax, %rbx
	leaq	96(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table1:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp2-.Lfunc_begin0           #     jumps to .Ltmp2
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp3-.Lfunc_begin0           # >> Call Site 3 <<
	.uleb128 .Ltmp6-.Ltmp3                  #   Call between .Ltmp3 and .Ltmp6
	.uleb128 .Ltmp7-.Lfunc_begin0           #     jumps to .Ltmp7
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp8-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp9-.Ltmp8                  #   Call between .Ltmp8 and .Ltmp9
	.uleb128 .Ltmp10-.Lfunc_begin0          #     jumps to .Ltmp10
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp11-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp12-.Ltmp11                #   Call between .Ltmp11 and .Ltmp12
	.uleb128 .Ltmp13-.Lfunc_begin0          #     jumps to .Ltmp13
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp14-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp29-.Ltmp14                #   Call between .Ltmp14 and .Ltmp29
	.uleb128 .Ltmp30-.Lfunc_begin0          #     jumps to .Ltmp30
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp31-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp46-.Ltmp31                #   Call between .Ltmp31 and .Ltmp46
	.uleb128 .Ltmp47-.Lfunc_begin0          #     jumps to .Ltmp47
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp48-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp61-.Ltmp48                #   Call between .Ltmp48 and .Ltmp61
	.uleb128 .Ltmp62-.Lfunc_begin0          #     jumps to .Ltmp62
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp63-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp66-.Ltmp63                #   Call between .Ltmp63 and .Ltmp66
	.uleb128 .Ltmp67-.Lfunc_begin0          #     jumps to .Ltmp67
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp68-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp69-.Ltmp68                #   Call between .Ltmp68 and .Ltmp69
	.uleb128 .Ltmp70-.Lfunc_begin0          #     jumps to .Ltmp70
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp71-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp72-.Ltmp71                #   Call between .Ltmp71 and .Ltmp72
	.uleb128 .Ltmp73-.Lfunc_begin0          #     jumps to .Ltmp73
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp74-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp75-.Ltmp74                #   Call between .Ltmp74 and .Ltmp75
	.uleb128 .Ltmp76-.Lfunc_begin0          #     jumps to .Ltmp76
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp77-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Ltmp86-.Ltmp77                #   Call between .Ltmp77 and .Ltmp86
	.uleb128 .Ltmp89-.Lfunc_begin0          #     jumps to .Ltmp89
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp86-.Lfunc_begin0          # >> Call Site 14 <<
	.uleb128 .Ltmp87-.Ltmp86                #   Call between .Ltmp86 and .Ltmp87
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp87-.Lfunc_begin0          # >> Call Site 15 <<
	.uleb128 .Ltmp88-.Ltmp87                #   Call between .Ltmp87 and .Ltmp88
	.uleb128 .Ltmp89-.Lfunc_begin0          #     jumps to .Ltmp89
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp88-.Lfunc_begin0          # >> Call Site 16 <<
	.uleb128 .Lfunc_end1-.Ltmp88            #   Call between .Ltmp88 and .Lfunc_end1
	.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:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7computePiS_S_S_S_S_i, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z7computePiS_S_S_S_S_i,@object # @_Z7computePiS_S_S_S_S_i
	.section	.rodata,"a",@progbits
	.globl	_Z7computePiS_S_S_S_S_i
	.p2align	3, 0x0
_Z7computePiS_S_S_S_S_i:
	.quad	_Z22__device_stub__computePiS_S_S_S_S_i
	.size	_Z7computePiS_S_S_S_S_i, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Usage: "
	.size	.L.str, 8

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" <graph_file_name>\n"
	.size	.L.str.1, 20

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Compute time in GPU: "
	.size	.L.str.4, 22

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"ms"
	.size	.L.str.5, 3

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/vrn25/CUDA-Playground/master/BreadthFirstSearch/parallel_BFS_work_efficient.hip"
	.size	.L.str.6, 142

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Depth : %d\n"
	.size	.L.str.7, 12

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

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"Found %d, Expected %d\n"
	.size	.L.str.12, 23

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Solution is correct!\n"
	.size	.L.str.14, 22

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Solution is incorrect!"
	.size	.L.str.15, 23

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	" testcases failed.\n"
	.size	.L.str.16, 20

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"\n====== Cuda Error Code %i ======\n %s in CUDA %s\n"
	.size	.L.str.17, 50

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"\nIn file :%s\nOn line: %d"
	.size	.L.str.18, 25

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

	.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	"Starting Computation"
	.size	.Lstr, 21

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Finished Computation"
	.size	.Lstr.1, 21

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"malloc done"
	.size	.Lstr.2, 12

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Finished reading output file"
	.size	.Lstr.3, 29

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Starting checking"
	.size	.Lstr.4, 18

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"Finished checking"
	.size	.Lstr.5, 18

	.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__computePiS_S_S_S_S_i
	.addrsig_sym __gxx_personality_v0
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Unwind_Resume
	.addrsig_sym _Z7computePiS_S_S_S_S_i
	.addrsig_sym _ZSt4cout
	.addrsig_sym _ZSt3cin
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7computePiS_S_S_S_S_i ; -- Begin function _Z7computePiS_S_S_S_S_i
	.globl	_Z7computePiS_S_S_S_S_i
	.p2align	8
	.type	_Z7computePiS_S_S_S_S_i,@function
_Z7computePiS_S_S_S_S_i:                ; @_Z7computePiS_S_S_S_S_i
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x30
	s_load_b128 s[12:15], s[0:1], 0x20
	s_load_b256 s[4:11], s[0:1], 0x0
	s_mov_b32 s1, exec_lo
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_i32_e64 s2, v0
	s_cbranch_execz .LBB0_3
; %bb.1:                                ; %.lr.ph.preheader
	v_dual_mov_b32 v4, v0 :: v_dual_lshlrev_b32 v1, 2, v0
	v_mov_b32_e32 v3, 0x5f5e100
	s_mov_b32 s3, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_co_u32 v1, s0, s8, v1
	v_add_co_ci_u32_e64 v2, null, s9, 0, s0
.LBB0_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	v_add_nc_u32_e32 v4, 0x400, v4
	global_store_b32 v[1:2], v3, off
	v_add_co_u32 v1, s0, 0x1000, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_add_co_ci_u32_e64 v2, s0, 0, v2, s0
	v_cmp_le_i32_e32 vcc_lo, s2, v4
	s_or_b32 s3, vcc_lo, s3
	s_and_not1_b32 exec_lo, exec_lo, s3
	s_cbranch_execnz .LBB0_2
.LBB0_3:                                ; %Flow98
	s_or_b32 exec_lo, exec_lo, s1
	v_cmp_eq_u32_e64 s0, 0, v0
	s_delay_alu instid0(VALU_DEP_1)
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB0_5
; %bb.4:
	v_dual_mov_b32 v1, 0 :: v_dual_mov_b32 v2, 1
	ds_store_b32 v1, v1 offset:8
	ds_store_b64 v1, v[1:2]
	s_clause 0x1
	global_store_b32 v1, v1, s[8:9]
	global_store_b32 v1, v1, s[12:13]
.LBB0_5:
	s_or_b32 exec_lo, exec_lo, s1
	v_mov_b32_e32 v2, 0
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	ds_load_b32 v14, v2 offset:4
	s_waitcnt lgkmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, 0, v14
	s_cbranch_vccnz .LBB0_22
; %bb.6:                                ; %.preheader45.lr.ph
	v_mov_b32_e32 v4, 0x5f5e100
	s_add_u32 s18, s4, 4
	s_addc_u32 s19, s5, 0
.LBB0_7:                                ; %.preheader45
                                        ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_9 Depth 2
                                        ;       Child Loop BB0_11 Depth 3
                                        ;     Child Loop BB0_19 Depth 2
	s_mov_b32 s2, exec_lo
	v_cmpx_lt_i32_e64 v0, v14
	s_cbranch_execz .LBB0_17
; %bb.8:                                ; %.lr.ph53.preheader
                                        ;   in Loop: Header=BB0_7 Depth=1
	v_mov_b32_e32 v1, v0
	s_mov_b32 s3, 0
.LBB0_9:                                ; %.lr.ph53
                                        ;   Parent Loop BB0_7 Depth=1
                                        ; =>  This Loop Header: Depth=2
                                        ;       Child Loop BB0_11 Depth 3
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[5:6], 2, v[1:2]
	s_mov_b32 s16, exec_lo
	v_add_co_u32 v5, vcc_lo, s12, v5
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v6, vcc_lo, s13, v6, vcc_lo
	global_load_b32 v10, v[5:6], off
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v11, 31, v10
	v_lshlrev_b64 v[7:8], 2, v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v7, vcc_lo, s4, v7
	v_add_co_ci_u32_e32 v8, vcc_lo, s5, v8, vcc_lo
	global_load_b64 v[7:8], v[7:8], off
	s_waitcnt vmcnt(0)
	v_cmpx_lt_i32_e64 v7, v8
	s_cbranch_execz .LBB0_16
; %bb.10:                               ; %.lr.ph50.preheader
                                        ;   in Loop: Header=BB0_9 Depth=2
	v_ashrrev_i32_e32 v8, 31, v7
	s_mov_b32 s17, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[8:9], 2, v[7:8]
	v_add_co_u32 v8, vcc_lo, s6, v8
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v9, vcc_lo, s7, v9, vcc_lo
.LBB0_11:                               ; %.lr.ph50
                                        ;   Parent Loop BB0_7 Depth=1
                                        ;     Parent Loop BB0_9 Depth=2
                                        ; =>    This Inner Loop Header: Depth=3
	global_load_b32 v12, v[8:9], off
	v_lshlrev_b64 v[10:11], 2, v[10:11]
	s_mov_b32 s1, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v10, vcc_lo, s8, v10
	v_add_co_ci_u32_e32 v11, vcc_lo, s9, v11, vcc_lo
	global_load_b32 v3, v[10:11], off
	s_waitcnt vmcnt(1)
	v_ashrrev_i32_e32 v13, 31, v12
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[10:11], 2, v[12:13]
	v_add_co_u32 v10, vcc_lo, s8, v10
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v11, vcc_lo, s9, v11, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v3, 1, v3
	global_atomic_cmpswap_b32 v3, v[10:11], v[3:4], off glc
	s_waitcnt vmcnt(0)
	v_cmpx_eq_u32_e32 0x5f5e100, v3
	s_cbranch_execz .LBB0_15
; %bb.12:                               ;   in Loop: Header=BB0_11 Depth=3
	s_mov_b32 s21, exec_lo
	s_mov_b32 s20, exec_lo
	v_mbcnt_lo_u32_b32 v3, s21, 0
                                        ; implicit-def: $vgpr10
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v3
	s_cbranch_execz .LBB0_14
; %bb.13:                               ;   in Loop: Header=BB0_11 Depth=3
	s_bcnt1_i32_b32 s21, s21
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mov_b32_e32 v10, s21
	ds_add_rtn_u32 v10, v2, v10 offset:8
.LBB0_14:                               ;   in Loop: Header=BB0_11 Depth=3
	s_or_b32 exec_lo, exec_lo, s20
	s_waitcnt lgkmcnt(0)
	v_readfirstlane_b32 s20, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_nc_u32_e32 v10, s20, v3
	v_ashrrev_i32_e32 v11, 31, v10
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[10:11], 2, v[10:11]
	v_add_co_u32 v10, vcc_lo, s14, v10
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v11, vcc_lo, s15, v11, vcc_lo
	global_store_b32 v[10:11], v12, off
.LBB0_15:                               ; %Flow90
                                        ;   in Loop: Header=BB0_11 Depth=3
	s_or_b32 exec_lo, exec_lo, s1
	global_load_b32 v10, v[5:6], off
	v_add_nc_u32_e32 v7, 1, v7
	v_add_co_u32 v8, s1, v8, 4
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v9, s1, 0, v9, s1
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v11, 31, v10
	v_lshlrev_b64 v[12:13], 2, v[10:11]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v12, vcc_lo, s18, v12
	v_add_co_ci_u32_e32 v13, vcc_lo, s19, v13, vcc_lo
	global_load_b32 v3, v[12:13], off
	s_waitcnt vmcnt(0)
	v_cmp_ge_i32_e32 vcc_lo, v7, v3
	s_or_b32 s17, vcc_lo, s17
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s17
	s_cbranch_execnz .LBB0_11
.LBB0_16:                               ; %Flow92
                                        ;   in Loop: Header=BB0_9 Depth=2
	s_or_b32 exec_lo, exec_lo, s16
	v_add_nc_u32_e32 v1, 0x400, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cmp_ge_i32_e32 vcc_lo, v1, v14
	s_or_b32 s3, vcc_lo, s3
	s_and_not1_b32 exec_lo, exec_lo, s3
	s_cbranch_execnz .LBB0_9
.LBB0_17:                               ; %Flow94
                                        ;   in Loop: Header=BB0_7 Depth=1
	s_or_b32 exec_lo, exec_lo, s2
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB0_21
; %bb.18:                               ; %.preheader
                                        ;   in Loop: Header=BB0_7 Depth=1
	ds_load_b32 v6, v2 offset:8
	s_mov_b64 s[2:3], s[12:13]
	s_mov_b64 s[16:17], s[14:15]
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, 1, v6
	v_mov_b32_e32 v1, v6
	s_cbranch_vccnz .LBB0_20
.LBB0_19:                               ; %.lr.ph56
                                        ;   Parent Loop BB0_7 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	global_load_b32 v3, v2, s[16:17]
	v_add_nc_u32_e32 v1, -1, v1
	s_add_u32 s16, s16, 4
	s_addc_u32 s17, s17, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_ne_u32_e32 vcc_lo, 0, v1
	s_waitcnt vmcnt(0)
	global_store_b32 v2, v3, s[2:3]
	s_add_u32 s2, s2, 4
	s_addc_u32 s3, s3, 0
	s_cbranch_vccnz .LBB0_19
.LBB0_20:                               ; %._crit_edge57
                                        ;   in Loop: Header=BB0_7 Depth=1
	ds_load_b32 v1, v2
	s_waitcnt lgkmcnt(0)
	v_add_nc_u32_e32 v5, 1, v1
	ds_store_b32 v2, v2 offset:8
	ds_store_b64 v2, v[5:6]
.LBB0_21:                               ; %Flow89
                                        ;   in Loop: Header=BB0_7 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	s_waitcnt lgkmcnt(0)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	ds_load_b32 v14, v2 offset:4
	s_waitcnt lgkmcnt(0)
	v_cmp_ne_u32_e32 vcc_lo, 0, v14
	s_cbranch_vccnz .LBB0_7
.LBB0_22:                               ; %._crit_edge59
	ds_load_b32 v0, v2
	s_waitcnt lgkmcnt(0)
	global_store_b32 v2, v0, s[10:11]
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7computePiS_S_S_S_S_i
		.amdhsa_group_segment_fixed_size 12
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 52
		.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 15
		.amdhsa_next_free_sgpr 22
		.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	_Z7computePiS_S_S_S_S_i, .Lfunc_end0-_Z7computePiS_S_S_S_S_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1004
; NumSgprs: 24
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 12 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 24
; NumVGPRsForWavesPerEU: 15
; 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
	.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
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         40
        .size:           8
        .value_kind:     global_buffer
      - .offset:         48
        .size:           4
        .value_kind:     by_value
    .group_segment_fixed_size: 12
    .kernarg_segment_align: 8
    .kernarg_segment_size: 52
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7computePiS_S_S_S_S_i
    .private_segment_fixed_size: 0
    .sgpr_count:     24
    .sgpr_spill_count: 0
    .symbol:         _Z7computePiS_S_S_S_S_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
