// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/elmd1001v2/ref/aes_round_6.h
// Function: AES_set_encrypt_key_6
int AES_set_encrypt_key_6(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 )
		return -2;

	rk = key->rd_key;

	key->rounds = 6;
	
	rk[0] = GETU32(userKey     );
	rk[1] = GETU32(userKey +  4);
	rk[2] = GETU32(userKey +  8);
	rk[3] = GETU32(userKey + 12);
	while (1) {
		temp  = rk[3];
		rk[4] = rk[0] ^
			(Te2[(temp >> 16) & 0xff] & 0xff000000) ^
			(Te3[(temp >>  8) & 0xff] & 0x00ff0000) ^
			(Te0[(temp      ) & 0xff] & 0x0000ff00) ^
			(Te1[(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 == 6) {
			return 0;
		}
		rk += 4;
	}
	
	return 0;
}

// Assembly:
movq %rdi, -0x10(%rsp)
movl %esi, -0x14(%rsp)
movq %rdx, -0x20(%rsp)
movl $0x0, -0x2c(%rsp)
cmpq $0x0, -0x10(%rsp)
je 0x1196
cmpq $0x0, -0x20(%rsp)
jne 0x11a3
movl $0xffffffff, -0x4(%rsp) # imm = 0xFFFFFFFF
jmp 0x13d8
cmpl $0x80, -0x14(%rsp)
je 0x11ba
movl $0xfffffffe, -0x4(%rsp) # imm = 0xFFFFFFFE
jmp 0x13d8
movq -0x20(%rsp), %rax
movq %rax, -0x28(%rsp)
movq -0x20(%rsp), %rax
movl $0x6, 0xf0(%rax)
movq -0x10(%rsp), %rax
movzbl (%rax), %ecx
shll $0x18, %ecx
movq -0x10(%rsp), %rax
movzbl 0x1(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x2(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x3(%rax), %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, (%rax)
movq -0x10(%rsp), %rax
movzbl 0x4(%rax), %ecx
shll $0x18, %ecx
movq -0x10(%rsp), %rax
movzbl 0x5(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x6(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0x7(%rax), %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rsp), %rax
movzbl 0x8(%rax), %ecx
shll $0x18, %ecx
movq -0x10(%rsp), %rax
movzbl 0x9(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0xa(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0xb(%rax), %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rsp), %rax
movzbl 0xc(%rax), %ecx
shll $0x18, %ecx
movq -0x10(%rsp), %rax
movzbl 0xd(%rax), %eax
shll $0x10, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0xe(%rax), %eax
shll $0x8, %eax
xorl %eax, %ecx
movq -0x10(%rsp), %rax
movzbl 0xf(%rax), %eax
xorl %eax, %ecx
movq -0x28(%rsp), %rax
movl %ecx, 0xc(%rax)
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 0x3d19(%rip), %rax      # 0x5000
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 0x40f8(%rip), %rax      # 0x5400
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 0x44da(%rip), %rax      # 0x5800
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 0x48be(%rip), %rax      # 0x5c00
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
xorl %eax, %ecx
movslq -0x2c(%rsp), %rdx
leaq 0x4ca8(%rip), %rax      # 0x6000
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 $0x6, %eax
jne 0x13c5
movl $0x0, -0x4(%rsp)
jmp 0x13d8
movq -0x28(%rsp), %rax
addq $0x10, %rax
movq %rax, -0x28(%rsp)
jmp 0x12bd
movl -0x4(%rsp), %eax
retq
nopl (%rax)