//	cudaDCA.cu
//
//This file contains the recursive DCA function, and the function that is used to invoke DCA and
//interperate the results.

//Included Files

#include <iostream>

//Function Prototypes
//	Functions found in this file
void RecDCA(double Zs[], int n, int i, double AF[], int cut_off,double Xs[]);

//	Functions found in Init_setup.cu
void CudaInitialize(double m[], double l[], double I[], double x[], int n, double Zs[]);

//	Functions found in Assemble_setup.cu
void cudaAssemble(double Zs[],double Xs[], int num, double nZs[], double nXs[], int odd, int newlen);

//	Functions found in Disassemble_setup.cu
void cudaDisassemble(double OldAF[], double Zs[], double Xs[],double nZs[], double nXs[], int odd, int morelen, int lesslen, double AF[]);

//	Functions found in Assemble.cu

//	Functions found in SolveBCs.cu
void solve_BCs(double Zs[], double Xs[], double AF[]);

void printa(double A[], int n);
void printm(double A[6][6]);
void update(double Mass[], double Inertia[], double Init_Zetas[], double Zetas[], int n, double Body_Vectors[], double ang_vels[], double DCMs[],double Ps[], double PdotUs[],double Ds[],bool active_DOF[], double speeds[],int dof_index[]);
void kinematics(bool Active_DOF[], double Coords[], double DCMs[], double speeds[], double omegas[], int dof_index[],int n);
void getGenAccel(double Y[], double AF[],double omegas[], bool Active_DOF[], int n,double PdotUs[], double Ps[]);
void multPinv(double Ps[], double tempy[], int b, int n);
void RecDCA(double Zs[], int n, int i, double AF[], int cut_off,double Xs[], double DCMs[], double omegas[], int dof_index[], bool Active_DOF[], double Speeds[],double PdotUs[], double Ds[], int Pindex[],int numbods);
void Assemble(double Zs[], double Xs[],double nZs[], double nXs[], int len, int odd, int n, double PdotUs[], double Ds[], int Pindex[],int numbods, bool active_DOF[]);
void Disassemble(double lessZs[], double lessXs[],double moreZs[], double moreXs[], double oldAs[] ,double newAs[], int num, int odd,double Ds[], int Pindex[],int numbods, double PdotUs[]);
void multPinv(double Ps[], double tempy[], int b, int n);
void Mat61Mult2(double A[6][6], double B[6], double C[6]);
void printzz(double A[], int n, int b, int zeta);


//DCAhelp:
//	Function that prepares the list of bodies for DCA and finds the final state vector
//		state is the state of the system at that timestep
//		bs is a list of bodies used for initialization
//		js is a list of joints
//		n is the number of bodies
//		Y is the array where the final velocities and accelerations are stored
void DCAhelp(int n,bool Active_DOF[],double Coords[], double Speeds[], int dof_index[], double initZetas[],double Mass[], double Inertia[],int DOF, double Y[], int cut_off, double Body_Vectors[])
{
	double *Zetas = new double[n*26*6];
	double *Xs = new double[n*5*5];
	double *DCMs = new double[n*3*3];
	double *omegas= new double[n*3];
	double *AF = new double[n*4*6];
	double *Ps = new double[n*6*6];
	double *PdotUs = new double[n*6];
	double *Ds = new double[n*6*6];
	int *Pindex = new int[n];
	for(int i =0; i<n; i++)
	{
		Pindex[i]=i;
	}

	kinematics(Active_DOF, Coords, DCMs, Speeds, omegas, dof_index, n);

	update(Mass, Inertia, initZetas, Zetas, n, Body_Vectors, omegas, DCMs,Ps,PdotUs,Ds,Active_DOF,Speeds,dof_index);


	RecDCA(Zetas, n, 0, AF, cut_off,Xs,DCMs,omegas,dof_index,Active_DOF,Speeds,PdotUs,Ds,Pindex,n);

	getGenAccel(Y,AF,omegas,Active_DOF,n,PdotUs,Ps);
	//Free memory
	delete[] Zetas;
	delete[] Xs;
	delete[] DCMs;
	delete[] omegas;
	delete[] AF;
	delete[] Ps;
	delete[] PdotUs;
	delete[] Ds;
	delete[] Pindex;
}

void printzz(double A[], int n, int b, int zeta)
{
	std::cout<<std::endl;
	for(int r = 0; r<6; r++)
	{
		for(int c =0; c<6; c++)
		{
			std::cout<<A[c+zeta+n*26*r+b*26]<<"\t";
		}
	std::cout<<std::endl;
	}
}
void getGenAccel(double Y[], double AF[],double omegas[], bool Active_DOF[], int n, double PdotUs[], double Ps[])
{
	int c =0;
	int l =0;
	//double A1[6];
	//double A2[6];
	double tempy[6];

	for(int i =0; i<6; i++)
	{
		tempy[i]=AF[i*4*n]-PdotUs[i];
	}
	multPinv(Ps,tempy,0,n);
	
	
	for(int i =0; i<6; i++)
	{
		if(Active_DOF[i])
		{
			Y[c]=tempy[c];
			c++;
		}
	}	
	for(int i =1; i<n; i++)
	{ l =0;
		for(int k =0; k<6; k++)
		{
			tempy[k]=AF[i*4+k*4*n-2]-AF[i*4+k*4*n]-PdotUs[i*6+k];
		}

		multPinv(Ps,tempy,i,n);
		for(int j=0; j<6; j++)
		{
			if(Active_DOF[6*i+j])
			{
				Y[c]=tempy[l];
				c++;
				l++;
			}
		}
	}
}

