// File: /workspace/github_c_makefile_star2_O3/cbouilla[P]AES-attacks-finder/Equation.c
// Function: remplaceEq
Equation remplaceEq(Equation a, int var, Equation b)
{
	int i;
	Equation p,tmp,tmp1;
	p=malloc(sizeof(EQUATION));
	p->nS=a->nS;
	if (p->nS>0)
	{
		p->S=malloc(p->nS*sizeof(Equation));
		p->coefS=malloc(p->nS*sizeof(unsigned char));
		p->sbox=malloc(p->nS*sizeof(unsigned char));
		for (i = 0; i < p->nS; i++)
		{
			p->sbox[i]=a->sbox[i];
			p->coefS[i]=a->coefS[i];
			if (dependEq(a->S[i],var)) p->S[i]=remplaceEq(a->S[i],var,b);
			else p->S[i]=copyEq(a->S[i]);
		}
	}
	else
	{
		p->S=NULL;
		p->coefS=NULL;
		p->sbox=NULL;
	}
	p->nV=0;
	tmp=NULL;
	if (a->nV>0)
	{
		p->var=malloc(a->nV*sizeof(unsigned int));
		p->coefV=malloc(a->nV*sizeof(unsigned char));
		for (i = 0; i < a->nV; i++)
		{
			if (a->var[i]==var) tmp=mulEq(a->coefV[i],b);
			else
			{
				p->var[p->nV]=a->var[i];
				p->coefV[p->nV]=a->coefV[i];
				p->nV++;
			}
		}
		if (p->nV==0)
		{
			free(p->var);
			free(p->coefV);
			p->var=NULL;
			p->coefV=NULL;
		}
	}
	else
	{
		p->var=NULL;
		p->coefV=NULL;
	}
	if (tmp==NULL)
	{
		tmp=reduitEq(p);
		freeEq(p);
		return tmp;
	}
	else
	{
		tmp1=addEq(tmp,p);
		freeEq(tmp);
		freeEq(p);
		return tmp1;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, 0x8(%rsp)
movl %esi, %ebp
movq %rdi, %r15
movl $0x38, %edi
callq 0x21d0
movq %rax, %rbx
movslq 0x18(%r15), %r12
movl %r12d, 0x18(%rax)
testq %r12, %r12
movq %rax, 0x10(%rsp)
jle 0x59ac
leaq (,%r12,8), %rdi
callq 0x21d0
movq %rax, 0x20(%rsp)
movq %rax, 0x20(%rbx)
movq %r12, %rdi
callq 0x21d0
movq %rax, 0x18(%rsp)
movq %rax, 0x28(%rbx)
movq %r12, %rdi
callq 0x21d0
movq %rax, %r13
movq %rax, 0x30(%rbx)
xorl %r14d, %r14d
movq %r12, %rbx
movq 0x30(%r15), %rax
movb (%rax,%r14), %al
movb %al, (%r13,%r14)
movq 0x28(%r15), %rax
movb (%rax,%r14), %al
movq 0x18(%rsp), %rcx
movb %al, (%rcx,%r14)
movq 0x20(%r15), %rax
movq (%rax,%r14,8), %r12
movq %r12, %rdi
movl %ebp, %esi
callq 0x5874
movq %r12, %rdi
testl %eax, %eax
je 0x5991
movl %ebp, %esi
movq 0x8(%rsp), %rdx
callq 0x58d5
jmp 0x5996
callq 0x4b4b
movq 0x20(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
movq %rbx, %r12
cmpq %rbx, %r14
jb 0x5949
jmp 0x59bb
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rbx)
movq $0x0, 0x30(%rbx)
movq 0x10(%rsp), %rbx
movl $0x0, (%rbx)
movslq (%r15), %r14
testq %r14, %r14
jle 0x5a85
leaq (,%r14,4), %rdi
callq 0x21d0
movq %rbx, %r13
addq $0x8, %r13
movq %rax, 0x8(%rbx)
movq %r14, %rdi
callq 0x21d0
movq %rax, 0x10(%rbx)
xorl %r14d, %r14d
xorl %r12d, %r12d
movq 0x8(%r15), %rax
movl (%rax,%r14,4), %eax
cmpl %ebp, %eax
jne 0x5a20
movq 0x10(%r15), %rax
movzbl (%rax,%r14), %edi
movq 0x8(%rsp), %rsi
callq 0x4e14
movq %rax, %r12
jmp 0x5a3e
movq 0x8(%rbx), %rcx
movslq (%rbx), %rdx
movl %eax, (%rcx,%rdx,4)
movq 0x10(%r15), %rax
movb (%rax,%r14), %al
movq 0x10(%rbx), %rcx
movslq (%rbx), %rdx
movb %al, (%rcx,%rdx)
incl (%rbx)
incq %r14
movslq (%r15), %rax
cmpq %rax, %r14
jl 0x59fc
cmpl $0x0, (%rbx)
jne 0x5a68
movq 0x8(%rbx), %rdi
callq 0x2030
movq 0x10(%rbx), %rdi
callq 0x2030
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
testq %r12, %r12
je 0x5a8c
movq %r12, %rdi
movq %rbx, %rsi
callq 0x557f
movq %rax, %r14
movq %r12, %rdi
callq 0x4ad9
jmp 0x5a97
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movq %rbx, %rdi
callq 0x4f82
movq %rax, %r14
movq %rbx, %rdi
callq 0x4ad9
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq