// File: /workspace/github_c_makefile_star2_O2/cbouilla[P]AES-attacks-finder/Symetric.c
// Function: SolverSymetrique
Solver SolverSymetrique(Solver B, const int decalage, Symetric_structure S)
{
	static unsigned char changement = 0;
	
	if (B!=NULL)
	{
		if (B->type!=0)
		{
			Solver B1 = SolverSymetrique(B->fils1,decalage,S);
			if (changement)
			{
				Solver out=NewSolver();
				out->fils1=B1;
				out->fils2=SolverSymetrique(B->fils2,decalage,S);
				out->var=UnionListesTriees(out->fils1->var,out->fils1->Nvar,out->fils2->var,out->fils2->Nvar,&out->Nvar);
				out->type=B->type;
				out->temps=B->temps;
				out->memoire=B->memoire;
				out->sortie=B->sortie;
				changement=1;
				return out;	
			}
			else
			{
				Solver B2 = SolverSymetrique(B->fils2,decalage,S);
				if (changement)
				{
					Solver out=NewSolver();
					out->fils1=B1;
					out->fils2=B2;
					out->var=UnionListesTriees(out->fils1->var,out->fils1->Nvar,out->fils2->var,out->fils2->Nvar,&out->Nvar);
					out->type=B->type;
					out->temps=B->temps;
					out->memoire=B->memoire;
					out->sortie=B->sortie;
					return out;	
				}
				else
				{
					freeSolver(B1);
					freeSolver(B2);
					return copySolver(B);
				}
			}
		}
		else
		{
			const int var = S->var_by_message[(decalage+S->message_by_var[B->var[0]])%S->n_message][S->position_by_var[B->var[0]]];
			if (B->var[0]!=var)
			{
				changement=1;
				Solver out=NewSolver();
				out->fils1=NULL;
				out->fils2=NULL;
				out->Nvar=1;
				out->var=malloc(sizeof(int));
				out->var[0]=var;
				out->type=B->type;
				out->temps=B->temps;
				out->memoire=B->memoire;
				out->sortie=B->sortie;
				return out;	
			}
			else
			{
				changement=0;
				return copySolver(B);
			}
		}
		
	}
	else
	{
		changement=0;
		return NULL;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x16558
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rbx
cmpb $0x0, 0x18(%rdi)
je 0x16567
movq 0x20(%rbx), %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x164bb
movq %rax, %r12
cmpb $0x0, 0x19f62(%rip)     # 0x30458
je 0x165a0
callq 0x67a4
movq %rax, %r14
movq %r12, 0x20(%rax)
movq 0x28(%rbx), %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x164bb
movq %rax, 0x28(%r14)
movq 0x20(%r14), %rcx
movq (%rcx), %rdi
movl 0x8(%rcx), %esi
movq (%rax), %rdx
movl 0x8(%rax), %ecx
leaq 0x8(%r14), %r8
callq 0x2440
movq %rax, (%r14)
movb 0x18(%rbx), %al
movb %al, 0x18(%r14)
movq 0xc(%rbx), %rax
movq %rax, 0xc(%r14)
movl 0x14(%rbx), %eax
movl %eax, 0x14(%r14)
movb $0x1, 0x19f05(%rip)     # 0x30458
jmp 0x16628
movb $0x0, 0x19ef9(%rip)     # 0x30458
xorl %r14d, %r14d
jmp 0x16628
movq (%r15), %rcx
movq 0x10(%r15), %rax
movq (%rbx), %rdx
movslq (%rdx), %rsi
addl (%rax,%rsi,4), %ebp
movl %ebp, %eax
cltd
idivl 0xc(%r15)
movslq %edx, %rax
movq (%rcx,%rax,8), %rax
movq 0x18(%r15), %rcx
movslq (%rcx,%rsi,4), %rcx
movl (%rax,%rcx,4), %ebp
cmpl %ebp, %esi
jne 0x165e8
movb $0x0, 0x19ebd(%rip)     # 0x30458
jmp 0x16644
movq 0x28(%rbx), %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x164bb
movq %rax, %r15
cmpb $0x1, 0x19ea0(%rip)     # 0x30458
jne 0x16634
callq 0x67a4
movq %rax, %r14
movq %r12, 0x20(%rax)
movq %r15, 0x28(%rax)
movq (%r12), %rdi
movl 0x8(%r12), %esi
movq (%r15), %rdx
movl 0x8(%r15), %ecx
leaq 0x8(%rax), %r8
callq 0x2440
movq %rax, (%r14)
jmp 0x16612
movb $0x1, 0x19e69(%rip)     # 0x30458
callq 0x67a4
movq %rax, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rax)
movl $0x1, 0x8(%rax)
pushq $0x4
popq %rdi
callq 0x21c0
movq %rax, (%r14)
movl %ebp, (%rax)
movb 0x18(%rbx), %al
movb %al, 0x18(%r14)
movq 0xc(%rbx), %rax
movq %rax, 0xc(%r14)
movl 0x14(%rbx), %eax
movl %eax, 0x14(%r14)
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x6852
movq %r15, %rdi
callq 0x6852
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6846