// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x38, %edi
callq 0x21c0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x30(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jle 0x6fdc
movq -0x30(%rbp), %rax
movslq 0x18(%rax), %rdi
shlq $0x3, %rdi
callq 0x21c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x30(%rbp), %rax
movslq 0x18(%rax), %rdi
shlq $0x0, %rdi
callq 0x21c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rax
movslq 0x18(%rax), %rdi
shlq $0x0, %rdi
callq 0x21c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x6fda
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl -0x14(%rbp), %esi
callq 0x6dc0
cmpl $0x0, %eax
je 0x6fa2
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
callq 0x6e70
movq %rax, %rdx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x6fca
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x59c0
movq %rax, %rdx
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x6fcc
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x6f08
jmp 0x7000
movq -0x30(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jle 0x713a
movq -0x10(%rbp), %rax
movslq (%rax), %rdi
shlq $0x2, %rdi
callq 0x21c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movslq (%rax), %rdi
shlq $0x0, %rdi
callq 0x21c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x70fd
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x14(%rbp), %eax
jne 0x70a0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx), %al
movq -0x20(%rbp), %rsi
movzbl %al, %edi
callq 0x5ea0
movq %rax, -0x38(%rbp)
jmp 0x70ed
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
movslq (%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movslq (%rcx), %rcx
movb %dl, (%rax,%rcx)
movq -0x30(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x70ef
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x705c
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x7138
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2030
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2030
movq -0x30(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x10(%rax)
jmp 0x7152
movq -0x30(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
movq $0x0, 0x10(%rax)
cmpq $0x0, -0x38(%rbp)
jne 0x7179
movq -0x30(%rbp), %rdi
callq 0x6100
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0x5900
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x71a4
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x6900
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x5900
movq -0x30(%rbp), %rdi
callq 0x5900
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop