// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/aes256otrsv3/ref/t-aes_enc_only.c
// Function: Encryption
int Encryption(int skeylen, unsigned char *plain, unsigned char *cipher)
{
	int				i, j;
	int				Nr;
	unsigned int	tmp_in[4];
	unsigned int	tmp_out[4];
	
	/* Set Nk, Nr from skeylen*/
	switch(skeylen)
	{
		case 128:
			Nr = 10;
			break;
		case 192:
			Nr = 12;
			break;
		case 256:
			Nr = 14;
			break;
		default:
			/* key-length error */
			return INVALID_PARAMETER;
	}
	
	/* round-key index initilization */
	i = 0;

	/* AddRoundKey */
	tmp_in[0] = ((plain[ 0] << 24) | (plain[ 1] << 16) | (plain[ 2] << 8) | plain[ 3]) ^ ekey[i++];
	tmp_in[1] = ((plain[ 4] << 24) | (plain[ 5] << 16) | (plain[ 6] << 8) | plain[ 7]) ^ ekey[i++];
	tmp_in[2] = ((plain[ 8] << 24) | (plain[ 9] << 16) | (plain[10] << 8) | plain[11]) ^ ekey[i++];
	tmp_in[3] = ((plain[12] << 24) | (plain[13] << 16) | (plain[14] << 8) | plain[15]) ^ ekey[i++];
	
	for(j=1; j<=(Nr-1); j++)
	{
		/* SubBytes + ShiftRows + MixColumns */
		tmp_out[0] = T0[tmp_in[0] >> 24] ^ T1[(tmp_in[1] >> 16) & 0xff] ^ T2[(tmp_in[2] >> 8) & 0xff] ^ T3[tmp_in[3] & 0xff];
		tmp_out[1] = T0[tmp_in[1] >> 24] ^ T1[(tmp_in[2] >> 16) & 0xff] ^ T2[(tmp_in[3] >> 8) & 0xff] ^ T3[tmp_in[0] & 0xff];
		tmp_out[2] = T0[tmp_in[2] >> 24] ^ T1[(tmp_in[3] >> 16) & 0xff] ^ T2[(tmp_in[0] >> 8) & 0xff] ^ T3[tmp_in[1] & 0xff];
		tmp_out[3] = T0[tmp_in[3] >> 24] ^ T1[(tmp_in[0] >> 16) & 0xff] ^ T2[(tmp_in[1] >> 8) & 0xff] ^ T3[tmp_in[2] & 0xff];

		/* AddRoundKey */
		tmp_in[0] = tmp_out[0] ^ ekey[i++];
		tmp_in[1] = tmp_out[1] ^ ekey[i++];
		tmp_in[2] = tmp_out[2] ^ ekey[i++];
		tmp_in[3] = tmp_out[3] ^ ekey[i++];
	}

	/* SubBytes + ShiftRows + AddRoundKey */
	cipher[ 0] = S[ tmp_in[0] >> 24        ] ^  (ekey[i  ] >> 24)        ;
	cipher[ 1] = S[(tmp_in[1] >> 16) & 0xff] ^ ((ekey[i  ] >> 16) & 0xff);
	cipher[ 2] = S[(tmp_in[2] >>  8) & 0xff] ^ ((ekey[i  ] >>  8) & 0xff);
	cipher[ 3] = S[ tmp_in[3]        & 0xff] ^ ( ekey[i++]        & 0xff);
	cipher[ 4] = S[ tmp_in[1] >> 24        ] ^  (ekey[i  ] >> 24)        ;
	cipher[ 5] = S[(tmp_in[2] >> 16) & 0xff] ^ ((ekey[i  ] >> 16) & 0xff);
	cipher[ 6] = S[(tmp_in[3] >>  8) & 0xff] ^ ((ekey[i  ] >>  8) & 0xff);
	cipher[ 7] = S[ tmp_in[0]        & 0xff] ^ ( ekey[i++]        & 0xff);
	cipher[ 8] = S[ tmp_in[2] >> 24        ] ^  (ekey[i  ] >> 24)        ;
	cipher[ 9] = S[(tmp_in[3] >> 16) & 0xff] ^ ((ekey[i  ] >> 16) & 0xff);
	cipher[10] = S[(tmp_in[0] >>  8) & 0xff] ^ ((ekey[i  ] >>  8) & 0xff);
	cipher[11] = S[ tmp_in[1]        & 0xff] ^ ( ekey[i++]        & 0xff);
	cipher[12] = S[ tmp_in[3] >> 24        ] ^  (ekey[i  ] >> 24)        ;
	cipher[13] = S[(tmp_in[0] >> 16) & 0xff] ^ ((ekey[i  ] >> 16) & 0xff);
	cipher[14] = S[(tmp_in[1] >>  8) & 0xff] ^ ((ekey[i  ] >>  8) & 0xff);
	cipher[15] = S[ tmp_in[2]        & 0xff] ^ ( ekey[i  ]        & 0xff);

	return SUCCESS;
}

