#include <stdio.h>
#include <stdlib.h>
#include <cmath>

__device__ int position;			//index of the largest value
__device__ int largest;				//value of the largest value
int lenString = 593;				
int maxNumStrings = 1000000;                           
int threshold = 2;

// Checks if there are any unmerged tuples (Parallelized)
__global__ void anyLeft(int *d_c, int *remaining, int size) {
	int my_id = blockDim.x * blockIdx.x + threadIdx.x;
	if((d_c[my_id] == 0) && (my_id < size)) {
		*remaining = 0;
	}
}

// Searches for the index of the largest count (Parallelized)
__global__ void search(int *d_b, int *d_c, int size) {
	int my_id = blockDim.x * blockIdx.x + threadIdx.x;
	if((d_c[my_id] == 0) && (d_b[my_id] == largest) && (my_id < size)) {
		position = my_id;
	}
}

// Populates copy_db such that the counts for merged tuple is 0
// but count for unmerged tuples is unchanged (Parallelized)
__global__ void populate (int *d_b, int *copy_db, int *d_c, int size, int *left) {
	int n = 0;
	*left = 1;	// reinitalized to false to check if all strings are merged

	int my_id = blockDim.x * blockIdx.x + threadIdx.x;

	if (my_id < size) {
		n = abs((bool)d_c[my_id] - 1);
		copy_db[my_id] = d_b[my_id] * n;
	}		
}

// Reduction-type tree implementation to find largest count (Parallelized)
__device__ void cuda_select(int *db, int size) {
	int my_id = blockDim.x * blockIdx.x + threadIdx.x;

	if(my_id < size) {
		if(db[2 * my_id] > db[2 * my_id + 1])
			db[my_id] = db[2 * my_id];
		else
			db[my_id] = db[2 * my_id + 1];
	}	
}

// Loops cuda_select function until largest value is at index 0
__global__ void select(int *db, int size) {
	int height = (int)ceil(log2((double)size));
	int i = 0;
	
	for(i = 0; i < height; i++) {
		size = (int)ceil((double) size/2);
		cuda_select(db, size);
	}
	largest = db[0];
}

// Compares target string to all other unmerged strings with lesser count
__global__ void compare(char *d_a, int *d_b, int *d_c, int size, int lenString, int threshold) {

	int my_id = blockDim.x * blockIdx.x + threadIdx.x;

	if (my_id == position) 
		d_c[my_id] = 2;
	
		
	if ((my_id < size) && (d_c[my_id] == 0) && (my_id != position)) {	
		int x, diffs = 0;

		for (x = 0; x < lenString; x++) {
			diffs += (bool)(d_a[(lenString*position)+x]^d_a[(my_id*lenString)+x]);
			
			if (diffs > threshold)
				break;
		}
		
		if (diffs <= threshold) {
			d_b[position] += d_b[my_id];
			d_c[my_id] = 1;
		}
	} 
}

int main(int argc, char** argv) {
	char *strings, *d_a;	// host and device copy of strings
	int *counts, *d_b;	// host and device copy of counts
	int *merged, *d_c;	// host and device copy of bools
	int *copy_db;		// device copy of counts (counts of merged is 0)
	char copy[lenString+1]; // intermediate variable to load strings into array from file
	int numbers;		// intermediate variable to load counts into array from file
	int *any_left, *left;   // host and device copies to check if all tuples are merged
	int size = 0;		// keeps track of number of tuples in the file
	int i = 0;		// loop variable
	int size_string = maxNumStrings*sizeof(char)*(lenString+1);
	int size_int = maxNumStrings*sizeof(int);

	// Open the file
	FILE *fp;
	fp = fopen("/cluster/home/charliep/courses/cs360/single-linkage-clustering/Iceland2014.trim.contigs.good.unique.good.filter.unique.count.fasta", "r");

	// Allocate space for arrays on the host
	if (!(strings = (char *)malloc(size_string))) {
		fprintf(stderr, "malloc() FAILED (Block)\n");
		exit(0);
	}

	if (!(counts = (int*)malloc(size_int))) {
		fprintf(stderr, "malloc() FAILED (Block)\n"); 
		exit(0);
	}

	if (!(merged = (int*)malloc(size_int))) {
                fprintf(stderr, "malloc() FAILED (Block)\n");
                exit(0);
        }
	
	any_left = (int *)malloc(sizeof(int));
	
	// Set the values of global variables on the device
	cudaMemset(&position, 0, sizeof(int));
	cudaMemset(&largest, 0, sizeof(int));

	// Load strings and counts into array
	while(fscanf(fp, "%s %d", copy, &numbers) != EOF && size < 1000){
		strcpy(&strings[i], copy);
		counts[size] = numbers;
		
		i = i + lenString;
		size++;	
	}
	
	// Close file
	fclose(fp);
	
	// Allocate space for arrays on the device
	cudaMalloc(&d_a, size_string);
	cudaMalloc(&d_b, size_int);
	cudaMalloc(&d_c, size_int);
	cudaMalloc(&copy_db, size_int);
	cudaMalloc(&left, sizeof(int));
	
	// Copy arrays from host to device
	cudaMemcpy(d_a, strings, size_string, cudaMemcpyHostToDevice);
	cudaMemcpy(d_b, counts, size_int, cudaMemcpyHostToDevice);
	cudaMemcpy(d_c, merged, size_int, cudaMemcpyHostToDevice);

	// Determine number of threads and blocks needed	
	int threads_num = 512, blocks_num;
	blocks_num = (int)ceil((float)size/threads_num);
	
	// Cluster the strings for the given threshold
	do {
	populate<<<blocks_num, threads_num>>>(d_b, copy_db, d_c, size,left); 	
	select<<<blocks_num, threads_num>>>(copy_db, size);	
	search<<<blocks_num, threads_num>>>(d_b, d_c, size);
	compare<<<blocks_num, threads_num>>>(d_a, d_b, d_c, size, lenString, threshold);
        anyLeft<<<blocks_num, threads_num>>>(d_c, left, size);
	cudaMemcpy(any_left, left, sizeof(int), cudaMemcpyDeviceToHost);
	} while (*any_left == 0);
	
	// Copy results back from device to host
	cudaMemcpy(strings, d_a, size_string, cudaMemcpyDeviceToHost);	
	cudaMemcpy(counts, d_b, size_int, cudaMemcpyDeviceToHost);
	cudaMemcpy(merged, d_c, size_int, cudaMemcpyDeviceToHost);
	
	int counter = 0;
	
	FILE *output = fopen("output2.txt", "w+");
	
	for(i = 0; i < size; i++) {
		strncpy(copy, &strings[i*lenString], lenString);
		fprintf(output, "%s %d\n", copy, counts[i]);
		if (merged[i] == 2)
			counter++;
	}
	
	fclose(output);

	printf("%d\n", counter);

	cudaFree(d_a);
	cudaFree(d_b);
	cudaFree(d_c);
	cudaFree(copy_db);
	cudaFree(left);

	free(strings);
	free(counts);
	free(merged);
	free(any_left);
}

	.file	"tmpxft_002bd32b_00000000-6_cluster.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z11cuda_selectPii
	.type	_Z11cuda_selectPii, @function
_Z11cuda_selectPii:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z11cuda_selectPii, .-_Z11cuda_selectPii
	.globl	_Z29__device_stub__Z7anyLeftPiS_iPiS_i
	.type	_Z29__device_stub__Z7anyLeftPiS_iPiS_i, @function
_Z29__device_stub__Z7anyLeftPiS_iPiS_i:
.LFB2053:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L4
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z7anyLeftPiS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L4:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2053:
	.size	_Z29__device_stub__Z7anyLeftPiS_iPiS_i, .-_Z29__device_stub__Z7anyLeftPiS_iPiS_i
	.globl	_Z7anyLeftPiS_i
	.type	_Z7anyLeftPiS_i, @function
_Z7anyLeftPiS_i:
.LFB2054:
	.cfi_startproc
	endbr64
	jmp	_Z29__device_stub__Z7anyLeftPiS_iPiS_i
	.cfi_endproc
.LFE2054:
	.size	_Z7anyLeftPiS_i, .-_Z7anyLeftPiS_i
	.globl	_Z28__device_stub__Z6searchPiS_iPiS_i
	.type	_Z28__device_stub__Z6searchPiS_iPiS_i, @function
