// File: /workspace/github_cpp_makefile_star2_O2/dcarrey[P]hgt-detection/./fonctions.cpp
// Function: findBestHGTtab(InputTree, InputTree, Parameters, HGT*, int*, int*, int)
int findBestHGTtab(struct InputTree SpeciesTree,struct InputTree GeneTree,struct Parameters param,struct HGT *aHGT, int *nbHgtFound,int *initial,int bootstrap){

	struct InputTree tmpTree;
	struct InputTree tmpTree2;
	
	int i,j,k,l,first=1,ret=0,trouve;
	int size = SpeciesTree.size;
	int ktSpecies;
	struct CRITERIA aCrit,aCritRef,aCritRef2,aCrit_tmpTree2;
	struct DescTree *DTSpecies,*DTGene;
	int encore = 0;
  
	initInputTree(&tmpTree);
	initInputTree(&tmpTree2);
	
	(*nbHgtFound) = 0;

	printf("\n\n== NEW STEP OF DETECTION == [size of the trees (after reduction)=%d]",SpeciesTree.size);
  
	//== compute criteria
	InitCriteria(&aCrit,size);
	InitCriteria(&aCritRef,size);
	InitCriteria(&aCritRef2,size);
	InitCriteria(&aCrit_tmpTree2,size);
	computeCriteria(SpeciesTree.ADD,GeneTree.ADD,size,&aCrit,SpeciesTree.LONGUEUR,SpeciesTree.ARETE,GeneTree.LONGUEUR,GeneTree.ARETE);
	computeCriteria(SpeciesTree.ADD,GeneTree.ADD,size,&aCritRef,SpeciesTree.LONGUEUR,SpeciesTree.ARETE,GeneTree.LONGUEUR,GeneTree.ARETE);
	computeCriteria(SpeciesTree.ADD,GeneTree.ADD,size,&aCritRef2,SpeciesTree.LONGUEUR,SpeciesTree.ARETE,GeneTree.LONGUEUR,GeneTree.ARETE);
	loadCriteria(aCrit,&aHGT[0]);
  
	DTGene = (struct DescTree*)malloc((2*GeneTree.size-2-GeneTree.kt+1)*sizeof(struct DescTree));
	RechercherBipartition(GeneTree.ARETE,GeneTree.ADD,GeneTree.Root,GeneTree.Adjacence,DTGene,GeneTree.size,GeneTree.kt);	

	DTSpecies = (struct DescTree*)malloc((2*SpeciesTree.size-2-SpeciesTree.kt+1)*sizeof(struct DescTree));
	RechercherBipartition(SpeciesTree.ARETE,SpeciesTree.ADD,SpeciesTree.Root,SpeciesTree.Adjacence,DTSpecies,SpeciesTree.size,SpeciesTree.kt);

	int flag2 = 1;
	int flag3;   		//== pour tester les especes avec sur la branche au dessus
	int initial3=1;
	
	
	do{
		for(i=1;i<2*size-3-SpeciesTree.kt;i++)
			for(j=i+1;j<2*size-3-SpeciesTree.kt;j++){
				//== is it a valid hgt ?
				trouve=0;
				if(isAValidHGT(SpeciesTree,i,j)==1 && i!=j ){
					copyInputTree(&tmpTree,SpeciesTree,0,0);
				
					if(strcmp(param.subtree,"yes") == 0){
						if(TestSubTreeConstraint(SpeciesTree,i,j,DTSpecies,DTGene) == 0)  {
							continue;
							//FreeMemory_InputTree(&tmpTree);
							tmpTree.ADD = NULL;
							tmpTree.ARETE = NULL;
						}
						flag3=0;
						if(TestSubTreeLeafs(SpeciesTree,i,j,DTSpecies,DTGene) == 1){
							//printf("\nTestSubTreeLeafs => ok");
							flag3=1;
						}
					}
					
					applyHGT(GeneTree.ADD,&tmpTree,i,j);
					
					if(strcmp(param.criterion,"ls") == 0)
						AdjustBranchLength(&tmpTree,GeneTree,0,1);
					computeCriteria(tmpTree.ADD,GeneTree.ADD,size,&aCrit,tmpTree.LONGUEUR,tmpTree.ARETE,GeneTree.LONGUEUR,GeneTree.ARETE);
				
					first=1;
					loadCriteria(aCritRef,&aHGT[(*nbHgtFound)]);
					//printf("\ninitial = %d,initial3= %d",*initial,initial3);
					if(((aCritRef.RF-aCrit.RF) == 1) && (*initial==1) && (
					  (SpeciesTree.ARETE[2*i-1] == SpeciesTree.ARETE[2*j-1]) || 
					  (SpeciesTree.ARETE[2*i-1] == SpeciesTree.ARETE[2*j-2]) || 
					  (SpeciesTree.ARETE[2*i-2] == SpeciesTree.ARETE[2*j-2]) || 
					  (SpeciesTree.ARETE[2*i-2] == SpeciesTree.ARETE[2*j-2])
					  )) {
						UpdateCriterion(&first,param.criterion,aCrit,&aHGT[(*nbHgtFound)],i,j,0);
						//printf("\n===========> initial = %d",*initial);
						//printf("\tRF1=%d | RF2=%d | BD1=%2.1lf | BD2=%2.1lf",aHGT[(*nbHgtFound)].crit.RF,aCrit.RF,aHGT[(*nbHgtFound)].crit.BD,aCrit.BD);
						
						aHGT[(*nbHgtFound)].source_A = SpeciesTree.ARETE[2*i-1];
						aHGT[(*nbHgtFound)].source_B = SpeciesTree.ARETE[2*i-2];
						aHGT[(*nbHgtFound)].dest_A = SpeciesTree.ARETE[2*j-1];
						aHGT[(*nbHgtFound)].dest_B = SpeciesTree.ARETE[2*j-2];
						
						findListSpecies(&aHGT[(*nbHgtFound)],DTSpecies,SpeciesTree);
						trouve=1;
					}
					else  if((*initial==0) && ((flag3 == 1) || (initial3 == 0) )){
						if(TestCriterionAndUpdate(&first,param.criterion,aCrit,&aHGT[(*nbHgtFound)],i,j,0,0) == 1){		
							//printf("\n===========> flag3 = %d, initial3=%d",flag3,initial3);
							//printf("\tRF1=%d | RF2=%d | BD1=%2.1lf | BD2=%2.1lf",aHGT[(*nbHgtFound)].crit.RF,aCrit.RF,aHGT[(*nbHgtFound)].crit.BD,aCrit.BD);
							aHGT[(*nbHgtFound)].source_A = SpeciesTree.ARETE[2*i-1];
							aHGT[(*nbHgtFound)].source_B = SpeciesTree.ARETE[2*i-2];
							aHGT[(*nbHgtFound)].dest_A = SpeciesTree.ARETE[2*j-1];
							aHGT[(*nbHgtFound)].dest_B = SpeciesTree.ARETE[2*j-2];
							findListSpecies(&aHGT[(*nbHgtFound)],DTSpecies,SpeciesTree);
							trouve=1;
						}
					}
				}

				if(isAValidHGT(SpeciesTree,j,i)==1 && i!=j ){
					//initInputTree(&tmpTree2);
					copyInputTree(&tmpTree2,tmpTree,0,0);
					copyInputTree(&tmpTree,SpeciesTree,0,0);
					
					if(strcmp(param.subtree,"yes") == 0){
						if(TestSubTreeConstraint(SpeciesTree,j,i,DTSpecies,DTGene) == 0) {
							continue;
							//FreeMemory_InputTree(&tmpTree);
							tmpTree.ADD = NULL;
							tmpTree.ARETE = NULL;
						}
					
						if(TestSubTreeLeafs(SpeciesTree,j,i,DTSpecies,DTGene)==1){
							//printf("\nTestSubTreeLeafs (reverse) => ok");
							flag3=2;
						 }
					}
					
					//if(flag3 == 0){
						//initial3 = 0;
					//}
					
					applyHGT(GeneTree.ADD,&tmpTree,j,i);
					
					if(strcmp(param.criterion,"ls") == 0)
					  AdjustBranchLength(&tmpTree,GeneTree,0,1);
					computeCriteria(tmpTree.ADD,GeneTree.ADD,size,&aCrit,tmpTree.LONGUEUR,tmpTree.ARETE,GeneTree.LONGUEUR,GeneTree.ARETE);
					if(tmpTree2.ADD == NULL){
						printf("HOUSTON, we have a problem !");
						aCrit_tmpTree2.RF = (int) INFINI;
					}
					else{
						computeCriteria(tmpTree.ADD,tmpTree2.ADD,size,&aCrit_tmpTree2,tmpTree.LONGUEUR,tmpTree.ARETE,tmpTree2.LONGUEUR,tmpTree2.ARETE);
					}
					int flag=0;
					first=1;
					int flag_bootstrap = 0;
					if(trouve==0)
						loadCriteria(aCritRef,&aHGT[(*nbHgtFound)]);
					else{
						//printf("\n===========> rand_bootstrap : RF = %d",aCrit_tmpTree2.RF);
						if((bootstrap == 1) && (aCrit_tmpTree2.RF == 0) && /*(aCrit.BD == aHGT[(*nbHgtFound)].crit.BD) && */(aCrit.RF == aHGT[(*nbHgtFound)].crit.RF) ){
							flag_bootstrap = 1;
							//printf("\n==> rand_bootstrap1 : [%2d--%2d -> %2d--%2d]",aHGT[(*nbHgtFound)].source_A,aHGT[(*nbHgtFound)].source_B,aHGT[(*nbHgtFound)].dest_A,aHGT[(*nbHgtFound)].dest_B);
						}
						else{
							aHGT[(*nbHgtFound)].crit.diff_bd = fabs(aCrit.BD - aHGT[(*nbHgtFound)].crit.BD);
							if((flag2 == 1) && (fabs(aCrit.BD - aHGT[(*nbHgtFound)].crit.BD) <= 1)){
								if( (aHGT[(*nbHgtFound)].crit.RF - aCrit.RF) >= 1 ){
									trouve = 0;
									flag = 2;
								}      
								else{
									flag = 1;
									//printf("\n--> TEST FLAG : RF1=%d | RF2=%d | BD1=%2.1lf | BD2=%2.1lf",aHGT[(*nbHgtFound)].crit.RF,aCrit.RF,aHGT[(*nbHgtFound)].crit.BD,aCrit.BD);
								}
							}
							else{
								//printf("\n-->[%2d--%2d -> %2d--%2d]",aHGT[(*nbHgtFound)].source_A,aHGT[(*nbHgtFound)].source_B,aHGT[(*nbHgtFound)].dest_A,aHGT[(*nbHgtFound)].dest_B);
								//printf("\tRF1=%d | RF2=%d | BD1=%2.1lf | BD2=%2.1lf",aHGT[(*nbHgtFound)].crit.RF,aCrit.RF,aHGT[(*nbHgtFound)].crit.BD,aCrit.BD);
							}
						}
					}
					
					//flag_bootstrap = 0;
					if(flag != 1){
						if(((aCritRef.RF-aCrit.RF) == 1) && (*initial==1) && (
						  (SpeciesTree.ARETE[2*i-1] == SpeciesTree.ARETE[2*j-1]) || 
						  (SpeciesTree.ARETE[2*i-1] == SpeciesTree.ARETE[2*j-2]) || 
						  (SpeciesTree.ARETE[2*i-2] == SpeciesTree.ARETE[2*j-2]) || 
						  (SpeciesTree.ARETE[2*i-2] == SpeciesTree.ARETE[2*j-2])
						)) {
						
							if ((flag_bootstrap == 1) && (rand_bootstrap == 1)){
								
								//printf("\n===========>REVERSE : initial = %d",*initial);
								//printf("\tRF1=%d | RF2=%d | BD1=%2.1lf | BD2=%2.1lf",aHGT[(*nbHgtFound)].crit.RF,aCrit.RF,aHGT[(*nbHgtFound)].crit.BD,aCrit.BD);
								UpdateCriterion(&first,param.criterion,aCrit,&aHGT[(*nbHgtFound)],j,i,flag_bootstrap);
								aHGT[(*nbHgtFound)].source_A = SpeciesTree.ARETE[2*j-1];
								aHGT[(*nbHgtFound)].source_B = SpeciesTree.ARETE[2*j-2];
								aHGT[(*nbHgtFound)].dest_A = SpeciesTree.ARETE[2*i-1];
								aHGT[(*nbHgtFound)].dest_B = SpeciesTree.ARETE[2*i-2];
								findListSpecies(&aHGT[(*nbHgtFound)],DTSpecies,SpeciesTree);
								trouve=1;
								//printf("\n==> rand_bootstrap1.5 : [%2d--%2d -> %2d--%2d]",aHGT[(*nbHgtFound)].source_A,aHGT[(*nbHgtFound)].source_B,aHGT[(*nbHgtFound)].dest_A,aHGT[(*nbHgtFound)].dest_B);
							}
						}
						else if(((*initial==0) && ((flag3 == 2) || (initial3 == 0))) || (flag_bootstrap == 1)){
							if(TestCriterionAndUpdate(&first,param.criterion,aCrit,&aHGT[(*nbHgtFound)],j,i,flag,flag_bootstrap) == 1){	
								//printf("\n===========>REVERSE : flag3 = %d, initial3=%d",flag3,initial3);
								//printf("\tRF1=%d | RF2=%d | BD1=%2.1lf | BD2=%2.1lf",aHGT[(*nbHgtFound)].crit.RF,aCrit.RF,aHGT[(*nbHgtFound)].crit.BD,aCrit.BD);
								aHGT[(*nbHgtFound)].source_A = SpeciesTree.ARETE[2*j-1];
								aHGT[(*nbHgtFound)].source_B = SpeciesTree.ARETE[2*j-2];
								aHGT[(*nbHgtFound)].dest_A = SpeciesTree.ARETE[2*i-1];
								aHGT[(*nbHgtFound)].dest_B = SpeciesTree.ARETE[2*i-2];
								findListSpecies(&aHGT[(*nbHgtFound)],DTSpecies,SpeciesTree);
								trouve=1;
								//printf("\n==> rand_bootstrap2 : [%2d--%2d -> %2d--%2d]",aHGT[(*nbHgtFound)].source_A,aHGT[(*nbHgtFound)].source_B,aHGT[(*nbHgtFound)].dest_A,aHGT[(*nbHgtFound)].dest_B);
							}
						}
					}				
				}
				
				if (trouve == 1){
					(*nbHgtFound)++;
					//printf("\n===================> rand_bootstrap final : [%2d--%2d -> %2d--%2d]",aHGT[(*nbHgtFound)-1].source_A,aHGT[(*nbHgtFound)-1].source_B,aHGT[(*nbHgtFound)-1].dest_A,aHGT[(*nbHgtFound)-1].dest_B);			
				}

			}
			encore = 0;
		
		if((*nbHgtFound == 0) && (flag2==1)){
		  flag2 = 0;
		  encore = 1;
		}
		
		if((*nbHgtFound == 0) && (initial3==1) && (*initial==0) ){
		  initial3 = 0;
		  flag2=1;
		  encore = 1;
		}
		
		if((*nbHgtFound == 0) && (*initial==1)){
		  (*initial) = 0;
		  encore = 1;
		  flag2=1;
		}
		
		//initial3 = 0;

		
	 //   printf("On est rendu icit");
	}while(encore == 1);
	
	
	
	deleteBipartition(DTSpecies,SpeciesTree);
	deleteBipartition(DTGene,GeneTree);
	FreeCriteria(&aCrit,size);
	FreeCriteria(&aCritRef,size);
	FreeMemory_InputTree(&tmpTree,tmpTree.size);

	//printf("\n3)RF=%d",aHGT[0].crit.RF);	
	return (*nbHgtFound);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4b8, %rsp            # imm = 0x4B8
movl %ecx, -0xa0(%rbp)
movq %rdx, -0x80(%rbp)
movq %rsi, -0x70(%rbp)
movq %rdi, %r13
leaq 0x68(%rbp), %r14
leaq 0x10(%rbp), %r12
leaq -0x198(%rbp), %rax
andq $0x0, 0x8(%rax)
xorps %xmm0, %xmm0
andq $0x0, 0x38(%rax)
movups %xmm0, 0x28(%rax)
orl $-0x1, 0x20(%rax)
pushq $0x1
popq %rdi
orl $-0x1, (%rax)
leaq -0x68(%rbp), %rcx
andl $0x0, 0x48(%rax)
leaq -0x2b0(%rbp), %rdx
andq $0x0, 0x8(%rdx)
movl %edi, (%rcx)
andq $0x0, 0x38(%rdx)
movups %xmm0, 0x28(%rdx)
orl $-0x1, 0x20(%rdx)
movl (%r12), %r15d
orl $-0x1, (%rdx)
movups %xmm0, 0x10(%rax)
andl $0x0, 0x48(%rdx)
movups %xmm0, 0x10(%rdx)
andl $0x0, (%rsi)
leaq 0x93be(%rip), %rdi      # 0x14993
movl %r15d, %esi
xorl %eax, %eax
callq 0x1030
leaq -0x140(%rbp), %rbx
movq %rbx, %rdi
movl %r15d, %esi
callq 0xa979
leaq -0x258(%rbp), %rdi
movl %r15d, %esi
callq 0xa979
leaq -0x310(%rbp), %rdi
movl %r15d, %esi
callq 0xa979
leaq -0x1f8(%rbp), %rdi
movl %r15d, %esi
callq 0xa979
movq %r14, %rax
movq 0x8(%r14), %r14
movq 0x30(%rax), %rcx
movq %rcx, -0x30(%rbp)
movq %r12, %rax
movq 0x8(%r12), %r12
movq 0x30(%rax), %rax
movq %rax, -0x58(%rbp)
movq %r12, %rdi
movq %r12, -0x38(%rbp)
movq %r14, %rsi
movl %r15d, %edx
movq %rbx, %rcx
callq 0x7f5c
movq %r12, %rdi
movq %r14, %rsi
movl %r15d, %edx
leaq -0x258(%rbp), %rcx
callq 0x7f5c
movq %r12, %rdi
movq %r14, %rsi
movl %r15d, %edx
leaq -0x310(%rbp), %rcx
callq 0x7f5c
movsd (%rbx), %xmm0
movsd 0x10(%rbx), %xmm1
movq 0x30(%rbx), %rax
movsd %xmm0, 0x20(%r13)
movq %rax, 0x50(%r13)
movsd %xmm1, 0x30(%r13)
pushq $0x1
popq %rax
movl %eax, (%r13)
leaq 0x68(%rbp), %rax
movl (%rax), %ecx
movq %rcx, -0x60(%rbp)
movl 0x48(%rax), %r12d
pushq $-0x1
popq %rbx
movl %r12d, %eax
xorl %ebx, %eax
leal (%rax,%rcx,2), %eax
cltq
imulq $0x18, %rax, %rdi
callq 0x1130
leaq 0x68(%rbp), %rcx
movl 0x20(%rcx), %edx
movq 0x28(%rcx), %rcx
movl %r12d, (%rsp)
movq -0x58(%rbp), %r12
movq -0x30(%rbp), %rdi
movq %r14, -0xd0(%rbp)
movq %r14, %rsi
movq %rax, -0x78(%rbp)
movq %rax, %r8
movq -0x60(%rbp), %r9
callq 0x4769
leal (%r15,%r15), %r14d
leaq 0x10(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x30(%rbp)
xorl %eax, %ebx
leal (%rbx,%r15,2), %eax
movq -0x70(%rbp), %rbx
cltq
imulq $0x18, %rax, %rdi
callq 0x1130
movq %rax, %r8
movq %rax, -0x40(%rbp)
leaq 0x10(%rbp), %rax
movl 0x20(%rax), %edx
movq 0x28(%rax), %rcx
movl -0x30(%rbp), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq -0x38(%rbp), %rsi
movq %r15, -0x90(%rbp)
movl %r15d, %r9d
callq 0x4769
movq -0x40(%rbp), %r8
leaq 0xf5e(%rbp), %rax
subl -0x30(%rbp), %r14d
addl $-0x3, %r14d
movl %r14d, -0xa4(%rbp)
movslq %r14d, %rcx
movq %rcx, -0xe0(%rbp)
movq %rax, %r14
leaq -0x258(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
movl 0x30(%rax), %edi
movl 0x34(%rax), %eax
movl %eax, -0x84(%rbp)
leaq 0x18(%r12), %rax
movq %rax, -0xd8(%rbp)
pushq $0x1
popq %rcx
movl %ecx, -0x48(%rbp)
movl %ecx, -0x4c(%rbp)
movl %edi, -0x44(%rbp)
movq %r13, -0x98(%rbp)
pushq $0x2
popq %rdx
movq -0xd8(%rbp), %rax
movq %rax, -0xb0(%rbp)
pushq $0x1
popq %rax
cmpq -0xe0(%rbp), %rax
jge 0xc07e
movq %rax, -0x38(%rbp)
leaq (%rax,%rax), %r15
movl %edx, -0x9c(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq 0x10(%rbp), %rbx
movq %r15, -0xb8(%rbp)
cmpl %edx, -0xa4(%rbp)
jle 0xc05e
pushq $0xb
popq %r13
movq %r13, %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x38(%rbp), %rdi
movl %edx, -0x30(%rbp)
movl %edx, %esi
callq 0x9610
xorl %r12d, %r12d
movb $0x1, %cl
movl %ecx, -0x88(%rbp)
testl %eax, %eax
je 0xbb90
movq %r13, %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x198(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x976c
cmpl $0x736579, (%r14)       # imm = 0x736579
je 0xb868
movq -0x98(%rbp), %r13
jmp 0xb8cc
movq %r13, %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x38(%rbp), %rdi
movl -0x30(%rbp), %r13d
movl %r13d, %esi
movq -0x40(%rbp), %r14
movq %r14, %rdx
movq -0x78(%rbp), %rcx
callq 0x735d
movl %r13d, %edx
movq %r14, %r8
leaq 0xf5e(%rbp), %r14
testl %eax, %eax
movq -0x98(%rbp), %r13
je 0xc03c
pushq $0xb
popq %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x38(%rbp), %rdi
movl %edx, %esi
movq %r8, %rdx
movq -0x78(%rbp), %rcx
callq 0x7959
movl %eax, -0x64(%rbp)
leaq -0x198(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl -0x30(%rbp), %ecx
callq 0x804e
leaq 0x4bc(%rbp), %rdi
leaq 0x9bd0(%rip), %rsi      # 0x154bd
pushq $0x3
popq %rdx
callq 0x1090
testl %eax, %eax
jne 0xb917
pushq $0xb
popq %rcx
movq %rsp, %rdi
leaq 0x68(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x198(%rbp), %rdi
xorl %esi, %esi
pushq $0x1
popq %rdx
callq 0xa854
movq -0x190(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movq -0x90(%rbp), %rdx
leaq -0x140(%rbp), %rcx
callq 0x7f5c
pushq $0x1
popq %rsi
movl %esi, -0x68(%rbp)
movq -0x70(%rbp), %rax
movslq (%rax), %rax
imulq $0xa8, %rax, %rax
movsd -0xc8(%rbp), %xmm0
movsd %xmm0, 0x20(%r13,%rax)
movl -0x44(%rbp), %edx
movl %edx, 0x50(%r13,%rax)
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, 0x30(%r13,%rax)
movl -0x84(%rbp), %ecx
movl %ecx, 0x54(%r13,%rax)
movl %esi, (%r13,%rax)
movl -0x110(%rbp), %ecx
movl %edx, %eax
subl %ecx, %eax
xorl %esi, %eax
movq -0x80(%rbp), %rdx
movl (%rdx), %edi
movl %edi, %edx
xorl %esi, %edx
orl %eax, %edx
jne 0xba71
movq -0x58(%rbp), %rax
movq -0x8(%rax,%r15,8), %rsi
movq -0x60(%rbp), %rax
movq -0x8(%rax), %r8
movq (%rax), %rdx
cmpq %rdx, %rsi
jne 0xb9be
movq %r8, %rax
jmp 0xb9d8
movq %rsi, %rax
cmpq %r8, %rsi
je 0xb9d8
movq %r8, %rax
movq -0x58(%rbp), %r9
cmpq %r8, -0x10(%r9,%r15,8)
jne 0xba71
movsd -0x140(%rbp), %xmm0
movsd -0x130(%rbp), %xmm1
movl -0x10c(%rbp), %edi
movq -0x70(%rbp), %rbx
movslq (%rbx), %r8
imulq $0xa8, %r8, %r8
movl -0x30(%rbp), %r9d
movl %r9d, 0x8(%r13,%r8)
movq -0x38(%rbp), %r9
movl %r9d, 0x4(%r13,%r8)
movsd %xmm1, 0x30(%r13,%r8)
movsd %xmm0, 0x20(%r13,%r8)
movl %ecx, 0x50(%r13,%r8)
movl %edi, 0x54(%r13,%r8)
movslq (%rbx), %rcx
imulq $0xa8, %rcx, %rcx
movl %esi, 0x80(%r13,%rcx)
movq -0x58(%rbp), %rcx
movl -0x10(%rcx,%r15,8), %ecx
movslq (%rbx), %rsi
imulq $0xa8, %rsi, %rsi
movl %ecx, 0x84(%r13,%rsi)
movslq (%rbx), %rcx
imulq $0xa8, %rcx, %rcx
movl %edx, 0x88(%r13,%rcx)
leaq -0x470(%rbp), %rdi
jmp 0xbb30
cmpl $0x0, -0x4c(%rbp)
sete %al
cmpl $0x1, -0x64(%rbp)
sete %cl
testl %edi, %edi
jne 0xbb8c
orb %al, %cl
je 0xbb8c
movq -0x70(%rbp), %rbx
movslq (%rbx), %rax
imulq $0xa8, %rax, %rdx
addq %r13, %rdx
pushq $0xc
popq %rcx
movq %rsp, %rdi
leaq -0x140(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
andl $0x0, 0x60(%rsp)
xorl %r12d, %r12d
leaq -0x68(%rbp), %rdi
leaq 0x4bc(%rbp), %rsi
movq -0x38(%rbp), %rcx
movl -0x30(%rbp), %r8d
xorl %r9d, %r9d
callq 0x9471
testl %eax, %eax
je 0xbb88
movq -0x58(%rbp), %rdx
movl -0x8(%rdx,%r15,8), %eax
movslq (%rbx), %rcx
imulq $0xa8, %rcx, %rcx
movl %eax, 0x80(%r13,%rcx)
movl -0x10(%rdx,%r15,8), %eax
movslq (%rbx), %rcx
imulq $0xa8, %rcx, %rcx
movl %eax, 0x84(%r13,%rcx)
movq -0x60(%rbp), %rdx
movl (%rdx), %eax
movslq (%rbx), %rcx
imulq $0xa8, %rcx, %rcx
movl %eax, 0x88(%r13,%rcx)
movq -0x8(%rdx), %rax
leaq -0x418(%rbp), %rdi
movslq (%rbx), %rcx
imulq $0xa8, %rcx, %rcx
movl %eax, 0x8c(%r13,%rcx)
movslq (%rbx), %rax
imulq $0xa8, %rax, %rax
addq %r13, %rax
pushq $0xb
popq %r13
movq %r13, %rcx
leaq 0x10(%rbp), %rbx
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x934f
movl $0x0, -0x88(%rbp)
pushq $0x1
popq %r12
jmp 0xbb90
leaq 0x10(%rbp), %rbx
pushq $0xb
popq %r13
movq %r13, %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl -0x30(%rbp), %edi
movq -0x38(%rbp), %rsi
callq 0x9610
testl %eax, %eax
je 0xc02a
movq %r13, %rcx
movq %rsp, %rdi
leaq -0x198(%rbp), %r12
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x2b0(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x976c
movq %r13, %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x976c
cmpl $0x736579, (%r14)       # imm = 0x736579
je 0xbbfd
movq -0x38(%rbp), %rcx
movl -0x30(%rbp), %edx
jmp 0xbc6f
movq %r13, %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl -0x30(%rbp), %r12d
movl %r12d, %edi
movq -0x38(%rbp), %r15
movl %r15d, %esi
movq -0x40(%rbp), %r14
movq %r14, %rdx
movq -0x78(%rbp), %rcx
callq 0x735d
testl %eax, %eax
je 0xc048
movq %r13, %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movl %r12d, %edi
movl %r15d, %esi
movq %r14, %rdx
movq -0x78(%rbp), %rcx
callq 0x7959
testl %eax, %eax
pushq $0x2
popq %rax
movl -0x64(%rbp), %ecx
cmovnel %eax, %ecx
movl %ecx, -0x64(%rbp)
leaq 0xf5e(%rbp), %r14
movq %r15, %rcx
movq -0xb8(%rbp), %r15
movl %r12d, %edx
leaq -0x198(%rbp), %rsi
callq 0x804e
leaq 0x4bc(%rbp), %rdi
leaq 0x9834(%rip), %rsi      # 0x154bd
pushq $0x3
popq %rdx
callq 0x1090
testl %eax, %eax
movq -0x90(%rbp), %rbx
jne 0xbcba
pushq $0xb
popq %rcx
movq %rsp, %rdi
leaq 0x68(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x198(%rbp), %rdi
xorl %esi, %esi
pushq $0x1
popq %rdx
callq 0xa854
movq -0x190(%rbp), %r12
movq %r12, %rdi
movq -0xd0(%rbp), %rsi
movl %ebx, %edx
leaq -0x140(%rbp), %rcx
callq 0x7f5c
movq -0x2a8(%rbp), %rsi
testq %rsi, %rsi
movq -0x98(%rbp), %r13
je 0xbcff
movq %r12, %rdi
movl %ebx, %edx
leaq -0x1f8(%rbp), %rcx
callq 0x7f5c
jmp 0xbd17
leaq 0x8cd4(%rip), %rdi      # 0x149da
xorl %eax, %eax
callq 0x1030
movl $0xf423f, -0x1c8(%rbp)  # imm = 0xF423F
movl $0x1, -0x68(%rbp)
cmpb $0x0, -0x88(%rbp)
je 0xbd85
movq -0x70(%rbp), %rbx
movslq (%rbx), %rax
imulq $0xa8, %rax, %rax
movsd -0xc8(%rbp), %xmm0
movsd %xmm0, 0x20(%r13,%rax)
movl -0x44(%rbp), %esi
movl %esi, 0x50(%r13,%rax)
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, 0x30(%r13,%rax)
movl -0x84(%rbp), %ecx
movl %ecx, 0x54(%r13,%rax)
movl $0x1, (%r13,%rax)
xorl %r8d, %r8d
movl -0x110(%rbp), %eax
xorl %ecx, %ecx
xorl %r9d, %r9d
xorl %r12d, %r12d
jmp 0xbe33
movq -0x70(%rbp), %rbx
movslq (%rbx), %rcx
movl -0x110(%rbp), %eax
cmpl $0x1, -0xa0(%rbp)
jne 0xbdc0
cmpl $0x0, -0x1c8(%rbp)
jne 0xbdc0
imulq $0xa8, %rcx, %rdx
cmpl 0x50(%r13,%rdx), %eax
jne 0xbdc0
xorl %r9d, %r9d
movb $0x1, %cl
pushq $0x1
popq %r12
movl %r12d, %r8d
jmp 0xbe30
imulq $0xa8, %rcx, %rcx
movsd -0x130(%rbp), %xmm0
subsd 0x30(%r13,%rcx), %xmm0
xorl %r8d, %r8d
andpd 0x829f(%rip), %xmm0     # 0x14080
movlpd %xmm0, 0x48(%r13,%rcx)
cmpl $0x1, -0x48(%rbp)
jne 0xbe27
movsd 0x8272(%rip), %xmm1     # 0x14068
ucomisd %xmm0, %xmm1
jb 0xbe27
leaq (%rcx,%r13), %rdx
addq $0x20, %rdx
xorl %r8d, %r8d
movl $0x0, %ecx
pushq $0x2
popq %r9
movl $0x0, %r12d
cmpl %eax, 0x30(%rdx)
movl -0x44(%rbp), %esi
jg 0xbe33
pushq $0x1
popq %r12
jmp 0xc026
xorl %ecx, %ecx
xorl %r9d, %r9d
pushq $0x1
popq %r12
movl -0x44(%rbp), %esi
subl %eax, %esi
xorl $0x1, %esi
movq -0x80(%rbp), %rdx
movl (%rdx), %edx
movl %edx, %edi
xorl $0x1, %edi
orl %esi, %edi
jne 0xbf18
movq -0x58(%rbp), %rdx
movq -0x8(%rdx,%r15,8), %rdx
movq -0x60(%rbp), %rsi
movq (%rsi), %rsi
cmpq %rsi, %rdx
je 0xbe7c
movq -0x60(%rbp), %rdi
movq -0x8(%rdi), %rdi
cmpq %rdi, %rdx
je 0xbe7c
movq -0x58(%rbp), %r10
cmpq %rdi, -0x10(%r10,%r15,8)
jne 0xbf1c
cmpl $0x1, 0xd2c1(%rip)      # 0x19144
sete %dil
andb %dil, %cl
cmpb $0x1, %cl
jne 0xc026
movsd -0x140(%rbp), %xmm0
movsd -0x130(%rbp), %xmm1
movl -0x10c(%rbp), %ecx
movslq (%rbx), %rdi
imulq $0xa8, %rdi, %rdi
movq -0x38(%rbp), %r8
movl %r8d, 0x8(%r13,%rdi)
movl -0x30(%rbp), %r8d
movl %r8d, 0x4(%r13,%rdi)
movsd %xmm1, 0x30(%r13,%rdi)
movsd %xmm0, 0x20(%r13,%rdi)
movl %eax, 0x50(%r13,%rdi)
movl %ecx, 0x54(%r13,%rdi)
movslq (%rbx), %rax
imulq $0xa8, %rax, %rax
movl %esi, 0x80(%r13,%rax)
movq -0x60(%rbp), %rax
movl -0x8(%rax), %eax
movslq (%rbx), %rcx
imulq $0xa8, %rcx, %rcx
movl %eax, 0x84(%r13,%rcx)
leaq -0x3c0(%rbp), %rdi
movq -0x58(%rbp), %rcx
jmp 0xbfbc
testl %edx, %edx
je 0xbf26
testb %cl, %cl
je 0xc026
jmp 0xbf3e
cmpl $0x0, -0x4c(%rbp)
sete %al
cmpl $0x2, -0x64(%rbp)
sete %dl
orb %al, %dl
orb %cl, %dl
je 0xc026
movslq (%rbx), %rax
imulq $0xa8, %rax, %rdx
addq %r13, %rdx
pushq $0xc
popq %rcx
movq %rsp, %rdi
leaq -0x140(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movl %r8d, 0x60(%rsp)
leaq -0x68(%rbp), %rdi
leaq 0x4bc(%rbp), %rsi
movl -0x30(%rbp), %ecx
movq -0x38(%rbp), %r8
callq 0x9471
testl %eax, %eax
je 0xc026
movq -0x60(%rbp), %rdx
movl (%rdx), %eax
movslq (%rbx), %rcx
imulq $0xa8, %rcx, %rcx
movl %eax, 0x80(%r13,%rcx)
movl -0x8(%rdx), %eax
movslq (%rbx), %rcx
imulq $0xa8, %rcx, %rcx
movl %eax, 0x84(%r13,%rcx)
movq -0x58(%rbp), %rcx
movq -0x8(%rcx,%r15,8), %rdx
leaq -0x368(%rbp), %rdi
movq -0x40(%rbp), %r8
movslq (%rbx), %rax
imulq $0xa8, %rax, %rax
movl %edx, 0x88(%r13,%rax)
movl -0x10(%rcx,%r15,8), %eax
movslq (%rbx), %rcx
imulq $0xa8, %rcx, %rcx
movl %eax, 0x8c(%r13,%rcx)
movslq (%rbx), %rax
imulq $0xa8, %rax, %rax
addq %r13, %rax
pushq $0xb
popq %rdx
movq %rdx, %rcx
leaq 0x10(%rbp), %rbx
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rdx, %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
movq %r8, %rsi
callq 0x934f
movq -0x40(%rbp), %r8
movl -0x30(%rbp), %edx
jmp 0xc036
leaq 0x10(%rbp), %rbx
movq -0x40(%rbp), %r8
movl -0x30(%rbp), %edx
testl %r12d, %r12d
je 0xc03c
movq -0x70(%rbp), %rax
incl (%rax)
addq $0x10, -0x60(%rbp)
incl %edx
jmp 0xb7fd
movq %r14, %r8
leaq 0xf5e(%rbp), %r14
movq -0xb8(%rbp), %r15
movl %r12d, %edx
jmp 0xc03c
movq -0x38(%rbp), %rax
incq %rax
addq $0x10, -0xb0(%rbp)
movl -0x9c(%rbp), %edx
incl %edx
movq -0x70(%rbp), %rbx
jmp 0xb7cc
movl (%rbx), %ecx
testl %ecx, %ecx
sete %dl
movl -0x48(%rbp), %r9d
cmpl $0x1, %r9d
sete %al
andb %dl, %al
movl $0x0, %esi
cmovnel %esi, %r9d
movl %r9d, -0x48(%rbp)
cmpl $0x1, -0x4c(%rbp)
sete %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0xc0d1
movq -0x80(%rbp), %rcx
movl (%rcx), %ecx
pushq $0x1
popq %rdx
movl %edx, -0x4c(%rbp)
testl %ecx, %ecx
jne 0xc0df
movb $0x1, %al
movl $0x0, -0x4c(%rbp)
pushq $0x1
popq %rcx
movl %ecx, -0x48(%rbp)
jmp 0xc0f6
testl %ecx, %ecx
je 0xc0d9
xorl %eax, %eax
jmp 0xc0f6
movq -0x80(%rbp), %rcx
movl (%rcx), %ecx
cmpl $0x1, %ecx
jne 0xc0f6
movq -0x80(%rbp), %rax
andl $0x0, (%rax)
pushq $0x1
popq %rax
movl %eax, -0x48(%rbp)
jmp 0xb7b8
testb %al, %al
jne 0xb7b8
pushq $0xb
popq %r14
movq %r14, %rcx
movq %rsp, %rdi
leaq 0x10(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r8, %rdi
callq 0x6dfa
movq %r14, %rcx
movq %rsp, %rdi
leaq 0x68(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x78(%rbp), %rdi
callq 0x6dfa
leaq -0x140(%rbp), %rdi
movq -0x90(%rbp), %r14
movl %r14d, %esi
callq 0xaa34
leaq -0x258(%rbp), %rdi
movl %r14d, %esi
callq 0xaa34
leaq -0x198(%rbp), %rdi
movl (%rdi), %esi
callq 0xa1b9
movl (%rbx), %eax
addq $0x4b8, %rsp            # imm = 0x4B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq