// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/aes128n8t8clocv2/ref/aes_core.c
// Function: AES_set_encrypt_key
int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
			AES_KEY *key) {

	u32 *rk;
   	int i = 0;
	u32 temp;

	if (!userKey || !key)
		return -1;
	if (bits != 128 && bits != 192 && bits != 256)
		return -2;

	rk = (u32*)key->rd_key;

	if (bits==128)
		key->rounds = 10;
	else if (bits==192)
		key->rounds = 12;
	else
		key->rounds = 14;

	rk[0] = GETU32(userKey     );
	rk[1] = GETU32(userKey +  4);
	rk[2] = GETU32(userKey +  8);
	rk[3] = GETU32(userKey + 12);
	if (bits == 128) {
		for (;;) {
			temp  = rk[3];
			rk[4] = rk[0] ^
				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
				(Te4[(temp >> 24)       ] & 0x000000ff) ^
				rcon[i];
			rk[5] = rk[1] ^ rk[4];
			rk[6] = rk[2] ^ rk[5];
			rk[7] = rk[3] ^ rk[6];
			if (++i == 10) {
				return 0;
			}
			rk += 4;
		}
	}
	rk[4] = GETU32(userKey + 16);
	rk[5] = GETU32(userKey + 20);
	if (bits == 192) {
		for (;;) {
			temp = rk[ 5];
			rk[ 6] = rk[ 0] ^
				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
				(Te4[(temp >> 24)       ] & 0x000000ff) ^
				rcon[i];
			rk[ 7] = rk[ 1] ^ rk[ 6];
			rk[ 8] = rk[ 2] ^ rk[ 7];
			rk[ 9] = rk[ 3] ^ rk[ 8];
			if (++i == 8) {
				return 0;
			}
			rk[10] = rk[ 4] ^ rk[ 9];
			rk[11] = rk[ 5] ^ rk[10];
			rk += 6;
		}
	}
	rk[6] = GETU32(userKey + 24);
	rk[7] = GETU32(userKey + 28);
	if (bits == 256) {
		for (;;) {
			temp = rk[ 7];
			rk[ 8] = rk[ 0] ^
				(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
				(Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
				(Te4[(temp      ) & 0xff] & 0x0000ff00) ^
				(Te4[(temp >> 24)       ] & 0x000000ff) ^
				rcon[i];
			rk[ 9] = rk[ 1] ^ rk[ 8];
			rk[10] = rk[ 2] ^ rk[ 9];
			rk[11] = rk[ 3] ^ rk[10];
			if (++i == 7) {
				return 0;
			}
			temp = rk[11];
			rk[12] = rk[ 4] ^
				(Te4[(temp >> 24)       ] & 0xff000000) ^
				(Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^
				(Te4[(temp >>  8) & 0xff] & 0x0000ff00) ^
				(Te4[(temp      ) & 0xff] & 0x000000ff);
			rk[13] = rk[ 5] ^ rk[12];
			rk[14] = rk[ 6] ^ rk[13];
			rk[15] = rk[ 7] ^ rk[14];

			rk += 8;
        	}
	}
	return 0;
}

// Assembly:
movq %rdi, -0x10(%rsp)
movl %esi, -0x14(%rsp)
movq %rdx, -0x20(%rsp)
movl $0x0, -0x2c(%rsp)
cmpq $0x0, -0x10(%rsp)
je 0x1226
cmpq $0x0, -0x20(%rsp)
jne 0x1233
movl $0xffffffff, -0x4(%rsp) # imm = 0xFFFFFFFF
jmp 0x1927
cmpl $0x80, -0x14(%rsp)
je 0x125e
cmpl $0xc0, -0x14(%rsp)
je 0x125e
cmpl $0x100, -0x14(%rsp)     # imm = 0x100
je 0x125e
movl $0xfffffffe, -0x4(%rsp) # imm = 0xFFFFFFFE
jmp 0x1927
movq -0x20(%rsp), %rax
movq %rax, -0x28(%rsp)
cmpl $0x80, -0x14(%rsp)
jne 0x1283
movq -0x20(%rsp), %rax
movl $0xa, 0xf0(%rax)
jmp 0x12af
cmpl $0xc0, -0x14(%rsp)
jne 0x129e
movq -0x20(%rsp), %rax
movl $0xc, 0xf0(%rax)
jmp 0x12ad
movq -0x20(%rsp), %rax
movl $0xe, 0xf0(%rax)
jmp 0x12af
movq -0x10(%rsp), %rax
movzbl 0x3(%rax), %ecx
movq -0x10(%rsp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x1(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl (%rax), %eax
shll $0x18, %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, (%rax)
movq -0x10(%rsp), %rax
movzbl 0x7(%rax), %ecx
movq -0x10(%rsp), %rax
movzbl 0x6(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x5(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x4(%rax), %eax
shll $0x18, %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rsp), %rax
movzbl 0xb(%rax), %ecx
movq -0x10(%rsp), %rax
movzbl 0xa(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x9(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x8(%rax), %eax
shll $0x18, %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rsp), %rax
movzbl 0xf(%rax), %ecx
movq -0x10(%rsp), %rax
movzbl 0xe(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0xd(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0xc(%rax), %eax
shll $0x18, %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0xc(%rax)
cmpl $0x80, -0x14(%rsp)
jne 0x14c7
jmp 0x13a9
movq -0x28(%rsp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x30(%rsp)
movq -0x28(%rsp), %rax
movl (%rax), %ecx
movl -0x30(%rsp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5c2d(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff000000, %eax       # imm = 0xFF000000
xorl %eax, %ecx
movl -0x30(%rsp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5c0c(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff0000, %eax         # imm = 0xFF0000
xorl %eax, %ecx
movl -0x30(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5bee(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff00, %eax           # imm = 0xFF00
xorl %eax, %ecx
movl -0x30(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5bd2(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
xorl %eax, %ecx
movslq -0x2c(%rsp), %rdx
leaq 0x5fbc(%rip), %rax      # 0x7400
xorl (%rax,%rdx,4), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x10(%rax)
movq -0x28(%rsp), %rax
movl 0x4(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x10(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x14(%rax)
movq -0x28(%rsp), %rax
movl 0x8(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x14(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x18(%rax)
movq -0x28(%rsp), %rax
movl 0xc(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x18(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x1c(%rax)
movl -0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rsp)
cmpl $0xa, %eax
jne 0x14b4
movl $0x0, -0x4(%rsp)
jmp 0x1927
movq -0x28(%rsp), %rax
addq $0x10, %rax
movq %rax, -0x28(%rsp)
jmp 0x13a9
movq -0x10(%rsp), %rax
movzbl 0x13(%rax), %ecx
movq -0x10(%rsp), %rax
movzbl 0x12(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x11(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x10(%rax), %eax
shll $0x18, %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rsp), %rax
movzbl 0x17(%rax), %ecx
movq -0x10(%rsp), %rax
movzbl 0x16(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x15(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x14(%rax), %eax
shll $0x18, %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x14(%rax)
cmpl $0xc0, -0x14(%rsp)
jne 0x169b
jmp 0x154d
movq -0x28(%rsp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x30(%rsp)
movq -0x28(%rsp), %rax
movl (%rax), %ecx
movl -0x30(%rsp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5a89(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff000000, %eax       # imm = 0xFF000000
xorl %eax, %ecx
movl -0x30(%rsp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5a68(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff0000, %eax         # imm = 0xFF0000
xorl %eax, %ecx
movl -0x30(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5a4a(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff00, %eax           # imm = 0xFF00
xorl %eax, %ecx
movl -0x30(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5a2e(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
xorl %eax, %ecx
movslq -0x2c(%rsp), %rdx
leaq 0x5e18(%rip), %rax      # 0x7400
xorl (%rax,%rdx,4), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x18(%rax)
movq -0x28(%rsp), %rax
movl 0x4(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x18(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x1c(%rax)
movq -0x28(%rsp), %rax
movl 0x8(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x1c(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x20(%rax)
movq -0x28(%rsp), %rax
movl 0xc(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x20(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x24(%rax)
movl -0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rsp)
cmpl $0x8, %eax
jne 0x1658
movl $0x0, -0x4(%rsp)
jmp 0x1927
movq -0x28(%rsp), %rax
movl 0x10(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x24(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x28(%rax)
movq -0x28(%rsp), %rax
movl 0x14(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x28(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x2c(%rax)
movq -0x28(%rsp), %rax
addq $0x18, %rax
movq %rax, -0x28(%rsp)
jmp 0x154d
movq -0x10(%rsp), %rax
movzbl 0x1b(%rax), %ecx
movq -0x10(%rsp), %rax
movzbl 0x1a(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x19(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x18(%rax), %eax
shll $0x18, %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rsp), %rax
movzbl 0x1f(%rax), %ecx
movq -0x10(%rsp), %rax
movzbl 0x1e(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x1d(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x1c(%rax), %eax
shll $0x18, %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x1c(%rax)
cmpl $0x100, -0x14(%rsp)     # imm = 0x100
jne 0x191f
jmp 0x1721
movq -0x28(%rsp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x30(%rsp)
movq -0x28(%rsp), %rax
movl (%rax), %ecx
movl -0x30(%rsp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x58b5(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff000000, %eax       # imm = 0xFF000000
xorl %eax, %ecx
movl -0x30(%rsp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5894(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff0000, %eax         # imm = 0xFF0000
xorl %eax, %ecx
movl -0x30(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5876(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff00, %eax           # imm = 0xFF00
xorl %eax, %ecx
movl -0x30(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x585a(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
xorl %eax, %ecx
movslq -0x2c(%rsp), %rdx
leaq 0x5c44(%rip), %rax      # 0x7400
xorl (%rax,%rdx,4), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x20(%rax)
movq -0x28(%rsp), %rax
movl 0x4(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x20(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x24(%rax)
movq -0x28(%rsp), %rax
movl 0x8(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x24(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x28(%rax)
movq -0x28(%rsp), %rax
movl 0xc(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x28(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x2c(%rax)
movl -0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rsp)
cmpl $0x7, %eax
jne 0x182c
movl $0x0, -0x4(%rsp)
jmp 0x1927
movq -0x28(%rsp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x30(%rsp)
movq -0x28(%rsp), %rax
movl 0x10(%rax), %ecx
movl -0x30(%rsp), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x57ae(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff000000, %eax       # imm = 0xFF000000
xorl %eax, %ecx
movl -0x30(%rsp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x578d(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff0000, %eax         # imm = 0xFF0000
xorl %eax, %ecx
movl -0x30(%rsp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x576c(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff00, %eax           # imm = 0xFF00
xorl %eax, %ecx
movl -0x30(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x574e(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x30(%rax)
movq -0x28(%rsp), %rax
movl 0x14(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x30(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x34(%rax)
movq -0x28(%rsp), %rax
movl 0x18(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x34(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x38(%rax)
movq -0x28(%rsp), %rax
movl 0x1c(%rax), %ecx
movq -0x28(%rsp), %rax
xorl 0x38(%rax), %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x3c(%rax)
movq -0x28(%rsp), %rax
addq $0x20, %rax
movq %rax, -0x28(%rsp)
jmp 0x1721
movl $0x0, -0x4(%rsp)
movl -0x4(%rsp), %eax
retq
nopl (%rax)