//
//	findCutoff.cu
//
//This file contains the function that determines the most
//efficient number of assemblies to perform on the gpu

#include <cuda.h>
#include <iostream>


void cudaAssemble(double Zs[],double Xs[], int num, double nZs[], double nXs[], int odd, int newlen);
void cudaDisassemble(double OldAF[], double Zs[], double Xs[],double nZs[], double nXs[], int odd, int morelen, int lesslen, double AF[]);
void Assemble(double Zs[], double Xs[],double nZs[], double nXs[], int len, int odd, int n);
void Disassemble(double lessZs[], double lessXs[],double moreZs[], double moreXs[], double oldAs[] ,double newAs[], int num, int odd);

int findCutoff(int n, int accuracy)
{
	//Variable declarations
	int x=n;
	int numAssemblies=0;
	int count=0;
	int *numbods;
	int odd;

	//Timer creation
	float time1;
	float time2;
	time1=0;
	time2=0;
	cudaEvent_t beginEvent;
	cudaEvent_t endEvent;
	cudaEventCreate( &beginEvent );
	cudaEventCreate( &endEvent );

	//Determine the number of assemblies needed to completely assemble n bodies
	while(x!=1)
	{
		if( x%2==0)
		{
			x=x/2;
		}
		else
		{
			x++;
			x=x/2;
		}
		numAssemblies++;
	}

	//Allocate space for a matrix that holds the number of bodies at each level of assembly
	numbods=(int*)malloc(sizeof(int)*numAssemblies);
	
	//Fill numbods
	x=n;
	while(count<numAssemblies)
	{
		numbods[count]=x;
		if(x%2==0)
		{
			x=x/2;
		}
		else
		{
			x++;
			x=x/2;
		}
		count++;
	}
	count=1;
	//Begin process of finding most efficient number of assemblies
	while((count<numAssemblies) && time1>=time2)	//Compare time for gpu and cpu to complete assembly
	{
		//Create and allocate space for empty variables to mimic the dca algorithm at a level of assembly
		double* AF;
		double* Zs;
		double* Xs;
		double* nZs;
		double* nXs;
		double* AFo;
		AF=(double*)malloc(sizeof(double)*numbods[numAssemblies-1-count]*4*6);
		Zs=(double*)malloc(sizeof(double)*numbods[numAssemblies-1-count]*26*6);
		Xs=(double*)malloc(sizeof(double)*numbods[numAssemblies-1-count]*5*5);
		if(count==0)
		{
			nZs=(double*)malloc(sizeof(double)*26*6);
			nXs=(double*)malloc(sizeof(double)*25);
			AFo=(double*)malloc(sizeof(double)*6*4);
		}
		else
		{
			nZs=(double*)malloc(sizeof(double)*26*6*numbods[numAssemblies-count]);
			nXs=(double*)malloc(sizeof(double)*numbods[numAssemblies-count]*25);
			AFo=(double*)malloc(sizeof(double)*numbods[numAssemblies-count]*6*4);
		}

		//Check the parity of the number of bodies at the current level of assembly
		if(numbods[numAssemblies-1-count]%2==0)
		{
			odd=0;
		}
		else
		{
			odd=1;
		}
		
		//Check the gpu speed
		cudaEventRecord( beginEvent, 0 );	//Begin timer
		for(int i=0; i<accuracy; i++)	//Perform the operations a set number of times to vary accuracy
		{			
			//Test both assembly and disassembly at this level
			if(count==0)
			{
				cudaAssemble(Zs,Xs,numbods[numAssemblies-1-count],nZs,nXs,odd,1);
				cudaDisassemble(AFo,Zs,Xs,nZs,nXs,odd,numbods[numAssemblies-1-count],1,AF);
			}
			else
			{
				cudaAssemble(Zs,Xs,numbods[numAssemblies-1-count],nZs,nXs,odd,numbods[numAssemblies-count]);
				cudaDisassemble(AFo,Zs,Xs,nZs,nXs,odd,numbods[numAssemblies-1-count],numbods[numAssemblies-count],AF);
			}
			
		}
		//End timer
		cudaEventRecord( endEvent, 0 );
		cudaEventSynchronize( endEvent );
		cudaEventElapsedTime( &time1, beginEvent, endEvent );
		
		//Check the cpu speed
		cudaEventRecord( beginEvent,0);	//begin timing
		for(int i=0; i<accuracy; i++)	//Perfom the operations a set number of times to vary accuracy
		{
			//Test both assembly and disassembly at this level
			if(count==0)
			{
				Assemble(Zs,Xs,nZs,nXs,1,odd,numbods[numAssemblies-1-count]);
				Disassemble(nZs,nXs,Zs,Xs,AFo,AF,numbods[numAssemblies-count],odd);
			}
			else
			{
				Assemble(Zs,Xs,nZs,nXs,numbods[numAssemblies-count],odd,numbods[numAssemblies-1-count]);
				Disassemble(nZs,nXs,Zs,Xs,AFo,AF,numbods[numAssemblies-count],odd);
			}
		}
		//End timer
		cudaEventRecord( endEvent,0);
		cudaEventSynchronize(endEvent);
		cudaEventElapsedTime( &time2,beginEvent, endEvent);

		count++;
	}
	return numAssemblies-count;
}

	.file	"tmpxft_0039bb91_00000000-6_findCutoff.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3638:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3638:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z10findCutoffii
	.type	_Z10findCutoffii, @function
