// File: /workspace/github_c_makefile_star2_O3/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
movl $0x38, %edi
callq 0x21d0
movq %rax, %r13
movl (%r15), %ebx
movl (%r14), %ebp
movl %ebp, %eax
addl %ebx, %eax
movl %eax, (%r13)
je 0x5635
cltq
movq %rax, (%rsp)
leaq (,%rax,4), %rdi
callq 0x21d0
movq %rax, %r12
movq %rax, 0x8(%r13)
movq (%rsp), %rdi
callq 0x21d0
movq %r13, %r9
movq %rax, 0x10(%r13)
testl %ebx, %ebx
jle 0x5603
movq 0x8(%r15), %rcx
movq 0x10(%r15), %rdx
xorl %esi, %esi
movl (%rcx,%rsi,4), %edi
movl %edi, (%r12,%rsi,4)
movb (%rdx,%rsi), %dil
movb %dil, (%rax,%rsi)
incq %rsi
cmpq %rbx, %rsi
jb 0x55ec
testl %ebp, %ebp
jle 0x5640
movslq %ebx, %rdi
movq 0x8(%r14), %rcx
movq 0x10(%r14), %rdx
leaq (%r12,%rdi,4), %rsi
addq %rdi, %rax
xorl %edi, %edi
movl (%rcx,%rdi,4), %r8d
movl %r8d, (%rsi,%rdi,4)
movb (%rdx,%rdi), %r8b
movb %r8b, (%rax,%rdi)
incq %rdi
cmpq %rbp, %rdi
jb 0x561b
jmp 0x5640
xorps %xmm0, %xmm0
movq %r13, %r9
movups %xmm0, 0x8(%r13)
movl 0x18(%r15), %ebx
movl 0x18(%r14), %ecx
movl %ecx, %eax
addl %ebx, %eax
movq %r9, %rbp
movl %eax, 0x18(%r9)
je 0x5745
movslq %eax, %r13
leaq (,%r13,8), %rdi
movl %ecx, 0x8(%rsp)
callq 0x21d0
movq %rax, (%rsp)
movq %rax, 0x20(%rbp)
movq %r13, %rdi
callq 0x21d0
movq %rax, %r12
movq %rax, 0x28(%rbp)
movq %r13, %rdi
callq 0x21d0
movl 0x8(%rsp), %ecx
movq %rax, %r13
movq %rax, 0x30(%rbp)
testl %ebx, %ebx
jle 0x56f5
movq %r14, 0x10(%rsp)
movq %rbp, 0x8(%rsp)
xorl %ebp, %ebp
movq %r12, %r14
movq (%rsp), %r12
movq 0x30(%r15), %rax
movb (%rax,%rbp), %al
movb %al, (%r13,%rbp)
movq 0x28(%r15), %rax
movb (%rax,%rbp), %al
movb %al, (%r14,%rbp)
movq 0x20(%r15), %rax
movq (%rax,%rbp,8), %rdi
callq 0x4b4b
movq %rax, (%r12,%rbp,8)
incq %rbp
movslq 0x18(%r15), %rbx
cmpq %rbx, %rbp
jl 0x56ae
movq 0x10(%rsp), %rax
movl 0x18(%rax), %ecx
movq 0x8(%rsp), %rbp
movq %r14, %r12
movq %rax, %r14
testl %ecx, %ecx
jle 0x5754
movslq %ebx, %rax
addq %rax, %r13
addq %rax, %r12
movq (%rsp), %rcx
leaq (%rcx,%rax,8), %rbx
xorl %r15d, %r15d
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 0x4b4b
movq %rax, (%rbx,%r15,8)
incq %r15
movslq 0x18(%r14), %rax
cmpq %rax, %r15
jl 0x570d
jmp 0x5754
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rbp)
movq $0x0, 0x30(%rbp)
movq %rbp, %rdi
callq 0x4f82
movq %rax, %r14
movq %rbp, %rdi
callq 0x4ad9
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq