// File: /workspace/github_c_makefile_star2_O3/cbouilla[P]AES-attacks-finder/Search.c
// Function: GenerateSolver_manual
Solver GenerateSolver_manual(int T, Solver *B1, int N1, SysEqLin E, string_list_t *variable_names) // Search manuelle
{
	int i,N;
	Solver B,*B1_tmp,tmp;

	for (i = 0; i < N1; i++)
	{
		printf(" Solver %d (%d || %d || %d): ",i,B1[i]->temps,B1[i]->memoire,B1[i]->sortie);
		PrintVarSolver2(B1[i],variable_names);
	}
	do
	{
		printf("index of guessed solver : ");
		scanf(" %d",&i);
		getchar();
	} while (i<0 || i>=N1);
	//i=rand()%N1;
	N=N1-1;
	B=B1[i];
	B1[i]=B1[N];
	B1[N]=B;
	B=copySolver(B);
	B1_tmp=malloc(N*sizeof(Solver));
	for (i = 0; i < N; i++) B1_tmp[i]=copySolver(B1[i]);
	while (B->sortie<T && N>0)
	{
		for (i = 0; i < N; i++)
		{
			tmp=UnionSpeciale(B1_tmp[i],B,E);
			if (tmp->sortie>T || tmp->temps>T)
			{
				printf("Something wrong - 2204 - Search.c");
				getchar();
			}
			freeSolver(B1_tmp[i]);
			B1_tmp[i]=tmp;
		}
		N=ReduireSolvers(B1_tmp,N,E);
		TriFusion1(B1_tmp,N);
		if (B1_tmp[0]->sortie<=B->sortie)
		{
			freeSolver(B);
			tmp=B1_tmp[0];
			N--;
			B1_tmp[0]=B1_tmp[N];
			B=PropagateSolver2(tmp,E,B1,N1);
			freeSolver(tmp);
			for (i = 0; i < N; i++) freeSolver(B1_tmp[i]);
			N=0;
			int *test,Ntest;
			for (i = 0; i < N1; i++)
			{
				test=UnionListesTriees(B->var,B->Nvar,B1[i]->var,B1[i]->Nvar,&Ntest);
				free(test);
				if (Ntest>B->Nvar) B1_tmp[N++]=copySolver(B1[i]);
			}			
		}
		else
		{
			for (i = 0; i < N; i++)
			{
				printf(" Solver %d : ",i);
				PrintVarSolver2(B1_tmp[i]->fils1,variable_names);
			}
			do
			{
				printf("index of guessed solver : ? ");
				scanf(" %d",&i);
				getchar();
			} while (i<0 || i>=N);
			freeSolver(B);
			B=B1_tmp[i];
			N--;
			B1_tmp[i]=B1_tmp[N];
		}
	}
	if (B->Nvar<T || B->memoire>1 || B->temps>T)
	{
		printf("Something wrong - 2249 - Search.c : %d %d %d\n",B->memoire,B->temps,B->sortie);
		PrintVarSolver(B);
		getchar();
	}
	printf(" Solver built (%d || %d || %d): ",B->temps,B->memoire,B->sortie);
	PrintVarSolver2(B,variable_names);
	getchar();
	for (i = 0; i < N; i++) freeSolver(B1_tmp[i]);
	free(B1_tmp);
	return B;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, 0x18(%rsp)
movq %rcx, %r13
movl %edi, %ebp
testl %edx, %edx
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
jle 0x16c5a
movl %edx, %ebx
leaq 0x15fee(%rip), %r14     # 0x2cc00
xorl %r15d, %r15d
movq 0x18(%rsp), %r12
movq (%rsi,%r15,8), %rax
movl 0xc(%rax), %edx
movl 0x10(%rax), %ecx
movl 0x14(%rax), %r8d
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x2110
movq 0x8(%rsp), %rax
movq (%rax,%r15,8), %rdi
movq %r12, %rsi
callq 0x78b0
movq 0x8(%rsp), %rsi
incq %r15
cmpq %r15, %rbx
jne 0x16c1a
movq 0x10(%rsp), %rax
jmp 0x16c5c
xorl %eax, %eax
leaq 0x4(%rsp), %r14
movl %eax, (%r14)
leaq 0x15fb3(%rip), %r15     # 0x2cc1e
leaq 0x15f8a(%rip), %r12     # 0x2cbfc
movq 0x10(%rsp), %rbx
movq %r15, %rdi
xorl %eax, %eax
callq 0x2110
movq %r12, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2230
callq 0x2180
movl 0x4(%rsp), %eax
testl %eax, %eax
sets %cl
cmpl %ebx, %eax
setge %dl
orb %cl, %dl
jne 0x16c77
leal -0x1(%rbx), %r14d
movq 0x8(%rsp), %rdx
movq (%rdx,%rax,8), %rdi
movslq %ebx, %r15
movq -0x8(%rdx,%r15,8), %rcx
movq %rcx, (%rdx,%rax,8)
movq %rdi, -0x8(%rdx,%r15,8)
callq 0x743b
movq %rax, %r12
leaq -0x8(,%r15,8), %rdi
callq 0x21d0
movq %rax, %r15
movl $0x0, 0x4(%rsp)
cmpl $0x2, %ebx
jl 0x16f68
movq %r13, 0x30(%rsp)
xorl %eax, %eax
movq 0x8(%rsp), %r13
cltq
movq (%r13,%rax,8), %rdi
callq 0x743b
movslq 0x4(%rsp), %rcx
movq %rax, (%r15,%rcx,8)
leal 0x1(%rcx), %eax
movl %eax, 0x4(%rsp)
cmpl %r14d, %eax
jl 0x16cf8
cmpl $0x2, %ebx
setl %al
movq %r12, %rbx
addq $0x14, %rbx
movl 0x14(%r12), %ecx
cmpl %ebp, %ecx
setge %dl
orb %al, %dl
jne 0x16f74
movq %rbx, 0x20(%rsp)
movl $0x0, 0x4(%rsp)
xorl %eax, %eax
movq 0x30(%rsp), %r13
cltq
movq (%r15,%rax,8), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x80de
movq %rax, %rbx
cmpl %ebp, 0x14(%rax)
jg 0x16d6a
cmpl %ebp, 0xc(%rbx)
jle 0x16d7d
leaq 0x15ec8(%rip), %rdi     # 0x2cc39
xorl %eax, %eax
callq 0x2110
callq 0x2180
movslq 0x4(%rsp), %rax
movq (%r15,%rax,8), %rdi
callq 0x7447
movslq 0x4(%rsp), %rax
movq %rbx, (%r15,%rax,8)
incl %eax
movl %eax, 0x4(%rsp)
cmpl %r14d, %eax
jl 0x16d4c
movq %r15, %rdi
movl %r14d, %esi
movq %r13, %rdx
callq 0x8342
movl %eax, %r14d
movq %r15, %rdi
movl %eax, %esi
callq 0x7ba5
movq (%r15), %rax
movl 0x14(%rax), %eax
movslq %r14d, %rbx
movq 0x20(%rsp), %rcx
cmpl (%rcx), %eax
jle 0x16e7e
movq %rbx, 0x20(%rsp)
movl $0x0, 0x4(%rsp)
testl %r14d, %r14d
movq 0x18(%rsp), %rbx
leaq 0x15e6f(%rip), %r13     # 0x2cc5b
jle 0x16e1e
xorl %esi, %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x2110
movslq 0x4(%rsp), %rax
movq (%r15,%rax,8), %rax
movq 0x20(%rax), %rdi
movq %rbx, %rsi
callq 0x78b0
movl 0x4(%rsp), %esi
incl %esi
movl %esi, 0x4(%rsp)
cmpl %r14d, %esi
jl 0x16df0
leaq 0x15e44(%rip), %rbx     # 0x2cc69
leaq 0x15dd0(%rip), %r13     # 0x2cbfc
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2110
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
xorl %eax, %eax
callq 0x2230
callq 0x2180
movl 0x4(%rsp), %eax
testl %eax, %eax
js 0x16e2c
cmpl %r14d, %eax
jge 0x16e2c
movq %r12, %rdi
callq 0x7447
movslq 0x4(%rsp), %rax
movq (%r15,%rax,8), %r12
decl %r14d
movq 0x20(%rsp), %rcx
movq -0x8(%r15,%rcx,8), %rcx
movq %rcx, (%r15,%rax,8)
jmp 0x16f4f
movq %r12, %rdi
callq 0x7447
movq (%r15), %rdi
movq -0x8(%r15,%rbx,8), %rax
movq %rax, (%r15)
movq %rdi, %rbx
movq %r13, %rsi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
callq 0x84b9
movq %rax, %r12
movq %rbx, %rdi
callq 0x7447
movl $0x0, 0x4(%rsp)
cmpl $0x2, %r14d
jl 0x16ede
decl %r14d
xorl %eax, %eax
cltq
movq (%r15,%rax,8), %rdi
callq 0x7447
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
cmpl %r14d, %eax
jl 0x16ec4
movl $0x0, 0x4(%rsp)
xorl %r14d, %r14d
xorl %eax, %eax
movq 0x10(%rsp), %rbx
movq (%r12), %rdi
movl 0x8(%r12), %esi
cltq
movq 0x8(%rsp), %r13
movq (%r13,%rax,8), %rax
movq (%rax), %rdx
movl 0x8(%rax), %ecx
leaq 0x2c(%rsp), %r8
callq 0x2544
movq %rax, %rdi
callq 0x2030
movl 0x2c(%rsp), %eax
cmpl 0x8(%r12), %eax
jle 0x16f41
movslq 0x4(%rsp), %rax
movq (%r13,%rax,8), %rdi
callq 0x743b
movslq %r14d, %rcx
incl %r14d
movq %rax, (%r15,%rcx,8)
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
cmpl %ebx, %eax
jl 0x16ef0
leaq 0x14(%r12), %rbx
movl 0x14(%r12), %ecx
cmpl %ebp, %ecx
jge 0x16f74
testl %r14d, %r14d
jg 0x16d38
jmp 0x16f74
movq %r12, %rbx
addq $0x14, %rbx
movl 0x14(%r12), %ecx
movl 0x10(%r12), %edx
cmpl %ebp, 0x8(%r12)
setl %al
cmpl $0x2, %edx
setge %sil
orb %al, %sil
jne 0x16f96
movl 0xc(%r12), %esi
cmpl %ebp, %esi
jle 0x16fc6
movl 0xc(%r12), %eax
leaq 0x15ce4(%rip), %rdi     # 0x2cc86
movl %edx, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x2110
movq %r12, %rdi
callq 0x786c
callq 0x2180
movl 0xc(%r12), %esi
movl 0x10(%r12), %edx
movl (%rbx), %ecx
leaq 0x15ce7(%rip), %rdi     # 0x2ccb4
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2110
movq %r12, %rdi
movq 0x18(%rsp), %rsi
callq 0x78b0
callq 0x2180
movl $0x0, 0x4(%rsp)
testl %r14d, %r14d
jle 0x17010
movslq %ebx, %rax
movq (%r15,%rax,8), %rdi
callq 0x7447
movl 0x4(%rsp), %ebx
incl %ebx
movl %ebx, 0x4(%rsp)
cmpl %r14d, %ebx
jl 0x16ff5
movq %r15, %rdi
callq 0x2030
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq