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

        u32 *rk;
	int i, j, status;
	u32 temp;

	/* first, start with an encryption schedule */
	status = AES_set_encrypt_key(userKey, bits, key);
	if (status < 0)
		return status;

	rk = (u32*) key->rd_key;

	/* invert the order of the round keys: */
	for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {
		temp = rk[i    ]; rk[i    ] = rk[j    ]; rk[j    ] = temp;
		temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
		temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
		temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;
	}
	/* apply the inverse MixColumn transform to all round keys but the first and the last: */
	for (i = 1; i < (key->rounds); i++) {
		rk += 4;
		rk[0] =
			Td0[Te4[(rk[0] >> 24)       ] & 0xff] ^
			Td1[Te4[(rk[0] >> 16) & 0xff] & 0xff] ^
			Td2[Te4[(rk[0] >>  8) & 0xff] & 0xff] ^
			Td3[Te4[(rk[0]      ) & 0xff] & 0xff];
		rk[1] =
			Td0[Te4[(rk[1] >> 24)       ] & 0xff] ^
			Td1[Te4[(rk[1] >> 16) & 0xff] & 0xff] ^
			Td2[Te4[(rk[1] >>  8) & 0xff] & 0xff] ^
			Td3[Te4[(rk[1]      ) & 0xff] & 0xff];
		rk[2] =
			Td0[Te4[(rk[2] >> 24)       ] & 0xff] ^
			Td1[Te4[(rk[2] >> 16) & 0xff] & 0xff] ^
			Td2[Te4[(rk[2] >>  8) & 0xff] & 0xff] ^
			Td3[Te4[(rk[2]      ) & 0xff] & 0xff];
		rk[3] =
			Td0[Te4[(rk[3] >> 24)       ] & 0xff] ^
			Td1[Te4[(rk[3] >> 16) & 0xff] & 0xff] ^
			Td2[Te4[(rk[3] >>  8) & 0xff] & 0xff] ^
			Td3[Te4[(rk[3]      ) & 0xff] & 0xff];
	}
	return 0;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movl %esi, 0x24(%rsp)
movq %rdx, 0x18(%rsp)
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
movq 0x18(%rsp), %rdx
callq 0x10a0
movl %eax, 0x4(%rsp)
cmpl $0x0, 0x4(%rsp)
jge 0x196d
movl 0x4(%rsp), %eax
movl %eax, 0x34(%rsp)
jmp 0x1e2c
movq 0x18(%rsp), %rax
movq %rax, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %rax
movl 0xf0(%rax), %eax
shll $0x2, %eax
movl %eax, 0x8(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x8(%rsp), %eax
jge 0x1ade
movq 0x10(%rsp), %rax
movslq 0xc(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rax
movslq 0x8(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x10(%rsp), %rax
movslq 0xc(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl (%rsp), %edx
movq 0x10(%rsp), %rax
movslq 0x8(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movq 0x10(%rsp), %rax
movl 0xc(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rax
movl 0x8(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x10(%rsp), %rax
movl 0xc(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl (%rsp), %edx
movq 0x10(%rsp), %rax
movl 0x8(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq 0x10(%rsp), %rax
movl 0xc(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rax
movl 0x8(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x10(%rsp), %rax
movl 0xc(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl (%rsp), %edx
movq 0x10(%rsp), %rax
movl 0x8(%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq 0x10(%rsp), %rax
movl 0xc(%rsp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, (%rsp)
movq 0x10(%rsp), %rax
movl 0x8(%rsp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq 0x10(%rsp), %rax
movl 0xc(%rsp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl (%rsp), %edx
movq 0x10(%rsp), %rax
movl 0x8(%rsp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl 0xc(%rsp), %eax
addl $0x4, %eax
movl %eax, 0xc(%rsp)
movl 0x8(%rsp), %eax
subl $0x4, %eax
movl %eax, 0x8(%rsp)
jmp 0x1991
movl $0x1, 0xc(%rsp)
movl 0xc(%rsp), %eax
movq 0x18(%rsp), %rcx
cmpl 0xf0(%rcx), %eax
jge 0x1e24
movq 0x10(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movl (%rax), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x54e2(%rip), %rax      # 0x7000
movl (%rax,%rcx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x58ff(%rip), %rax      # 0x7430
movl (%rax,%rcx,4), %ecx
movq 0x10(%rsp), %rax
movl (%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x54b2(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5ccf(%rip), %rax      # 0x7830
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl (%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5482(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x609f(%rip), %rax      # 0x7c30
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl (%rax), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5455(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x6472(%rip), %rax      # 0x8030
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl %ecx, (%rax)
movq 0x10(%rsp), %rax
movl 0x4(%rax), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x5422(%rip), %rax      # 0x7000
movl (%rax,%rcx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x583f(%rip), %rax      # 0x7430
movl (%rax,%rcx,4), %ecx
movq 0x10(%rsp), %rax
movl 0x4(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x53f1(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5c0e(%rip), %rax      # 0x7830
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl 0x4(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x53c0(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5fdd(%rip), %rax      # 0x7c30
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl 0x4(%rax), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5392(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x63af(%rip), %rax      # 0x8030
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x10(%rsp), %rax
movl 0x8(%rax), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x535e(%rip), %rax      # 0x7000
movl (%rax,%rcx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x577b(%rip), %rax      # 0x7430
movl (%rax,%rcx,4), %ecx
movq 0x10(%rsp), %rax
movl 0x8(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x532d(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5b4a(%rip), %rax      # 0x7830
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl 0x8(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x52fc(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5f19(%rip), %rax      # 0x7c30
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl 0x8(%rax), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x52ce(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x62eb(%rip), %rax      # 0x8030
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0x8(%rax)
movq 0x10(%rsp), %rax
movl 0xc(%rax), %eax
shrl $0x18, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x529a(%rip), %rax      # 0x7000
movl (%rax,%rcx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x56b7(%rip), %rax      # 0x7430
movl (%rax,%rcx,4), %ecx
movq 0x10(%rsp), %rax
movl 0xc(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5269(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5a86(%rip), %rax      # 0x7830
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl 0xc(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5238(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x5e55(%rip), %rax      # 0x7c30
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl 0xc(%rax), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x520a(%rip), %rax      # 0x7000
movl (%rax,%rdx,4), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %edx
leaq 0x6227(%rip), %rax      # 0x8030
xorl (%rax,%rdx,4), %ecx
movq 0x10(%rsp), %rax
movl %ecx, 0xc(%rax)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x1ae6
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)