void multPinv(double Ps[], double tempy[], int b, int n)
{
	double Pinv[6][6];
	
	for( int r =0; r<6; r++)
	{
		for(int c =0; c<6; c++)
		{
			Pinv[c][r]=Ps[c+b*6+r*6*n];
		}
	}
	
	Mat61Mult2(Pinv,tempy,tempy);
}
	
			
//RecDCA:
//	Function used to solve for the velocty and acceleration of the list of bodies at
//	the current timestep.  This is a recursive function that continues to call itself
//	until there is a single body left.  Once at this point the accelerations and forces
//	are found using the boundary conditions of a pendulum.  These values are then returned
//	to the previous level of recursion which then finds the new accelerations and forces
//	for the disassembled bodies.  This continues until all bodies are disassembled, ultimately
//	returning the forces and accelerations at both handles of every body in the system.  These
//	results are intererated by DCAhelp (above) to obtain the actual generalized accelerations.  
//		bodies is the list of bodies
//		n is the number of bodies
//		i is the level of recursion
//		AF is the array in which the accelerations and forces at the handles of the bodies 
//			will be stored.
void RecDCA(double Zs[], int n, int i, double AF[], int cut_off,double Xs[], double DCMs[], double omegas[], int dof_index[], bool Active_DOF[], double Speeds[],double PdotUs[], double Ds[], int Pindex[],int numbods)
{
	if (n==1)	//If there is only 1 body
	{	
		
		solve_BCs(Zs,Xs, AF);	//Solve the boundary conditions and find the acceleratins and forces
	
		
	}
	else	//If there is more than 1 body
	{	
		int newlen;	//New number of bodies after assembly
		bool odd = 0;	//Flag to keep track of the parity of the length of the list of
		
		if(n % 2 == 0)	//If there is an even number of bodies
		{
			newlen = (int) (n/2);	//The new number of bodies will be half the original number
		}
		else	//If there is an odd number of bodies
		{
			newlen = (int)((n+1)/2);	//The new number of bodies will be half the original number
										//rounded down, plus 1
			odd = 1;	//odd is set to 1 because there are an odd number of bodies
		}
		double *nZs=new double[newlen*26*6];
		double *nXs=new double[newlen*5*5];
		int *nPindex = new int[newlen];

		for(int k =0; k<newlen-odd; k++)
		{
			nPindex[i]=Pindex[i*2];
		}
		if(odd)
		{
			nPindex[newlen-1]=Pindex[n-1];
		}

/*
		if(i<cut_off)
		{
			cudaAssemble(Zs,Xs, n, nZs, nXs , odd, newlen);	//Assemble the bodies, storing them in newbds			
		}
		else
		{*/

			Assemble(Zs,Xs,nZs,nXs, newlen,odd, n,PdotUs,Ds,Pindex,numbods,Active_DOF);	//Assemble the bodies, storing them in newbds


		//}

		//Create a list of accelerations and forces of the new bodies.
		double *AFo= new double[6*newlen*4];

		//Call the DCA function again to return the accelerations and forces of the new bodies
		RecDCA(nZs,newlen,i+1 ,AFo,cut_off,nXs,DCMs,omegas,dof_index,Active_DOF,Speeds,PdotUs,Ds,nPindex,numbods);

		//Knowing the accelerations and forces of the new bodies, the new bodies can be disassembled
		//again, finding the accelerations and forces of the old bodies.
		/*if(i<cut_off)
		{
			
			cudaDisassemble(AFo, Zs,Xs , nZs,nXs, odd, n, newlen, AF);
			
		}
		else
		{*/
		Disassemble(nZs,nXs,Zs,Xs,AFo, AF, newlen,odd,Ds,Pindex,numbods,PdotUs);
		//}
		//Free memory
		delete[] nZs;
		
		delete[] nXs;
		
		delete[] AFo;

		delete[] nPindex;
		 
	
	}
}
		
			


	.file	"tmpxft_003b43f8_00000000-6_hybridDCA.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3642:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3642:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"\t"
	.text
	.globl	_Z7printzzPdiii
	.type	_Z7printzzPdiii, @function