_Z10findCutoffii:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edi, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%r13d, %ebx
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movl	%esi, 52(%rsp)
	leaq	72(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	movl	$0x00000000, 64(%rsp)
	movl	$0x00000000, 68(%rsp)
	call	cudaEventCreate@PLT
	leaq	80(%rsp), %rdi
	call	cudaEventCreate@PLT
	movl	$2, %ecx
.L3:
	cmpl	$1, %ebx
	je	.L23
	testb	$1, %bl
	je	.L20
	incl	%ebx
.L20:
	movl	%ebx, %eax
	incl	%r12d
	cltd
	idivl	%ecx
	movl	%eax, %ebx
	jmp	.L3
.L23:
	movslq	%r12d, %r14
	salq	$2, %r14
	movq	%r14, %rdi
	call	malloc@PLT
	xorl	%ecx, %ecx
	movl	$2, %esi
	movq	%rax, %rbp
.L7:
	cmpl	%ecx, %r12d
	jle	.L24
	movl	%r13d, 0(%rbp,%rcx,4)
	testl	$1, %r13d
	je	.L21
	incl	%r13d
.L21:
	movl	%r13d, %eax
	incq	%rcx
	cltd
	idivl	%esi
	movl	%eax, %r13d
	jmp	.L7
.L24:
	leaq	64(%rsp), %rax
	addq	%r14, %rbp
	movq	%rax, 56(%rsp)
.L11:
	cmpl	%ebx, %r12d
	jle	.L16
	movss	64(%rsp), %xmm0
	comiss	68(%rsp), %xmm0
	jb	.L16
	movslq	-8(%rbp), %r14
	imulq	$192, %r14, %rdi
	movq	%r14, %r13
	call	malloc@PLT
	imulq	$1248, %r14, %rdi
	movq	%rax, 32(%rsp)
	call	malloc@PLT
	imulq	$200, %r14, %rdi
	movq	%rax, (%rsp)
	call	malloc@PLT
	movslq	-4(%rbp), %r15
	movq	%rax, 8(%rsp)
	imulq	$1248, %r15, %rdi
	movq	%r15, %r14
	call	malloc@PLT
	imulq	$200, %r15, %rdi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	imulq	$192, %r15, %rdi
	xorl	%r15d, %r15d
	movq	%rax, 24(%rsp)
	call	malloc@PLT
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	movq	%rax, 40(%rsp)
	movl	%r13d, %eax
	andl	$1, %eax
	movl	%eax, 48(%rsp)
	call	cudaEventRecord@PLT
.L12:
	movl	52(%rsp), %eax
	cmpl	%eax, %r15d
	jge	.L25
	pushq	%r8
	.cfi_def_cfa_offset 168
	movl	%r13d, %edx
	incl	%r15d
	pushq	%r14
	.cfi_def_cfa_offset 176
	movq	40(%rsp), %r8
	movq	32(%rsp), %rcx
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	movl	64(%rsp), %r9d
	call	_Z12cudaAssemblePdS_iS_S_ii@PLT
	popq	%r9
	.cfi_def_cfa_offset 168
	pushq	40(%rsp)
	.cfi_def_cfa_offset 176
	pushq	%r14
	.cfi_def_cfa_offset 184
	pushq	%r13
	.cfi_def_cfa_offset 192
	movl	80(%rsp), %r9d
	movq	56(%rsp), %r8
	movq	48(%rsp), %rcx
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	72(%rsp), %rdi
	call	_Z15cudaDisassemblePdS_S_S_S_iiiS_@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 160
	jmp	.L12
.L25:
	movq	80(%rsp), %rdi
	xorl	%esi, %esi
	xorl	%r15d, %r15d
	call	cudaEventRecord@PLT
	movq	80(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	80(%rsp), %rdx
	movq	72(%rsp), %rsi
	movq	56(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
.L14:
	movl	52(%rsp), %eax
	cmpl	%eax, %r15d
	jge	.L26
	pushq	%rax
	.cfi_def_cfa_offset 168
	movl	%r14d, %r8d
	incl	%r15d
	pushq	%r13
	.cfi_def_cfa_offset 176
	movl	64(%rsp), %r9d
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	movq	40(%rsp), %rcx
	movq	32(%rsp), %rdx
	call	_Z8AssemblePdS_S_S_iii@PLT
	popq	%rdx
	.cfi_def_cfa_offset 168
	popq	%rcx
	.cfi_def_cfa_offset 160
	movl	48(%rsp), %eax
	pushq	%rax
	.cfi_def_cfa_offset 168
	pushq	%r14
	.cfi_def_cfa_offset 176
	movq	48(%rsp), %r9
	movq	56(%rsp), %r8
	movq	24(%rsp), %rcx
	movq	16(%rsp), %rdx
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdi
	call	_Z11DisassemblePdS_S_S_S_S_ii@PLT
	popq	%rsi
	.cfi_def_cfa_offset 168
	popq	%rdi
	.cfi_def_cfa_offset 160
	jmp	.L14
.L26:
	movq	80(%rsp), %rdi
	xorl	%esi, %esi
	incl	%ebx
	subq	$4, %rbp
	call	cudaEventRecord@PLT
	movq	80(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	80(%rsp), %rdx
	movq	72(%rsp), %rsi
	leaq	68(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	jmp	.L11
.L16:
	movl	%r12d, %eax
	subl	%ebx, %eax
	movq	88(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	_Z10findCutoffii, .-_Z10findCutoffii
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3661:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3661:
	.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
	.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:

//
//	findCutoff.cu
//
//This file contains the function that determines the most
//efficient number of assemblies to perform on the gpu

#include <hip/hip_runtime.h>
#include <iostream>


void cudaAssemble(double Zs[],double Xs[], int num, double nZs[], double nXs[], int odd, int newlen);
void cudaDisassemble(double OldAF[], double Zs[], double Xs[],double nZs[], double nXs[], int odd, int morelen, int lesslen, double AF[]);
void Assemble(double Zs[], double Xs[],double nZs[], double nXs[], int len, int odd, int n);
void Disassemble(double lessZs[], double lessXs[],double moreZs[], double moreXs[], double oldAs[] ,double newAs[], int num, int odd);

int findCutoff(int n, int accuracy)
{
	//Variable declarations
	int x=n;
	int numAssemblies=0;
	int count=0;
	int *numbods;
	int odd;

	//Timer creation
	float time1;
	float time2;
	time1=0;
	time2=0;
	hipEvent_t beginEvent;
	hipEvent_t endEvent;
	hipEventCreate( &beginEvent );
	hipEventCreate( &endEvent );

	//Determine the number of assemblies needed to completely assemble n bodies
	while(x!=1)
	{
		if( x%2==0)
		{
			x=x/2;
		}
		else
		{
			x++;
			x=x/2;
		}
		numAssemblies++;
	}

	//Allocate space for a matrix that holds the number of bodies at each level of assembly
	numbods=(int*)malloc(sizeof(int)*numAssemblies);
	
	//Fill numbods
	x=n;
	while(count<numAssemblies)
	{
		numbods[count]=x;
		if(x%2==0)
		{
			x=x/2;
		}
		else
		{
			x++;
			x=x/2;
		}
		count++;
	}
	count=1;
	//Begin process of finding most efficient number of assemblies
	while((count<numAssemblies) && time1>=time2)	//Compare time for gpu and cpu to complete assembly
	{
		//Create and allocate space for empty variables to mimic the dca algorithm at a level of assembly
		double* AF;
		double* Zs;
		double* Xs;
		double* nZs;
		double* nXs;
		double* AFo;
		AF=(double*)malloc(sizeof(double)*numbods[numAssemblies-1-count]*4*6);
		Zs=(double*)malloc(sizeof(double)*numbods[numAssemblies-1-count]*26*6);
		Xs=(double*)malloc(sizeof(double)*numbods[numAssemblies-1-count]*5*5);
		if(count==0)
		{
			nZs=(double*)malloc(sizeof(double)*26*6);
			nXs=(double*)malloc(sizeof(double)*25);
			AFo=(double*)malloc(sizeof(double)*6*4);
		}
		else
		{
			nZs=(double*)malloc(sizeof(double)*26*6*numbods[numAssemblies-count]);
			nXs=(double*)malloc(sizeof(double)*numbods[numAssemblies-count]*25);
			AFo=(double*)malloc(sizeof(double)*numbods[numAssemblies-count]*6*4);
		}

		//Check the parity of the number of bodies at the current level of assembly
		if(numbods[numAssemblies-1-count]%2==0)
		{
			odd=0;
		}
		else
		{
			odd=1;
		}
		
		//Check the gpu speed
		hipEventRecord( beginEvent, 0 );	//Begin timer
		for(int i=0; i<accuracy; i++)	//Perform the operations a set number of times to vary accuracy
		{			
			//Test both assembly and disassembly at this level
			if(count==0)
			{
				cudaAssemble(Zs,Xs,numbods[numAssemblies-1-count],nZs,nXs,odd,1);
				cudaDisassemble(AFo,Zs,Xs,nZs,nXs,odd,numbods[numAssemblies-1-count],1,AF);
			}
			else
			{
				cudaAssemble(Zs,Xs,numbods[numAssemblies-1-count],nZs,nXs,odd,numbods[numAssemblies-count]);
				cudaDisassemble(AFo,Zs,Xs,nZs,nXs,odd,numbods[numAssemblies-1-count],numbods[numAssemblies-count],AF);
			}
			
		}
		//End timer
		hipEventRecord( endEvent, 0 );
		hipEventSynchronize( endEvent );
		hipEventElapsedTime( &time1, beginEvent, endEvent );
		
		//Check the cpu speed
		hipEventRecord( beginEvent,0);	//begin timing
		for(int i=0; i<accuracy; i++)	//Perfom the operations a set number of times to vary accuracy
		{
			//Test both assembly and disassembly at this level
			if(count==0)
			{
				Assemble(Zs,Xs,nZs,nXs,1,odd,numbods[numAssemblies-1-count]);
				Disassemble(nZs,nXs,Zs,Xs,AFo,AF,numbods[numAssemblies-count],odd);
			}
			else
			{
				Assemble(Zs,Xs,nZs,nXs,numbods[numAssemblies-count],odd,numbods[numAssemblies-1-count]);
				Disassemble(nZs,nXs,Zs,Xs,AFo,AF,numbods[numAssemblies-count],odd);
			}
		}
		//End timer
		hipEventRecord( endEvent,0);
		hipEventSynchronize(endEvent);
		hipEventElapsedTime( &time2,beginEvent, endEvent);

		count++;
	}
	return numAssemblies-count;
}

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

                                        # End of file scope inline assembly
	.globl	_Z10findCutoffii                # -- Begin function _Z10findCutoffii
	.type	_Z10findCutoffii,@function
_Z10findCutoffii:                       # @_Z10findCutoffii
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$152, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, 32(%rsp)                  # 4-byte Spill
	movl	%edi, %ebx
	xorl	%ebp, %ebp
	movl	%ebp, 20(%rsp)
	movl	%ebp, 36(%rsp)
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	leaq	8(%rsp), %rdi
	callq	hipEventCreate
	movl	$1, %r15d
	cmpl	$1, %ebx
	je	.LBB0_16
# %bb.1:                                # %.lr.ph.preheader
	xorl	%ebp, %ebp
	movl	$1, %ecx
	movl	%ebx, %eax
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%ebp, %r12d
	movq	%rcx, %r14
	movl	%eax, %edx
	andl	$1, %edx
	addl	%eax, %edx
	movl	%edx, %eax
	sarl	%eax
	leal	1(%r12), %ebp
	incq	%rcx
	cmpl	$2, %edx
	jne	.LBB0_2
# %bb.3:                                # %.lr.ph150.preheader
	movl	%ebp, %r13d
	leaq	(,%r13,4), %rdi
	callq	malloc
	movq	%rax, 136(%rsp)                 # 8-byte Spill
	movl	%ebx, %ecx
.LBB0_4:                                # %.lr.ph150
                                        # =>This Inner Loop Header: Depth=1
	movl	%ebx, (%rax)
	andl	$1, %ecx
	addl	%ebx, %ecx
	sarl	%ecx
	addq	$4, %rax
	movl	%ecx, %ebx
	decq	%r14
	jne	.LBB0_4
# %bb.5:                                # %.preheader
	testl	%r12d, %r12d
	je	.LBB0_16
# %bb.6:                                # %.lr.ph160
	movl	%ebp, 68(%rsp)                  # 4-byte Spill
	movl	$1, %r15d
	movq	%r12, 128(%rsp)                 # 8-byte Spill
	movq	%r13, 120(%rsp)                 # 8-byte Spill
.LBB0_7:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_9 Depth 2
                                        #     Child Loop BB0_11 Depth 2
	movl	%r12d, %eax
	subl	%r15d, %eax
	cltq
	movq	136(%rsp), %rbx                 # 8-byte Reload
	movslq	(%rbx,%rax,4), %r14
	movq	%r14, %rax
	shlq	$6, %rax
	leaq	(%rax,%rax,2), %rdi
	callq	malloc
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	imulq	$1248, %r14, %rdi               # imm = 0x4E0
	callq	malloc
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	movq	%r14, 40(%rsp)                  # 8-byte Spill
	imulq	$200, %r14, %rdi
	callq	malloc
	movq	%rax, %rbp
	movq	%r13, %rax
	movq	%r15, 144(%rsp)                 # 8-byte Spill
	subq	%r15, %rax
	movslq	(%rbx,%rax,4), %r15
	imulq	$1248, %r15, %rdi               # imm = 0x4E0
	callq	malloc
	movq	%rax, %rbx
	imulq	$200, %r15, %rdi
	callq	malloc
	movq	%rax, %r14
	movq	%r15, %rax
	shlq	$6, %rax
	leaq	(%rax,%rax,2), %rdi
	callq	malloc
	movq	%rax, %r13
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	32(%rsp), %r12d                 # 4-byte Reload
	testl	%r12d, %r12d
	jle	.LBB0_12
# %bb.8:                                #   in Loop: Header=BB0_7 Depth=1
	movq	%r13, 112(%rsp)                 # 8-byte Spill
	movq	40(%rsp), %r13                  # 8-byte Reload
                                        # kill: def $r13d killed $r13d killed $r13 def $r13
	andl	$1, %r13d
	movq	%r13, 104(%rsp)                 # 8-byte Spill
	movq	%rbx, 96(%rsp)                  # 8-byte Spill
	movq	%rbp, 48(%rsp)                  # 8-byte Spill
	movq	%r14, 88(%rsp)                  # 8-byte Spill
	movq	%r15, 56(%rsp)                  # 8-byte Spill
.LBB0_9:                                # %.lr.ph153
                                        #   Parent Loop BB0_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movq	80(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %rdi
	movq	56(%rsp), %r14                  # 8-byte Reload
	movq	%r14, %rsi
	movq	48(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	movq	104(%rsp), %rbp                 # 8-byte Reload
	movq	%rbp, %rcx
	movq	96(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %r8
	movq	112(%rsp), %r15                 # 8-byte Reload
	movl	%r15d, %r9d
	pushq	64(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	callq	_Z12cudaAssemblePdS_iS_S_ii
	addq	$8, %rsp
	.cfi_adjust_cfa_offset -8
	movq	120(%rsp), %rdi                 # 8-byte Reload
	movq	%rbx, %rsi
	movq	%r14, %rdx
	movq	%rbp, %rcx
	movq	%r13, %r8
	movl	%r15d, %r9d
	movq	64(%rsp), %r15                  # 8-byte Reload
	pushq	88(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	pushq	64(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	callq	_Z15cudaDisassemblePdS_S_S_S_iiiS_
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	decl	%r12d
	jne	.LBB0_9
# %bb.10:                               # %._crit_edge154
                                        #   in Loop: Header=BB0_7 Depth=1
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	20(%rsp), %rdi
	callq	hipEventElapsedTime
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movl	32(%rsp), %eax                  # 4-byte Reload
	movl	%eax, %r12d
	testl	%eax, %eax
	movq	80(%rsp), %r13                  # 8-byte Reload
	movq	72(%rsp), %rbp                  # 8-byte Reload
	movq	48(%rsp), %r14                  # 8-byte Reload
	jle	.LBB0_13
.LBB0_11:                               # %.lr.ph157
                                        #   Parent Loop BB0_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movq	%rbp, %rdi
	movq	%r14, %rsi
	movq	96(%rsp), %rbx                  # 8-byte Reload
	movq	%rbp, %r14
	movq	104(%rsp), %rbp                 # 8-byte Reload
	movq	%rbp, %rdx
	movq	%rbx, %rcx
	movl	%r15d, %r8d
	movq	112(%rsp), %r15                 # 8-byte Reload
	movl	%r15d, %r9d
	pushq	48(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	callq	_Z8AssemblePdS_S_S_iii
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movq	%rbp, %rdi
	movq	%r14, %rbp
	movq	48(%rsp), %r14                  # 8-byte Reload
	movq	%rbx, %rsi
	movq	%rbp, %rdx
	movq	%r14, %rcx
	movq	112(%rsp), %r8                  # 8-byte Reload
	movq	%r13, %r9
	pushq	%r15
	movq	64(%rsp), %r15                  # 8-byte Reload
	.cfi_adjust_cfa_offset 8
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	callq	_Z11DisassemblePdS_S_S_S_S_ii
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	decl	%r12d
	jne	.LBB0_11
	jmp	.LBB0_13
.LBB0_12:                               # %._crit_edge158.critedge
                                        #   in Loop: Header=BB0_7 Depth=1
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	20(%rsp), %rdi
	callq	hipEventElapsedTime
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
.LBB0_13:                               # %._crit_edge158
                                        #   in Loop: Header=BB0_7 Depth=1
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	8(%rsp), %rdi
	callq	hipEventSynchronize
	movq	24(%rsp), %rsi
	movq	8(%rsp), %rdx
	leaq	36(%rsp), %rdi
	callq	hipEventElapsedTime
	movq	144(%rsp), %r15                 # 8-byte Reload
	incq	%r15
	movq	120(%rsp), %r13                 # 8-byte Reload
	cmpq	%r13, %r15
	movq	128(%rsp), %r12                 # 8-byte Reload
	jae	.LBB0_15
# %bb.14:                               # %._crit_edge158
                                        #   in Loop: Header=BB0_7 Depth=1
	movss	20(%rsp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	ucomiss	36(%rsp), %xmm0
	jae	.LBB0_7
.LBB0_15:                               # %._crit_edge161.loopexit
	movl	68(%rsp), %ebp                  # 4-byte Reload
.LBB0_16:                               # %._crit_edge161
	subl	%r15d, %ebp
	movl	%ebp, %eax
	addq	$152, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z10findCutoffii, .Lfunc_end0-_Z10findCutoffii
	.cfi_endproc
                                        # -- End function
	.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 __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
