// File: /workspace/github_c_makefile_star2_O2/mjosaarinen[P]brutus/crypto_aead/aezv3/ref/rijndael-alg-fst.c
// Function: rijndaelKeySetupDec
int rijndaelKeySetupDec(u32 rk[/*4*(Nr + 1)*/], const u8 cipherKey[], int keyBits) {
	int Nr, i, j;
	u32 temp;

	/* expand the cipher key: */
	Nr = rijndaelKeySetupEnc(rk, cipherKey, keyBits);
	/* invert the order of the round keys: */
	for (i = 0, j = 4*Nr; 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 < Nr; 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 Nr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x1080
leal (,%rax,4), %ecx
xorl %edx, %edx
cmpq %rcx, %rdx
jge 0x2c31
movl (%rbx,%rdx,4), %esi
movl (%rbx,%rcx,4), %edi
movl %edi, (%rbx,%rdx,4)
movl %esi, (%rbx,%rcx,4)
movl 0x4(%rbx,%rdx,4), %esi
movl 0x4(%rbx,%rcx,4), %edi
movl %edi, 0x4(%rbx,%rdx,4)
movl %esi, 0x4(%rbx,%rcx,4)
movl 0x8(%rbx,%rdx,4), %esi
movl 0x8(%rbx,%rcx,4), %edi
movl %edi, 0x8(%rbx,%rdx,4)
movl %esi, 0x8(%rbx,%rcx,4)
movl 0xc(%rbx,%rdx,4), %esi
movl 0xc(%rbx,%rcx,4), %edi
movl %edi, 0xc(%rbx,%rdx,4)
movl %esi, 0xc(%rbx,%rcx,4)
addq $0x4, %rdx
addq $-0x4, %rcx
jmp 0x2be6
addq $0x1c, %rbx
pushq $0x1
popq %rcx
leaq 0x1461(%rip), %rdx      # 0x40a0
leaq 0x188a(%rip), %rsi      # 0x44d0
movl $0x3fc, %edi            # imm = 0x3FC
leaq 0x1c7e(%rip), %r8       # 0x48d0
movl $0xff, %r9d
leaq 0x2071(%rip), %r10      # 0x4cd0
leaq 0x246a(%rip), %r11      # 0x50d0
cmpl %eax, %ecx
jae 0x2d9c
movl -0xc(%rbx), %r15d
movl -0x8(%rbx), %r14d
movl %r15d, %r12d
shrl $0x18, %r12d
movzbl (%rdx,%r12,4), %r12d
movl %r15d, %r13d
shrl $0xe, %r13d
andl %edi, %r13d
movzbl (%r13,%rdx), %r13d
movl (%r8,%r13,4), %ebp
xorl (%rsi,%r12,4), %ebp
movl %r15d, %r12d
shrl $0x8, %r12d
andl %r9d, %r12d
movzbl (%rdx,%r12,4), %r12d
xorl (%r10,%r12,4), %ebp
andl %r9d, %r15d
movzbl (%rdx,%r15,4), %r15d
xorl (%r11,%r15,4), %ebp
movl %ebp, -0xc(%rbx)
movl %r14d, %r15d
shrl $0x18, %r15d
movzbl (%rdx,%r15,4), %r15d
movl %r14d, %r12d
shrl $0xe, %r12d
andl %edi, %r12d
movzbl (%r12,%rdx), %r12d
movl (%r8,%r12,4), %ebp
xorl (%rsi,%r15,4), %ebp
movl %r14d, %r15d
shrl $0x8, %r15d
andl %r9d, %r15d
movzbl (%rdx,%r15,4), %r15d
xorl (%r10,%r15,4), %ebp
andl %r9d, %r14d
movzbl (%rdx,%r14,4), %r14d
xorl (%r11,%r14,4), %ebp
movl %ebp, -0x8(%rbx)
movl -0x4(%rbx), %r14d
movl %r14d, %r15d
shrl $0x18, %r15d
movzbl (%rdx,%r15,4), %r15d
movl %r14d, %r12d
shrl $0xe, %r12d
andl %edi, %r12d
movzbl (%r12,%rdx), %r12d
movl (%r8,%r12,4), %ebp
xorl (%rsi,%r15,4), %ebp
movl %r14d, %r15d
shrl $0x8, %r15d
andl %r9d, %r15d
movzbl (%rdx,%r15,4), %r15d
xorl (%r10,%r15,4), %ebp
andl %r9d, %r14d
movzbl (%rdx,%r14,4), %r14d
xorl (%r11,%r14,4), %ebp
movl %ebp, -0x4(%rbx)
movl (%rbx), %r14d
movl %r14d, %r15d
shrl $0x18, %r15d
movzbl (%rdx,%r15,4), %r15d
movl %r14d, %r12d
shrl $0xe, %r12d
andl %edi, %r12d
movzbl (%r12,%rdx), %r12d
movl (%r8,%r12,4), %ebp
xorl (%rsi,%r15,4), %ebp
movl %r14d, %r15d
shrl $0x8, %r15d
andl %r9d, %r15d
movzbl (%rdx,%r15,4), %r15d
xorl (%r10,%r15,4), %ebp
andl %r9d, %r14d
movzbl (%rdx,%r14,4), %r14d
xorl (%r11,%r14,4), %ebp
movl %ebp, (%rbx)
incl %ecx
addq $0x10, %rbx
jmp 0x2c66
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq