// File: /workspace/github_cpp_makefile_star2_O3/dcarrey[P]hgt-detection/./utils_tree.cpp
// Function: RechercherBipartition(long*, double**, int, double**, DescTree*, int, int)
void RechercherBipartition(long int *ARETE,double ** DIST,int P,double ** Adjacence2,struct DescTree *DT,int n,int kt)
{
	/*/===== variables =====*/
	int i,j,k,l,taille,plus,ns=2*n-2;
	double ** Adjacence =(double**)malloc((2*n+1)*sizeof(double*));
	struct TNoeud * arbre;
	
	for (i=0;i<=2*n;i++)
		Adjacence[i]=(double*)malloc((2*n+1)*sizeof(double));

	/*/==== Processus =====*/

	for(i=0;i<=2*n-2;i++)
		for(j=0;j<=2*n-2;j++)
			Adjacence[i][j] = Adjacence2[i][j];
	i=1;

	Adjacence[P][n] = Adjacence[n][P] = INFINI; 

	arbre = CreerSousArbre(ARETE,&i,Adjacence,P,n);

/*	printf("\n-------------------------------\n");
	AfficherArbre(arbre,0);
	printf("\n-------------------------------");
*/

	ParcoursArbre(arbre,DT);
	//printf("\nRechercher bipartition :");
	for(i=1;i<=ns-kt;i++){
    	if(i!=n){
        	taille = DT[i].nbSommet;

		/*	printf("\n=== %d\n",i);
			for(j=1;j<=DT[i].nbSommet;j++)
				printf(" %d",DT[i].Tableau[j]);*/

        	/*if(taille == 3) plus=1;
                else */
					plus=1;
			
            DT[i].Matrice = (double**)malloc((taille+1+plus)*sizeof(double*));
            for(j=0;j<=taille+plus;j++){
                DT[i].Matrice[j] = (double*)malloc((taille+1+plus)*sizeof(double));
            }
            for(k=1;k<=taille;k++){
                for(l=1;l<=taille;l++){
                    DT[i].Matrice[k][l] = DIST[DT[i].Tableau[k]][DT[i].Tableau[l]] ;
                }
            }
			 
			for(l=1;l<=taille;l++){
				DT[i].Matrice[taille+1][l] = DT[i].Matrice[l][taille+1] = DIST[n][DT[i].Tableau[l]];
            }

            DT[i].Matrice[taille+1][taille+1] = 0.0;
          /*  if(taille == 3){
                for(l=1;l<=taille;l++){
                    DT[i].Matrice[taille+1][l] = DT[i].Matrice[l][taille+1] = DIST[n][DT[i].Tableau[l]];
                }
                DT[i].Matrice[taille+1][taille+1] = 0.0;
            }*/
     	}
	}
	//printf("\n Fin Rechercher bipartition :");
	viderArbre(arbre);
	for (i=0;i<=2*n;i++)
		free(Adjacence[i]);
	free(Adjacence);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r9d, %ebx
movq %r8, -0x60(%rbp)
movq %rcx, %r13
movl %edx, -0x40(%rbp)
movq %rsi, -0x68(%rbp)
movq %rdi, -0x48(%rbp)
movl 0x10(%rbp), %eax
movq %rax, -0x58(%rbp)
leal (%rbx,%rbx), %eax
movq %rax, -0x50(%rbp)
leal -0x2(,%rbx,2), %r15d
leal 0x1(,%rbx,2), %eax
movslq %eax, %r14
shlq $0x3, %r14
movq %r14, %rdi
callq 0x1140
movq %rax, %r12
movq %rbx, -0x38(%rbp)
testl %ebx, %ebx
js 0x4ec6
movl %r15d, -0x30(%rbp)
movq -0x50(%rbp), %rbx
orl $0x1, %ebx
movq %r12, %r15
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x1140
movq %rax, (%r15,%r12,8)
incq %r12
cmpq %r12, %rbx
jne 0x4e6f
cmpl $0x0, -0x38(%rbp)
movq %r15, %r12
movl -0x30(%rbp), %r15d
je 0x4ec6
xorl %eax, %eax
testl %r15d, %r15d
movl $0x0, %ecx
cmovgl %r15d, %ecx
orl $0x1, %ecx
movq (%r13,%rax,8), %rdx
movq (%r12,%rax,8), %rsi
xorl %edi, %edi
movsd (%rdx,%rdi,8), %xmm0
movsd %xmm0, (%rsi,%rdi,8)
incq %rdi
cmpq %rdi, %rcx
jne 0x4eac
incq %rax
cmpq %rcx, %rax
jne 0x4ea1
movq -0x38(%rbp), %r8
movslq %r8d, %rsi
movq (%r12,%rsi,8), %rax
movslq -0x40(%rbp), %rcx
movabsq $0x412e847ffae147ae, %rdx # imm = 0x412E847FFAE147AE
movq %rdx, (%rax,%rcx,8)
movq (%r12,%rcx,8), %rax
movq %rsi, -0x80(%rbp)
movq %rdx, (%rax,%rsi,8)
leaq -0x8c(%rbp), %rsi
movq -0x48(%rbp), %rdi
movq %r12, %rdx
callq 0x49cc
movq %rax, -0x78(%rbp)
movq %rax, %rdi
movq -0x60(%rbp), %rsi
callq 0x4b68
movq -0x58(%rbp), %rax
cmpl %eax, %r15d
jle 0x5083
movl -0x38(%rbp), %ecx
notl %eax
addl -0x50(%rbp), %eax
movl $0x1, %r15d
movq %r12, -0x70(%rbp)
movq %rax, -0x58(%rbp)
movq %rcx, -0x88(%rbp)
cmpq %rcx, %r15
je 0x5077
leaq (%r15,%r15,2), %rcx
movq -0x60(%rbp), %rax
movq %rcx, -0x30(%rbp)
leaq (%rax,%rcx,8), %r13
addq $0x8, %r13
movl -0x8(%r13), %r12d
leal 0x1(%r12), %eax
movl %eax, -0x48(%rbp)
leal 0x2(%r12), %ebx
movslq %ebx, %r14
shlq $0x3, %r14
movq %r14, %rdi
callq 0x1140
movq %rax, (%r13)
movq %r12, -0x40(%rbp)
cmpl $-0x1, %r12d
jl 0x5054
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movl %ebx, %r12d
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x1140
movq (%r13), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
cmpq %rbx, %r12
jne 0x4fa0
cmpl $0x0, -0x40(%rbp)
movq -0x30(%rbp), %rbx
jle 0x5054
movl -0x48(%rbp), %eax
movq 0x8(%rbx), %rcx
movq 0x10(%rbx), %rdx
movl $0x1, %esi
movq -0x68(%rbp), %r11
movslq (%rdx,%rsi,4), %rdi
movq (%r11,%rdi,8), %rdi
movq (%rcx,%rsi,8), %r8
movl $0x1, %r9d
movslq (%rdx,%r9,4), %r10
movsd (%rdi,%r10,8), %xmm0
movsd %xmm0, (%r8,%r9,8)
incq %r9
cmpq %r9, %rax
jne 0x4fec
incq %rsi
cmpq %rax, %rsi
jne 0x4fda
cmpl $0x0, -0x40(%rbp)
jle 0x5054
movq -0x68(%rbp), %rcx
movq -0x80(%rbp), %rdx
movq (%rcx,%rdx,8), %rdx
movq 0x8(%rbx), %rcx
movq 0x10(%rbx), %rsi
movq (%rcx,%rax,8), %rdi
movl $0x1, %r8d
movslq (%rsi,%r8,4), %r9
movsd (%rdx,%r9,8), %xmm0
movq (%rcx,%r8,8), %r9
movsd %xmm0, (%r9,%rax,8)
movsd %xmm0, (%rdi,%r8,8)
incq %r8
cmpq %r8, %rax
jne 0x5030
jmp 0x5058
movq (%r13), %rcx
movq -0x70(%rbp), %r12
movslq -0x48(%rbp), %rax
movq (%rcx,%rax,8), %rcx
movq $0x0, (%rcx,%rax,8)
movq -0x58(%rbp), %rax
movq -0x88(%rbp), %rcx
incq %r15
cmpq %rax, %r15
jne 0x4f3c
movq -0x78(%rbp), %rdi
callq 0x4cc1
cmpl $0x0, -0x38(%rbp)
movq -0x50(%rbp), %r14
js 0x50ad
orl $0x1, %r14d
xorl %ebx, %ebx
movq (%r12,%rbx,8), %rdi
callq 0x1100
incq %rbx
cmpq %rbx, %r14
jne 0x509c
movq %r12, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1100