// File: /workspace/github_c_makefile_star2_O1/MartinDrab[P]netpipe/aes.c
// Function: rijndaelSetupDecrypt
int rijndaelSetupDecrypt(u32 *rk, const u8 *key, int keybits)
{
  int nrounds, i, j;
  u32 temp;

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x257c
testl %eax, %eax
je 0x28f5
leal (,%rax,4), %ecx
addq $-0x4, %rcx
xorl %edx, %edx
movq (%rbx,%rdx,8), %rsi
movq 0x20(%rbx,%rcx,8), %rdi
movq %rdi, (%rbx,%rdx,8)
movq %rsi, 0x20(%rbx,%rcx,8)
movq 0x8(%rbx,%rdx,8), %rsi
movq 0x28(%rbx,%rcx,8), %rdi
movq %rdi, 0x8(%rbx,%rdx,8)
movq %rsi, 0x28(%rbx,%rcx,8)
movq 0x10(%rbx,%rdx,8), %rsi
movq 0x30(%rbx,%rcx,8), %rdi
movq %rdi, 0x10(%rbx,%rdx,8)
movq %rsi, 0x30(%rbx,%rcx,8)
movq 0x18(%rbx,%rdx,8), %rsi
movq 0x38(%rbx,%rcx,8), %rdi
movq %rdi, 0x18(%rbx,%rdx,8)
movq %rsi, 0x38(%rbx,%rcx,8)
addq $0x4, %rdx
leaq -0x4(%rcx), %rsi
cmpq %rcx, %rdx
movq %rsi, %rcx
jl 0x2897
cmpl $0x2, %eax
jb 0x2a77
movl %eax, %ecx
shlq $0x5, %rcx
addq $-0x20, %rcx
xorl %edx, %edx
leaq 0x56ff(%rip), %rsi      # 0x8010
leaq 0x5f48(%rip), %rdi      # 0x8860
movl $0x7f8, %r8d            # imm = 0x7F8
leaq 0x673b(%rip), %r9       # 0x9060
movl $0xff, %r10d
leaq 0x6f2e(%rip), %r11      # 0x9860
leaq 0x7727(%rip), %r14      # 0xa060
movq 0x20(%rbx,%rdx), %r12
movq %r12, %r15
shrq $0x18, %r15
movzbl (%rsi,%r15,8), %r15d
movl %r12d, %r13d
shrl $0xd, %r13d
andl %r8d, %r13d
movzbl (%r13,%rsi), %r13d
movq (%r9,%r13,8), %r13
xorq (%rdi,%r15,8), %r13
movq 0x28(%rbx,%rdx), %r15
movl %r12d, %ebp
shrl $0x8, %ebp
andl %r10d, %ebp
movzbl (%rsi,%rbp,8), %ebp
xorq (%r11,%rbp,8), %r13
andl %r10d, %r12d
movzbl (%rsi,%r12,8), %r12d
xorq (%r14,%r12,8), %r13
movq %r13, 0x20(%rbx,%rdx)
movq %r15, %r12
shrq $0x18, %r12
movzbl (%rsi,%r12,8), %r12d
movl %r15d, %r13d
shrl $0xd, %r13d
andl %r8d, %r13d
movzbl (%r13,%rsi), %r13d
movq (%r9,%r13,8), %r13
xorq (%rdi,%r12,8), %r13
movl %r15d, %r12d
shrl $0x8, %r12d
andl %r10d, %r12d
movzbl (%rsi,%r12,8), %r12d
xorq (%r11,%r12,8), %r13
andl %r10d, %r15d
movzbl (%rsi,%r15,8), %r15d
xorq (%r14,%r15,8), %r13
movq %r13, 0x28(%rbx,%rdx)
movq 0x30(%rbx,%rdx), %r15
movq %r15, %r12
shrq $0x18, %r12
movzbl (%rsi,%r12,8), %r12d
movl %r15d, %r13d
shrl $0xd, %r13d
andl %r8d, %r13d
movzbl (%r13,%rsi), %r13d
movq (%r9,%r13,8), %r13
xorq (%rdi,%r12,8), %r13
movl %r15d, %r12d
shrl $0x8, %r12d
andl %r10d, %r12d
movzbl (%rsi,%r12,8), %r12d
xorq (%r11,%r12,8), %r13
andl %r10d, %r15d
movzbl (%rsi,%r15,8), %r15d
xorq (%r14,%r15,8), %r13
movq %r13, 0x30(%rbx,%rdx)
movq 0x38(%rbx,%rdx), %r15
movq %r15, %r12
shrq $0x18, %r12
movzbl (%rsi,%r12,8), %r12d
movl %r15d, %r13d
shrl $0xd, %r13d
andl %r8d, %r13d
movzbl (%r13,%rsi), %r13d
movq (%r9,%r13,8), %r13
xorq (%rdi,%r12,8), %r13
movl %r15d, %r12d
shrl $0x8, %r12d
andl %r10d, %r12d
movzbl (%rsi,%r12,8), %r12d
xorq (%r11,%r12,8), %r13
andl %r10d, %r15d
movzbl (%rsi,%r15,8), %r15d
xorq (%r14,%r15,8), %r13
movq %r13, 0x38(%rbx,%rdx)
addq $0x20, %rdx
cmpl %edx, %ecx
jne 0x2939
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq