// File: 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
subq $0x60, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
shll %eax
subl $0x2, %eax
movl %eax, -0x48(%rbp)
movl -0x2c(%rbp), %eax
shll %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, -0x50(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl -0x2c(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jg 0x8566
movl -0x2c(%rbp), %eax
shll %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, %rdx
movq -0x50(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x852c
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl -0x2c(%rbp), %ecx
shll %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jg 0x85d4
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x2c(%rbp), %ecx
shll %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jg 0x85c7
movq -0x20(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x50(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x34(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x8583
jmp 0x85c9
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x856d
movl $0x1, -0x30(%rbp)
movq -0x50(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x14(%rbp), %rcx
movsd 0x1ca35(%rip), %xmm0    # 0x25028
movsd %xmm0, (%rax,%rcx,8)
movq -0x50(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd 0x1ca18(%rip), %xmm0    # 0x25028
movsd %xmm0, (%rax,%rcx,8)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl -0x14(%rbp), %ecx
movl -0x2c(%rbp), %r8d
leaq -0x30(%rbp), %rsi
callq 0x7ec0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x80d0
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl -0x48(%rbp), %ecx
subl 0x10(%rbp), %ecx
cmpl %ecx, %eax
jg 0x887e
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0x886e
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x40(%rbp)
movl $0x1, -0x44(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
addl -0x44(%rbp), %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, %rcx
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x40(%rbp), %ecx
addl -0x44(%rbp), %ecx
cmpl %ecx, %eax
jg 0x86fa
movl -0x40(%rbp), %eax
addl $0x1, %eax
addl -0x44(%rbp), %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x1110
movq %rax, %rdx
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x86af
movl $0x1, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0x879e
movl $0x1, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0x878e
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movslq -0x30(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
movslq -0x38(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movq (%rax,%rcx,8), %rax
movq -0x28(%rbp), %rcx
movslq -0x30(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
movslq -0x3c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8714
jmp 0x8790
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x8701
movl $0x1, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jg 0x883d
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x28(%rbp), %rcx
movslq -0x30(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
movslq -0x3c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x87a5
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl -0x40(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x8870
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x8645
movq -0x58(%rbp), %rdi
callq 0x8310
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movl -0x2c(%rbp), %ecx
shll %ecx
cmpl %ecx, %eax
jg 0x88b6
movq -0x50(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x10e0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x888e
movq -0x50(%rbp), %rdi
callq 0x10e0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)