// File: /workspace/github_c_makefile_star2_O2/cbouilla[P]AES-attacks-finder/Equation.c
// Function: addEq
Equation addEq(Equation a, Equation b)
{	
	Equation p=malloc(sizeof(EQUATION));
	p->nV=a->nV+b->nV;
	if (p->nV!=0)
	{
		p->var=malloc(p->nV*sizeof(int));
		p->coefV=malloc(p->nV*sizeof(unsigned char));
		int i;
		for (i = 0; i < a->nV; i++)
		{
			p->var[i]=a->var[i];
			p->coefV[i]=a->coefV[i];
		}
		int k=a->nV;
		for (i = 0; i < b->nV; i++)
		{
			p->var[i+k]=b->var[i];
			p->coefV[i+k]=b->coefV[i];
		}
	}
	else
	{
		p->var=NULL;
		p->coefV=NULL;
	}
	p->nS=a->nS+b->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));
		int i;
		for (i = 0; i < a->nS; i++)
		{
			p->sbox[i]=a->sbox[i];
			p->coefS[i]=a->coefS[i];
			p->S[i]=copyEq(a->S[i]);
		}
		int k=a->nS;
		for (i = 0; i < b->nS; i++)
		{
			p->sbox[i+k]=b->sbox[i];
			p->coefS[i+k]=b->coefS[i];
			p->S[i+k]=copyEq(b->S[i]);
		}
	}
	else
	{
		p->S=NULL;
		p->coefS=NULL;
		p->sbox=NULL;
	}
	Equation pp=reduitEq(p);
	freeEq(p);
	return pp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %r15
pushq $0x38
popq %rdi
callq 0x21c0
movq %rax, %rbx
movslq (%r15), %rbp
movslq (%r14), %r13
addq %rbp, %r13
movl %r13d, (%rax)
testl %r13d, %r13d
je 0x4c03
leaq (,%r13,4), %rdi
callq 0x21c0
movq %rax, %r12
movq %rax, 0x8(%rbx)
movq %r13, %rdi
callq 0x21c0
movq %rbx, %rdi
movq %rax, 0x10(%rbx)
xorl %ecx, %ecx
cmpq %rbp, %rcx
jge 0x4bd4
movq 0x8(%r15), %rdx
movl (%rdx,%rcx,4), %edx
movl %edx, (%r12,%rcx,4)
movq 0x10(%r15), %rdx
movb (%rdx,%rcx), %dl
movb %dl, (%rax,%rcx)
incq %rcx
jmp 0x4bb5
movslq (%r14), %rcx
leaq (%r12,%rbp,4), %rdx
addq %rbp, %rax
xorl %esi, %esi
movq %rdi, %rbp
cmpq %rcx, %rsi
jge 0x4c0d
movq 0x8(%r14), %rdi
movl (%rdi,%rsi,4), %edi
movl %edi, (%rdx,%rsi,4)
movq 0x10(%r14), %rdi
movb (%rdi,%rsi), %dil
movb %dil, (%rax,%rsi)
incq %rsi
jmp 0x4be3
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movq %rbx, %rbp
movslq 0x18(%r15), %rbx
movslq 0x18(%r14), %r13
addq %rbx, %r13
movl %r13d, 0x18(%rbp)
testl %r13d, %r13d
je 0x4ced
leaq (,%r13,8), %rdi
callq 0x21c0
movq %rax, 0x8(%rsp)
movq %rax, 0x20(%rbp)
movq %r13, %rdi
callq 0x21c0
movq %rax, %r12
movq %rax, 0x28(%rbp)
movq %r13, %rdi
callq 0x21c0
movq %rax, %r13
movq %rbp, 0x10(%rsp)
movq %rax, 0x30(%rbp)
xorl %ebp, %ebp
movslq %ebx, %rax
cmpq %rax, %rbp
jge 0x4c9e
movq 0x30(%r15), %rax
movb (%rax,%rbp), %al
movb %al, (%r13,%rbp)
movq 0x28(%r15), %rax
movb (%rax,%rbp), %al
movb %al, (%r12,%rbp)
movq 0x20(%r15), %rax
movq (%rax,%rbp,8), %rdi
callq 0x4319
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%rbp,8)
incq %rbp
movl 0x18(%r15), %ebx
jmp 0x4c60
addq %rax, %r13
addq %rax, %r12
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,8), %rbx
xorl %r15d, %r15d
movq 0x10(%rsp), %rbp
movslq 0x18(%r14), %rax
cmpq %rax, %r15
jge 0x4cf9
movq 0x30(%r14), %rax
movb (%rax,%r15), %al
movb %al, (%r13,%r15)
movq 0x28(%r14), %rax
movb (%rax,%r15), %al
movb %al, (%r12,%r15)
movq 0x20(%r14), %rax
movq (%rax,%r15,8), %rdi
callq 0x4319
movq %rax, (%rbx,%r15,8)
incq %r15
jmp 0x4cb5
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rbp)
andq $0x0, 0x30(%rbp)
movq %rbp, %rdi
callq 0x4716
movq %rax, %r14
movq %rbp, %rdi
callq 0x42a5
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq