// File: /workspace/github_c_makefile_star2_O3/cbouilla[P]AES-attacks-finder/Search.c
// Function: ExhaustiveSearchBalancedSolver
Solver * ExhaustiveSearchBalancedSolver(SysEqLin E, const int T, int * taille)
{
	int nb_wait;
	Solver * __restrict wait=SearchAlgoLowMem_All(E,T,&nb_wait);		
	
	int alloc_wait = nb_wait;
	
	Solver * __restrict checked=malloc(nb_wait*sizeof(Solver));
	int alloc_checked = nb_wait;
	int nb_checked = 0;
	
	int nb_low_time;
	Solver * __restrict low_time=MakeSolver1(E,&nb_low_time);
	
	int max_checked=0;
	int max_wait=nb_wait;
	start_1 :
	while (nb_wait>0)
	{
		if (nb_checked>max_checked) max_checked=nb_checked;
		if (nb_wait>max_wait) max_wait=nb_wait;
		printf("\r wait : %d - checked : %d - ",nb_wait,nb_checked);
		Solver B = wait[--nb_wait];
		const int nb_wait_backup = nb_wait;
		int nb_staying = nb_checked;
		start_2 :
		while (nb_staying>0)
		{
			Solver result = UnionSolverBorne(B,checked[--nb_staying],E,T);
			if (result!=NULL)
			{
				if (result->Nvar==checked[nb_staying]->Nvar)
				{
					freeSolver(result);
					if (PlusInteressant2(checked[nb_staying],B))
					{
						freeSolver(B);
						int i;
						for (i = nb_wait_backup; i < nb_wait; i++) freeSolver(wait[i]);
						nb_wait=nb_wait_backup;
						goto start_1;
					}
					else goto start_2;
				}
				if (result->Nvar==B->Nvar)
				{
					if (PlusInteressant2(B,checked[nb_staying]))
					{
						freeSolver(checked[nb_staying]);
						checked[nb_staying--]=checked[--nb_checked];
					}
					freeSolver(result);
					goto start_2;
				}
				Solver tmp = PropagateSolver2(result,E,low_time,nb_low_time);
				freeSolver(result);
				if (PlusInteressant_NoVarsNoMem(tmp,B))
				{
					freeSolver(B);
					int i=nb_checked;
					while (i>0)
					{
						i--;
						if (ContenuListesTriees(checked[i]->var,checked[i]->Nvar,tmp->var,tmp->Nvar) && PlusInteressant_NoVarsNoMem(tmp,checked[i]))
						{
							freeSolver(checked[i]);
							checked[i]=checked[--nb_checked];
						}
					}
					if (nb_wait==alloc_wait)
					{
						alloc_wait=2*alloc_wait;
						wait=realloc(wait,alloc_wait*sizeof(Solver));
					}
					wait[nb_wait++]=tmp;
					goto start_1;
				}
				else
				{
					int i=nb_staying;
					while (i>0)
					{
						i--;
						if (ContenuListesTriees(checked[i]->var,checked[i]->Nvar,tmp->var,tmp->Nvar) && PlusInteressant_NoVarsNoMem(tmp,checked[i]))
						{
							freeSolver(checked[i]);
							checked[i]=checked[--nb_staying];
							checked[nb_staying]=checked[--nb_checked];
						}
					}
					i=nb_checked;
					while (i>nb_staying)
					{
						i--;
						if (ContenuListesTriees(checked[i]->var,checked[i]->Nvar,tmp->var,tmp->Nvar) && PlusInteressant_NoVarsNoMem(tmp,checked[i]))
						{
							freeSolver(checked[i]);
							checked[i]=checked[--nb_checked];
						}
					}
					if (nb_wait==alloc_wait)
					{
						alloc_wait=2*alloc_wait;
						wait=realloc(wait,alloc_wait*sizeof(Solver));
					}
					wait[nb_wait++]=tmp;					
				}		
			}
		}
		if (nb_checked==alloc_checked)
		{
			alloc_checked=2*alloc_checked;
			checked=realloc(checked,alloc_checked*sizeof(Solver));
		}
		checked[nb_checked++]=B;		
	}
	printf("\n");
	printf("\r wait : %d - checked : %d",max_wait,max_checked);
	free(wait);
	int i;
	for (i = 0; i < nb_low_time; i++) freeSolver(low_time[i]);
	free(low_time);
	*taille=nb_checked;
	return checked;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdx, %rbx
movq %rdi, %r12
leaq 0x4(%rsp), %r14
movl %esi, 0x44(%rsp)
movq %r14, %rdx
callq 0x14df1
movq %rax, 0x8(%rsp)
movslq (%r14), %r15
leaq (,%r15,8), %rdi
callq 0x21d0
movq %rax, %r14
leaq 0x1c(%rsp), %rsi
movq %r12, 0x58(%rsp)
movq %r12, %rdi
callq 0x834c
movq %rax, %r13
testq %r15, %r15
movq %rbx, 0x60(%rsp)
jle 0x16a71
movl %r15d, %ebx
movl %r15d, 0x14(%rsp)
movl %r15d, 0x34(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
movq %r13, 0x48(%rsp)
leaq -0x8(%r14), %rax
movq %rax, 0x28(%rsp)
cmpl %r12d, %ebp
cmovgl %ebp, %r12d
movl %r12d, 0x18(%rsp)
cmpl %r15d, %ebx
cmovgl %ebx, %r15d
movq %r15, 0x20(%rsp)
leaq 0x16540(%rip), %rdi     # 0x2cbc7
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2110
leal -0x1(%rbx), %ecx
movl %ecx, 0x4(%rsp)
movq 0x8(%rsp), %rax
movq (%rax,%rcx,8), %r12
testl %ebp, %ebp
movl %ebp, (%rsp)
jle 0x16a2d
movq %rcx, %rax
movl %ebp, %r15d
movq %rax, 0x50(%rsp)
movq %rax, 0x38(%rsp)
movq %rbx, 0x68(%rsp)
movl %r15d, %ebx
leal -0x1(%rbx), %r15d
movq (%r14,%r15,8), %rsi
movq %r12, %rdi
movq 0x58(%rsp), %rdx
movl 0x44(%rsp), %ecx
callq 0x7ff0
testq %rax, %rax
je 0x168f3
movq %rax, %rbp
movl 0x8(%rax), %eax
movq (%r14,%r15,8), %rdi
movl 0x8(%rdi), %ecx
cmpl %ecx, %eax
jne 0x16727
movq %rbp, %rdi
callq 0x7447
movq (%r14,%r15,8), %rax
movl 0x8(%rax), %ecx
cmpl 0x8(%r12), %ecx
jl 0x1676d
movl 0x14(%rax), %ecx
cmpl 0x14(%r12), %ecx
jg 0x1676d
movl 0xc(%rax), %eax
cmpl 0xc(%r12), %eax
jg 0x1676d
jmp 0x16901
cmpl 0x8(%r12), %eax
jne 0x1677e
cmpl %ecx, %eax
jl 0x16765
movl 0x14(%r12), %eax
cmpl 0x14(%rdi), %eax
jg 0x16765
movl 0xc(%r12), %eax
cmpl 0xc(%rdi), %eax
jg 0x16765
callq 0x7447
movl (%rsp), %ecx
movslq %ecx, %rax
decl %ecx
movl %ecx, (%rsp)
movq -0x8(%r14,%rax,8), %rax
addl $-0x2, %ebx
movq %rax, (%r14,%r15,8)
movl %ebx, %r15d
movq %rbp, %rdi
callq 0x7447
movl %r15d, %ebx
testl %r15d, %r15d
jg 0x166c5
jmp 0x16a2d
movl 0x1c(%rsp), %ecx
movq %rbp, %rdi
movq 0x58(%rsp), %rsi
movq %r13, %rdx
callq 0x84b9
movq %rax, %r13
movq %rbp, %rdi
callq 0x7447
movl 0x14(%r13), %eax
cmpl 0x14(%r12), %eax
jg 0x167b7
movl 0xc(%r13), %eax
cmpl 0xc(%r12), %eax
jle 0x16967
cmpl $0x1, %ebx
jne 0x167c1
xorl %r15d, %r15d
jmp 0x16832
leal -0x1(%rbx), %eax
movq 0x28(%rsp), %rcx
leaq (%rcx,%rax,8), %rbp
movq (%rbp), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
movq (%r13), %rdx
movl 0x8(%r13), %ecx
callq 0x2e80
testl %eax, %eax
je 0x16827
movl 0x14(%r13), %eax
movq (%rbp), %rdi
cmpl 0x14(%rdi), %eax
jg 0x16827
movl 0xc(%r13), %eax
cmpl 0xc(%rdi), %eax
jg 0x16827
callq 0x7447
movslq %r15d, %rax
decl %r15d
movq -0x8(%r14,%rax,8), %rcx
movq %rcx, (%rbp)
movl (%rsp), %edx
movslq %edx, %rcx
decl %edx
movl %edx, (%rsp)
movq -0x8(%r14,%rcx,8), %rcx
movq %rcx, -0x8(%r14,%rax,8)
decl %ebx
addq $-0x8, %rbp
cmpl $0x1, %ebx
jg 0x167cd
movl (%rsp), %eax
cmpl %r15d, %eax
jle 0x168a6
movslq %eax, %rbx
movslq %r15d, %rax
movq %rax, 0x70(%rsp)
movq 0x28(%rsp), %rbp
movq (%rbp,%rbx,8), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
movq (%r13), %rdx
movl 0x8(%r13), %ecx
callq 0x2e80
testl %eax, %eax
je 0x1689c
movl 0x14(%r13), %eax
movq (%rbp,%rbx,8), %rdi
cmpl 0x14(%rdi), %eax
jg 0x16897
movl 0xc(%r13), %eax
cmpl 0xc(%rdi), %eax
jg 0x16897
callq 0x7447
movl (%rsp), %ecx
movslq %ecx, %rax
decl %ecx
movl %ecx, (%rsp)
movq -0x8(%r14,%rax,8), %rax
movq %rax, -0x8(%r14,%rbx,8)
movq 0x28(%rsp), %rbp
decq %rbx
cmpq 0x70(%rsp), %rbx
jg 0x1684a
movq 0x38(%rsp), %rcx
cmpl 0x14(%rsp), %ecx
jne 0x168d0
movl %ecx, %eax
addl %ecx, %eax
movl %eax, 0x14(%rsp)
movslq %eax, %rsi
shlq $0x3, %rsi
movq 0x8(%rsp), %rdi
callq 0x2200
movl 0x4(%rsp), %ecx
jmp 0x168d5
movq 0x8(%rsp), %rax
movslq %ecx, %rdx
incl %ecx
movl %ecx, 0x4(%rsp)
movq %rax, 0x8(%rsp)
movq %r13, (%rax,%rdx,8)
movl %ecx, %eax
movq %rax, 0x38(%rsp)
movq 0x48(%rsp), %r13
testl %r15d, %r15d
jg 0x166c2
jmp 0x16a2d
movq %r12, %rdi
callq 0x7447
movq 0x38(%rsp), %r12
movq 0x68(%rsp), %rdx
cmpl %r12d, %edx
jg 0x16940
movslq 0x50(%rsp), %rax
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,8), %rbx
subl %edx, %r12d
incl %r12d
xorl %r15d, %r15d
movq (%rbx,%r15,8), %rdi
callq 0x7447
incq %r15
cmpl %r15d, %r12d
jne 0x1692f
movq 0x50(%rsp), %rax
movl %eax, 0x4(%rsp)
movl (%rsp), %ebp
movq 0x20(%rsp), %r15
movl 0x18(%rsp), %r12d
movl 0x4(%rsp), %ebx
testl %ebx, %ebx
jg 0x16668
jmp 0x16a76
movq %r12, %rdi
callq 0x7447
movl (%rsp), %ebp
testl %ebp, %ebp
jle 0x169d7
movl %ebp, %ebx
incq %rbx
movq 0x20(%rsp), %r15
movl 0x18(%rsp), %r12d
movq -0x10(%r14,%rbx,8), %rax
movq (%rax), %rdi
movl 0x8(%rax), %esi
movq (%r13), %rdx
movl 0x8(%r13), %ecx
callq 0x2e80
testl %eax, %eax
je 0x169cc
movl 0x14(%r13), %eax
movq -0x10(%r14,%rbx,8), %rdi
cmpl 0x14(%rdi), %eax
jg 0x169cc
movl 0xc(%r13), %eax
cmpl 0xc(%rdi), %eax
jg 0x169cc
callq 0x7447
movslq %ebp, %rax
decl %ebp
movq -0x8(%r14,%rax,8), %rax
movq %rax, -0x10(%r14,%rbx,8)
decq %rbx
cmpq $0x1, %rbx
ja 0x16985
jmp 0x169e1
movq 0x20(%rsp), %r15
movl 0x18(%rsp), %r12d
movq 0x38(%rsp), %rdx
cmpl 0x14(%rsp), %edx
jne 0x16a0b
movl %edx, %eax
addl %edx, %eax
movl %eax, 0x14(%rsp)
movslq %eax, %rsi
shlq $0x3, %rsi
movq 0x8(%rsp), %rdi
callq 0x2200
movl 0x4(%rsp), %edx
jmp 0x16a10
movq 0x8(%rsp), %rax
leal 0x1(%rdx), %ecx
movl %ecx, 0x4(%rsp)
movslq %edx, %rcx
movq %rax, 0x8(%rsp)
movq %r13, (%rax,%rcx,8)
movq 0x48(%rsp), %r13
jmp 0x16956
movl (%rsp), %ebp
movl 0x34(%rsp), %eax
cmpl %eax, %ebp
jne 0x16a50
addl %eax, %eax
movl %eax, 0x34(%rsp)
movslq %eax, %rsi
shlq $0x3, %rsi
movq %r14, %rdi
callq 0x2200
movq %rax, %r14
movq 0x20(%rsp), %r15
movslq %ebp, %rax
incl %ebp
movq %r12, (%r14,%rax,8)
movl 0x4(%rsp), %ebx
testl %ebx, %ebx
movl 0x18(%rsp), %r12d
jg 0x1665f
jmp 0x16a76
xorl %ebp, %ebp
xorl %r12d, %r12d
movl $0xa, %edi
callq 0x2040
leaq 0x1615e(%rip), %rdi     # 0x2cbe5
movl %r15d, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2110
movq 0x8(%rsp), %rdi
callq 0x2030
cmpl $0x0, 0x1c(%rsp)
jle 0x16abe
xorl %ebx, %ebx
movq (%r13,%rbx,8), %rdi
callq 0x7447
incq %rbx
movslq 0x1c(%rsp), %rax
cmpq %rax, %rbx
jl 0x16aa7
movq %r13, %rdi
callq 0x2030
movq 0x60(%rsp), %rax
movl %ebp, (%rax)
movq %r14, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq