// File: /workspace/github_c_makefile_star2_O3/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 $0x58, %rsp
movq %r8, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movl %edx, 0x1c(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, 0x30(%rsp)
movl $0x1f40, %edi           # imm = 0x1F40
callq 0x21d0
movq %rax, %r12
leaq 0xf(%rsp), %rax
movb $0x79, (%rax)
leaq 0x158b1(%rip), %rdi     # 0x2cefb
callq 0x2090
movl $0x3e8, %r13d           # imm = 0x3E8
movb $0x79, %al
movq $0x0, 0x38(%rsp)
xorl %ebp, %ebp
cmpb $0x79, %al
jne 0x176b1
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl 0x1c(%rsp), %edx
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %r8
callq 0x16be3
movq %rax, %rbx
leaq 0x156b9(%rip), %rdi     # 0x2cd46
xorl %eax, %eax
callq 0x2110
leaq 0x11fcb(%rip), %rdi     # 0x29666
leaq 0xf(%rsp), %rsi
xorl %eax, %eax
callq 0x2230
callq 0x2180
movq %rbx, %rax
jmp 0x176c9
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl 0x1c(%rsp), %edx
movq 0x20(%rsp), %rcx
callq 0x16adf
movq %r13, 0x48(%rsp)
testl %ebp, %ebp
movq %r12, 0x10(%rsp)
jle 0x17836
xorl %r13d, %r13d
movslq %r13d, %r15
movq (%r12,%r15,8), %rdi
movq %rax, %rbx
movq %rax, %rsi
movq 0x20(%rsp), %rdx
callq 0x7f14
movq %rax, %r14
cmpb $0x6f, 0xf(%rsp)
jne 0x17726
movl 0xc(%r14), %esi
movl 0x10(%r14), %edx
movl 0x14(%r14), %ecx
leaq 0x15655(%rip), %rdi     # 0x2cd67
xorl %eax, %eax
callq 0x2110
movq %r14, %rdi
movq 0x28(%rsp), %rsi
callq 0x78b0
movl 0xc(%r14), %eax
cmpl 0x30(%rsp), %eax
jle 0x17740
movq %r14, %rdi
callq 0x7447
incl %r13d
jmp 0x1780b
movq (%r12,%r15,8), %rdi
movl 0x8(%r14), %ecx
cmpl %ecx, 0x8(%rdi)
movq %rbp, %rsi
jl 0x17762
movl 0x14(%rdi), %edx
cmpl 0x14(%r14), %edx
jg 0x17762
cmpl %eax, 0xc(%rdi)
jle 0x17961
movslq %esi, %r12
movq %rbx, %rdx
cmpl %ecx, 0x8(%rbx)
jl 0x1777f
movl 0x14(%rdx), %ecx
cmpl 0x14(%r14), %ecx
jg 0x1777f
cmpl %eax, 0xc(%rdx)
jle 0x17819
xorl %r13d, %r13d
leaq 0x155f6(%rip), %rdi     # 0x2cd7f
xorl %eax, %eax
movq %rdx, 0x50(%rsp)
callq 0x2110
movl 0xc(%r14), %esi
movl 0x10(%r14), %edx
movl 0x14(%r14), %ecx
leaq 0x155bf(%rip), %rdi     # 0x2cd67
xorl %eax, %eax
callq 0x2110
movq %r14, %rdi
movq 0x28(%rsp), %rsi
callq 0x78b0
callq 0x2180
leal -0x1(%r12), %ebp
movq 0x10(%rsp), %rbx
movq (%rbx,%r15,8), %rdi
callq 0x7447
movq -0x8(%rbx,%r12,8), %rax
movq %rbx, %r12
movq %rax, (%rbx,%r15,8)
movq 0x50(%rsp), %rdi
callq 0x7447
movq %r14, %rdi
movq 0x20(%rsp), %rsi
movq 0x40(%rsp), %rdx
movl 0x1c(%rsp), %ecx
callq 0x84b9
movq %rax, %rbx
movq %r14, %rdi
callq 0x7447
cmpl %ebp, %r13d
movq %rbx, %rax
jl 0x176de
jmp 0x17839
leal -0x1(%r12), %ebp
callq 0x7447
movq 0x10(%rsp), %rcx
movq -0x8(%rcx,%r12,8), %rax
movq %rcx, %r12
movq %rax, (%rcx,%r15,8)
jmp 0x17803
xorl %r13d, %r13d
cmpl %ebp, %r13d
jne 0x17913
leal 0x1(%rbp), %ebx
movslq %ebp, %rdx
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%rdx,8)
movl 0x8(%rax), %esi
movl 0xc(%rax), %edx
movq 0x38(%rsp), %rcx
cmpl %esi, %ecx
cmovlel %esi, %ecx
movq %rcx, 0x38(%rsp)
movl 0x10(%rax), %ecx
movl 0x14(%rax), %r8d
leaq 0x15523(%rip), %rdi     # 0x2cd97
movq %rax, %r15
movl %ebp, %esi
xorl %eax, %eax
callq 0x2110
movq %r15, %rdi
movq 0x28(%rsp), %rsi
callq 0x78b0
movq 0x48(%rsp), %r13
cmpl %r13d, %ebx
jne 0x17922
testl %ebp, %ebp
js 0x178ed
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
addl %ecx, %eax
movl %eax, %ebx
shrl $0x1f, %ebx
addl %eax, %ebx
sarl %ebx
xorl %r14d, %r14d
movl %r13d, %ebp
movslq %r14d, %r15
movq 0x10(%rsp), %r12
movq (%r12,%r15,8), %rdi
cmpl %ebx, 0x8(%rdi)
jle 0x178d0
incl %r14d
jmp 0x178e3
callq 0x7447
movslq %ebp, %rax
decl %ebp
movq -0x8(%r12,%rax,8), %rax
movq %rax, (%r12,%r15,8)
cmpl %ebp, %r14d
jl 0x178ba
cmpl %r13d, %ebp
jne 0x17924
leal (,%r13,2), %ebx
movslq %ebx, %rsi
shlq $0x3, %rsi
movq 0x10(%rsp), %rdi
callq 0x2200
movq %rax, 0x10(%rsp)
movl %r13d, %ebp
movl %ebx, %r13d
jmp 0x17924
movq %rax, %rdi
callq 0x7447
movq 0x48(%rsp), %r13
jmp 0x17924
movl %ebx, %ebp
cmpl $0x1, %ebp
jne 0x1794e
movq 0x10(%rsp), %rdi
movq (%rdi), %r14
movl 0x8(%r14), %ecx
movq 0x20(%rsp), %r8
movl 0x8(%r8), %eax
cltd
idivl 0x10(%r8)
cmpl %eax, %ecx
je 0x17971
cmpl %r13d, %ebp
jl 0x17953
jmp 0x1799a
cmpl %r13d, %ebp
jge 0x17996
movb 0xf(%rsp), %al
movq 0x10(%rsp), %r12
jmp 0x17662
movq %r14, %rdi
callq 0x7447
movq %rbx, %rax
jmp 0x17839
callq 0x2030
movl 0xc(%r14), %esi
movl 0x10(%r14), %edx
leaq 0x15431(%rip), %rdi     # 0x2cdb6
xorl %eax, %eax
callq 0x2110
movq %r14, %rdi
callq 0x786c
jmp 0x179c2
testl %ebp, %ebp
jle 0x179b5
movl %ebp, %ebx
xorl %r14d, %r14d
movq 0x10(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x7447
incq %r14
cmpq %r14, %rbx
jne 0x1799f
movq 0x10(%rsp), %rdi
callq 0x2030
xorl %r14d, %r14d
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq