// File: /workspace/github_c_makefile_star2_O1/cbouilla[P]AES-attacks-finder/Search.c
// Function: ManualSearch
Solver ManualSearch(int T, Solver *B1, int N1, SysEqLin E, string_list_t *variable_names)
{
	int Alloue,N,i,N2,v_max;
	Solver *Candidat,tmp,tmp2;
	char c;
	Alloue=1000;
	Candidat=malloc(Alloue*sizeof(Solver));
	N=0;
	N2=N1/2;
	v_max=0;
	c='y';
	printf("Manual Search : \n");
	while (N<Alloue)
	{
		if (c=='y')
		{
			tmp=GenerateSolver_manual(T,B1,N1,E,variable_names);
			printf("Choose the next solver ? (y/n) :");
			scanf(" %c",&c);
			getchar();
		}
		else tmp=GenerateSolver(T,B1,N1,E);
		i=0;
		while (i < N)
		{
			tmp2=UnionSolver(Candidat[i],tmp,E);
			if (c=='o')
			{
				printf("Join (%d || %d || %d): ",tmp2->temps,tmp2->memoire,tmp2->sortie);
				PrintVarSolver2(tmp2,variable_names);
			}
			if (tmp2->temps<=T)
			{
				if (PlusInteressant2(Candidat[i],tmp2))
				{
					freeSolver(tmp2);
					break;
				}
				if (PlusInteressant2(tmp,tmp2))
				{
					N--;
					freeSolver(Candidat[i]);
					Candidat[i]=Candidat[N];
					freeSolver(tmp2);
				}
				else
				{
					printf("Two solvers were merged");
					printf("Join (%d || %d || %d): ",tmp2->temps,tmp2->memoire,tmp2->sortie);
					PrintVarSolver2(tmp2,variable_names);
					getchar();
					N--;
					freeSolver(Candidat[i]);
					Candidat[i]=Candidat[N];
					freeSolver(tmp);
					tmp=PropagateSolver2(tmp2,E,B1,N1);
					freeSolver(tmp2);
					i=0;
				}
			}
			else
			{
				freeSolver(tmp2);
				i++;
			}
		}
		if (i==N)
		{
			Candidat[N++]=tmp;
			v_max=max(v_max,tmp->Nvar);
			printf("Candidat %d (%d || %d || %d): ",i,tmp->temps,tmp->memoire,tmp->sortie);
			PrintVarSolver2(tmp,variable_names);
			if (N==Alloue)
			{
				i=0;
				while (i<N)
				{
					if (Candidat[i]->Nvar<=(T+v_max)/2)
					{
						freeSolver(Candidat[i]);
						N--;
						Candidat[i]=Candidat[N];
					}
					else i++;
				}
				if (N==Alloue)
				{
					Alloue=2*Alloue;
					Candidat=realloc(Candidat,Alloue*sizeof(Solver));
				}
			}		
		}
		else freeSolver(tmp);
		if (N==1 && Candidat[0]->Nvar==E->a/E->gen)
		{
			tmp=Candidat[0];
			free(Candidat);
			printf("Solution %d || %d : ",tmp->temps,tmp->memoire);
			PrintVarSolver(tmp);
			return tmp;
		}
	}
	for (i = 0; i < N; i++) freeSolver(Candidat[i]);
	free(Candidat);
	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, 0x28(%rsp)
movq %rcx, 0x18(%rsp)
movl %edx, 0x14(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, 0x30(%rsp)
movl $0x1f40, %edi           # imm = 0x1F40
callq 0x21d0
movq %rax, %rbx
leaq 0xf(%rsp), %rax
movb $0x79, (%rax)
leaq 0x15af4(%rip), %rdi     # 0x2ce9b
callq 0x2090
movl $0x3e8, %ebp            # imm = 0x3E8
movq $0x0, 0x38(%rsp)
xorl %r13d, %r13d
movl %ebp, 0x10(%rsp)
cmpb $0x79, 0xf(%rsp)
jne 0x17412
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl 0x14(%rsp), %edx
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %r8
callq 0x16935
movq %rax, 0x20(%rsp)
leaq 0x158f5(%rip), %rdi     # 0x2cce6
xorl %eax, %eax
callq 0x2110
leaq 0x12207(%rip), %rdi     # 0x29606
leaq 0xf(%rsp), %rsi
xorl %eax, %eax
callq 0x2230
callq 0x2180
jmp 0x1742f
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl 0x14(%rsp), %edx
movq 0x18(%rsp), %rcx
callq 0x16842
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
testl %r13d, %r13d
jle 0x17589
movslq %r12d, %rbp
movq (%rbx,%rbp,8), %rdi
movq 0x20(%rsp), %r15
movq %r15, %rsi
movq 0x18(%rsp), %rdx
callq 0x7be3
movq %rax, %r14
cmpb $0x6f, 0xf(%rsp)
jne 0x17485
movl 0xc(%r14), %esi
movl 0x10(%r14), %edx
movl 0x14(%r14), %ecx
leaq 0x15896(%rip), %rdi     # 0x2cd07
xorl %eax, %eax
callq 0x2110
movq %r14, %rdi
movq 0x28(%rsp), %rsi
callq 0x74f1
movl 0xc(%r14), %eax
cmpl 0x30(%rsp), %eax
jle 0x174a2
movq %r14, %rdi
callq 0x7060
incl %r12d
movq %r13, %r15
jmp 0x1755f
movq (%rbx,%rbp,8), %rdi
movl 0x8(%r14), %ecx
cmpl %ecx, 0x8(%rdi)
jl 0x174c1
movl 0x14(%rdi), %edx
cmpl 0x14(%r14), %edx
jg 0x174c1
cmpl %eax, 0xc(%rdi)
jle 0x17581
movslq %r13d, %r13
cmpl %ecx, 0x8(%r15)
jl 0x174de
movl 0x14(%r15), %ecx
cmpl 0x14(%r14), %ecx
jg 0x174de
cmpl %eax, 0xc(%r15)
jle 0x1756d
leaq 0x1583a(%rip), %rdi     # 0x2cd1f
xorl %eax, %eax
callq 0x2110
movl 0xc(%r14), %esi
movl 0x10(%r14), %edx
movl 0x14(%r14), %ecx
leaq 0x15808(%rip), %rdi     # 0x2cd07
xorl %eax, %eax
callq 0x2110
movq %r14, %rdi
movq 0x28(%rsp), %rsi
callq 0x74f1
callq 0x2180
movq %r15, %r12
leal -0x1(%r13), %r15d
movq (%rbx,%rbp,8), %rdi
callq 0x7060
movq -0x8(%rbx,%r13,8), %rax
movq %rax, (%rbx,%rbp,8)
movq %r12, %rdi
xorl %r12d, %r12d
callq 0x7060
movq %r14, %rdi
movq 0x18(%rsp), %rsi
movq 0x40(%rsp), %rdx
movl 0x14(%rsp), %ecx
callq 0x817d
movq %rax, 0x20(%rsp)
movq %r14, %rdi
callq 0x7060
cmpl %r15d, %r12d
movq %r15, %r13
jl 0x1743b
jmp 0x17589
leal -0x1(%r13), %r15d
callq 0x7060
movq -0x8(%rbx,%r13,8), %rax
movq %rax, (%rbx,%rbp,8)
jmp 0x17557
movq %r14, %rdi
callq 0x7060
cmpl %r13d, %r12d
jne 0x17655
leal 0x1(%r13), %r14d
movslq %r13d, %rax
movl %r12d, %esi
movq 0x20(%rsp), %r12
movq %r12, (%rbx,%rax,8)
movl 0x8(%r12), %eax
movl 0xc(%r12), %edx
movq 0x38(%rsp), %rcx
cmpl %eax, %ecx
cmovlel %eax, %ecx
movq %rcx, 0x38(%rsp)
movl 0x10(%r12), %ecx
movl 0x14(%r12), %r8d
leaq 0x15768(%rip), %rdi     # 0x2cd37
xorl %eax, %eax
callq 0x2110
movq %r12, %rdi
movq 0x28(%rsp), %rsi
callq 0x74f1
movl 0x10(%rsp), %ebp
cmpl %ebp, %r14d
jne 0x17650
testl %r13d, %r13d
js 0x17633
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
addl %ecx, %eax
movl %eax, %ebp
shrl $0x1f, %ebp
addl %eax, %ebp
sarl %ebp
xorl %r15d, %r15d
movslq %r15d, %r12
movq (%rbx,%r12,8), %rdi
cmpl %ebp, 0x8(%rdi)
jle 0x1761a
incl %r15d
jmp 0x1762e
callq 0x7060
movslq %r14d, %rax
decl %r14d
movq -0x8(%rbx,%rax,8), %rax
movq %rax, (%rbx,%r12,8)
cmpl %r14d, %r15d
jl 0x17609
movl 0x10(%rsp), %ebp
cmpl %ebp, %r14d
jne 0x17650
addl %ebp, %ebp
movslq %ebp, %rsi
shlq $0x3, %rsi
movq %rbx, %rdi
callq 0x2200
movq %rax, %rbx
movl %r14d, %r13d
jmp 0x17663
movq 0x20(%rsp), %rdi
callq 0x7060
movl 0x10(%rsp), %ebp
cmpl $0x1, %r13d
jne 0x17680
movq (%rbx), %r14
movl 0x8(%r14), %ecx
movq 0x18(%rsp), %rsi
movl 0x8(%rsi), %eax
cltd
idivl 0x10(%rsi)
cmpl %eax, %ecx
je 0x176b2
cmpl %ebp, %r13d
jl 0x173bd
testl %r13d, %r13d
jle 0x176a5
movl %r13d, %r14d
xorl %r15d, %r15d
movq (%rbx,%r15,8), %rdi
callq 0x7060
incq %r15
cmpq %r15, %r14
jne 0x17694
movq %rbx, %rdi
callq 0x2030
xorl %r14d, %r14d
jmp 0x176d8
movq %rbx, %rdi
callq 0x2030
movl 0xc(%r14), %esi
movl 0x10(%r14), %edx
leaq 0x1568d(%rip), %rdi     # 0x2cd56
xorl %eax, %eax
callq 0x2110
movq %r14, %rdi
callq 0x74ad
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq