// File: /workspace/github_cpp_makefile_star2_O1/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, %r15d
movq %r8, -0x50(%rbp)
movq %rcx, %r13
movl %edx, -0x48(%rbp)
movq %rsi, -0x88(%rbp)
movq %rdi, -0x38(%rbp)
movl 0x10(%rbp), %eax
movq %rax, -0x40(%rbp)
leal (%r15,%r15), %ebx
leal 0x1(,%r15,2), %eax
movslq %eax, %r14
shlq $0x3, %r14
movq %r14, %rdi
callq 0x1140
movq %rax, %r12
movq %r15, -0x60(%rbp)
testl %r15d, %r15d
movq %rbx, -0x58(%rbp)
js 0x4f6d
orl $0x1, %ebx
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x1140
movq %rax, (%r12,%r15,8)
incq %r15
cmpq %r15, %rbx
jne 0x4f57
jmp 0x4f70
xorl %r15d, %r15d
movq -0x60(%rbp), %r14
leal -0x2(,%r14,2), %ebx
movl %r15d, -0x2c(%rbp)
testl %r14d, %r14d
jle 0x4fb9
xorl %eax, %eax
testl %ebx, %ebx
movl $0x0, %ecx
cmovgl %ebx, %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 0x4f9f
incq %rax
cmpq %rcx, %rax
jne 0x4f94
leaq -0x2c(%rbp), %rsi
movl $0x1, (%rsi)
movslq %r14d, %rdi
movq (%r12,%rdi,8), %rax
movslq -0x48(%rbp), %rcx
movabsq $0x412e847ffae147ae, %rdx # imm = 0x412E847FFAE147AE
movq %rdx, (%rax,%rcx,8)
movq (%r12,%rcx,8), %rax
movq %rdi, -0x70(%rbp)
movq %rdx, (%rax,%rdi,8)
movq -0x38(%rbp), %rdi
movq %r12, %rdx
movl %r14d, %r8d
callq 0x4a9b
movq %rax, -0x68(%rbp)
movq %rax, %rdi
movq -0x50(%rbp), %rsi
callq 0x4c5d
movq %r14, %r15
movl $0x1, %r14d
movq -0x40(%rbp), %rax
cmpl %eax, %ebx
jle 0x5180
movl %r15d, %ecx
notl %eax
addl -0x58(%rbp), %eax
movl $0x1, %r14d
movq %r12, -0x80(%rbp)
movq %rax, -0x40(%rbp)
movq %rcx, -0x78(%rbp)
cmpq %rcx, %r14
je 0x5170
leaq (%r14,%r14,2), %rcx
movq -0x50(%rbp), %rax
movq %rcx, -0x90(%rbp)
leaq (%rax,%rcx,8), %r15
addq $0x8, %r15
movslq -0x8(%r15), %rbx
leaq 0x10(,%rbx,8), %r13
movq %r13, %rdi
callq 0x1140
movl %ebx, %ecx
movq %rcx, -0x38(%rbp)
movq %rax, (%r15)
movq %rbx, -0x48(%rbp)
cmpq $-0x1, %rbx
jl 0x509e
movq -0x38(%rbp), %rax
leal 0x2(%rax), %ebx
xorl %r12d, %r12d
movq %r13, %rdi
callq 0x1140
movq (%r15), %rcx
movq %rax, (%rcx,%r12,8)
incq %r12
cmpq %r12, %rbx
jne 0x5087
movq -0x50(%rbp), %rax
movq -0x90(%rbp), %rcx
leaq (%rax,%rcx,8), %rax
movq -0x38(%rbp), %r12
testl %r12d, %r12d
movq -0x88(%rbp), %r13
jle 0x5105
leaq 0x1(%r12), %rcx
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rsi
movl %ecx, %edi
movl $0x1, %r8d
movslq (%rsi,%r8,4), %r9
movq (%r13,%r9,8), %r9
movq (%rdx,%r8,8), %r10
movl $0x1, %r11d
movslq (%rsi,%r11,4), %rbx
movsd (%r9,%rbx,8), %xmm0
movsd %xmm0, (%r10,%r11,8)
incq %r11
cmpq %r11, %rdi
jne 0x50e5
incq %r8
cmpq %rcx, %r8
jne 0x50d2
movq -0x48(%rbp), %rcx
incl %ecx
testl %r12d, %r12d
movq -0x80(%rbp), %r12
jle 0x5156
movq -0x70(%rbp), %rdx
movq (%r13,%rdx,8), %rdx
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rax
movl %ecx, %edi
movq (%r15), %r8
movq (%r8,%rdi,8), %r8
movl $0x1, %r9d
movslq (%rax,%r9,4), %r10
movsd (%rdx,%r10,8), %xmm0
movq (%rsi,%r9,8), %r10
movsd %xmm0, (%r10,%rdi,8)
movsd %xmm0, (%r8,%r9,8)
incq %r9
cmpq %r9, %rdi
jne 0x5134
movq (%r15), %rax
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, (%rax,%rcx,8)
movq -0x40(%rbp), %rax
movq -0x78(%rbp), %rcx
incq %r14
cmpq %rax, %r14
jne 0x5036
movq -0x60(%rbp), %r15
movl %r14d, -0x2c(%rbp)
movq -0x68(%rbp), %rdi
callq 0x4db0
testl %r15d, %r15d
js 0x51af
movq -0x58(%rbp), %r14
orl $0x1, %r14d
xorl %ebx, %ebx
movq (%r12,%rbx,8), %rdi
callq 0x1100
incq %rbx
cmpq %rbx, %r14
jne 0x519c
jmp 0x51b1
xorl %ebx, %ebx
movl %ebx, -0x2c(%rbp)
movq %r12, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1100