_Z28__device_stub__Z6searchPiS_iPiS_i:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L10
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z6searchPiS_i(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L10:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z28__device_stub__Z6searchPiS_iPiS_i, .-_Z28__device_stub__Z6searchPiS_iPiS_i
	.globl	_Z6searchPiS_i
	.type	_Z6searchPiS_i, @function
_Z6searchPiS_i:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z6searchPiS_iPiS_i
	.cfi_endproc
.LFE2056:
	.size	_Z6searchPiS_i, .-_Z6searchPiS_i
	.globl	_Z34__device_stub__Z8populatePiS_S_iS_PiS_S_iS_
	.type	_Z34__device_stub__Z8populatePiS_S_iS_PiS_S_iS_, @function
_Z34__device_stub__Z8populatePiS_S_iS_PiS_S_iS_:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$168, %rsp
	.cfi_def_cfa_offset 176
	movq	%rdi, 40(%rsp)
	leaq	64(%rsp), %rdi
	movq	%rsi, 32(%rsp)
	leaq	76(%rsp), %rsi
	movq	%rdx, 24(%rsp)
	leaq	48(%rsp), %rdx
	movl	%ecx, 20(%rsp)
	leaq	56(%rsp), %rcx
	movq	%r8, 8(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 152(%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	20(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 144(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 64(%rsp)
	movq	%rax, 76(%rsp)
	movl	$1, 84(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	pushq	56(%rsp)
	.cfi_def_cfa_offset 184
	leaq	_Z8populatePiS_S_iS_(%rip), %rdi
	pushq	56(%rsp)
	.cfi_def_cfa_offset 192
	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 184
	popq	%rdx
	.cfi_def_cfa_offset 176
.L15:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$168, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z34__device_stub__Z8populatePiS_S_iS_PiS_S_iS_, .-_Z34__device_stub__Z8populatePiS_S_iS_PiS_S_iS_
	.globl	_Z8populatePiS_S_iS_
	.type	_Z8populatePiS_S_iS_, @function
_Z8populatePiS_S_iS_:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z8populatePiS_S_iS_PiS_S_iS_
	.cfi_endproc
.LFE2058:
	.size	_Z8populatePiS_S_iS_, .-_Z8populatePiS_S_iS_
	.globl	_Z26__device_stub__Z6selectPiiPii
	.type	_Z26__device_stub__Z6selectPiiPii, @function
_Z26__device_stub__Z6selectPiiPii:
.LFB2059:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movl	%esi, 4(%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	leaq	4(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L20
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z6selectPii(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L20:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2059:
	.size	_Z26__device_stub__Z6selectPiiPii, .-_Z26__device_stub__Z6selectPiiPii
	.globl	_Z6selectPii
	.type	_Z6selectPii, @function
_Z6selectPii:
.LFB2060:
	.cfi_startproc
	endbr64
	jmp	_Z26__device_stub__Z6selectPiiPii
	.cfi_endproc
.LFE2060:
	.size	_Z6selectPii, .-_Z6selectPii
	.globl	_Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii
	.type	_Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii, @function
_Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$184, %rsp
	.cfi_def_cfa_offset 192
	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, 168(%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)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L25
	pushq	64(%rsp)
	.cfi_def_cfa_offset 200
	leaq	_Z7comparePcPiS0_iii(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 208
	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 200
	popq	%rdx
	.cfi_def_cfa_offset 192
.L25:
	movq	168(%rsp), %rax
	subq	%fs:40, %rax
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	addq	$184, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii, .-_Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii
	.globl	_Z7comparePcPiS0_iii
	.type	_Z7comparePcPiS0_iii, @function
_Z7comparePcPiS0_iii:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii
	.cfi_endproc
.LFE2062:
	.size	_Z7comparePcPiS0_iii, .-_Z7comparePcPiS0_iii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"/cluster/home/charliep/courses/cs360/single-linkage-clustering/Iceland2014.trim.contigs.good.unique.good.filter.unique.count.fasta"
.LC2:
	.string	"malloc() FAILED (Block)\n"
.LC3:
	.string	"%s %d"
.LC5:
	.string	"w+"
.LC6:
	.string	"output2.txt"
.LC7:
	.string	"%s %d\n"
.LC8:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2028:
	.cfi_startproc
	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
	subq	$152, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	movl	lenString(%rip), %eax
	movq	%rsp, %rcx
	leal	1(%rax), %r13d
	movslq	%r13d, %rax
	leaq	15(%rax), %rdx
	movq	%rax, -192(%rbp)
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rcx
.L31:
	cmpq	%rcx, %rsp
	je	.L32
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L31
.L32:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L33
	orq	$0, -8(%rsp,%rax)
.L33:
	movl	maxNumStrings(%rip), %r14d
	leaq	.LC0(%rip), %rsi
	leaq	.LC1(%rip), %rdi
	movq	%rsp, -168(%rbp)
	call	fopen@PLT
	imull	%r14d, %r13d
	movq	%rax, -184(%rbp)
	leal	0(,%r14,4), %r12d
	movslq	%r13d, %rax
	movq	%rax, %rdi
	movq	%rax, -152(%rbp)
	call	malloc@PLT
	movq	%rax, %r13
	testq	%rax, %rax
	je	.L56
	movslq	%r12d, %rax
	movq	%rax, %rdi
	movq	%rax, -136(%rbp)
	call	malloc@PLT
	movq	%rax, %r12
	testq	%rax, %rax
	jne	.L35
.L56:
	movq	stderr(%rip), %rdi
	leaq	.LC2(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	jmp	.L57
.L35:
	movq	-136(%rbp), %rdi
	call	malloc@PLT
	movq	%rax, -160(%rbp)
	testq	%rax, %rax
	jne	.L36
	movq	stderr(%rip), %rdi
	leaq	.LC2(%rip), %rdx
	movl	$2, %esi
.L57:
	call	__fprintf_chk@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L36:
	movl	$4, %edi
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
	call	malloc@PLT
	movl	$4, %edx
	xorl	%esi, %esi
	leaq	_ZL8position(%rip), %rdi
	movq	%rax, -176(%rbp)
	leaq	.LC3(%rip), %r15
	call	cudaMemset@PLT
	movl	$4, %edx
	xorl	%esi, %esi
	leaq	_ZL7largest(%rip), %rdi
	call	cudaMemset@PLT
.L39:
	movq	-168(%rbp), %rdx
	xorl	%eax, %eax
	leaq	-124(%rbp), %rcx
	movq	%r15, %rsi
	movq	-184(%rbp), %rdi
	call	__isoc23_fscanf@PLT
	incl	%eax
	je	.L37
	cmpq	$1000, %rbx
	je	.L50
	movq	-152(%rbp), %rdx
	movslq	%r14d, %rdi
	cmpq	%rdi, -152(%rbp)
	movq	-168(%rbp), %rsi
	cmovb	%rdi, %rdx
	subq	%rdi, %rdx
	addq	%r13, %rdi
	call	__strcpy_chk@PLT
	movl	-124(%rbp), %eax
	addl	lenString(%rip), %r14d
	movl	%eax, (%r12,%rbx,4)
	incq	%rbx
	jmp	.L39
.L37:
	movl	%ebx, -140(%rbp)
	jmp	.L38
.L50:
	movl	$1000, -140(%rbp)
.L38:
	movq	-184(%rbp), %rdi
	movl	$8388609, %ebx
	movabsq	$4294967297, %r15
	salq	$9, %rbx
	call	fclose@PLT
	movq	-152(%rbp), %rsi
	leaq	-120(%rbp), %rdi
	call	cudaMalloc@PLT
	movq	-136(%rbp), %rsi
	leaq	-112(%rbp), %rdi
	call	cudaMalloc@PLT
	movq	-136(%rbp), %rsi
	leaq	-104(%rbp), %rdi
	call	cudaMalloc@PLT
	movq	-136(%rbp), %rsi
	leaq	-96(%rbp), %rdi
	call	cudaMalloc@PLT
	leaq	-88(%rbp), %rdi
	movl	$4, %esi
	call	cudaMalloc@PLT
	movq	-152(%rbp), %rdx
	movq	-120(%rbp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	-136(%rbp), %rdx
	movq	-112(%rbp), %rdi
	movq	%r12, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	-136(%rbp), %rdx
	movq	-104(%rbp), %rdi
	movl	$1, %ecx
	movq	-160(%rbp), %rsi
	call	cudaMemcpy@PLT
	cvtsi2ssl	-140(%rbp), %xmm0
	mulss	.LC4(%rip), %xmm0
	call	ceilf@PLT
	cvttss2sil	%xmm0, %r14d
.L45:
	movq	%r15, -76(%rbp)
	movl	-72(%rbp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%r14d, -80(%rbp)
	movq	-80(%rbp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	movq	%rbx, -68(%rbp)
	movl	$1, -60(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L40
	movq	-88(%rbp), %r8
	movl	-140(%rbp), %ecx
	movq	-104(%rbp), %rdx
	movq	-96(%rbp), %rsi
	movq	-112(%rbp), %rdi
	call	_Z34__device_stub__Z8populatePiS_S_iS_PiS_S_iS_
.L40:
	movq	%r15, -76(%rbp)
	movl	-72(%rbp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%r14d, -80(%rbp)
	movq	-80(%rbp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	movq	%rbx, -68(%rbp)
	movl	$1, -60(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L41
	movl	-140(%rbp), %esi
	movq	-96(%rbp), %rdi
	call	_Z26__device_stub__Z6selectPiiPii
.L41:
	movq	%r15, -76(%rbp)
	movl	-72(%rbp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%r14d, -80(%rbp)
	movq	-80(%rbp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	movq	%rbx, -68(%rbp)
	movl	$1, -60(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L42
	movl	-140(%rbp), %edx
	movq	-104(%rbp), %rsi
	movq	-112(%rbp), %rdi
	call	_Z28__device_stub__Z6searchPiS_iPiS_i
.L42:
	movq	%r15, -76(%rbp)
	movl	-72(%rbp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%r14d, -80(%rbp)
	movq	-80(%rbp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	movq	%rbx, -68(%rbp)
	movl	$1, -60(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L43
	movl	threshold(%rip), %r9d
	movl	lenString(%rip), %r8d
	movl	-140(%rbp), %ecx
	movq	-104(%rbp), %rdx
	movq	-112(%rbp), %rsi
	movq	-120(%rbp), %rdi
	call	_Z34__device_stub__Z7comparePcPiS0_iiiPcPiS0_iii
.L43:
	movq	%r15, -76(%rbp)
	movl	-72(%rbp), %esi
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%r14d, -80(%rbp)
	movq	-80(%rbp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	movq	%rbx, -68(%rbp)
	movl	$1, -60(%rbp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L44
	movl	-140(%rbp), %edx
	movq	-88(%rbp), %rsi
	movq	-104(%rbp), %rdi
	call	_Z29__device_stub__Z7anyLeftPiS_iPiS_i
.L44:
	movq	-88(%rbp), %rsi
	movl	$2, %ecx
	movl	$4, %edx
	movq	-176(%rbp), %rdi
	call	cudaMemcpy@PLT
	movq	-176(%rbp), %rax
	cmpl	$0, (%rax)
	je	.L45
	movq	-152(%rbp), %rdx
	movq	-120(%rbp), %rsi
	movq	%r13, %rdi
	xorl	%ebx, %ebx
	movl	$2, %ecx
	xorl	%r14d, %r14d
	leaq	.LC7(%rip), %r15
	call	cudaMemcpy@PLT
	movq	-136(%rbp), %rdx
	movq	-112(%rbp), %rsi
	movq	%r12, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	movq	-136(%rbp), %rdx
	movq	-104(%rbp), %rsi
	movl	$2, %ecx
	movq	-160(%rbp), %rdi
	call	cudaMemcpy@PLT
	leaq	.LC5(%rip), %rsi
	leaq	.LC6(%rip), %rdi
	call	fopen@PLT
	movq	%rax, -136(%rbp)
.L46:
	cmpl	%ebx, -140(%rbp)
	jle	.L58
	movslq	lenString(%rip), %rdx
	movq	-192(%rbp), %rcx
	movq	-168(%rbp), %rdi
	movq	%rdx, %rsi
	imull	%ebx, %esi
	movslq	%esi, %rsi
	addq	%r13, %rsi
	call	__strncpy_chk@PLT
	movl	(%r12,%rbx,4), %r8d
	xorl	%eax, %eax
	movq	%r15, %rdx
	movq	-168(%rbp), %rcx
	movq	-136(%rbp), %rdi
	movl	$2, %esi
	call	__fprintf_chk@PLT
	movq	-160(%rbp), %rax
	cmpl	$2, (%rax,%rbx,4)
	jne	.L47
	incl	%r14d
.L47:
	incq	%rbx
	jmp	.L46
.L58:
	movq	-136(%rbp), %rdi
	call	fclose@PLT
	movl	%r14d, %edx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rsi
	call	__printf_chk@PLT
	movq	-120(%rbp), %rdi
	call	cudaFree@PLT
	movq	-112(%rbp), %rdi
	call	cudaFree@PLT
	movq	-104(%rbp), %rdi
	call	cudaFree@PLT
	movq	-96(%rbp), %rdi
	call	cudaFree@PLT
	movq	-88(%rbp), %rdi
	call	cudaFree@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	-160(%rbp), %rdi
	call	free@PLT
	movq	-176(%rbp), %rdi
	call	free@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	je	.L49
	call	__stack_chk_fail@PLT
.L49:
	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
.LFE2028:
	.size	main, .-main
	.section	.rodata.str1.1
.LC9:
	.string	"_Z7comparePcPiS0_iii"
.LC10:
	.string	"_Z6selectPii"
.LC11:
	.string	"_Z8populatePiS_S_iS_"
.LC12:
	.string	"_Z6searchPiS_i"
.LC13:
	.string	"_Z7anyLeftPiS_i"
.LC14:
	.string	"position"
.LC15:
	.string	"largest"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2064:
	.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	.LC9(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z7comparePcPiS0_iii(%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	.LC10(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z6selectPii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC11(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z8populatePiS_S_iS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC12(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z6searchPiS_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC13(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z7anyLeftPiS_i(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC14(%rip), %rdx
	movl	$4, %r9d
	leaq	_ZL8position(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	call	__cudaRegisterVar@PLT
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rdx
	.cfi_def_cfa_offset 16
	pushq	$0
	.cfi_def_cfa_offset 24
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC15(%rip), %rdx
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	movq	%rdx, %rcx
	movl	$4, %r9d
	leaq	_ZL7largest(%rip), %rsi
	call	__cudaRegisterVar@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	popq	%rcx
	.cfi_def_cfa_offset 24
	popq	%rsi
	.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
.LFE2064:
	.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
	.globl	threshold
	.data
	.align 4
	.type	threshold, @object
	.size	threshold, 4
threshold:
	.long	2
	.globl	maxNumStrings
	.align 4
	.type	maxNumStrings, @object
	.size	maxNumStrings, 4
maxNumStrings:
	.long	1000000
	.globl	lenString
	.align 4
	.type	lenString, @object
	.size	lenString, 4
lenString:
	.long	593
	.local	_ZL7largest
	.comm	_ZL7largest,4,4
	.local	_ZL8position
	.comm	_ZL8position,4,4
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC4:
	.long	989855744
	.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 <cmath>

__device__ int position;			//index of the largest value
__device__ int largest;				//value of the largest value
int lenString = 593;				
int maxNumStrings = 1000000;                           
int threshold = 2;

// Checks if there are any unmerged tuples (Parallelized)
__global__ void anyLeft(int *d_c, int *remaining, int size) {
	int my_id = blockDim.x * blockIdx.x + threadIdx.x;
	if((d_c[my_id] == 0) && (my_id < size)) {
		*remaining = 0;
	}
}

// Searches for the index of the largest count (Parallelized)
__global__ void search(int *d_b, int *d_c, int size) {
	int my_id = blockDim.x * blockIdx.x + threadIdx.x;
	if((d_c[my_id] == 0) && (d_b[my_id] == largest) && (my_id < size)) {
		position = my_id;
	}
}

// Populates copy_db such that the counts for merged tuple is 0
// but count for unmerged tuples is unchanged (Parallelized)
__global__ void populate (int *d_b, int *copy_db, int *d_c, int size, int *left) {
	int n = 0;
	*left = 1;	// reinitalized to false to check if all strings are merged

	int my_id = blockDim.x * blockIdx.x + threadIdx.x;

	if (my_id < size) {
		n = abs((bool)d_c[my_id] - 1);
		copy_db[my_id] = d_b[my_id] * n;
	}		
}

// Reduction-type tree implementation to find largest count (Parallelized)
__device__ void cuda_select(int *db, int size) {
	int my_id = blockDim.x * blockIdx.x + threadIdx.x;

	if(my_id < size) {
		if(db[2 * my_id] > db[2 * my_id + 1])
			db[my_id] = db[2 * my_id];
		else
			db[my_id] = db[2 * my_id + 1];
	}	
}

// Loops cuda_select function until largest value is at index 0
__global__ void select(int *db, int size) {
	int height = (int)ceil(log2((double)size));
	int i = 0;
	
	for(i = 0; i < height; i++) {
		size = (int)ceil((double) size/2);
		cuda_select(db, size);
	}
	largest = db[0];
}

// Compares target string to all other unmerged strings with lesser count
__global__ void compare(char *d_a, int *d_b, int *d_c, int size, int lenString, int threshold) {

	int my_id = blockDim.x * blockIdx.x + threadIdx.x;

	if (my_id == position) 
		d_c[my_id] = 2;
	
		
	if ((my_id < size) && (d_c[my_id] == 0) && (my_id != position)) {	
		int x, diffs = 0;

		for (x = 0; x < lenString; x++) {
			diffs += (bool)(d_a[(lenString*position)+x]^d_a[(my_id*lenString)+x]);
			
			if (diffs > threshold)
				break;
		}
		
		if (diffs <= threshold) {
			d_b[position] += d_b[my_id];
			d_c[my_id] = 1;
		}
	} 
}

int main(int argc, char** argv) {
	char *strings, *d_a;	// host and device copy of strings
	int *counts, *d_b;	// host and device copy of counts
	int *merged, *d_c;	// host and device copy of bools
	int *copy_db;		// device copy of counts (counts of merged is 0)
	char copy[lenString+1]; // intermediate variable to load strings into array from file
	int numbers;		// intermediate variable to load counts into array from file
	int *any_left, *left;   // host and device copies to check if all tuples are merged
	int size = 0;		// keeps track of number of tuples in the file
	int i = 0;		// loop variable
	int size_string = maxNumStrings*sizeof(char)*(lenString+1);
	int size_int = maxNumStrings*sizeof(int);

	// Open the file
	FILE *fp;
	fp = fopen("/cluster/home/charliep/courses/cs360/single-linkage-clustering/Iceland2014.trim.contigs.good.unique.good.filter.unique.count.fasta", "r");

	// Allocate space for arrays on the host
	if (!(strings = (char *)malloc(size_string))) {
		fprintf(stderr, "malloc() FAILED (Block)\n");
		exit(0);
	}

	if (!(counts = (int*)malloc(size_int))) {
		fprintf(stderr, "malloc() FAILED (Block)\n"); 
		exit(0);
	}

	if (!(merged = (int*)malloc(size_int))) {
                fprintf(stderr, "malloc() FAILED (Block)\n");
                exit(0);
        }
	
	any_left = (int *)malloc(sizeof(int));
	
	// Set the values of global variables on the device
	hipMemset(&position, 0, sizeof(int));
	hipMemset(&largest, 0, sizeof(int));

	// Load strings and counts into array
	while(fscanf(fp, "%s %d", copy, &numbers) != EOF && size < 1000){
		strcpy(&strings[i], copy);
		counts[size] = numbers;
		
		i = i + lenString;
		size++;	
	}
	
	// Close file
	fclose(fp);
	
	// Allocate space for arrays on the device
	hipMalloc(&d_a, size_string);
	hipMalloc(&d_b, size_int);
	hipMalloc(&d_c, size_int);
	hipMalloc(&copy_db, size_int);
	hipMalloc(&left, sizeof(int));
	
	// Copy arrays from host to device
	hipMemcpy(d_a, strings, size_string, hipMemcpyHostToDevice);
	hipMemcpy(d_b, counts, size_int, hipMemcpyHostToDevice);
	hipMemcpy(d_c, merged, size_int, hipMemcpyHostToDevice);

	// Determine number of threads and blocks needed	
	int threads_num = 512, blocks_num;
	blocks_num = (int)ceil((float)size/threads_num);
	
	// Cluster the strings for the given threshold
	do {
	populate<<<blocks_num, threads_num>>>(d_b, copy_db, d_c, size,left); 	
	select<<<blocks_num, threads_num>>>(copy_db, size);	
	search<<<blocks_num, threads_num>>>(d_b, d_c, size);
	compare<<<blocks_num, threads_num>>>(d_a, d_b, d_c, size, lenString, threshold);
        anyLeft<<<blocks_num, threads_num>>>(d_c, left, size);
	hipMemcpy(any_left, left, sizeof(int), hipMemcpyDeviceToHost);
	} while (*any_left == 0);
	
	// Copy results back from device to host
	hipMemcpy(strings, d_a, size_string, hipMemcpyDeviceToHost);	
	hipMemcpy(counts, d_b, size_int, hipMemcpyDeviceToHost);
	hipMemcpy(merged, d_c, size_int, hipMemcpyDeviceToHost);
	
	int counter = 0;
	
	FILE *output = fopen("output2.txt", "w+");
	
	for(i = 0; i < size; i++) {
		strncpy(copy, &strings[i*lenString], lenString);
		fprintf(output, "%s %d\n", copy, counts[i]);
		if (merged[i] == 2)
			counter++;
	}
	
	fclose(output);

	printf("%d\n", counter);

	hipFree(d_a);
	hipFree(d_b);
	hipFree(d_c);
	hipFree(copy_db);
	hipFree(left);

	free(strings);
	free(counts);
	free(merged);
	free(any_left);
}

	.text
	.file	"cluster.hip"
	.globl	_Z22__device_stub__anyLeftPiS_i # -- Begin function _Z22__device_stub__anyLeftPiS_i
	.type	_Z22__device_stub__anyLeftPiS_i,@function
_Z22__device_stub__anyLeftPiS_i:        # @_Z22__device_stub__anyLeftPiS_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	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z7anyLeftPiS_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z22__device_stub__anyLeftPiS_i, .Lfunc_end0-_Z22__device_stub__anyLeftPiS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__searchPiS_i  # -- Begin function _Z21__device_stub__searchPiS_i
	.type	_Z21__device_stub__searchPiS_i,@function
_Z21__device_stub__searchPiS_i:         # @_Z21__device_stub__searchPiS_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	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z6searchPiS_i, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z21__device_stub__searchPiS_i, .Lfunc_end1-_Z21__device_stub__searchPiS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z23__device_stub__populatePiS_S_iS_ # -- Begin function _Z23__device_stub__populatePiS_S_iS_
	.type	_Z23__device_stub__populatePiS_S_iS_,@function
_Z23__device_stub__populatePiS_S_iS_:   # @_Z23__device_stub__populatePiS_S_iS_
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.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	12(%rsp), %rdx
	movl	%ecx, (%rdx)
	leaq	32(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%rcx, 32(%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	$_Z8populatePiS_S_iS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z23__device_stub__populatePiS_S_iS_, .Lfunc_end2-_Z23__device_stub__populatePiS_S_iS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__selectPii    # -- Begin function _Z21__device_stub__selectPii
	.type	_Z21__device_stub__selectPii,@function
_Z21__device_stub__selectPii:           # @_Z21__device_stub__selectPii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	4(%rsp), %rcx
	movl	%esi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z6selectPii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z21__device_stub__selectPii, .Lfunc_end3-_Z21__device_stub__selectPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z22__device_stub__comparePcPiS0_iii # -- Begin function _Z22__device_stub__comparePcPiS0_iii
	.type	_Z22__device_stub__comparePcPiS0_iii,@function
_Z22__device_stub__comparePcPiS0_iii:   # @_Z22__device_stub__comparePcPiS0_iii
	.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	$144, %rsp
	.cfi_def_cfa_offset 192
	.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	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	$_Z7comparePcPiS0_iii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$160, %rsp
	.cfi_adjust_cfa_offset -160
	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_end4:
	.size	_Z22__device_stub__comparePcPiS0_iii, .Lfunc_end4-_Z22__device_stub__comparePcPiS0_iii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI5_0:
	.long	0x3b000000                      # float 0.001953125
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$120, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsp, %r12
	movl	lenString(%rip), %eax
	incl	%eax
	movq	%rsp, %r14
	addq	$15, %rax
	andq	$-16, %rax
	subq	%rax, %r14
	movq	%r14, %rsp
	movl	maxNumStrings(%rip), %ebx
	movl	lenString(%rip), %r15d
	incl	%r15d
	imull	%ebx, %r15d
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, -104(%rbp)                # 8-byte Spill
	movslq	%r15d, %rdi
	movq	%rdi, -136(%rbp)                # 8-byte Spill
	callq	malloc
	movq	%rax, -64(%rbp)                 # 8-byte Spill
	testq	%rax, %rax
	je	.LBB5_25
# %bb.1:
	shll	$2, %ebx
	movslq	%ebx, %rbx
	movq	%rbx, %rdi
	callq	malloc
	testq	%rax, %rax
	je	.LBB5_25
# %bb.2:
	movq	%rax, %r15
	movq	%r12, -160(%rbp)                # 8-byte Spill
	movq	%rbx, %rdi
	callq	malloc
	testq	%rax, %rax
	je	.LBB5_25
# %bb.3:
	movq	%rax, %r13
	movq	%rbx, -128(%rbp)                # 8-byte Spill
	movl	$4, %edi
	callq	malloc
	movq	%rax, -152(%rbp)                # 8-byte Spill
	xorl	%r12d, %r12d
	movl	$position, %edi
	movl	$4, %edx
	xorl	%esi, %esi
	callq	hipMemset
	movl	$largest, %edi
	movl	$4, %edx
	xorl	%esi, %esi
	callq	hipMemset
	leaq	-68(%rbp), %rcx
	movl	$.L.str.3, %esi
	movq	-104(%rbp), %rdi                # 8-byte Reload
	movq	%r14, -144(%rbp)                # 8-byte Spill
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$-1, %eax
	movq	%r13, -80(%rbp)                 # 8-byte Spill
	je	.LBB5_8
# %bb.4:                                # %.lr.ph.preheader
	movq	%r15, %r14
	xorl	%r15d, %r15d
	xorl	%r13d, %r13d
	movq	-144(%rbp), %rbx                # 8-byte Reload
.LBB5_5:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movslq	%r13d, %r13
	movq	-64(%rbp), %rax                 # 8-byte Reload
	leaq	(%rax,%r13), %rdi
	movq	%rbx, %rsi
	callq	strcpy
	movl	-68(%rbp), %eax
	movl	%eax, (%r14,%r15,4)
	addl	lenString(%rip), %r13d
	leaq	1(%r15), %r12
	movl	$.L.str.3, %esi
	movq	-104(%rbp), %rdi                # 8-byte Reload
	movq	%rbx, %rdx
	leaq	-68(%rbp), %rcx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$-1, %eax
	je	.LBB5_7
# %bb.6:                                # %.lr.ph
                                        #   in Loop: Header=BB5_5 Depth=1
	cmpq	$999, %r15                      # imm = 0x3E7
	movq	%r12, %r15
	jb	.LBB5_5
.LBB5_7:                                # %._crit_edge.loopexit
	movq	%r14, %r15
	movq	-80(%rbp), %r13                 # 8-byte Reload
.LBB5_8:                                # %._crit_edge
	movq	%r15, -112(%rbp)                # 8-byte Spill
	movabsq	$4294967808, %rbx               # imm = 0x100000200
	movq	-104(%rbp), %rdi                # 8-byte Reload
	callq	fclose
	leaq	-96(%rbp), %rdi
	movq	%r13, %r14
	movq	-136(%rbp), %r13                # 8-byte Reload
	movq	%r13, %rsi
	callq	hipMalloc
	leaq	-56(%rbp), %rdi
	movq	-128(%rbp), %r15                # 8-byte Reload
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	-48(%rbp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	-120(%rbp), %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	leaq	-88(%rbp), %rdi
	movl	$4, %esi
	callq	hipMalloc
	leaq	-96(%rbp), %rax
	movq	(%rax), %rdi
	movq	-64(%rbp), %rsi                 # 8-byte Reload
	movq	%r13, %rdx
	movq	-112(%rbp), %r13                # 8-byte Reload
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	-56(%rbp), %rax
	movq	(%rax), %rdi
	movq	%r13, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	-48(%rbp), %rax
	movq	(%rax), %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	cvtsi2ss	%r12d, %xmm0
	mulss	.LCPI5_0(%rip), %xmm0
	callq	ceilf@PLT
	cvttss2si	%xmm0, %eax
	leaq	(%rax,%rbx), %r14
	addq	$-512, %r14                     # imm = 0xFE00
	movq	-152(%rbp), %r15                # 8-byte Reload
.LBB5_9:                                # =>This Inner Loop Header: Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_11
# %bb.10:                               #   in Loop: Header=BB5_9 Depth=1
	movq	-56(%rbp), %rdi
	movq	-120(%rbp), %rsi
	movq	-48(%rbp), %rdx
	movq	-88(%rbp), %r8
	movl	%r12d, %ecx
	callq	_Z23__device_stub__populatePiS_S_iS_
.LBB5_11:                               #   in Loop: Header=BB5_9 Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_13
# %bb.12:                               #   in Loop: Header=BB5_9 Depth=1
	movq	-120(%rbp), %rdi
	movl	%r12d, %esi
	callq	_Z21__device_stub__selectPii
.LBB5_13:                               #   in Loop: Header=BB5_9 Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_15
# %bb.14:                               #   in Loop: Header=BB5_9 Depth=1
	movq	-56(%rbp), %rdi
	movq	-48(%rbp), %rsi
	movl	%r12d, %edx
	callq	_Z21__device_stub__searchPiS_i
.LBB5_15:                               #   in Loop: Header=BB5_9 Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_17
# %bb.16:                               #   in Loop: Header=BB5_9 Depth=1
	movq	-96(%rbp), %rdi
	movq	-56(%rbp), %rsi
	movq	-48(%rbp), %rdx
	movl	lenString(%rip), %r8d
	movl	threshold(%rip), %r9d
	movl	%r12d, %ecx
	callq	_Z22__device_stub__comparePcPiS0_iii
.LBB5_17:                               #   in Loop: Header=BB5_9 Depth=1
	movq	%r14, %rdi
	movl	$1, %esi
	movq	%rbx, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB5_19
# %bb.18:                               #   in Loop: Header=BB5_9 Depth=1
	movq	-48(%rbp), %rdi
	movq	-88(%rbp), %rsi
	movl	%r12d, %edx
	callq	_Z22__device_stub__anyLeftPiS_i
.LBB5_19:                               #   in Loop: Header=BB5_9 Depth=1
	movq	-88(%rbp), %rsi
	movl	$4, %edx
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$0, (%r15)
	je	.LBB5_9
# %bb.20:
	movq	-96(%rbp), %rsi
	movq	-64(%rbp), %rdi                 # 8-byte Reload
	movq	-136(%rbp), %rdx                # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
	movq	-56(%rbp), %rsi
	movq	%r13, %rdi
	movq	-128(%rbp), %rbx                # 8-byte Reload
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	-48(%rbp), %rsi
	movq	-80(%rbp), %rdi                 # 8-byte Reload
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.L.str.4, %edi
	movl	$.L.str.5, %esi
	callq	fopen
	movq	%rax, %rbx
	testl	%r12d, %r12d
	je	.LBB5_21
# %bb.22:                               # %.lr.ph128.preheader
	movl	%r12d, %r15d
	xorl	%r13d, %r13d
	xorl	%r14d, %r14d
	movq	-144(%rbp), %r12                # 8-byte Reload
.LBB5_23:                               # %.lr.ph128
                                        # =>This Inner Loop Header: Depth=1
	movslq	lenString(%rip), %rdx
	movslq	%r13d, %rsi
	imulq	%rdx, %rsi
	addq	-64(%rbp), %rsi                 # 8-byte Folded Reload
	movq	%r12, %rdi
	callq	strncpy
	movq	-112(%rbp), %rax                # 8-byte Reload
	movl	(%rax,%r13,4), %ecx
	movl	$.L.str.6, %esi
	movq	%rbx, %rdi
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	fprintf
	xorl	%eax, %eax
	movq	-80(%rbp), %rcx                 # 8-byte Reload
	cmpl	$2, (%rcx,%r13,4)
	sete	%al
	addl	%eax, %r14d
	incq	%r13
	cmpq	%r13, %r15
	jne	.LBB5_23
	jmp	.LBB5_24
.LBB5_21:
	xorl	%r14d, %r14d
.LBB5_24:                               # %._crit_edge129
	movq	%rbx, %rdi
	callq	fclose
	movl	$.L.str.7, %edi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	printf
	movq	-96(%rbp), %rdi
	callq	hipFree
	movq	-56(%rbp), %rdi
	callq	hipFree
	movq	-48(%rbp), %rdi
	callq	hipFree
	movq	-120(%rbp), %rdi
	callq	hipFree
	movq	-88(%rbp), %rdi
	callq	hipFree
	movq	-64(%rbp), %rdi                 # 8-byte Reload
	callq	free
	movq	-112(%rbp), %rdi                # 8-byte Reload
	callq	free
	movq	-80(%rbp), %rdi                 # 8-byte Reload
	callq	free
	movq	-152(%rbp), %rdi                # 8-byte Reload
	callq	free
	movq	-160(%rbp), %rsp                # 8-byte Reload
	xorl	%eax, %eax
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa %rsp, 8
	retq
.LBB5_25:
	.cfi_def_cfa %rbp, 16
	movq	stderr(%rip), %rcx
	movl	$.L.str.2, %edi
	movl	$24, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	xorl	%edi, %edi
	callq	exit
.Lfunc_end5:
	.size	main, .Lfunc_end5-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7anyLeftPiS_i, %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	$_Z6searchPiS_i, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z8populatePiS_S_iS_, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6selectPii, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z7comparePcPiS0_iii, %esi
	movl	$.L__unnamed_5, %edx
	movl	$.L__unnamed_5, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$0, 8(%rsp)
	movl	$0, (%rsp)
	movl	$position, %esi
	movl	$.L__unnamed_6, %edx
	movl	$.L__unnamed_6, %ecx
	movl	$4, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$0, 8(%rsp)
	movl	$0, (%rsp)
	movl	$largest, %esi
	movl	$.L__unnamed_7, %edx
	movl	$.L__unnamed_7, %ecx
	movl	$4, %r9d
	movq	%rbx, %rdi
	xorl	%r8d, %r8d
	callq	__hipRegisterVar
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	position,@object                # @position
	.local	position
	.comm	position,4,4
	.type	largest,@object                 # @largest
	.local	largest
	.comm	largest,4,4
	.type	lenString,@object               # @lenString
	.data
	.globl	lenString
	.p2align	2, 0x0
lenString:
	.long	593                             # 0x251
	.size	lenString, 4

	.type	maxNumStrings,@object           # @maxNumStrings
	.globl	maxNumStrings
	.p2align	2, 0x0
maxNumStrings:
	.long	1000000                         # 0xf4240
	.size	maxNumStrings, 4

	.type	threshold,@object               # @threshold
	.globl	threshold
	.p2align	2, 0x0
threshold:
	.long	2                               # 0x2
	.size	threshold, 4

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

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

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

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

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

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"/cluster/home/charliep/courses/cs360/single-linkage-clustering/Iceland2014.trim.contigs.good.unique.good.filter.unique.count.fasta"
	.size	.L.str, 131

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"malloc() FAILED (Block)\n"
	.size	.L.str.2, 25

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"%s %d"
	.size	.L.str.3, 6

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"output2.txt"
	.size	.L.str.4, 12

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

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

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

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z7anyLeftPiS_i"
	.size	.L__unnamed_1, 16

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z6searchPiS_i"
	.size	.L__unnamed_2, 15

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z8populatePiS_S_iS_"
	.size	.L__unnamed_3, 21

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"_Z6selectPii"
	.size	.L__unnamed_4, 13

	.type	.L__unnamed_5,@object           # @4
.L__unnamed_5:
	.asciz	"_Z7comparePcPiS0_iii"
	.size	.L__unnamed_5, 21

	.type	.L__unnamed_6,@object           # @5
.L__unnamed_6:
	.asciz	"position"
	.size	.L__unnamed_6, 9

	.type	.L__unnamed_7,@object           # @6
.L__unnamed_7:
	.asciz	"largest"
	.size	.L__unnamed_7, 8

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

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

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z22__device_stub__anyLeftPiS_i
	.addrsig_sym _Z21__device_stub__searchPiS_i
	.addrsig_sym _Z23__device_stub__populatePiS_S_iS_
	.addrsig_sym _Z21__device_stub__selectPii
	.addrsig_sym _Z22__device_stub__comparePcPiS0_iii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym position
	.addrsig_sym largest
	.addrsig_sym _Z7anyLeftPiS_i
	.addrsig_sym _Z6searchPiS_i
	.addrsig_sym _Z8populatePiS_S_iS_
	.addrsig_sym _Z6selectPii
	.addrsig_sym _Z7comparePcPiS0_iii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z7anyLeftPiS_i         ; -- Begin function _Z7anyLeftPiS_i
	.globl	_Z7anyLeftPiS_i
	.p2align	8
	.type	_Z7anyLeftPiS_i,@function
_Z7anyLeftPiS_i:                        ; @_Z7anyLeftPiS_i
; %bb.0:
	s_clause 0x2
	s_load_b32 s2, s[0:1], 0x24
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b32 s0, s[0:1], 0x10
	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_ashrrev_i32_e32 v2, 31, v1
	v_cmp_gt_i32_e64 s0, s0, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, s4, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
	global_load_b32 v0, v[2:3], off
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, 0, v0
	s_and_b32 s0, vcc_lo, s0
	s_and_saveexec_b32 s1, s0
	s_cbranch_execz .LBB0_2
; %bb.1:
	v_mov_b32_e32 v0, 0
	global_store_b32 v0, v0, s[6:7]
.LBB0_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7anyLeftPiS_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 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 4
		.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	_Z7anyLeftPiS_i, .Lfunc_end0-_Z7anyLeftPiS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 144
; NumSgprs: 18
; NumVgprs: 4
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 4
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z6searchPiS_i          ; -- Begin function _Z6searchPiS_i
	.globl	_Z6searchPiS_i
	.p2align	8
	.type	_Z6searchPiS_i,@function
_Z6searchPiS_i:                         ; @_Z6searchPiS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x24
	s_load_b128 s[4:7], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_mov_b32 s2, exec_lo
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_co_u32 v4, vcc_lo, s6, v2
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v3, vcc_lo
	global_load_b32 v0, v[4:5], off
	s_waitcnt vmcnt(0)
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB1_3
; %bb.1:
	v_add_co_u32 v2, vcc_lo, s4, v2
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, largest@rel32@lo+4
	s_addc_u32 s3, s3, largest@rel32@hi+12
	global_load_b32 v0, v[2:3], off
	s_load_b32 s2, s[2:3], 0x0
	s_load_b32 s0, s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_i32_e64 s0, s0, v1
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, s2, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s0, s0, vcc_lo
	s_and_b32 exec_lo, exec_lo, s0
	s_cbranch_execz .LBB1_3
; %bb.2:
	v_mov_b32_e32 v0, 0
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, position@rel32@lo+4
	s_addc_u32 s1, s1, position@rel32@hi+12
	global_store_b32 v0, v1, s[0:1]
.LBB1_3:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6searchPiS_i
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 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 6
		.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	_Z6searchPiS_i, .Lfunc_end1-_Z6searchPiS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 236
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z8populatePiS_S_iS_    ; -- Begin function _Z8populatePiS_S_iS_
	.globl	_Z8populatePiS_S_iS_
	.p2align	8
	.type	_Z8populatePiS_S_iS_,@function
_Z8populatePiS_S_iS_:                   ; @_Z8populatePiS_S_iS_
; %bb.0:
	s_clause 0x2
	s_load_b32 s4, s[0:1], 0x34
	s_load_b32 s5, s[0:1], 0x18
	s_load_b64 s[2:3], s[0:1], 0x20
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1)
	v_mad_u64_u32 v[1:2], null, s15, s4, v[0:1]
	v_mov_b32_e32 v0, 0
	v_mov_b32_e32 v2, 1
	global_store_b32 v0, v2, s[2:3]
	s_mov_b32 s2, exec_lo
	v_cmpx_gt_i32_e64 s5, v1
	s_cbranch_execz .LBB2_2
; %bb.1:
	s_clause 0x1
	s_load_b64 s[4:5], s[0:1], 0x10
	s_load_b128 s[0:3], s[0:1], 0x0
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s4, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v1, vcc_lo
	v_add_co_u32 v4, vcc_lo, s0, v0
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v1, vcc_lo
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v[4:5], off
	s_waitcnt vmcnt(1)
	v_cmp_eq_u32_e32 vcc_lo, 0, v2
	s_waitcnt vmcnt(0)
	v_cndmask_b32_e32 v2, 0, v3, vcc_lo
	v_add_co_u32 v0, vcc_lo, s2, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
.LBB2_2:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z8populatePiS_S_iS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end2:
	.size	_Z8populatePiS_S_iS_, .Lfunc_end2-_Z8populatePiS_S_iS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 216
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z6selectPii            ; -- Begin function _Z6selectPii
	.globl	_Z6selectPii
	.p2align	8
	.type	_Z6selectPii,@function
_Z6selectPii:                           ; @_Z6selectPii
; %bb.0:
	s_load_b32 s4, s[0:1], 0x8
	s_mov_b32 s3, 0x3fe55555
	s_mov_b32 s2, 0x55555555
	s_mov_b32 s6, 0x6b47b09a
	s_mov_b32 s8, 0xbf559e2b
	s_mov_b32 s7, 0x3fc38538
	s_mov_b32 s9, 0x3fc3ab76
	s_waitcnt lgkmcnt(0)
	v_cvt_f64_i32_e32 v[1:2], s4
	s_cmp_gt_i32 s4, -1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_frexp_mant_f64_e32 v[3:4], v[1:2]
	v_cmp_gt_f64_e32 vcc_lo, s[2:3], v[3:4]
	s_mov_b32 s2, 0x55555780
	v_cndmask_b32_e64 v5, 0, 1, vcc_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ldexp_f64 v[3:4], v[3:4], v5
	v_add_f64 v[5:6], v[3:4], 1.0
	v_add_f64 v[11:12], v[3:4], -1.0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_rcp_f64_e32 v[7:8], v[5:6]
	v_add_f64 v[13:14], v[5:6], -1.0
	v_add_f64 v[3:4], v[3:4], -v[13:14]
	s_waitcnt_depctr 0xfff
	v_fma_f64 v[9:10], -v[5:6], v[7:8], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[7:8], v[9:10], v[7:8], v[7:8]
	v_fma_f64 v[9:10], -v[5:6], v[7:8], 1.0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[7:8], v[9:10], v[7:8], v[7:8]
	v_mul_f64 v[9:10], v[11:12], v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[15:16], v[5:6], v[9:10]
	v_fma_f64 v[5:6], v[9:10], v[5:6], -v[15:16]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f64 v[3:4], v[9:10], v[3:4], v[5:6]
	v_add_f64 v[5:6], v[15:16], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_f64 v[13:14], v[11:12], -v[5:6]
	v_add_f64 v[15:16], v[5:6], -v[15:16]
	v_add_f64 v[11:12], v[11:12], -v[13:14]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[3:4], v[15:16], -v[3:4]
	v_add_f64 v[5:6], v[11:12], -v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[3:4], v[3:4], v[5:6]
	v_add_f64 v[3:4], v[13:14], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[3:4], v[7:8], v[3:4]
	v_add_f64 v[5:6], v[9:10], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[7:8], v[5:6], v[5:6]
	v_fma_f64 v[11:12], v[7:8], s[8:9], s[6:7]
	s_mov_b32 s6, 0xd7f4df2e
	s_mov_b32 s7, 0x3fc7474d
	v_mul_f64 v[13:14], v[5:6], v[7:8]
	s_delay_alu instid0(VALU_DEP_2)
	v_fma_f64 v[11:12], v[7:8], v[11:12], s[6:7]
	s_mov_b32 s6, 0x16291751
	s_mov_b32 s7, 0x3fcc71c0
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[7:8], v[11:12], s[6:7]
	s_mov_b32 s6, 0x9b27acf1
	s_mov_b32 s7, 0x3fd24924
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[7:8], v[11:12], s[6:7]
	s_mov_b32 s6, 0x998ef7b6
	s_mov_b32 s7, 0x3fd99999
	s_delay_alu instid0(VALU_DEP_1) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[11:12], v[7:8], v[11:12], s[6:7]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_3)
	v_fma_f64 v[7:8], v[7:8], v[11:12], s[2:3]
	v_ldexp_f64 v[11:12], v[5:6], 1
	v_add_f64 v[5:6], v[5:6], -v[9:10]
	s_mov_b32 s2, 0x652b82fe
	s_mov_b32 s3, 0x3ff71547
	v_mul_f64 v[7:8], v[13:14], v[7:8]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[3:4], v[3:4], -v[5:6]
	v_add_f64 v[9:10], v[11:12], v[7:8]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ldexp_f64 v[3:4], v[3:4], 1
	v_add_f64 v[5:6], v[9:10], -v[11:12]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[7:8], -v[5:6]
	v_add_f64 v[3:4], v[3:4], v[5:6]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[9:10], v[3:4]
	v_add_f64 v[7:8], v[5:6], -v[9:10]
	v_mul_f64 v[9:10], v[5:6], s[2:3]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[3:4], v[3:4], -v[7:8]
	v_fma_f64 v[7:8], v[5:6], s[2:3], -v[9:10]
	s_delay_alu instid0(VALU_DEP_1)
	v_fma_f64 v[3:4], v[3:4], s[2:3], v[7:8]
	v_frexp_exp_i32_f64_e32 v7, v[1:2]
	s_mov_b32 s2, 0xffda0d24
	s_mov_b32 s3, 0x3c7777d0
	s_delay_alu instid0(VALU_DEP_2) | instid1(SALU_CYCLE_1)
	v_fma_f64 v[1:2], v[5:6], s[2:3], v[3:4]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_subrev_co_ci_u32_e32 v3, vcc_lo, 0, v7, vcc_lo
	s_cselect_b32 vcc_lo, -1, 0
	s_cmp_lg_u32 s4, 0
	v_cvt_f64_i32_e32 v[3:4], v3
	s_cselect_b32 s2, -1, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[5:6], v[9:10], v[1:2]
	v_add_f64 v[7:8], v[5:6], v[3:4]
	v_add_f64 v[9:10], v[5:6], -v[9:10]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f64 v[11:12], v[7:8], -v[3:4]
	v_add_f64 v[1:2], v[1:2], -v[9:10]
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_f64 v[13:14], v[11:12], -v[7:8]
	v_add_f64 v[5:6], v[5:6], -v[11:12]
	v_add_f64 v[3:4], v[13:14], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[3:4], v[5:6], v[3:4]
	v_add_f64 v[1:2], v[1:2], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[1:2], v[7:8], v[1:2]
	v_cndmask_b32_e32 v2, 0x7ff80000, v2, vcc_lo
	s_and_b32 vcc_lo, s2, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cndmask_b32_e32 v1, 0, v1, vcc_lo
	v_cndmask_b32_e64 v2, 0xfff00000, v2, s2
	s_load_b64 s[2:3], s[0:1], 0x0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ceil_f64_e32 v[1:2], v[1:2]
	v_cvt_i32_f64_e32 v6, v[1:2]
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_gt_i32_e32 vcc_lo, 1, v6
	s_cbranch_vccnz .LBB3_5
; %bb.1:                                ; %.lr.ph
	s_load_b32 s0, s[0:1], 0x1c
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s0, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s0, v[0:1]
	v_dual_mov_b32 v0, s4 :: v_dual_lshlrev_b32 v3, 1, v1
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v4, 31, v3
	v_lshlrev_b64 v[7:8], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[3:4], 2, v[3:4]
	v_add_co_u32 v2, vcc_lo, s2, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v4, vcc_lo
	v_sub_co_u32 v4, vcc_lo, v2, v7
	s_delay_alu instid0(VALU_DEP_2)
	v_sub_co_ci_u32_e32 v5, vcc_lo, v3, v8, vcc_lo
.LBB3_2:                                ; =>This Inner Loop Header: Depth=1
	v_cvt_f64_i32_e32 v[7:8], v0
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[7:8], v[7:8], 0.5
	v_ceil_f64_e32 v[7:8], v[7:8]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_i32_f64_e32 v0, v[7:8]
	v_cmpx_lt_i32_e64 v1, v0
	s_cbranch_execz .LBB3_4
; %bb.3:                                ; %.sink.split.i
                                        ;   in Loop: Header=BB3_2 Depth=1
	global_load_b64 v[7:8], v[2:3], off
	s_waitcnt vmcnt(0)
	v_max_i32_e32 v7, v7, v8
	global_store_b32 v[4:5], v7, off
.LBB3_4:                                ; %_Z11cuda_selectPii.exit
                                        ;   in Loop: Header=BB3_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	v_add_nc_u32_e32 v6, -1, v6
	s_delay_alu instid0(VALU_DEP_1)
	v_cmp_ne_u32_e32 vcc_lo, 0, v6
	s_cbranch_vccnz .LBB3_2
.LBB3_5:                                ; %._crit_edge
	v_mov_b32_e32 v0, 0
	s_getpc_b64 s[0:1]
	s_add_u32 s0, s0, largest@rel32@lo+4
	s_addc_u32 s1, s1, largest@rel32@hi+12
	s_waitcnt lgkmcnt(0)
	global_load_b32 v1, v0, s[2:3]
	s_waitcnt vmcnt(0)
	global_store_b32 v0, v1, s[0:1]
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6selectPii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 17
		.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_end3:
	.size	_Z6selectPii, .Lfunc_end3-_Z6selectPii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 1120
; NumSgprs: 18
; NumVgprs: 17
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 17
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.protected	_Z7comparePcPiS0_iii    ; -- Begin function _Z7comparePcPiS0_iii
	.globl	_Z7comparePcPiS0_iii
	.p2align	8
	.type	_Z7comparePcPiS0_iii,@function
_Z7comparePcPiS0_iii:                   ; @_Z7comparePcPiS0_iii
; %bb.0:
	s_load_b32 s4, s[0:1], 0x34
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, position@rel32@lo+4
	s_addc_u32 s3, s3, position@rel32@hi+12
	s_load_b32 s5, s[2:3], 0x0
	s_load_b64 s[2:3], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[4:5], null, s15, s4, v[0:1]
	s_mov_b32 s4, exec_lo
	v_ashrrev_i32_e32 v5, 31, v4
	v_cmpx_eq_u32_e64 s5, v4
	s_cbranch_execz .LBB4_2
; %bb.1:
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_lshlrev_b64 v[0:1], 2, v[4:5]
	v_mov_b32_e32 v2, 2
	v_add_co_u32 v0, vcc_lo, s2, v0
	s_delay_alu instid0(VALU_DEP_3)
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v1, vcc_lo
	global_store_b32 v[0:1], v2, off
.LBB4_2:
	s_or_b32 exec_lo, exec_lo, s4
	s_load_b128 s[4:7], s[0:1], 0x18
	s_waitcnt lgkmcnt(0)
	v_cmp_gt_i32_e32 vcc_lo, s4, v4
	s_and_saveexec_b32 s4, vcc_lo
	s_cbranch_execz .LBB4_10
; %bb.3:
	v_lshlrev_b64 v[2:3], 2, v[4:5]
	v_mov_b32_e32 v6, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_co_u32 v0, vcc_lo, s2, v2
	v_add_co_ci_u32_e32 v1, vcc_lo, s3, v3, vcc_lo
	s_getpc_b64 s[2:3]
	s_add_u32 s2, s2, position@rel32@lo+4
	s_addc_u32 s3, s3, position@rel32@hi+12
	global_load_b32 v5, v[0:1], off
	global_load_b32 v7, v6, s[2:3]
	s_waitcnt vmcnt(1)
	v_cmp_eq_u32_e32 vcc_lo, 0, v5
	s_waitcnt vmcnt(0)
	v_cmp_ne_u32_e64 s2, v4, v7
	v_readfirstlane_b32 s4, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s2, vcc_lo, s2
	s_and_b32 exec_lo, exec_lo, s2
	s_cbranch_execz .LBB4_10
; %bb.4:                                ; %.preheader
	s_load_b128 s[0:3], s[0:1], 0x0
	s_cmp_lt_i32 s5, 1
	s_cbranch_scc1 .LBB4_8
; %bb.5:                                ; %.lr.ph
	v_mul_lo_u32 v4, v4, s5
	s_mul_i32 s7, s4, s5
	v_dual_mov_b32 v6, 0 :: v_dual_mov_b32 v7, 0
	s_add_i32 s5, s5, -1
	s_ashr_i32 s9, s7, 31
	s_waitcnt lgkmcnt(0)
	s_add_u32 s8, s0, s7
	s_addc_u32 s9, s1, s9
	v_ashrrev_i32_e32 v5, 31, v4
	v_add_co_u32 v4, vcc_lo, s0, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v5, vcc_lo
	s_mov_b32 s1, 0
.LBB4_6:                                ; =>This Inner Loop Header: Depth=1
	global_load_u8 v8, v7, s[8:9]
	global_load_u8 v9, v[4:5], off
	s_cmp_eq_u32 s5, 0
	s_cselect_b32 s7, -1, 0
	s_add_i32 s5, s5, -1
	s_waitcnt vmcnt(0)
	v_cmp_ne_u16_e32 vcc_lo, v8, v9
	v_add_co_ci_u32_e32 v6, vcc_lo, 0, v6, vcc_lo
	v_add_co_u32 v4, vcc_lo, v4, 1
	v_add_co_ci_u32_e32 v5, vcc_lo, 0, v5, vcc_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cmp_lt_i32_e64 s0, s6, v6
	s_or_b32 s0, s0, s7
	s_add_u32 s8, s8, 1
	s_addc_u32 s9, s9, 0
	s_and_b32 s0, exec_lo, s0
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s1, s0, s1
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB4_6
; %bb.7:                                ; %Flow68
	s_or_b32 exec_lo, exec_lo, s1
.LBB4_8:                                ; %._crit_edge
	v_cmp_ge_i32_e32 vcc_lo, s6, v6
	s_and_b32 exec_lo, exec_lo, vcc_lo
	s_cbranch_execz .LBB4_10
; %bb.9:
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v2, vcc_lo, s2, v2
	s_ashr_i32 s5, s4, 31
	v_add_co_ci_u32_e32 v3, vcc_lo, s3, v3, vcc_lo
	s_lshl_b64 s[0:1], s[4:5], 2
	v_mov_b32_e32 v4, 0
	s_add_u32 s0, s2, s0
	s_addc_u32 s1, s3, s1
	s_clause 0x1
	global_load_b32 v2, v[2:3], off
	global_load_b32 v3, v4, s[0:1]
	s_waitcnt vmcnt(0)
	v_dual_mov_b32 v3, 1 :: v_dual_add_nc_u32 v2, v3, v2
	global_store_b32 v4, v2, s[0:1]
	global_store_b32 v[0:1], v3, off
.LBB4_10:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z7comparePcPiS0_iii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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 10
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end4:
	.size	_Z7comparePcPiS0_iii, .Lfunc_end4-_Z7comparePcPiS0_iii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 548
; NumSgprs: 18
; NumVgprs: 10
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 10
; Occupancy: 16
; WaveLimiterHint : 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
	.protected	position                ; @position
	.type	position,@object
	.section	.bss,"aw",@nobits
	.globl	position
	.p2align	2, 0x0
position:
	.long	0                               ; 0x0
	.size	position, 4

	.protected	largest                 ; @largest
	.type	largest,@object
	.globl	largest
	.p2align	2, 0x0
largest:
	.long	0                               ; 0x0
	.size	largest, 4

	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.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 position
	.addrsig_sym largest
	.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
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7anyLeftPiS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7anyLeftPiS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     4
    .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
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6searchPiS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z6searchPiS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .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
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z8populatePiS_S_iS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z8populatePiS_S_iS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6selectPii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z6selectPii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     17
    .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:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z7comparePcPiS0_iii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z7comparePcPiS0_iii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     10
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