_Z7printzzPdiii:
.LFB3636:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movslq	%ecx, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	_ZSt4cout(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movslq	%esi, %rbp
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movslq	%edx, %rbx
	imulq	$208, %rbp, %rbp
	imulq	$26, %rbx, %rbx
	pushq	%r8
	.cfi_def_cfa_offset 64
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	addq	%r13, %rbx
	leaq	(%r14,%rbx,8), %r13
	movl	$6, %r14d
.L3:
	xorl	%ebx, %ebx
.L4:
	movsd	0(%r13,%rbx,8), %xmm0
	movq	%r12, %rdi
	incq	%rbx
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movl	$1, %edx
	movq	%r15, %rsi
	movq	%rax, %rdi
	call	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l@PLT
	cmpq	$6, %rbx
	jne	.L4
	movq	%r12, %rdi
	addq	%rbp, %r13
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	decl	%r14d
	jne	.L3
	popq	%rax
	.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
.LFE3636:
	.size	_Z7printzzPdiii, .-_Z7printzzPdiii
	.globl	_Z8multPinvPdS_ii
	.type	_Z8multPinvPdS_ii, @function
_Z8multPinvPdS_ii:
.LFB3638:
	.cfi_startproc
	endbr64
	movslq	%edx, %rdx
	movslq	%ecx, %rcx
	subq	$312, %rsp
	.cfi_def_cfa_offset 320
	movq	%fs:40, %rax
	movq	%rax, 296(%rsp)
	xorl	%eax, %eax
	imulq	$48, %rdx, %rdx
	leaq	8(%rsp), %rax
	imulq	$48, %rcx, %rcx
	leaq	56(%rsp), %r10
	movq	%rax, %r9
	addq	%rdx, %rdi
.L10:
	movq	%rax, %r8
	xorl	%edx, %edx
.L11:
	movsd	(%rdi,%rdx,8), %xmm0
	incq	%rdx
	addq	$48, %r8
	movsd	%xmm0, -48(%r8)
	cmpq	$6, %rdx
	jne	.L11
	addq	$8, %rax
	addq	%rcx, %rdi
	cmpq	%r10, %rax
	jne	.L10
	movq	%rsi, %rdx
	movq	%r9, %rdi
	call	_Z10Mat61Mult2PA6_dPdS1_@PLT
	movq	296(%rsp), %rax
	subq	%fs:40, %rax
	je	.L13
	call	__stack_chk_fail@PLT
.L13:
	addq	$312, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3638:
	.size	_Z8multPinvPdS_ii, .-_Z8multPinvPdS_ii
	.globl	_Z11getGenAccelPdS_S_PbiS_S_
	.type	_Z11getGenAccelPdS_S_PbiS_S_, @function
_Z11getGenAccelPdS_S_PbiS_S_:
.LFB3637:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rcx, %r11
	movq	%rsi, %r15
	movq	%rsi, %rcx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rdi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leal	0(,%r8,4), %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movslq	%r12d, %r12
	movl	%r8d, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	salq	$3, %r12
	movq	%r9, %rbx
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	160(%rsp), %rax
	leaq	40(%rsp), %r14
	movq	%rax, (%rsp)
	movq	%fs:40, %rdx
	movq	%rdx, 88(%rsp)
	xorl	%edx, %edx
.L17:
	movsd	(%rcx), %xmm0
	subsd	(%rbx,%rdx), %xmm0
	addq	$8, %rdx
	addq	%r12, %rcx
	movsd	%xmm0, -8(%rdx,%r14)
	cmpq	$48, %rdx
	jne	.L17
	movq	(%rsp), %rdi
	xorl	%edx, %edx
	movl	%ebp, %ecx
	movq	%r14, %rsi
	movq	%r11, 8(%rsp)
	call	_Z8multPinvPdS_ii
	movq	8(%rsp), %r11
	xorl	%edx, %edx
	xorl	%r10d, %r10d
.L19:
	cmpb	$0, (%r11,%rdx)
	je	.L18
	movslq	%r10d, %rcx
	incl	%r10d
	movsd	40(%rsp,%rcx,8), %xmm0
	movsd	%xmm0, 0(%r13,%rcx,8)
.L18:
	incq	%rdx
	cmpq	$6, %rdx
	jne	.L19
	leaq	32(%r15), %rax
	addq	$6, %r11
	addq	$48, %rbx
	movl	$1, %r15d
.L20:
	cmpl	%ebp, %r15d
	jge	.L31
	movq	%rax, %rcx
	xorl	%edx, %edx
.L21:
	movsd	-16(%rcx), %xmm0
	subsd	(%rcx), %xmm0
	addq	%r12, %rcx
	subsd	(%rbx,%rdx), %xmm0
	movsd	%xmm0, (%r14,%rdx)
	addq	$8, %rdx
	cmpq	$48, %rdx
	jne	.L21
	movq	(%rsp), %rdi
	movl	%ebp, %ecx
	movl	%r15d, %edx
	movq	%r14, %rsi
	movq	%r11, 24(%rsp)
	movq	%rax, 16(%rsp)
	movl	%r10d, 8(%rsp)
	call	_Z8multPinvPdS_ii
	movq	24(%rsp), %r11
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	movq	16(%rsp), %rax
	movl	8(%rsp), %r10d
.L23:
	cmpb	$0, (%r11,%rdx)
	je	.L22
	movslq	%ecx, %rdi
	movslq	%r10d, %rsi
	incl	%ecx
	incl	%r10d
	movsd	40(%rsp,%rdi,8), %xmm0
	movsd	%xmm0, 0(%r13,%rsi,8)
.L22:
	incq	%rdx
	cmpq	$6, %rdx
	jne	.L23
	incl	%r15d
	addq	$6, %r11
	addq	$32, %rax
	addq	$48, %rbx
	jmp	.L20
.L31:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	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
.LFE3637:
	.size	_Z11getGenAccelPdS_S_PbiS_S_, .-_Z11getGenAccelPdS_S_PbiS_S_
	.globl	_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i
	.type	_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i, @function
_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i:
.LFB3639:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	176(%rsp), %rax
	movq	%rdi, 32(%rsp)
	movl	%edx, 64(%rsp)
	movq	216(%rsp), %r15
	movq	%rax, 72(%rsp)
	movq	184(%rsp), %rax
	movq	%rcx, 48(%rsp)
	movq	224(%rsp), %r13
	movq	%rax, 80(%rsp)
	movq	192(%rsp), %rax
	movl	%r8d, 68(%rsp)
	movq	232(%rsp), %r12
	movq	%rax, 88(%rsp)
	movq	200(%rsp), %rax
	movq	%r9, 40(%rsp)
	movq	%rax, 56(%rsp)
	movq	208(%rsp), %rax
	movq	%rax, 96(%rsp)
	movl	240(%rsp), %r14d
	cmpl	$1, %esi
	jne	.L33
	addq	$120, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movq	%rcx, %rdx
	movq	%r9, %rsi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_Z9solve_BCsPdS_S_@PLT
.L33:
	.cfi_restore_state
	testl	$1, %esi
	jne	.L34
	movl	%esi, %eax
	movl	$2, %ecx
	cltd
	idivl	%ecx
	xorl	%edx, %edx
	movl	%eax, 12(%rsp)
	jmp	.L35
.L34:
	leal	1(%rsi), %eax
	movl	$2, %ecx
	cltd
	idivl	%ecx
	movb	$1, %dl
	movl	%eax, 12(%rsp)
.L35:
	imull	$156, 12(%rsp), %edi
	movl	%esi, 108(%rsp)
	movabsq	$1152921504606846975, %rax
	movb	%dl, 104(%rsp)
	movslq	%edi, %rdi
	cmpq	%rdi, %rax
	jb	.L36
	salq	$3, %rdi
	call	_Znam@PLT
	imull	$25, 12(%rsp), %edi
	movq	%rax, 16(%rsp)
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	_Znam@PLT
	movslq	12(%rsp), %rbp
	movq	%rax, 24(%rsp)
	salq	$2, %rbp
	movq	%rbp, %rdi
	call	_Znam@PLT
	movzbl	104(%rsp), %r10d
	movl	12(%rsp), %ecx
	movq	%rax, %rbx
	movl	64(%rsp), %eax
	movl	108(%rsp), %esi
	movl	%r10d, %edx
	subl	%r10d, %ecx
	addl	%eax, %eax
	cltq
	leaq	(%r12,%rax,4), %rdi
	movslq	64(%rsp), %rax
	leaq	(%rbx,%rax,4), %r8
	xorl	%eax, %eax
	jmp	.L37
.L36:
	call	__cxa_throw_bad_array_new_length@PLT
.L37:
	cmpl	%eax, %ecx
	jle	.L44
	movl	(%rdi), %r9d
	incl	%eax
	movl	%r9d, (%r8)
	jmp	.L37
.L44:
	testb	%dl, %dl
	je	.L39
	movslq	%esi, %rax
	movl	-4(%r12,%rax,4), %eax
	movl	%eax, -4(%rbx,%rbp)
.L39:
	pushq	56(%rsp)
	.cfi_def_cfa_offset 184
	movl	%r10d, %r9d
	pushq	%r14
	.cfi_def_cfa_offset 192
	pushq	%r12
	.cfi_def_cfa_offset 200
	pushq	%r13
	.cfi_def_cfa_offset 208
	pushq	%r15
	.cfi_def_cfa_offset 216
	pushq	%rsi
	.cfi_def_cfa_offset 224
	movq	72(%rsp), %rcx
	movl	60(%rsp), %r8d
	movq	64(%rsp), %rdx
	movq	88(%rsp), %rsi
	movq	80(%rsp), %rdi
	movl	%r10d, 152(%rsp)
	call	_Z8AssemblePdS_S_S_iiiS_S_PiiPb@PLT
	imull	$24, 60(%rsp), %edi
	addq	$48, %rsp
	.cfi_def_cfa_offset 176
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	_Znam@PLT
	movl	64(%rsp), %edx
	movq	%rax, %rbp
	pushq	%rax
	.cfi_def_cfa_offset 184
	pushq	%r14
	.cfi_def_cfa_offset 192
	movq	%rbp, %rcx
	incl	%edx
	pushq	%rbx
	.cfi_def_cfa_offset 200
	pushq	%r13
	.cfi_def_cfa_offset 208
	pushq	%r15
	.cfi_def_cfa_offset 216
	pushq	136(%rsp)
	.cfi_def_cfa_offset 224
	pushq	104(%rsp)
	.cfi_def_cfa_offset 232
	pushq	144(%rsp)
	.cfi_def_cfa_offset 240
	pushq	144(%rsp)
	.cfi_def_cfa_offset 248
	pushq	144(%rsp)
	.cfi_def_cfa_offset 256
	movl	148(%rsp), %r8d
	movq	104(%rsp), %r9
	movl	92(%rsp), %esi
	movq	96(%rsp), %rdi
	call	_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i
	addq	$80, %rsp
	.cfi_def_cfa_offset 176
	movq	%rbp, %r8
	pushq	%r15
	.cfi_def_cfa_offset 184
	pushq	%r14
	.cfi_def_cfa_offset 192
	pushq	%r12
	.cfi_def_cfa_offset 200
	pushq	%r13
	.cfi_def_cfa_offset 208
	movl	136(%rsp), %r10d
	pushq	%r10
	.cfi_def_cfa_offset 216
	movl	52(%rsp), %eax
	pushq	%rax
	.cfi_def_cfa_offset 224
	movq	96(%rsp), %r9
	movq	88(%rsp), %rcx
	movq	80(%rsp), %rdx
	movq	72(%rsp), %rsi
	movq	64(%rsp), %rdi
	call	_Z11DisassemblePdS_S_S_S_S_iiS_PiiS_@PLT
	movq	64(%rsp), %rdi
	addq	$48, %rsp
	.cfi_def_cfa_offset 176
	call	_ZdaPv@PLT
	movq	24(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
	addq	$120, %rsp
	.cfi_def_cfa_offset 56
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_ZdaPv@PLT
	.cfi_endproc
.LFE3639:
	.size	_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i, .-_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i
	.globl	_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_
	.type	_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_, @function
_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_:
.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
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edi, %ebx
	imull	$156, %edi, %edi
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movslq	%edi, %rdi
	movq	176(%rsp), %rax
	movq	%rsi, 8(%rsp)
	movq	%rdx, 104(%rsp)
	movq	%rax, 64(%rsp)
	movq	184(%rsp), %rax
	movq	%rcx, 32(%rsp)
	movq	%rax, 72(%rsp)
	movq	200(%rsp), %rax
	movq	%r8, 40(%rsp)
	movq	%rax, 80(%rsp)
	movl	208(%rsp), %eax
	movq	%r9, 56(%rsp)
	movl	%eax, 92(%rsp)
	movq	216(%rsp), %rax
	movq	%rax, 96(%rsp)
	movabsq	$1152921504606846975, %rax
	cmpq	%rdi, %rax
	jb	.L46
	salq	$3, %rdi
	call	_Znam@PLT
	imull	$25, %ebx, %edi
	movq	%rax, 16(%rsp)
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	_Znam@PLT
	leal	(%rbx,%rbx,8), %edi
	movslq	%edi, %rdi
	movq	%rax, 48(%rsp)
	salq	$3, %rdi
	call	_Znam@PLT
	leal	(%rbx,%rbx,2), %edi
	movslq	%edi, %rdi
	movq	%rax, (%rsp)
	salq	$3, %rdi
	call	_Znam@PLT
	imull	$24, %ebx, %edi
	movq	%rax, %r15
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	_Znam@PLT
	movq	%rax, 24(%rsp)
	imull	$36, %ebx, %eax
	cltq
	leaq	0(,%rax,8), %r12
	movq	%r12, %rdi
	call	_Znam@PLT
	imull	$6, %ebx, %edi
	movq	%rax, %r14
	movslq	%edi, %rdi
	salq	$3, %rdi
	call	_Znam@PLT
	movq	%r12, %rdi
	movq	%rax, %rbp
	call	_Znam@PLT
	movslq	%ebx, %rdi
	salq	$2, %rdi
	movq	%rax, %r13
	call	_Znam@PLT
	movq	104(%rsp), %rsi
	movq	%rax, %r12
	xorl	%eax, %eax
	jmp	.L47
.L46:
	call	__cxa_throw_bad_array_new_length@PLT
.L47:
	cmpl	%eax, %ebx
	jle	.L50
	movl	%eax, (%r12,%rax,4)
	incq	%rax
	jmp	.L47
.L50:
	pushq	%rax
	.cfi_def_cfa_offset 184
	movq	%r15, %r8
	pushq	%rbx
	.cfi_def_cfa_offset 192
	movq	56(%rsp), %r9
	movq	24(%rsp), %rdi
	movq	48(%rsp), %rcx
	movq	16(%rsp), %rdx
	call	_Z10kinematicsPbPdS0_S0_S0_Pii@PLT
	popq	%rdx
	.cfi_def_cfa_offset 184
	popq	%rcx
	.cfi_def_cfa_offset 176
	pushq	40(%rsp)
	.cfi_def_cfa_offset 184
	pushq	40(%rsp)
	.cfi_def_cfa_offset 192
	movl	%ebx, %r8d
	pushq	24(%rsp)
	.cfi_def_cfa_offset 200
	pushq	%r13
	.cfi_def_cfa_offset 208
	pushq	%rbp
	.cfi_def_cfa_offset 216
	pushq	%r14
	.cfi_def_cfa_offset 224
	pushq	48(%rsp)
	.cfi_def_cfa_offset 232
	pushq	%r15
	.cfi_def_cfa_offset 240
	movq	120(%rsp), %rdx
	movq	136(%rsp), %rsi
	movq	160(%rsp), %r9
	movq	80(%rsp), %rcx
	movq	128(%rsp), %rdi
	call	_Z6updatePdS_S_S_iS_S_S_S_S_S_PbS_Pi@PLT
	addq	$56, %rsp
	.cfi_def_cfa_offset 184
	movl	%ebx, %esi
	xorl	%edx, %edx
	pushq	%rbx
	.cfi_def_cfa_offset 192
	pushq	%r12
	.cfi_def_cfa_offset 200
	pushq	%r13
	.cfi_def_cfa_offset 208
	pushq	%rbp
	.cfi_def_cfa_offset 216
	pushq	72(%rsp)
	.cfi_def_cfa_offset 224
	pushq	56(%rsp)
	.cfi_def_cfa_offset 232
	pushq	96(%rsp)
	.cfi_def_cfa_offset 240
	pushq	%r15
	.cfi_def_cfa_offset 248
	pushq	72(%rsp)
	.cfi_def_cfa_offset 256
	movq	128(%rsp), %r9
	movl	172(%rsp), %r8d
	movq	104(%rsp), %rcx
	movq	96(%rsp), %rdi
	call	_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i
	addq	$72, %rsp
	.cfi_def_cfa_offset 184
	movq	%rbp, %r9
	movl	%ebx, %r8d
	pushq	%r14
	.cfi_def_cfa_offset 192
	movq	24(%rsp), %rcx
	movq	%r15, %rdx
	movq	40(%rsp), %rsi
	movq	96(%rsp), %rdi
	call	_Z11getGenAccelPdS_S_PbiS_S_
	movq	32(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	64(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	16(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	%r15, %rdi
	call	_ZdaPv@PLT
	movq	40(%rsp), %rdi
	call	_ZdaPv@PLT
	movq	%r14, %rdi
	call	_ZdaPv@PLT
	movq	%rbp, %rdi
	call	_ZdaPv@PLT
	movq	%r13, %rdi
	call	_ZdaPv@PLT
	addq	$136, %rsp
	.cfi_def_cfa_offset 56
	movq	%r12, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	jmp	_ZdaPv@PLT
	.cfi_endproc
.LFE3635:
	.size	_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_, .-_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3665:
	.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
.LFE3665:
	.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:

//	cudaDCA.cu
//
//This file contains the recursive DCA function, and the function that is used to invoke DCA and
//interperate the results.

//Included Files


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

//Function Prototypes
//	Functions found in this file
void RecDCA(double Zs[], int n, int i, double AF[], int cut_off,double Xs[]);

//	Functions found in Init_setup.cu
void CudaInitialize(double m[], double l[], double I[], double x[], int n, double Zs[]);

//	Functions found in Assemble_setup.cu
void cudaAssemble(double Zs[],double Xs[], int num, double nZs[], double nXs[], int odd, int newlen);

//	Functions found in Disassemble_setup.cu
void cudaDisassemble(double OldAF[], double Zs[], double Xs[],double nZs[], double nXs[], int odd, int morelen, int lesslen, double AF[]);

//	Functions found in Assemble.cu

//	Functions found in SolveBCs.cu
void solve_BCs(double Zs[], double Xs[], double AF[]);

void printa(double A[], int n);
void printm(double A[6][6]);
void update(double Mass[], double Inertia[], double Init_Zetas[], double Zetas[], int n, double Body_Vectors[], double ang_vels[], double DCMs[],double Ps[], double PdotUs[],double Ds[],bool active_DOF[], double speeds[],int dof_index[]);
void kinematics(bool Active_DOF[], double Coords[], double DCMs[], double speeds[], double omegas[], int dof_index[],int n);
void getGenAccel(double Y[], double AF[],double omegas[], bool Active_DOF[], int n,double PdotUs[], double Ps[]);
void multPinv(double Ps[], double tempy[], int b, int n);
void RecDCA(double Zs[], int n, int i, double AF[], int cut_off,double Xs[], double DCMs[], double omegas[], int dof_index[], bool Active_DOF[], double Speeds[],double PdotUs[], double Ds[], int Pindex[],int numbods);
void Assemble(double Zs[], double Xs[],double nZs[], double nXs[], int len, int odd, int n, double PdotUs[], double Ds[], int Pindex[],int numbods, bool active_DOF[]);
void Disassemble(double lessZs[], double lessXs[],double moreZs[], double moreXs[], double oldAs[] ,double newAs[], int num, int odd,double Ds[], int Pindex[],int numbods, double PdotUs[]);
void multPinv(double Ps[], double tempy[], int b, int n);
void Mat61Mult2(double A[6][6], double B[6], double C[6]);
void printzz(double A[], int n, int b, int zeta);


//DCAhelp:
//	Function that prepares the list of bodies for DCA and finds the final state vector
//		state is the state of the system at that timestep
//		bs is a list of bodies used for initialization
//		js is a list of joints
//		n is the number of bodies
//		Y is the array where the final velocities and accelerations are stored
void DCAhelp(int n,bool Active_DOF[],double Coords[], double Speeds[], int dof_index[], double initZetas[],double Mass[], double Inertia[],int DOF, double Y[], int cut_off, double Body_Vectors[])
{
	double *Zetas = new double[n*26*6];
	double *Xs = new double[n*5*5];
	double *DCMs = new double[n*3*3];
	double *omegas= new double[n*3];
	double *AF = new double[n*4*6];
	double *Ps = new double[n*6*6];
	double *PdotUs = new double[n*6];
	double *Ds = new double[n*6*6];
	int *Pindex = new int[n];
	for(int i =0; i<n; i++)
	{
		Pindex[i]=i;
	}

	kinematics(Active_DOF, Coords, DCMs, Speeds, omegas, dof_index, n);

	update(Mass, Inertia, initZetas, Zetas, n, Body_Vectors, omegas, DCMs,Ps,PdotUs,Ds,Active_DOF,Speeds,dof_index);


	RecDCA(Zetas, n, 0, AF, cut_off,Xs,DCMs,omegas,dof_index,Active_DOF,Speeds,PdotUs,Ds,Pindex,n);

	getGenAccel(Y,AF,omegas,Active_DOF,n,PdotUs,Ps);
	//Free memory
	delete[] Zetas;
	delete[] Xs;
	delete[] DCMs;
	delete[] omegas;
	delete[] AF;
	delete[] Ps;
	delete[] PdotUs;
	delete[] Ds;
	delete[] Pindex;
}

void printzz(double A[], int n, int b, int zeta)
{
	std::cout<<std::endl;
	for(int r = 0; r<6; r++)
	{
		for(int c =0; c<6; c++)
		{
			std::cout<<A[c+zeta+n*26*r+b*26]<<"\t";
		}
	std::cout<<std::endl;
	}
}
void getGenAccel(double Y[], double AF[],double omegas[], bool Active_DOF[], int n, double PdotUs[], double Ps[])
{
	int c =0;
	int l =0;
	//double A1[6];
	//double A2[6];
	double tempy[6];

	for(int i =0; i<6; i++)
	{
		tempy[i]=AF[i*4*n]-PdotUs[i];
	}
	multPinv(Ps,tempy,0,n);
	
	
	for(int i =0; i<6; i++)
	{
		if(Active_DOF[i])
		{
			Y[c]=tempy[c];
			c++;
		}
	}	
	for(int i =1; i<n; i++)
	{ l =0;
		for(int k =0; k<6; k++)
		{
			tempy[k]=AF[i*4+k*4*n-2]-AF[i*4+k*4*n]-PdotUs[i*6+k];
		}

		multPinv(Ps,tempy,i,n);
		for(int j=0; j<6; j++)
		{
			if(Active_DOF[6*i+j])
			{
				Y[c]=tempy[l];
				c++;
				l++;
			}
		}
	}
}

void multPinv(double Ps[], double tempy[], int b, int n)
{
	double Pinv[6][6];
	
	for( int r =0; r<6; r++)
	{
		for(int c =0; c<6; c++)
		{
			Pinv[c][r]=Ps[c+b*6+r*6*n];
		}
	}
	
	Mat61Mult2(Pinv,tempy,tempy);
}
	
			
//RecDCA:
//	Function used to solve for the velocty and acceleration of the list of bodies at
//	the current timestep.  This is a recursive function that continues to call itself
//	until there is a single body left.  Once at this point the accelerations and forces
//	are found using the boundary conditions of a pendulum.  These values are then returned
//	to the previous level of recursion which then finds the new accelerations and forces
//	for the disassembled bodies.  This continues until all bodies are disassembled, ultimately
//	returning the forces and accelerations at both handles of every body in the system.  These
//	results are intererated by DCAhelp (above) to obtain the actual generalized accelerations.  
//		bodies is the list of bodies
//		n is the number of bodies
//		i is the level of recursion
//		AF is the array in which the accelerations and forces at the handles of the bodies 
//			will be stored.
void RecDCA(double Zs[], int n, int i, double AF[], int cut_off,double Xs[], double DCMs[], double omegas[], int dof_index[], bool Active_DOF[], double Speeds[],double PdotUs[], double Ds[], int Pindex[],int numbods)
{
	if (n==1)	//If there is only 1 body
	{	
		
		solve_BCs(Zs,Xs, AF);	//Solve the boundary conditions and find the acceleratins and forces
	
		
	}
	else	//If there is more than 1 body
	{	
		int newlen;	//New number of bodies after assembly
		bool odd = 0;	//Flag to keep track of the parity of the length of the list of
		
		if(n % 2 == 0)	//If there is an even number of bodies
		{
			newlen = (int) (n/2);	//The new number of bodies will be half the original number
		}
		else	//If there is an odd number of bodies
		{
			newlen = (int)((n+1)/2);	//The new number of bodies will be half the original number
										//rounded down, plus 1
			odd = 1;	//odd is set to 1 because there are an odd number of bodies
		}
		double *nZs=new double[newlen*26*6];
		double *nXs=new double[newlen*5*5];
		int *nPindex = new int[newlen];

		for(int k =0; k<newlen-odd; k++)
		{
			nPindex[i]=Pindex[i*2];
		}
		if(odd)
		{
			nPindex[newlen-1]=Pindex[n-1];
		}

/*
		if(i<cut_off)
		{
			cudaAssemble(Zs,Xs, n, nZs, nXs , odd, newlen);	//Assemble the bodies, storing them in newbds			
		}
		else
		{*/

			Assemble(Zs,Xs,nZs,nXs, newlen,odd, n,PdotUs,Ds,Pindex,numbods,Active_DOF);	//Assemble the bodies, storing them in newbds


		//}

		//Create a list of accelerations and forces of the new bodies.
		double *AFo= new double[6*newlen*4];

		//Call the DCA function again to return the accelerations and forces of the new bodies
		RecDCA(nZs,newlen,i+1 ,AFo,cut_off,nXs,DCMs,omegas,dof_index,Active_DOF,Speeds,PdotUs,Ds,nPindex,numbods);

		//Knowing the accelerations and forces of the new bodies, the new bodies can be disassembled
		//again, finding the accelerations and forces of the old bodies.
		/*if(i<cut_off)
		{
			
			cudaDisassemble(AFo, Zs,Xs , nZs,nXs, odd, n, newlen, AF);
			
		}
		else
		{*/
		Disassemble(nZs,nXs,Zs,Xs,AFo, AF, newlen,odd,Ds,Pindex,numbods,PdotUs);
		//}
		//Free memory
		delete[] nZs;
		
		delete[] nXs;
		
		delete[] AFo;

		delete[] nPindex;
		 
	
	}
}
		
			


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

                                        # End of file scope inline assembly
	.globl	_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_ # -- Begin function _Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_
	.type	_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_,@function
_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_:  # @_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_
	.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
	movq	%r9, 136(%rsp)                  # 8-byte Spill
	movq	%r8, 96(%rsp)                   # 8-byte Spill
	movq	%rcx, 88(%rsp)                  # 8-byte Spill
	movq	%rdx, 128(%rsp)                 # 8-byte Spill
	movl	%edi, %ebx
	leal	(%rbx,%rbx), %eax
	leal	(%rax,%rax,2), %eax
	movslq	%eax, %r15
	movl	%edi, %ebp
	leaq	(,%rbp,4), %rax
	testl	%edi, %edi
	movq	$-1, %rcx
	cmovsq	%rcx, %rax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	shlq	$3, %r15
	testl	%edi, %edi
	cmovsq	%rcx, %r15
	leal	(,%rbx,8), %eax
	leal	(%rax,%rax,2), %eax
	movslq	%eax, %r12
	shlq	$3, %r12
	testl	%edi, %edi
	leal	(%rbx,%rbx,2), %eax
	movslq	%eax, %r14
	movq	$-1, %rax
	cmovsq	%rax, %r12
	shlq	$3, %r14
	testl	%edi, %edi
	cmovsq	%rax, %r14
	movq	%rsi, 144(%rsp)                 # 8-byte Spill
	imull	$156, %edi, %eax
	leaq	(,%rax,8), %rdi
	testl	%eax, %eax
	leal	(%rbx,%rbx,4), %eax
	leal	(%rax,%rax,4), %r13d
	cmovsq	%rcx, %rdi
	callq	_Znam
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	leaq	(,%r13,8), %rdi
	testl	%r13d, %r13d
	leal	(%rbx,%rbx,8), %r13d
	movq	$-1, %rax
	cmovsq	%rax, %rdi
	callq	_Znam
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	leaq	(,%r13,8), %rdi
	testl	%r13d, %r13d
	movq	$-1, %r13
	cmovsq	%r13, %rdi
	callq	_Znam
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movq	%r14, %rdi
	callq	_Znam
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	leal	(,%rbx,4), %eax
	leal	(%rax,%rax,8), %eax
	leaq	(,%rax,8), %r12
	testl	%eax, %eax
	cmovsq	%r13, %r12
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	movq	%r15, %rdi
	callq	_Znam
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	callq	_Znam
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movq	8(%rsp), %rdi                   # 8-byte Reload
	callq	_Znam
	movq	%rax, %r13
	movq	248(%rsp), %rax
	movq	%rax, 120(%rsp)                 # 8-byte Spill
	movl	240(%rsp), %eax
	movl	%eax, 36(%rsp)                  # 4-byte Spill
	movq	232(%rsp), %rax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movq	216(%rsp), %rax
	movq	%rax, 112(%rsp)                 # 8-byte Spill
	movq	208(%rsp), %rax
	movq	%rax, 104(%rsp)                 # 8-byte Spill
	testl	%ebx, %ebx
	jle	.LBB0_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB0_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	%eax, (%r13,%rax,4)
	incq	%rax
	cmpq	%rax, %rbp
	jne	.LBB0_2
.LBB0_3:                                # %._crit_edge
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movq	152(%rsp), %r15                 # 8-byte Reload
	movq	%r15, %rdi
	movq	136(%rsp), %rsi                 # 8-byte Reload
	movq	32(%rsp), %rdx                  # 8-byte Reload
	movq	96(%rsp), %r12                  # 8-byte Reload
	movq	%r12, %rcx
	movq	72(%rsp), %r8                   # 8-byte Reload
	movq	104(%rsp), %r14                 # 8-byte Reload
	movq	%r14, %r9
	pushq	%rbx
	.cfi_adjust_cfa_offset 8
	callq	_Z10kinematicsPbPdS0_S0_S0_Pii
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movq	104(%rsp), %rdi                 # 8-byte Reload
	movq	112(%rsp), %rsi                 # 8-byte Reload
	movq	136(%rsp), %rdx                 # 8-byte Reload
	movq	80(%rsp), %rbp                  # 8-byte Reload
	movq	%rbp, %rcx
	movl	%ebx, %r8d
	movq	120(%rsp), %r9                  # 8-byte Reload
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	%r12
	.cfi_adjust_cfa_offset 8
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	movq	64(%rsp), %r14                  # 8-byte Reload
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	80(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	96(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	72(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	movq	120(%rsp), %r12                 # 8-byte Reload
	pushq	%r12
	.cfi_adjust_cfa_offset 8
	callq	_Z6updatePdS_S_S_iS_S_S_S_S_S_PbS_Pi
	addq	$56, %rsp
	.cfi_adjust_cfa_offset -56
	movq	%rbp, %rdi
	movl	%ebx, %esi
	xorl	%edx, %edx
	movq	24(%rsp), %rcx                  # 8-byte Reload
	movl	44(%rsp), %r8d                  # 4-byte Reload
	movq	80(%rsp), %r9                   # 8-byte Reload
	pushq	%rbx
	.cfi_adjust_cfa_offset 8
	pushq	%r13
	.cfi_adjust_cfa_offset 8
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	movq	80(%rsp), %r14                  # 8-byte Reload
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	128(%rsp)                       # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	%r15
	.cfi_adjust_cfa_offset 8
	pushq	152(%rsp)                       # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	%r12
	.cfi_adjust_cfa_offset 8
	movq	96(%rsp), %rbp                  # 8-byte Reload
	pushq	%rbp
	.cfi_adjust_cfa_offset 8
	callq	_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i
	addq	$72, %rsp
	.cfi_adjust_cfa_offset -72
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movq	24(%rsp), %rsi                  # 8-byte Reload
	movq	%r15, %rcx
	movl	%ebx, %r8d
	movq	%r14, %r9
	movq	64(%rsp), %rbx                  # 8-byte Reload
	pushq	%rbx
	.cfi_adjust_cfa_offset 8
	callq	_Z11getGenAccelPdS_S_PbiS_S_
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movq	80(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	72(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	%rbp, %rdi
	callq	_ZdaPv
	movq	%r12, %rdi
	callq	_ZdaPv
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	%rbx, %rdi
	callq	_ZdaPv
	movq	%r14, %rdi
	callq	_ZdaPv
	movq	40(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	%r13, %rdi
	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
	jmp	_ZdaPv                          # TAILCALL
.Lfunc_end0:
	.size	_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_, .Lfunc_end0-_Z7DCAhelpiPbPdS0_PiS0_S0_S0_iS0_iS0_
	.cfi_endproc
                                        # -- End function
	.globl	_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i # -- Begin function _Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i
	.type	_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i,@function
_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i:   # @_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i
	.cfi_startproc
# %bb.0:
                                        # kill: def $edx killed $edx def $rdx
	cmpl	$1, %esi
	jne	.LBB1_1
# %bb.6:                                # %common.ret
	movq	%r9, %rsi
	movq	%rcx, %rdx
	jmp	_Z9solve_BCsPdS_S_              # TAILCALL
.LBB1_1:
	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	$136, %rsp
	.cfi_def_cfa_offset 192
	.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, %r12d
	movq	%rdx, (%rsp)                    # 8-byte Spill
	movl	%r8d, 20(%rsp)                  # 4-byte Spill
	movq	%rdi, 48(%rsp)                  # 8-byte Spill
	movq	%r9, 72(%rsp)                   # 8-byte Spill
	movq	%rcx, 128(%rsp)                 # 8-byte Spill
	movl	256(%rsp), %eax
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	movq	248(%rsp), %rax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movq	240(%rsp), %rax
	movq	%rax, 64(%rsp)                  # 8-byte Spill
	movq	232(%rsp), %rax
	movq	%rax, 120(%rsp)                 # 8-byte Spill
	movq	224(%rsp), %rax
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	216(%rsp), %rax
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movq	208(%rsp), %rax
	movq	%rax, 96(%rsp)                  # 8-byte Spill
	movq	200(%rsp), %rax
	movq	%rax, 104(%rsp)                 # 8-byte Spill
	movq	192(%rsp), %rax
	movq	%rax, 112(%rsp)                 # 8-byte Spill
	movl	%esi, %r15d
	andl	$1, %r15d
	leal	(%r15,%r12), %r13d
	sarl	%r13d
	imull	$156, %r13d, %eax
	leaq	(,%rax,8), %rdi
	testl	%eax, %eax
	movq	$-1, %rbx
	cmovsq	%rbx, %rdi
	callq	_Znam
	movq	%rax, %r14
	leal	(%r13,%r13,4), %eax
	leal	(%rax,%rax,4), %eax
	leaq	(,%rax,8), %rdi
	testl	%eax, %eax
	cmovsq	%rbx, %rdi
	callq	_Znam
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movslq	%r13d, %rbp
	leaq	(,%rbp,4), %rdi
	testl	%ebp, %ebp
	cmovsq	%rbx, %rdi
	callq	_Znam
	cmpl	%r15d, %ebp
	jle	.LBB1_3
# %bb.2:                                # %.lr.ph
	movq	(%rsp), %rsi                    # 8-byte Reload
	leal	(%rsi,%rsi), %ecx
	movslq	%ecx, %rdx
	movq	8(%rsp), %rcx                   # 8-byte Reload
	movl	(%rcx,%rdx,4), %edx
	movslq	%esi, %rcx
	movl	%edx, (%rax,%rcx,4)
.LBB1_3:                                # %._crit_edge
	testl	%r15d, %r15d
	movq	72(%rsp), %rsi                  # 8-byte Reload
	je	.LBB1_5
# %bb.4:
	movslq	%r12d, %rdx
	movq	8(%rsp), %rcx                   # 8-byte Reload
	movl	-4(%rcx,%rdx,4), %ecx
	movl	%ecx, -4(%rax,%rbp,4)
.LBB1_5:
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movq	48(%rsp), %rdi                  # 8-byte Reload
	movq	%r14, %rdx
	movq	40(%rsp), %rcx                  # 8-byte Reload
	movq	%rcx, %rbp
	movl	%r13d, %r8d
	movl	%r15d, %r9d
	pushq	32(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	movq	64(%rsp), %rbx                  # 8-byte Reload
	pushq	%rbx
	.cfi_adjust_cfa_offset 8
	pushq	24(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	88(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	movq	%r14, %rbx
	movq	152(%rsp), %r14                 # 8-byte Reload
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	%r12
	.cfi_adjust_cfa_offset 8
	callq	_Z8AssemblePdS_S_S_iiiS_S_PiiPb
	addq	$48, %rsp
	.cfi_adjust_cfa_offset -48
	movl	%r13d, %eax
	shll	$3, %eax
	leal	(%rax,%rax,2), %eax
	leaq	(,%rax,8), %rcx
	testl	%eax, %eax
	movq	$-1, %rdi
	cmovnsq	%rcx, %rdi
	callq	_Znam
	movq	%rax, 80(%rsp)                  # 8-byte Spill
	movq	(%rsp), %rdx                    # 8-byte Reload
	incl	%edx
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	movq	%rbx, %rdi
	movq	%r15, 8(%rsp)                   # 8-byte Spill
	movq	%rbx, %r15
	movl	%r13d, %esi
                                        # kill: def $edx killed $edx killed $rdx
	movq	%rax, %rcx
	movl	28(%rsp), %r8d                  # 4-byte Reload
	movq	%rbp, %rbx
	movq	%rbp, %r9
	movq	64(%rsp), %rbp                  # 8-byte Reload
	pushq	%rbp
	.cfi_adjust_cfa_offset 8
	pushq	40(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	movq	88(%rsp), %r12                  # 8-byte Reload
	pushq	%r12
	.cfi_adjust_cfa_offset 8
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	128(%rsp)                       # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	80(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	152(%rsp)                       # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	168(%rsp)                       # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	184(%rsp)                       # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	callq	_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	movq	%r15, %rdi
	movq	%rbx, %rsi
	movq	48(%rsp), %rdx                  # 8-byte Reload
	movq	72(%rsp), %rcx                  # 8-byte Reload
	movq	80(%rsp), %rbx                  # 8-byte Reload
	movq	%rbx, %r8
	movq	128(%rsp), %r9                  # 8-byte Reload
	pushq	%r14
	.cfi_adjust_cfa_offset 8
	pushq	%rbp
	.cfi_adjust_cfa_offset 8
	pushq	24(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	%r12
	.cfi_adjust_cfa_offset 8
	pushq	32(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	%r13
	.cfi_adjust_cfa_offset 8
	callq	_Z11DisassemblePdS_S_S_S_S_iiS_PiiS_
	addq	$48, %rsp
	.cfi_adjust_cfa_offset -48
	movq	%r15, %rdi
	callq	_ZdaPv
	movq	40(%rsp), %rdi                  # 8-byte Reload
	callq	_ZdaPv
	movq	%rbx, %rdi
	callq	_ZdaPv
	movq	24(%rsp), %rdi                  # 8-byte Reload
	addq	$136, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	_ZdaPv                          # TAILCALL
.Lfunc_end1:
	.size	_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i, .Lfunc_end1-_Z6RecDCAPdiiS_iS_S_S_PiPbS_S_S_S0_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z11getGenAccelPdS_S_PbiS_S_    # -- Begin function _Z11getGenAccelPdS_S_PbiS_S_
	.type	_Z11getGenAccelPdS_S_PbiS_S_,@function
_Z11getGenAccelPdS_S_PbiS_S_:           # @_Z11getGenAccelPdS_S_PbiS_S_
	.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	$88, %rsp
	.cfi_def_cfa_offset 144
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r9, %rbx
                                        # kill: def $r8d killed $r8d def $r8
	movq	%rcx, %r15
	movq	%rsi, %r12
	movq	%rdi, 16(%rsp)                  # 8-byte Spill
	movq	%r8, (%rsp)                     # 8-byte Spill
	leal	(,%r8,4), %r14d
	xorl	%eax, %eax
	xorl	%ecx, %ecx
.LBB2_1:                                # =>This Inner Loop Header: Depth=1
	cltq
	movsd	(%r12,%rax,8), %xmm0            # xmm0 = mem[0],zero
	subsd	(%rbx,%rcx,8), %xmm0
	movsd	%xmm0, 32(%rsp,%rcx,8)
	incq	%rcx
	addl	%r14d, %eax
	cmpq	$6, %rcx
	jne	.LBB2_1
# %bb.2:
	leaq	32(%rsp), %rsi
	xorl	%r13d, %r13d
	movq	144(%rsp), %rdi
	xorl	%edx, %edx
	movq	(%rsp), %rcx                    # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
	callq	_Z8multPinvPdS_ii
	xorl	%ebp, %ebp
	movq	16(%rsp), %rax                  # 8-byte Reload
.LBB2_3:                                # =>This Inner Loop Header: Depth=1
	cmpb	$0, (%r15,%r13)
	je	.LBB2_5
# %bb.4:                                #   in Loop: Header=BB2_3 Depth=1
	movslq	%ebp, %rbp
	movsd	32(%rsp,%rbp,8), %xmm0          # xmm0 = mem[0],zero
	movsd	%xmm0, (%rax,%rbp,8)
	incl	%ebp
.LBB2_5:                                #   in Loop: Header=BB2_3 Depth=1
	incq	%r13
	cmpq	$6, %r13
	jne	.LBB2_3
# %bb.6:                                # %.preheader56
	cmpl	$2, (%rsp)                      # 4-byte Folded Reload
	jl	.LBB2_15
# %bb.7:                                # %.preheader.preheader
	movl	(%rsp), %eax                    # 4-byte Reload
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	addq	$48, %rbx
	addq	$6, %r15
	movl	$1, %edx
	movl	$4, %eax
.LBB2_8:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_9 Depth 2
                                        #     Child Loop BB2_11 Depth 2
	movl	%eax, 12(%rsp)                  # 4-byte Spill
                                        # kill: def $eax killed $eax def $rax
	xorl	%ecx, %ecx
.LBB2_9:                                #   Parent Loop BB2_8 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cltq
	movsd	-16(%r12,%rax,8), %xmm0         # xmm0 = mem[0],zero
	subsd	(%r12,%rax,8), %xmm0
	subsd	(%rbx,%rcx,8), %xmm0
	movsd	%xmm0, 32(%rsp,%rcx,8)
	incq	%rcx
	addl	%r14d, %eax
	cmpq	$6, %rcx
	jne	.LBB2_9
# %bb.10:                               #   in Loop: Header=BB2_8 Depth=1
	movq	144(%rsp), %rdi
	leaq	32(%rsp), %rsi
	movq	%rdx, %r13
                                        # kill: def $edx killed $edx killed $rdx
	movq	(%rsp), %rcx                    # 8-byte Reload
                                        # kill: def $ecx killed $ecx killed $rcx
	callq	_Z8multPinvPdS_ii
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	movq	16(%rsp), %rdx                  # 8-byte Reload
.LBB2_11:                               #   Parent Loop BB2_8 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpb	$0, (%r15,%rax)
	je	.LBB2_13
# %bb.12:                               #   in Loop: Header=BB2_11 Depth=2
	movslq	%ecx, %rcx
	movsd	32(%rsp,%rcx,8), %xmm0          # xmm0 = mem[0],zero
	movslq	%ebp, %rbp
	movsd	%xmm0, (%rdx,%rbp,8)
	incl	%ebp
	incl	%ecx
.LBB2_13:                               #   in Loop: Header=BB2_11 Depth=2
	incq	%rax
	cmpq	$6, %rax
	jne	.LBB2_11
# %bb.14:                               #   in Loop: Header=BB2_8 Depth=1
	movq	%r13, %rdx
	incq	%rdx
	addq	$48, %rbx
	movl	12(%rsp), %eax                  # 4-byte Reload
	addl	$4, %eax
	addq	$6, %r15
	cmpq	24(%rsp), %rdx                  # 8-byte Folded Reload
	jne	.LBB2_8
.LBB2_15:                               # %._crit_edge
	addq	$88, %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_end2:
	.size	_Z11getGenAccelPdS_S_PbiS_S_, .Lfunc_end2-_Z11getGenAccelPdS_S_PbiS_S_
	.cfi_endproc
                                        # -- End function
	.globl	_Z7printzzPdiii                 # -- Begin function _Z7printzzPdiii
	.type	_Z7printzzPdiii,@function
_Z7printzzPdiii:                        # @_Z7printzzPdiii
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.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	%ecx, %ebx
	movl	%edx, %r12d
	movl	%esi, %r15d
	movq	%rdi, %r14
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %r13d
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	leal	(%r12,%r12,4), %eax
	leal	(%rax,%rax,4), %eax
	addl	%r12d, %ebx
	addl	%eax, %ebx
	leal	(%r15,%r15,4), %eax
	leal	(%rax,%rax,4), %r12d
	addl	%r15d, %r12d
	xorl	%r15d, %r15d
.LBB3_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_2 Depth 2
	xorl	%ebp, %ebp
.LBB3_2:                                #   Parent Loop BB3_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	leal	(%rbx,%rbp), %eax
	cltq
	movsd	(%r14,%rax,8), %xmm0            # xmm0 = mem[0],zero
	movl	$_ZSt4cout, %edi
	callq	_ZNSo9_M_insertIdEERSoT_
	movl	$.L.str, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	incq	%rbp
	cmpq	$6, %rbp
	jne	.LBB3_2
# %bb.3:                                #   in Loop: Header=BB3_1 Depth=1
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incl	%r15d
	addq	%r12, %rbx
	cmpl	$6, %r15d
	jne	.LBB3_1
# %bb.4:
	addq	$8, %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_end3:
	.size	_Z7printzzPdiii, .Lfunc_end3-_Z7printzzPdiii
	.cfi_endproc
                                        # -- End function
	.globl	_Z8multPinvPdS_ii               # -- Begin function _Z8multPinvPdS_ii
	.type	_Z8multPinvPdS_ii,@function
_Z8multPinvPdS_ii:                      # @_Z8multPinvPdS_ii
	.cfi_startproc
# %bb.0:
	subq	$296, %rsp                      # imm = 0x128
	.cfi_def_cfa_offset 304
                                        # kill: def $ecx killed $ecx def $rcx
                                        # kill: def $edx killed $edx def $rdx
	addl	%edx, %edx
	leal	(%rdx,%rdx,2), %eax
	addl	%ecx, %ecx
	leal	(%rcx,%rcx,2), %ecx
	movq	%rsp, %rdx
	xorl	%r8d, %r8d
.LBB4_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB4_2 Depth 2
	movq	$-288, %r9                      # imm = 0xFEE0
	movl	%eax, %r10d
.LBB4_2:                                #   Parent Loop BB4_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movslq	%r10d, %r10
	movsd	(%rdi,%r10,8), %xmm0            # xmm0 = mem[0],zero
	movsd	%xmm0, 288(%rdx,%r9)
	incl	%r10d
	addq	$48, %r9
	jne	.LBB4_2
# %bb.3:                                #   in Loop: Header=BB4_1 Depth=1
	incq	%r8
	addq	$8, %rdx
	addl	%ecx, %eax
	cmpq	$6, %r8
	jne	.LBB4_1
# %bb.4:
	movq	%rsp, %rdi
	movq	%rsi, %rdx
	callq	_Z10Mat61Mult2PA6_dPdS1_
	addq	$296, %rsp                      # imm = 0x128
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	_Z8multPinvPdS_ii, .Lfunc_end4-_Z8multPinvPdS_ii
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"\t"
	.size	.L.str, 2

	.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 _ZSt4cout
	.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
