// File: /workspace/github_c_makefile_star2_O3/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 %rbx
movq %rdi, %rbx
callq 0x1080
testl %eax, %eax
je 0x33d2
leal (,%rax,4), %ecx
addq $-0x4, %rcx
xorl %edx, %edx
movl (%rbx,%rdx,4), %esi
movl 0x10(%rbx,%rcx,4), %edi
movl %edi, (%rbx,%rdx,4)
movl %esi, 0x10(%rbx,%rcx,4)
movl 0x4(%rbx,%rdx,4), %esi
movl 0x14(%rbx,%rcx,4), %edi
movl %edi, 0x4(%rbx,%rdx,4)
movl %esi, 0x14(%rbx,%rcx,4)
movl 0x8(%rbx,%rdx,4), %esi
movl 0x18(%rbx,%rcx,4), %edi
movl %edi, 0x8(%rbx,%rdx,4)
movl %esi, 0x18(%rbx,%rcx,4)
movl 0xc(%rbx,%rdx,4), %esi
movl 0x1c(%rbx,%rcx,4), %edi
movl %edi, 0xc(%rbx,%rdx,4)
movl %esi, 0x1c(%rbx,%rcx,4)
addq $0x4, %rdx
leaq -0x4(%rcx), %rsi
cmpq %rcx, %rdx
movq %rsi, %rcx
jl 0x2f56
cmpl $0x1, %eax
je 0x33d2
movl %eax, %edx
decl %edx
leaq 0x7(%rdx), %rcx
andq $-0x8, %rcx
decq %rdx
vpbroadcastq %rdx, %ymm0
vpmovsxbq 0x214d(%rip), %ymm1 # 0x5118
xorl %edx, %edx
vpmovsxbq 0x2146(%rip), %ymm2 # 0x511c
vpmovsxbd 0x2269(%rip), %ymm3 # 0x5248
leaq 0x22da(%rip), %rsi      # 0x52c0
vpbroadcastd 0x2251(%rip), %ymm4 # 0x5240
leaq 0x26fa(%rip), %rdi      # 0x56f0
vmovdqa 0x2182(%rip), %ymm5     # 0x5180
leaq 0x2aeb(%rip), %r8       # 0x5af0
vmovdqa 0x2193(%rip), %ymm6     # 0x51a0
leaq 0x2edc(%rip), %r9       # 0x5ef0
leaq 0x32d5(%rip), %r10      # 0x62f0
vpmovzxbd 0x222c(%rip), %ymm7 # 0x5250
vpmovzxbd 0x222b(%rip), %ymm8 # 0x5258
vpmovzxbd 0x222a(%rip), %ymm9 # 0x5260
vpmovzxbd 0x2229(%rip), %ymm10 # 0x5268
vpbroadcastq %rdx, %ymm11
vpor %ymm1, %ymm11, %ymm12
vpor %ymm2, %ymm11, %ymm11
vpcmpleuq %ymm0, %ymm11, %k0
vpcmpleuq %ymm0, %ymm12, %k1
kshiftlb $0x4, %k1, %k1
korb %k1, %k0, %k1
kmovq %k1, %k2
vpxor %xmm11, %xmm11, %xmm11
vpgatherdd 0x10(%rbx,%ymm3), %ymm11 {%k2}
vpsrld $0x18, %ymm11, %ymm12
vpxor %xmm13, %xmm13, %xmm13
vpxor %xmm14, %xmm14, %xmm14
vpshufb %ymm5, %ymm11, %ymm15
kmovq %k1, %k2
kmovq %k1, %k3
vpshufb %ymm6, %ymm11, %ymm16
kmovq %k1, %k4
vpgatherdd (%rsi,%ymm12,4), %ymm13 {%k2}
vpxor %xmm12, %xmm12, %xmm12
vpgatherdd (%rsi,%ymm15,4), %ymm14 {%k3}
vpand %ymm4, %ymm11, %ymm11
kmovq %k1, %k2
vpgatherdd (%rsi,%ymm16,4), %ymm12 {%k4}
vpxor %xmm15, %xmm15, %xmm15
vpgatherdd (%rsi,%ymm11,4), %ymm15 {%k2}
vpand %ymm4, %ymm13, %ymm11
vpxor %xmm13, %xmm13, %xmm13
vpxord %xmm16, %xmm16, %xmm16
vpand %ymm4, %ymm14, %ymm14
kmovq %k1, %k2
kmovq %k1, %k3
vpand %ymm4, %ymm12, %ymm12
kmovq %k1, %k4
vpgatherdd (%rdi,%ymm11,4), %ymm13 {%k2}
vpxor %xmm11, %xmm11, %xmm11
vpgatherdd (%r8,%ymm14,4), %ymm16 {%k3}
vpand %ymm4, %ymm15, %ymm14
kmovq %k1, %k2
vpgatherdd (%r9,%ymm12,4), %ymm11 {%k4}
vpxor %xmm12, %xmm12, %xmm12
vpgatherdd (%r10,%ymm14,4), %ymm12 {%k2}
vpxord %ymm13, %ymm16, %ymm13
vpternlogd $0x96, %ymm11, %ymm13, %ymm12
kmovq %k1, %k2
kmovq %k1, %k3
vpscatterdd %ymm12, (%rbx,%ymm7) {%k2}
vpxor %xmm11, %xmm11, %xmm11
vpgatherdd (%rbx,%ymm8), %ymm11 {%k3}
vpsrld $0x18, %ymm11, %ymm12
vpxor %xmm13, %xmm13, %xmm13
vpxor %xmm14, %xmm14, %xmm14
vpshufb %ymm5, %ymm11, %ymm15
kmovq %k1, %k2
kmovq %k1, %k3
vpshufb %ymm6, %ymm11, %ymm16
kmovq %k1, %k4
vpgatherdd (%rsi,%ymm12,4), %ymm13 {%k2}
vpxor %xmm12, %xmm12, %xmm12
vpgatherdd (%rsi,%ymm15,4), %ymm14 {%k3}
vpand %ymm4, %ymm11, %ymm11
kmovq %k1, %k2
vpgatherdd (%rsi,%ymm16,4), %ymm12 {%k4}
vpxor %xmm15, %xmm15, %xmm15
vpgatherdd (%rsi,%ymm11,4), %ymm15 {%k2}
vpand %ymm4, %ymm13, %ymm11
vpxor %xmm13, %xmm13, %xmm13
vpxord %xmm16, %xmm16, %xmm16
vpand %ymm4, %ymm14, %ymm14
kmovq %k1, %k2
kmovq %k1, %k3
vpand %ymm4, %ymm12, %ymm12
kmovq %k1, %k4
vpgatherdd (%rdi,%ymm11,4), %ymm13 {%k2}
vpxor %xmm11, %xmm11, %xmm11
vpgatherdd (%r8,%ymm14,4), %ymm16 {%k3}
vpand %ymm4, %ymm15, %ymm14
kmovq %k1, %k2
vpgatherdd (%r9,%ymm12,4), %ymm11 {%k4}
vpxor %xmm12, %xmm12, %xmm12
vpgatherdd (%r10,%ymm14,4), %ymm12 {%k2}
vpxord %ymm13, %ymm16, %ymm13
vpternlogd $0x96, %ymm11, %ymm13, %ymm12
kmovq %k1, %k2
kmovq %k1, %k3
vpscatterdd %ymm12, (%rbx,%ymm8) {%k2}
vpxor %xmm11, %xmm11, %xmm11
vpgatherdd (%rbx,%ymm9), %ymm11 {%k3}
vpsrld $0x18, %ymm11, %ymm12
vpxor %xmm13, %xmm13, %xmm13
vpxor %xmm14, %xmm14, %xmm14
vpshufb %ymm5, %ymm11, %ymm15
kmovq %k1, %k2
kmovq %k1, %k3
vpshufb %ymm6, %ymm11, %ymm16
kmovq %k1, %k4
vpgatherdd (%rsi,%ymm12,4), %ymm13 {%k2}
vpxor %xmm12, %xmm12, %xmm12
vpgatherdd (%rsi,%ymm15,4), %ymm14 {%k3}
vpand %ymm4, %ymm11, %ymm11
kmovq %k1, %k2
vpgatherdd (%rsi,%ymm16,4), %ymm12 {%k4}
vpxor %xmm15, %xmm15, %xmm15
vpgatherdd (%rsi,%ymm11,4), %ymm15 {%k2}
vpand %ymm4, %ymm13, %ymm11
vpxor %xmm13, %xmm13, %xmm13
vpxord %xmm16, %xmm16, %xmm16
vpand %ymm4, %ymm14, %ymm14
kmovq %k1, %k2
kmovq %k1, %k3
vpand %ymm4, %ymm12, %ymm12
kmovq %k1, %k4
vpgatherdd (%rdi,%ymm11,4), %ymm13 {%k2}
vpxor %xmm11, %xmm11, %xmm11
vpgatherdd (%r8,%ymm14,4), %ymm16 {%k3}
vpand %ymm4, %ymm15, %ymm14
kmovq %k1, %k2
vpgatherdd (%r9,%ymm12,4), %ymm11 {%k4}
vpxor %xmm12, %xmm12, %xmm12
vpgatherdd (%r10,%ymm14,4), %ymm12 {%k2}
vpxord %ymm13, %ymm16, %ymm13
vpternlogd $0x96, %ymm11, %ymm13, %ymm12
kmovq %k1, %k2
kmovq %k1, %k3
vpscatterdd %ymm12, (%rbx,%ymm9) {%k2}
vpxor %xmm11, %xmm11, %xmm11
vpgatherdd (%rbx,%ymm10), %ymm11 {%k3}
vpsrld $0x18, %ymm11, %ymm12
vpxor %xmm13, %xmm13, %xmm13
vpxor %xmm14, %xmm14, %xmm14
vpshufb %ymm5, %ymm11, %ymm15
kmovq %k1, %k2
kmovq %k1, %k3
vpshufb %ymm6, %ymm11, %ymm16
kmovq %k1, %k4
vpgatherdd (%rsi,%ymm12,4), %ymm13 {%k2}
vpxor %xmm12, %xmm12, %xmm12
vpgatherdd (%rsi,%ymm15,4), %ymm14 {%k3}
vpand %ymm4, %ymm11, %ymm11
kmovq %k1, %k2
vpgatherdd (%rsi,%ymm16,4), %ymm12 {%k4}
vpxor %xmm15, %xmm15, %xmm15
vpgatherdd (%rsi,%ymm11,4), %ymm15 {%k2}
vpand %ymm4, %ymm13, %ymm11
vpxor %xmm13, %xmm13, %xmm13
vpxord %xmm16, %xmm16, %xmm16
vpand %ymm4, %ymm14, %ymm14
kmovq %k1, %k2
kmovq %k1, %k3
vpand %ymm4, %ymm12, %ymm12
kmovq %k1, %k4
vpgatherdd (%rdi,%ymm11,4), %ymm13 {%k2}
vpxor %xmm11, %xmm11, %xmm11
vpgatherdd (%r8,%ymm14,4), %ymm16 {%k3}
vpand %ymm4, %ymm15, %ymm14
kmovq %k1, %k2
vpgatherdd (%r9,%ymm12,4), %ymm11 {%k4}
vpxor %xmm12, %xmm12, %xmm12
vpgatherdd (%r10,%ymm14,4), %ymm12 {%k2}
vpxord %ymm13, %ymm16, %ymm13
vpternlogd $0x96, %ymm11, %ymm13, %ymm12
vpscatterdd %ymm12, (%rbx,%ymm10) {%k1}
addq $0x8, %rdx
subq $-0x80, %rbx
cmpq %rdx, %rcx
jne 0x303f
popq %rbx
vzeroupper
retq