// File: /workspace/github_cpp_makefile_star2_O3/dcarrey[P]hgt-detection/./utils_tree.cpp
// Function: lectureNewick(char const*, long*, double*, char**, int*)
int lectureNewick(const char * newick, long int * ARETE, double * LONGUEUR, char ** lesNoms, int *kt)
{
	int n;                                     
	int cpt_x;
	// Ce sous programme permet de lire un arbre au format newick et de le transcrire dans
	// des vecteurs arete-longueur commencant � 1
	// ATTENTION: les noms commencent � 0
	// 7 octobre 2004
	// Elmaestro

	// TODO: Add your command handler code here
	int i,j,j1,k, a, a1, a2,a3, VertexNumber,numero;
	char symbol, *string, *string1, *string2, *string4;
	int taxaPos; // le nombre de taxas recup�r�
	int aretePos; // le nombre d'aretes recup�r�
	char symbolOld =' ';
	int zz, xx,jj,ii;
	double longueur;
	char * tempString;
	int cpt=0;
	//char *string4 = (char*) malloc(100000 * sizeof(char));
	string4 = (char*)malloc((100000) * sizeof(char));
	//char *string4 = (char*) malloc(100000);
	//char *string4 = new char[10000];

	int temoin=0;
	int cpt_parenthese=0;
	//long int *ARETE;
	//double *LONGUEUR; 	

	//Correctness of the Newick format verification
	i=0;
	n = 0;

	do
	{
		symbol = newick[cpt++];
		if (symbol==':') i++;
		if(symbol == ':' && symbolOld !=')' && temoin != 1) n++;
		if(symbol >= '0' && symbol <= '9' && symbolOld==')') temoin=1;
		if(symbol==':' && temoin==1) temoin=0;
		symbolOld = symbol;
	}  while(symbol != '\0');

	cpt=0;

	if(i<=2*n-3)(*kt)=i;
	else (*kt)=2*n-3;

	if (i == 0) { printf("Incorrect Newick file format. Edge lengths must be indicated after a ':' characters."); exit(FAIL);}

	if ((i>2*n-3) || (i<n)){
		//printf("Unable to read your input data, please check it and try again...");
		//exit(-1);
	}

	j=0;
	do{ 
	   symbol=newick[cpt++]; 
	   if (symbol=='(') j++; 
	}while(symbol != '\0');
	
	cpt=0;	
	j1=0;
	
	do{
		symbol=newick[cpt++];
		if (symbol==')') j1++; 
	}while(symbol != '\0');  
	
	cpt=0;

	// verification des arit�s de l'arbre
	if (j1!=j) { printf("Incorrect Newick file format. Number of right parentheses must be equal to number of left parentheses."); exit(FAIL);}
	//else if (j!=n-2) { printf("Incorrect Newick file format. Only trees with vertices of degree 1 and 3 are allowed by T-REX."); fclose (data); exit(FAIL);}

	k=0;

	do{ 
		symbol=newick[cpt++];
		if (symbol==',') k++; 
	}while(symbol != '\0');   
	
	cpt=0;
	//if (k!=(n-1)) { printf("Incorrect Newick file format. Number of objects must be equal to number of commas plus 1."); fclose (data); exit(FAIL);}

	a=0;

	do{ 
		symbol=newick[cpt++];
		if (symbol==';') a++; 
	}while(symbol != '\0');    
	cpt=0;

	if (a==0) { printf("Incorrect Newick file format. Newick string must be followed by a ';' character."); exit(FAIL);}
	else if (a>1) { printf("Incorrect Newick file format. Newick string must contain (in the end) only one ';' character."); exit(FAIL);}

	a=0;
	do{
		symbol=newick[cpt++];a++;
	}while(symbol == ' '); 
	
	cpt=0;

	if (symbol!='(') { printf("Incorrect Newick file format. Newick string must begin with a '(' character."); exit(FAIL);}  

	a=0;
	
	do{ symbol=newick[cpt++];
		if (symbol=='%') a++; 
	}while(symbol != '\0');

	cpt=0;

	if (a>0) { printf("Incorrect Newick file format. Newick string cannot contain \'%%\' character."); exit(FAIL);}

	do
	{
		symbol=newick[cpt++];
		if ((symbol=='(')||(symbol==','))		
		{ 
			symbol=newick[cpt++]; a=0;
			if ((symbol!='(')&&(symbol!=',')&&(symbol!=';')&&(symbol!=':'))		   
			{ 
				cpt--; 
				do{
					symbol=newick[cpt++];a++;
				}while ((symbol!=':')&&(symbol!='\0'));  
			}
			else cpt--;
			if (a>50) { printf("Incorrect Newick file format. Names of objects must not exceed 50 characters.");  exit(FAIL);}   
		}	
	}while(symbol != '\0');
	cpt=0;

	string = (char*)malloc((100000) * sizeof(char));
	string2 = (char*)malloc((100000) * sizeof(char));
	//string3 = (char*)malloc((1000*n) * sizeof(char));
	string1 = (char*)malloc((100000) * sizeof(char));

	if ((string == NULL)||(string1 == NULL)||(string2 == NULL)/*||(string3 == NULL)*/)
	{ printf("Input data are too large or not a correct Newick file chosen"); exit(FAIL);}

	a=0;

	do{		
		symbol=newick[cpt++];
		if ((symbol!=' ')&&(symbol!='\n')&&(symbol!='\t')) { string[a++]=symbol; } 
	}while(symbol !='\0'); 

	int boot_value;
	int temoin3 = 0;
	k=0; VertexNumber=n;
	//a1 = 0;
	//a2 = 0;
	taxaPos =1;    // nous allons commencer � mettre les taxas � la position 1
	aretePos = 1;
	boot_value=0;
	
	while (string[0] == '(')   // traiter toute la chaine
	{
		a1 = 0;
		a2 = 0;
		while( string[a2] != ')')  // traiter la paire () la plus profonde
		{
			if(string[a2] == '(') a1 = a2;  // retrouver ;a parenth�se ouvrante
			a2++;
		}
		

		// a   => contient la longueur de la chaine
		// a1  => contient le debut d'un noeud � traiter
		// a2  => contient la fin d'un noeud � traiter
		// a3  => d�limite le noeud et sa longueur

		zz = a1+1;
		VertexNumber++;  // augmenter le nombre de noeuds
		boot_value=0;
		for ( ii = a1+1; ii <= a2; ii++)
		{// decortiquer cette chaine

			if (string[ii] == ':')
			{
				xx = 0;
				a3 = ii+1;

				if( string[zz] == '%')
				{ // cela veut dire que c'est un  noeud que l'on traite

					for ( jj = zz+1; jj < ii; jj++)
					{
						if(string[jj] == '|')
							break;
						string1[xx++] = string[jj]; 
					}
					temoin3=1;
					string1[xx++] = '\0';
					numero = atoi(string1);
					
					if(string[jj] == '|' ){
						boot_value=1;
						cpt_x=0;
						jj++;
						while(string[jj] != ':')
							string4[cpt_x++] = string[jj++];
						string4[cpt_x] = '\0';
					}
					
				}
				else
				{
					// on recup�re le nom du taxa

					for(jj = zz; jj < ii; jj++)
					{
						lesNoms[taxaPos-1][xx++] = string[jj];
					}
					numero = taxaPos;
					lesNoms[taxaPos-1][xx] = '\0';  // mettre la fin de chaine
					taxaPos++;  // augmenter le nombre de taxas pris
				}

			}
			else if(string[ii] == ','  || string[ii] == ')')
			{
				xx = 0;
				zz = ii +1;   // faire pointer sur le prochain noeud
				for ( jj = a3; jj < ii; jj++)
				{
					string1[xx++] = string[jj]; 
				}
				string1[xx++] = '\0';
				longueur = atof(string1);
				ARETE[aretePos++] = VertexNumber;
				ARETE[aretePos++] = numero;
				LONGUEUR[(aretePos-1)/ 2] = longueur;

				if(boot_value == 1){
					//printf("\n%d--%d : %lf (%s)",VertexNumber,numero,longueur,string4);
					boot_value=0;
				}
			}

		}

		// fin for pour traiter noeud
		//transcrire la nouvelle chaine
		xx = 0;
		for ( jj = 0; jj < (int)a1; jj++)
		{string2[xx++] = string[jj];}

		// ecrire le vertex
		//	char buffer[50];
		itoa_(VertexNumber,string1,10);
		string2[xx++] = '%';   // indiquer que c'est un noeud
		for( jj = 0; jj < (int) strlen(string1); jj++)
		{string2[xx++] = string1[jj];}

		int temoin=0;
		
		// transcrire la fin
		for( jj = a2+1; jj <= a; jj++)  // il faut voir si c'est  <= a ou c < a
		{
			if(string[jj] != ':' && temoin==0){
				string2[xx++] = '|';	
			}
			temoin = 1;
			//if(temoin==1)
				string2[xx++] = string[jj];
			
		}

		// remplacer string par string2 en remplacant les pointeurs
		
		tempString = string;
		string = string2;
		string2 = tempString;
		tempString = 0;
		a = xx;  // mettre la longueur � jour 

	} // fin du while pour traiter toute la string

	int root_existance = -1;
	for( jj=n;jj>0;jj--){
		strcpy(lesNoms[jj],lesNoms[jj-1]);
		if (strcmp(lesNoms[jj],"Root") == 0)
			root_existance = jj;
	}
	printf("\nRoot_existance = %d",root_existance);
	for( jj=1;jj<=n;jj++){
		printf("\n(%d) - %s",jj,lesNoms[jj]); 
	}
	
	
	ARETE[aretePos++] = 0;
	ARETE[aretePos++] = 0;


	for(i=1;i<=2*n-3;i++){
		LONGUEUR[i-1] = LONGUEUR[i];
		if(LONGUEUR[i-1] < 5*epsilon){
			LONGUEUR[i-1] = 5*epsilon;
		}
	}
	for(i=1;i<=2*(2*n-3);i++){
		ARETE[i-1] = ARETE[i];
	}
	
	//== recherche des branches connexes a celle de la racine;
	if( root_existance > 0){
		int noeud_interne = -1;
		for(i=1;i<=2*n-3;i++){
			if(ARETE[2*i-1] == root_existance)
				noeud_interne = ARETE[2*i-2];
			if(ARETE[2*i-2] == root_existance)
				noeud_interne = ARETE[2*i-1];
		}
		printf("\n[%d,%d]",noeud_interne,root_existance);
		for(i=1;i<=2*n-3;i++){
			if((ARETE[2*i-1] != root_existance) && (noeud_interne == ARETE[2*i-2])){
				LONGUEUR[i-1] = 50;
				printf("\n[%d,%ld]",noeud_interne,ARETE[2*i-1]);
			}
			if((ARETE[2*i-2] != root_existance) && (noeud_interne == ARETE[2*i-1])){
				LONGUEUR[i-1] = 50;
				printf("\n[%d,%ld]",noeud_interne,ARETE[2*i-2]);
			}
		}
		
		
	}
	
	
	//=== on teste si il y a un noeud de degre 2 et un noeud de degre 1

	printf("\n");
	for(i=1;i<=2*n-3;i++){
		printf("\n%ld-%ld --> %lf",ARETE[2*i-1],ARETE[2*i-2],LONGUEUR[i-1]);
	}
    printf("\n");
  
	int * tableau = (int*)malloc((2*n)*sizeof(int));
	int deg2=-1,deg1=-1;
	for(i=1;i<2*n;i++)
		tableau[i-1] = 0;
	for(i=1;i<=2*n-3;i++){
		tableau[ARETE[2*i-1]]++;
		tableau[ARETE[2*i-2]]++;
	}
//	printf("\n");
	i=n+1;
	while(tableau[i] > 0){
		//printf("\n%d-->%d",i,tableau[i]);
		if(tableau[i] == 2) deg2 = i;
		if(tableau[i] == 1) deg1 = i;
		i++;
	}
	//printf("\ndeg2=%d , deg1=%d",deg2,deg1);
	int pos_racine=-1;
	
	for(i=1;i<=2*n-3;i++){
		if(ARETE[2*i-1] == deg1){ ARETE[2*i-1] = deg2; pos_racine=i; break;} 
		if(ARETE[2*i-2] == deg1){ ARETE[2*i-2] = deg2; pos_racine=i; break;} 
	}
    if(pos_racine != -1){
        LONGUEUR[pos_racine-1] = 100;
    }
	/*printf("\n");
	for(i=1;i<=2*n-3;i++){
		printf("\n%d-%d --> %lf",ARETE[2*i-1],ARETE[2*i-2],LONGUEUR[i-1]);
	}
  printf("\n");
*/

	free(string);
	free(string1);
	free(string2);
	//free(string3);

	(*kt) = 2*n-3 - (*kt);
    
    
	return pos_racine;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r8, %r14
movq %rcx, -0x80(%rbp)
movq %rsi, %r12
movq %rdi, %r15
xorl %r9d, %r9d
movb $0x20, %bl
movl $0x1, %eax
movq %rdi, %rcx
xorl %r8d, %r8d
xorl %r10d, %r10d
movl %r8d, %edi
movl %r10d, %esi
movq %rsi, -0x78(%rbp)
movl %r9d, %esi
movl %ebx, %r9d
movb (%rcx), %bl
leal -0x30(%rbx), %r10d
cmpb $0xa, %r10b
cmovbl %eax, %edi
cmpb $0x29, %r9b
setne %r10b
cmovnel %r8d, %edi
movl $0x0, %r9d
cmpl $0x1, %edi
je 0x5208
movl %edi, %r9d
xorl %r11d, %r11d
cmpb $0x3a, %bl
sete %r11b
cmovel %r9d, %edi
leal (%rsi,%r11), %r9d
cmpl $0x1, %r8d
setne %r8b
andb %r8b, %r10b
andb %r10b, %r11b
movzbl %r11b, %r10d
addl -0x78(%rbp), %r10d
incq %rcx
movl %edi, %r8d
testb %bl, %bl
jne 0x51d4
leal -0x3(,%r10,2), %eax
cmpl %eax, %esi
movl %eax, -0x30(%rbp)
cmovll %esi, %eax
movl %eax, (%r14)
testl %esi, %esi
je 0x5b7c
leal (%r10,%r10), %r9d
xorl %eax, %eax
movq %r15, %rcx
movb (%rcx), %dil
xorl %esi, %esi
cmpb $0x28, %dil
sete %sil
addl %esi, %eax
incq %rcx
testb %dil, %dil
jne 0x525e
xorl %esi, %esi
movq %r15, %rcx
movl %esi, %r8d
movb (%rcx), %dil
xorl %esi, %esi
cmpb $0x29, %dil
sete %sil
addl %r8d, %esi
incq %rcx
testb %dil, %dil
jne 0x527a
cmpl %eax, %r8d
jne 0x5b85
xorl %edi, %edi
movq %r15, %rcx
movl %edi, %eax
movb (%rcx), %sil
xorl %edi, %edi
cmpb $0x3b, %sil
sete %dil
addl %eax, %edi
incq %rcx
testb %sil, %sil
jne 0x52a3
cmpl $0x1, %eax
jne 0x5b6f
movq %r15, %rax
movzbl (%rax), %ecx
incq %rax
cmpl $0x20, %ecx
je 0x52c8
cmpl $0x28, %ecx
jne 0x5b57
xorl %ecx, %ecx
movq %r15, %rax
movl %ecx, %edi
movb (%rax), %sil
xorl %ecx, %ecx
cmpb $0x25, %sil
sete %cl
addl %edi, %ecx
incq %rax
testb %sil, %sil
jne 0x52e1
testl %edi, %edi
jne 0x5b97
xorl %eax, %eax
movabsq $0xc00110000000000, %rcx # imm = 0xC00110000000000
movslq %eax, %rsi
incl %eax
movb (%r15,%rsi), %r8b
movl %r8d, %esi
andb $-0x5, %sil
cmpb $0x28, %sil
jne 0x5337
movslq %eax, %rsi
movzbl (%r15,%rsi), %r8d
cmpq $0x3b, %r8
ja 0x533e
btq %r8, %rcx
jae 0x533e
testb %r8b, %r8b
jne 0x530d
jmp 0x536d
addq %r15, %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movzbl (%rsi), %r8d
incl %eax
incl %edi
cmpl $0x3a, %r8d
je 0x535c
incq %rsi
testl %r8d, %r8d
jne 0x5346
cmpl $0x32, %edi
jb 0x5337
leaq 0x10304(%rip), %rdi     # 0x1566c
jmp 0x5b5e
movl %r9d, -0x9c(%rbp)
movq %r10, -0x90(%rbp)
movq %rdx, -0x58(%rbp)
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1140
movq %rax, %r13
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1140
movq %rax, %rbx
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1140
testq %rbx, %rbx
je 0x5ba0
testq %r13, %r13
je 0x5ba0
movq %rax, %r8
testq %rax, %rax
je 0x5ba0
movl $0x0, -0x34(%rbp)
movabsq $0x100000600, %rax      # imm = 0x100000600
movq -0x80(%rbp), %r10
movzbl (%r15), %ecx
cmpq $0x20, %rcx
ja 0x53e6
btq %rcx, %rax
jb 0x53f6
movl -0x34(%rbp), %esi
movslq %esi, %rdx
incl %esi
movl %esi, -0x34(%rbp)
movb %cl, (%r13,%rdx)
incq %r15
testb %cl, %cl
jne 0x53d6
movq %r14, -0xa8(%rbp)
movl $0x1, %r14d
cmpb $0x28, (%r13)
movq -0x78(%rbp), %rax
movl %eax, %ecx
movq %r12, -0x40(%rbp)
movq %r8, -0x60(%rbp)
movq %rcx, -0xb0(%rbp)
jne 0x5716
movl $0x1, %eax
movq %rax, -0x68(%rbp)
movq %rcx, -0x98(%rbp)
movl $0x1, -0x4c(%rbp)
movq %r13, %rsi
movq %rbx, %rcx
movb $0x28, %al
xorl %ebx, %ebx
xorl %r14d, %r14d
cmpb $0x28, %al
je 0x545c
movzbl %al, %eax
cmpl $0x29, %eax
jne 0x545f
jmp 0x5468
movl %ebx, %r14d
movb 0x1(%rsi,%rbx), %al
incq %rbx
jmp 0x544e
movq %rcx, -0x70(%rbp)
incq -0x98(%rbp)
cmpl %ebx, %r14d
movq %rsi, -0x88(%rbp)
jge 0x5624
leal 0x1(%r14), %r11d
movslq %r14d, %r15
incq %r15
movl %r14d, %r12d
movzbl (%rsi,%r15), %eax
cmpl $0x29, %eax
je 0x54fe
cmpl $0x2c, %eax
je 0x54fe
cmpl $0x3a, %eax
jne 0x558d
leaq 0x1(%r15), %r13
movslq %r11d, %rax
cmpb $0x25, (%rsi,%rax)
jne 0x5595
incq %rax
cmpq %rax, %r15
movl %r11d, -0xa0(%rbp)
jle 0x55bd
movl %r12d, %ecx
subl %r11d, %ecx
leaq (%rsi,%rax), %rdx
xorl %esi, %esi
movb (%rdx,%rsi), %dil
cmpb $0x7c, %dil
je 0x55e2
movb %dil, (%r8,%rsi)
leaq (%rax,%rsi), %rdi
incq %rdi
incq %rsi
cmpq %r15, %rdi
jl 0x54d8
jmp 0x55e4
movslq -0x2c(%rbp), %rcx
cmpq %rcx, %r15
jle 0x5523
movl %r15d, %eax
subl %ecx, %eax
addq %rsi, %rcx
xorl %edx, %edx
movb (%rcx,%rdx), %sil
movb %sil, (%r8,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x5511
jmp 0x5525
xorl %eax, %eax
incq %r15
movb $0x0, (%r8,%rax)
movq %r8, %rdi
callq 0x1120
movq -0x60(%rbp), %r8
movq -0x68(%rbp), %rsi
movslq %esi, %rax
incl %esi
movq -0x40(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq %rcx, (%rdx,%rax,8)
movslq -0x48(%rbp), %rcx
movq %rcx, 0x8(%rdx,%rax,8)
leal 0x2(%rax), %ecx
shrl $0x1f, %esi
addl %esi, %eax
incl %eax
sarl %eax
cltq
movq -0x58(%rbp), %rdx
movsd %xmm0, (%rdx,%rax,8)
movl %r15d, %r13d
movl %ecx, %eax
movq %rax, -0x68(%rbp)
movl %r15d, %r11d
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %r10
jmp 0x5613
incq %r15
movl %r15d, %r13d
jmp 0x5613
movslq -0x4c(%rbp), %rcx
cmpq %rax, %r15
jle 0x55c1
subl %eax, %r15d
addq %rsi, %rax
xorl %edx, %edx
movb (%rax,%rdx), %r9b
movq -0x8(%r10,%rcx,8), %rdi
movb %r9b, (%rdi,%rdx)
incq %rdx
cmpq %rdx, %r15
jne 0x55a6
jmp 0x55c4
xorl %eax, %eax
jmp 0x55e6
xorl %r15d, %r15d
movq -0x8(%r10,%rcx,8), %rax
movb $0x0, (%rax,%r15)
incl %ecx
movq %r13, %r15
movl %r13d, -0x2c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl %ecx, -0x4c(%rbp)
jmp 0x5613
movl %esi, %ecx
movl %ecx, %eax
movb $0x0, (%r8,%rax)
movq %r8, %rdi
callq 0x11a0
movq -0x60(%rbp), %r8
movl %eax, -0x48(%rbp)
movq %r13, %r15
movl %r13d, -0x2c(%rbp)
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %r10
movl -0xa0(%rbp), %r11d
movl %ebx, %eax
subl %r13d, %eax
incl %r12d
cmpl $-0x1, %eax
jne 0x5490
testl %r14d, %r14d
jle 0x563e
movl %r14d, %edx
movq -0x70(%rbp), %r12
movq %r12, %rdi
callq 0x1080
movq -0x60(%rbp), %r8
jmp 0x5645
xorl %r14d, %r14d
movq -0x70(%rbp), %r12
movq -0x98(%rbp), %rdi
movq %r8, %rsi
movl $0xa, %edx
movq %r8, %r13
callq 0x50c3
movl %r14d, %r15d
movb $0x25, (%r12,%r15)
movq %r13, %rdi
callq 0x1050
testl %eax, %eax
jle 0x56a6
addq %r15, %r12
incq %r12
incq %r15
xorl %r14d, %r14d
movq -0x60(%rbp), %r13
movb (%r13,%r14), %al
movb %al, (%r12,%r14)
incq %r14
movq %r13, %rdi
callq 0x1050
cltq
cmpq %rax, %r14
jl 0x5680
addl %r14d, %r15d
movl %r15d, %r14d
movq %r13, %r8
jmp 0x56ad
incl %r14d
movq -0x60(%rbp), %r8
movl -0x34(%rbp), %eax
cmpl %ebx, %eax
movq -0x40(%rbp), %r12
movq -0x70(%rbp), %r13
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %r10
jle 0x56fa
movl %eax, %eax
movb $0x1, %dl
movb 0x1(%rsi,%rbx), %cl
testb $0x1, %dl
je 0x56e5
cmpb $0x3a, %cl
je 0x56e5
movslq %r14d, %rdx
incl %r14d
movb $0x7c, (%r13,%rdx)
incq %rbx
movslq %r14d, %rdx
incl %r14d
movb %cl, (%r13,%rdx)
xorl %edx, %edx
cmpq %rbx, %rax
jne 0x56cb
cmpb $0x28, (%r13)
movq %rsi, %rbx
movl %r14d, -0x34(%rbp)
je 0x5441
movslq -0x68(%rbp), %r14
movq -0x78(%rbp), %rax
jmp 0x5719
movq %rbx, %rsi
movq %rsi, -0x88(%rbp)
movq %r13, -0x70(%rbp)
movq -0x90(%rbp), %rcx
movl %ecx, %edx
movq %rdx, -0x68(%rbp)
testl %ecx, %ecx
je 0x599c
movq %r14, -0x48(%rbp)
leal 0x1(%rax), %r12d
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leaq 0xffa9(%rip), %rbx      # 0x156f7
movq -0xb0(%rbp), %r13
movq %r10, %r14
movq -0x8(%r14,%r13,8), %rsi
movq (%r14,%r13,8), %rdi
callq 0x1090
movq (%r14,%r13,8), %rdi
movq %rbx, %rsi
callq 0x1170
testl %eax, %eax
cmovel %r13d, %r15d
decq %r13
decl %r12d
cmpl $0x1, %r12d
jg 0x5758
leaq 0xff71(%rip), %rdi      # 0x156fc
movl %r15d, %esi
xorl %eax, %eax
callq 0x1030
cmpl $0x0, -0x90(%rbp)
je 0x59bb
movl $0x1, %ebx
movq -0x40(%rbp), %r12
movq -0x80(%rbp), %r14
movq -0x68(%rbp), %r13
movq (%r14,%rbx,8), %rdx
leaq 0xff53(%rip), %rdi      # 0x15711
movl %ebx, %esi
xorl %eax, %eax
callq 0x1030
leaq 0x1(%rbx), %rax
cmpq %r13, %rbx
movq %rax, %rbx
jb 0x57b3
xorpd %xmm0, %xmm0
movq -0x48(%rbp), %rax
movupd %xmm0, (%r12,%rax,8)
movb $0x1, %dil
movq -0x90(%rbp), %rsi
cmpl $0x1, %esi
je 0x5847
movslq -0x30(%rbp), %rax
xorl %ecx, %ecx
movsd 0xf842(%rip), %xmm0     # 0x15040
movq -0x58(%rbp), %rdx
movapd %xmm0, %xmm1
maxsd 0x8(%rdx,%rcx,8), %xmm1
movsd %xmm1, (%rdx,%rcx,8)
incq %rcx
cmpq %rax, %rcx
jl 0x5802
cmpl $0x1, %esi
je 0x5847
leaq 0x8(%r12), %rsi
movq -0x78(%rbp), %rax
leal -0x6(,%rax,4), %eax
cmpl $0x2, %eax
movl $0x1, %edx
cmovgel %eax, %edx
shlq $0x3, %rdx
movq %r12, %rdi
callq 0x11c0
xorl %edi, %edi
movl %edi, -0x2c(%rbp)
testl %r15d, %r15d
jle 0x593f
movl -0x2c(%rbp), %ebx
testb %bl, %bl
jne 0x59d1
movl %r15d, %r13d
movslq -0x30(%rbp), %r12
movq -0x40(%rbp), %rax
addq $0x8, %rax
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movq -0x8(%rax), %rdx
movq (%rax), %rsi
cmpq %r13, %rsi
movl %edx, %edi
cmovnel %r14d, %edi
cmpq %r13, %rdx
movl %esi, %r14d
cmovnel %edi, %r14d
addq $0x10, %rax
incq %rcx
cmpq %r12, %rcx
jl 0x5875
leaq 0xfe7a(%rip), %rdi      # 0x1571c
movl %r14d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1030
testb %bl, %bl
jne 0x59e7
movslq %r14d, %rcx
movq -0x40(%rbp), %rax
leaq 0x8(%rax), %rbx
xorl %r15d, %r15d
movq %rcx, -0x48(%rbp)
movq (%rbx), %rdx
cmpq %r13, %rdx
je 0x58fe
cmpq %rcx, -0x8(%rbx)
jne 0x58fe
movq -0x58(%rbp), %rax
movabsq $0x4049000000000000, %rcx # imm = 0x4049000000000000
movq %rcx, (%rax,%r15,8)
leaq 0xfe35(%rip), %rdi      # 0x15725
movl %r14d, %esi
xorl %eax, %eax
callq 0x1030
movq -0x48(%rbp), %rcx
movq -0x8(%rbx), %rdx
cmpq %r13, %rdx
je 0x5933
cmpq %rcx, (%rbx)
jne 0x5933
movq -0x58(%rbp), %rax
movabsq $0x4049000000000000, %rcx # imm = 0x4049000000000000
movq %rcx, (%rax,%r15,8)
leaq 0xfe00(%rip), %rdi      # 0x15725
movl %r14d, %esi
xorl %eax, %eax
callq 0x1030
movq -0x48(%rbp), %rcx
addq $0x10, %rbx
incq %r15
cmpq %r12, %r15
jl 0x58c9
movl $0xa, %edi
callq 0x1160
movb $0x1, %r14b
cmpb $0x0, -0x2c(%rbp)
jne 0x59f4
movslq -0x30(%rbp), %r14
movq -0x40(%rbp), %rax
leaq 0x8(%rax), %r15
xorl %r12d, %r12d
leaq 0xfdc3(%rip), %rbx      # 0x1572f
movq -0x58(%rbp), %r13
movq -0x8(%r15), %rdx
movq (%r15), %rsi
movsd (%r13,%r12,8), %xmm0
movq %rbx, %rdi
movb $0x1, %al
callq 0x1030
addq $0x10, %r15
incq %r12
cmpq %r14, %r12
jl 0x5970
movl -0x2c(%rbp), %eax
movl %eax, %r14d
jmp 0x59f4
leaq 0xfd59(%rip), %rdi      # 0x156fc
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %eax, %eax
callq 0x1030
xorpd %xmm0, %xmm0
movupd %xmm0, (%r12,%r14,8)
jmp 0x59e7
xorpd %xmm0, %xmm0
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
movupd %xmm0, (%rax,%rcx,8)
testl %r15d, %r15d
jle 0x59e7
leaq 0xfd44(%rip), %rdi      # 0x1571c
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %r15d, %edx
xorl %eax, %eax
callq 0x1030
movl $0xa, %edi
callq 0x1160
movb $0x1, %r14b
movl $0xa, %edi
callq 0x1160
movl -0x9c(%rbp), %edi
shlq $0x2, %rdi
callq 0x1140
movq %rax, %rbx
cmpl $0x0, -0x90(%rbp)
movq -0x40(%rbp), %r15
movl -0x30(%rbp), %r12d
je 0x5a47
movq -0x78(%rbp), %rcx
addl %ecx, %ecx
cmpl $0x3, %ecx
movl $0x2, %eax
cmovael %ecx, %eax
addl $-0x2, %eax
leaq 0x4(,%rax,4), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1060
testb %r14b, %r14b
movq -0xb0(%rbp), %rdi
movq -0x68(%rbp), %r8
jne 0x5a79
movslq %r12d, %rax
leaq 0x8(%r15), %rcx
xorl %edx, %edx
movq (%rcx), %rsi
incl (%rbx,%rsi,4)
movq -0x8(%rcx), %rsi
incl (%rbx,%rsi,4)
addq $0x10, %rcx
incq %rdx
cmpq %rax, %rdx
jl 0x5a60
movl 0x4(%rbx,%r8,4), %eax
testl %eax, %eax
jle 0x5aaf
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
leaq 0x1(%rdi), %rdx
cmpl $0x2, %eax
cmovel %edx, %esi
cmpl $0x1, %eax
cmovel %edx, %ecx
movl 0x8(%rbx,%rdi,4), %eax
movq %rdx, %rdi
testl %eax, %eax
jg 0x5a8c
movslq %ecx, %rdx
movslq %esi, %rax
jmp 0x5abd
movq $-0x1, %rax
movq $-0x1, %rdx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testb %r14b, %r14b
je 0x5ad0
movq -0xa8(%rbp), %r14
jmp 0x5b1f
movslq %r12d, %rsi
xorl %ecx, %ecx
movq -0xa8(%rbp), %r14
cmpq %rdx, 0x8(%r15)
je 0x5af5
cmpq %rdx, (%r15)
je 0x5afe
incq %rcx
addq $0x10, %r15
cmpq %rsi, %rcx
jl 0x5adc
jmp 0x5b1f
movq $-0x8, %rdx
jmp 0x5b05
movq $-0x10, %rdx
movq %rax, 0x10(%rdx,%r15)
leal 0x1(%rcx), %ebx
movabsq $0x4059000000000000, %rax # imm = 0x4059000000000000
movq -0x58(%rbp), %rdx
movq %rax, (%rdx,%rcx,8)
movq -0x70(%rbp), %rdi
callq 0x1100
movq -0x60(%rbp), %rdi
callq 0x1100
movq -0x88(%rbp), %rdi
callq 0x1100
subl (%r14), %r12d
movl %r12d, (%r14)
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfa76(%rip), %rdi      # 0x155d4
xorl %eax, %eax
callq 0x1030
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1110
testl %eax, %eax
jne 0x5b8e
leaq 0xf9ab(%rip), %rdi      # 0x15525
jmp 0x5b5e
leaq 0xf8e6(%rip), %rdi      # 0x15469
jmp 0x5b5e
leaq 0xf932(%rip), %rdi      # 0x154be
jmp 0x5b5e
leaq 0xf9e1(%rip), %rdi      # 0x15576
jmp 0x5b5e
leaq 0xfa83(%rip), %rdi      # 0x15621
jmp 0x5b5e
leaq 0xfb13(%rip), %rdi      # 0x156ba
jmp 0x5b5e