// File: /workspace/github_c_makefile_star2_O0/cbouilla[P]AES-attacks-finder/EquationAES.c
// Function: MakeKS
int MakeKS(Equation *Eq, int Nk, int Tours, int Final)
{
	Equation tmp,tmp1,tmp2,tmp3;
	int i,j,pos;
	pos=0;
	for (i = Nk; i < (Tours+Final+1)*4; i++)
	{
		for (j = 0; j < 4; j++)
		{
			if (i%Nk==0)
			{
				tmp=varEq(4*(i-1)+(j+1)%4);
				tmp1=appliqueS(tmp,0);
				freeEq(tmp);
				if (j==0)
				{
					tmp2=varEq(VARIABLES-(i/Nk));
					tmp=addEq(tmp1,tmp2);
					freeEq(tmp1);
					freeEq(tmp2);
				}
				else tmp=tmp1;
				tmp1=varEq(4*(i-Nk)+j);
				tmp2=varEq(4*i+j);
				tmp3=addEq(tmp1,tmp2);
				Eq[pos++]=addEq(tmp,tmp3);
				freeEq(tmp);
				freeEq(tmp1);
				freeEq(tmp2);
				freeEq(tmp3);
			}
			else
			{
				if (Nk>6 && (i%Nk)==4)
				{
					tmp=varEq(4*(i-1)+j);
					tmp1=appliqueS(tmp,0);
					freeEq(tmp);
					tmp=tmp1;
					tmp1=varEq(4*(i-Nk)+j);
					tmp2=varEq(4*i+j);
					tmp3=addEq(tmp1,tmp2);
					Eq[pos++]=addEq(tmp,tmp3);
					freeEq(tmp);
					freeEq(tmp1);
					freeEq(tmp2);
					freeEq(tmp3);
				}
				else
				{
					tmp=varEq(4*(i-1)+j);
					tmp1=varEq(4*(i-Nk)+j);
					tmp2=varEq(4*i+j);
					tmp3=addEq(tmp1,tmp2);
					Eq[pos++]=addEq(tmp,tmp3);
					freeEq(tmp);
					freeEq(tmp1);
					freeEq(tmp2);
					freeEq(tmp3);
				}
			}
		}
	}
	return pos;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl $0x0, -0x44(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl -0x10(%rbp), %ecx
addl -0x14(%rbp), %ecx
addl $0x1, %ecx
shll $0x2, %ecx
cmpl %ecx, %eax
jge 0x84c5
movl $0x0, -0x40(%rbp)
cmpl $0x4, -0x40(%rbp)
jge 0x84b5
movl -0x3c(%rbp), %eax
cltd
idivl -0xc(%rbp)
cmpl $0x0, %edx
jne 0x8336
movl -0x3c(%rbp), %edi
subl $0x1, %edi
shll $0x2, %edi
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl $0x4, %ecx
cltd
idivl %ecx
addl %edx, %edi
callq 0x5da0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x6ce0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5900
cmpl $0x0, -0x40(%rbp)
jne 0x82a7
movl 0x35058(%rip), %edi     # 0x3d2c8
movl -0x3c(%rbp), %eax
cltd
idivl -0xc(%rbp)
subl %eax, %edi
callq 0x5da0
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x6900
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rdi
callq 0x5900
movq -0x30(%rbp), %rdi
callq 0x5900
jmp 0x82af
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x3c(%rbp), %edi
subl -0xc(%rbp), %edi
shll $0x2, %edi
addl -0x40(%rbp), %edi
callq 0x5da0
movq %rax, -0x28(%rbp)
movl -0x3c(%rbp), %edi
shll $0x2, %edi
addl -0x40(%rbp), %edi
callq 0x5da0
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x6900
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x6900
movq %rax, %rdx
movq -0x8(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x44(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdi
callq 0x5900
movq -0x28(%rbp), %rdi
callq 0x5900
movq -0x30(%rbp), %rdi
callq 0x5900
movq -0x38(%rbp), %rdi
callq 0x5900
jmp 0x84a5
cmpl $0x6, -0xc(%rbp)
jle 0x840c
movl -0x3c(%rbp), %eax
cltd
idivl -0xc(%rbp)
cmpl $0x4, %edx
jne 0x840c
movl -0x3c(%rbp), %edi
subl $0x1, %edi
shll $0x2, %edi
addl -0x40(%rbp), %edi
callq 0x5da0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x6ce0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5900
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
movl -0x3c(%rbp), %edi
subl -0xc(%rbp), %edi
shll $0x2, %edi
addl -0x40(%rbp), %edi
callq 0x5da0
movq %rax, -0x28(%rbp)
movl -0x3c(%rbp), %edi
shll $0x2, %edi
addl -0x40(%rbp), %edi
callq 0x5da0
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x6900
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x6900
movq %rax, %rdx
movq -0x8(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x44(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdi
callq 0x5900
movq -0x28(%rbp), %rdi
callq 0x5900
movq -0x30(%rbp), %rdi
callq 0x5900
movq -0x38(%rbp), %rdi
callq 0x5900
jmp 0x84a3
movl -0x3c(%rbp), %edi
subl $0x1, %edi
shll $0x2, %edi
addl -0x40(%rbp), %edi
callq 0x5da0
movq %rax, -0x20(%rbp)
movl -0x3c(%rbp), %edi
subl -0xc(%rbp), %edi
shll $0x2, %edi
addl -0x40(%rbp), %edi
callq 0x5da0
movq %rax, -0x28(%rbp)
movl -0x3c(%rbp), %edi
shll $0x2, %edi
addl -0x40(%rbp), %edi
callq 0x5da0
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x6900
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x6900
movq %rax, %rdx
movq -0x8(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x44(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rdi
callq 0x5900
movq -0x28(%rbp), %rdi
callq 0x5900
movq -0x30(%rbp), %rdi
callq 0x5900
movq -0x38(%rbp), %rdi
callq 0x5900
jmp 0x84a5
jmp 0x84a7
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x8210
jmp 0x84b7
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x81f2
movl -0x44(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop