// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movq %r8, -0x60(%rbp)
movq %rcx, %r12
movl %edx, -0x40(%rbp)
movq %rsi, %r15
movq %rdi, -0x50(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0x30(%rbp)
leal (%r9,%r9), %eax
movq %rax, -0x48(%rbp)
movq %r9, -0x38(%rbp)
leal 0x1(%r9,%r9), %eax
movslq %eax, %rbx
leaq (,%rbx,8), %r13
movq %r13, %rdi
callq 0x1130
movq %rax, -0x58(%rbp)
xorl %r14d, %r14d
testl %ebx, %ebx
cmovlel %r14d, %ebx
movq %rbx, -0x68(%rbp)
cmpq %r14, -0x68(%rbp)
je 0x47e1
movq %r13, %rdi
callq 0x1130
movq -0x58(%rbp), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
jmp 0x47c6
movq -0x48(%rbp), %rbx
leal -0x1(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
movq -0x58(%rbp), %r14
cmpq %rdx, %rcx
je 0x4823
movq (%r12,%rcx,8), %rsi
movq (%r14,%rcx,8), %rdi
xorl %r8d, %r8d
cmpq %r8, %rax
je 0x481e
movsd (%rsi,%r8,8), %xmm0
movsd %xmm0, (%rdi,%r8,8)
incq %r8
jmp 0x4808
incq %rcx
jmp 0x47f8
movq -0x38(%rbp), %r12
movslq %r12d, %r13
movq (%r14,%r13,8), %rax
movslq -0x40(%rbp), %rcx
movabsq $0x412e847ffae147ae, %rdx # imm = 0x412E847FFAE147AE
movq %rdx, (%rax,%rcx,8)
movq (%r14,%rcx,8), %rax
movq %rdx, (%rax,%r13,8)
leaq -0x7c(%rbp), %rsi
movq -0x50(%rbp), %rdi
movq %r14, %rdx
movl %r12d, %r8d
callq 0x43b5
movq %rax, -0x70(%rbp)
movq %rax, %rdi
movq -0x60(%rbp), %rsi
callq 0x44e6
subl -0x30(%rbp), %ebx
addl $-0x2, %ebx
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
movl %r12d, %eax
incl %ebx
pushq $0x1
popq %rdi
movq %rbx, -0x48(%rbp)
movq %r13, -0x78(%rbp)
movq %rax, -0x40(%rbp)
cmpq %rbx, %rdi
je 0x49bf
cmpq %rax, %rdi
je 0x49b7
movq %rdi, -0x50(%rbp)
imulq $0x18, %rdi, %rax
movq -0x60(%rbp), %rcx
leaq (%rcx,%rax), %r12
leaq (%rcx,%rax), %rbx
addq $0x8, %rbx
movslq -0x8(%rbx), %rax
leaq 0x1(%rax), %r14
movq %rax, -0x30(%rbp)
leaq 0x10(,%rax,8), %r13
movq %r13, %rdi
callq 0x1130
movq %rbx, -0x38(%rbp)
movq %rax, (%rbx)
xorl %ebx, %ebx
cmpq %r14, %rbx
jg 0x48f8
movq %r13, %rdi
callq 0x1130
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
jmp 0x48db
movq -0x30(%rbp), %rcx
testl %ecx, %ecx
movl $0x0, %eax
cmovgl %ecx, %eax
leal 0x1(%rax), %ecx
movl %r14d, %edx
pushq $0x1
popq %r11
movq %r11, %rsi
movq -0x58(%rbp), %r14
movq -0x48(%rbp), %rbx
movq -0x78(%rbp), %r13
cmpq %rcx, %rsi
je 0x495c
movq %r11, %rdi
cmpq %rdi, %rdx
je 0x4957
movq 0x8(%r12), %r8
movq 0x10(%r12), %r9
movslq (%r9,%rsi,4), %r10
movq (%r15,%r10,8), %r10
movslq (%r9,%rdi,4), %r9
movsd (%r10,%r9,8), %xmm0
movq (%r8,%rsi,8), %r8
movsd %xmm0, (%r8,%rdi,8)
incq %rdi
jmp 0x4927
incq %rsi
jmp 0x491f
movl %eax, %eax
xorl %ecx, %ecx
movq -0x30(%rbp), %r8
cmpq %rcx, %rax
je 0x499d
movq (%r15,%r13,8), %rdx
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdi
movslq 0x4(%rdi,%rcx,4), %rdi
movsd (%rdx,%rdi,8), %xmm0
movq 0x8(%rsi,%rcx,8), %rdx
movsd %xmm0, 0x8(%rdx,%r8,8)
movq 0x8(%rsi,%r8,8), %rdx
movsd %xmm0, 0x8(%rdx,%rcx,8)
incq %rcx
jmp 0x4964
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax,%r8,8), %rax
andq $0x0, 0x8(%rax,%r8,8)
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rdi
incq %rdi
jmp 0x488c
movq -0x70(%rbp), %rdi
callq 0x4612
xorl %ebx, %ebx
cmpq %rbx, -0x68(%rbp)
je 0x49de
movq (%r14,%rbx,8), %rdi
callq 0x10f0
incq %rbx
jmp 0x49ca
movq %r14, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0