// Assembly:
movl %edi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movq %rdx, -0x18(%rsp)
movl -0x8(%rsp), %eax
movl %eax, -0x4c(%rsp)
subl $0x80, %eax
je 0x26b9
jmp 0x269f
movl -0x4c(%rsp), %eax
subl $0xc0, %eax
je 0x26c3
jmp 0x26ac
movl -0x4c(%rsp), %eax
subl $0x100, %eax            # imm = 0x100
je 0x26cd
jmp 0x26d7
movl $0xa, -0x24(%rsp)
jmp 0x26e4
movl $0xc, -0x24(%rsp)
jmp 0x26e4
movl $0xe, -0x24(%rsp)
jmp 0x26e4
movl $0x1, -0x4(%rsp)
jmp 0x2e52
movl $0x0, -0x1c(%rsp)
movq -0x10(%rsp), %rax
movzbl (%rax), %eax
shll $0x18, %eax
movq -0x10(%rsp), %rcx
movzbl 0x1(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rsp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rsp), %rcx
movzbl 0x3(%rcx), %ecx
orl %ecx, %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x4b0b(%rip), %rcx      # 0x7240
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x38(%rsp)
movq -0x10(%rsp), %rax
movzbl 0x4(%rax), %eax
shll $0x18, %eax
movq -0x10(%rsp), %rcx
movzbl 0x5(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rsp), %rcx
movzbl 0x6(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rsp), %rcx
movzbl 0x7(%rcx), %ecx
orl %ecx, %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x4aba(%rip), %rcx      # 0x7240
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x34(%rsp)
movq -0x10(%rsp), %rax
movzbl 0x8(%rax), %eax
shll $0x18, %eax
movq -0x10(%rsp), %rcx
movzbl 0x9(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rsp), %rcx
movzbl 0xa(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rsp), %rcx
movzbl 0xb(%rcx), %ecx
orl %ecx, %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x4a69(%rip), %rcx      # 0x7240
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x30(%rsp)
movq -0x10(%rsp), %rax
movzbl 0xc(%rax), %eax
shll $0x18, %eax
movq -0x10(%rsp), %rcx
movzbl 0xd(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movq -0x10(%rsp), %rcx
movzbl 0xe(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x10(%rsp), %rcx
movzbl 0xf(%rcx), %ecx
orl %ecx, %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x4a18(%rip), %rcx      # 0x7240
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x2c(%rsp)
movl $0x1, -0x20(%rsp)
movl -0x20(%rsp), %eax
movl -0x24(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0x2a7e
movl -0x38(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x376c(%rip), %rax      # 0x5fc8
movl (%rax,%rcx,4), %eax
movl -0x34(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x3761(%rip), %rcx      # 0x5fd8
xorl (%rcx,%rdx,4), %eax
movl -0x30(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x36f6(%rip), %rcx      # 0x5f88
xorl (%rcx,%rdx,4), %eax
movl -0x2c(%rsp), %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x36ee(%rip), %rcx      # 0x5f98
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x48(%rsp)
movl -0x34(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x3705(%rip), %rax      # 0x5fc8
movl (%rax,%rcx,4), %eax
movl -0x30(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x36fa(%rip), %rcx      # 0x5fd8
xorl (%rcx,%rdx,4), %eax
movl -0x2c(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x368f(%rip), %rcx      # 0x5f88
xorl (%rcx,%rdx,4), %eax
movl -0x38(%rsp), %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x3687(%rip), %rcx      # 0x5f98
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x44(%rsp)
movl -0x30(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x369e(%rip), %rax      # 0x5fc8
movl (%rax,%rcx,4), %eax
movl -0x2c(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x3693(%rip), %rcx      # 0x5fd8
xorl (%rcx,%rdx,4), %eax
movl -0x38(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x3628(%rip), %rcx      # 0x5f88
xorl (%rcx,%rdx,4), %eax
movl -0x34(%rsp), %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x3620(%rip), %rcx      # 0x5f98
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x40(%rsp)
movl -0x2c(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x3637(%rip), %rax      # 0x5fc8
movl (%rax,%rcx,4), %eax
movl -0x38(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x362c(%rip), %rcx      # 0x5fd8
xorl (%rcx,%rdx,4), %eax
movl -0x34(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x35c1(%rip), %rcx      # 0x5f88
xorl (%rcx,%rdx,4), %eax
movl -0x30(%rsp), %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movq 0x35b9(%rip), %rcx      # 0x5f98
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x3c(%rsp)
movl -0x48(%rsp), %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x483f(%rip), %rcx      # 0x7240
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x38(%rsp)
movl -0x44(%rsp), %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x481d(%rip), %rcx      # 0x7240
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x34(%rsp)
movl -0x40(%rsp), %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x47fb(%rip), %rcx      # 0x7240
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x30(%rsp)
movl -0x3c(%rsp), %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x47d9(%rip), %rcx      # 0x7240
xorl (%rcx,%rdx,4), %eax
movl %eax, -0x2c(%rsp)
movl -0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rsp)
jmp 0x2837
movl -0x38(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x3560(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x47a0(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x18, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, (%rax)
movl -0x34(%rsp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x3528(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x4768(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0x1(%rax)
movl -0x30(%rsp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x34e9(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x4729(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0x2(%rax)
movl -0x2c(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x34ad(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x46e2(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0x3(%rax)
movl -0x34(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x346b(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x46ab(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x18, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0x4(%rax)
movl -0x30(%rsp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x3432(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x4672(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0x5(%rax)
movl -0x2c(%rsp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x33f3(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x4633(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0x6(%rax)
movl -0x38(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x33b7(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x45ec(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0x7(%rax)
movl -0x30(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x3375(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x45b5(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x18, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0x8(%rax)
movl -0x2c(%rsp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x333c(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x457c(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0x9(%rax)
movl -0x38(%rsp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x32fd(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x453d(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0xa(%rax)
movl -0x34(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x32c1(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movl -0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rsp)
movslq %ecx, %rdx
leaq 0x44f6(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0xb(%rax)
movl -0x2c(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x327f(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x44bf(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x18, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0xc(%rax)
movl -0x38(%rsp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x3246(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x4486(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0xd(%rax)
movl -0x34(%rsp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x3207(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x4447(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0xe(%rax)
movl -0x30(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x31cb(%rip), %rax      # 0x5ff0
movzbl (%rax,%rcx), %eax
movslq -0x1c(%rsp), %rdx
leaq 0x440b(%rip), %rcx      # 0x7240
movl (%rcx,%rdx,4), %ecx
andl $0xff, %ecx
xorl %ecx, %eax
movb %al, %cl
movq -0x18(%rsp), %rax
movb %cl, 0xf(%rax)
movl $0x0, -0x4(%rsp)
movl -0x4(%rsp), %eax
retq
nopw (%rax,%rax)