// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
callq 0x258c
testl %eax, %eax
je 0x2a75
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 0x28a6
cmpl $0x1, %eax
je 0x2a75
addq $0x38, %rbx
movl %eax, %ecx
decl %ecx
leaq 0x56f4(%rip), %rdx      # 0x8010
leaq 0x5f3d(%rip), %rsi      # 0x8860
movl $0x7f8, %edi            # imm = 0x7F8
leaq 0x6731(%rip), %r8       # 0x9060
movl $0xff, %r9d
leaq 0x6f24(%rip), %r10      # 0x9860
leaq 0x771d(%rip), %r11      # 0xa060
movq -0x18(%rbx), %r15
movq %r15, %r14
shrq $0x18, %r14
movzbl (%rdx,%r14,8), %r14d
movl %r15d, %r12d
shrl $0xd, %r12d
andl %edi, %r12d
movzbl (%r12,%rdx), %r12d
movq (%r8,%r12,8), %r12
xorq (%rsi,%r14,8), %r12
movq -0x10(%rbx), %r14
movl %r15d, %r13d
shrl $0x8, %r13d
andl %r9d, %r13d
movzbl (%rdx,%r13,8), %r13d
xorq (%r10,%r13,8), %r12
andl %r9d, %r15d
movzbl (%rdx,%r15,8), %r15d
xorq (%r11,%r15,8), %r12
movq %r12, -0x18(%rbx)
movq %r14, %r15
shrq $0x18, %r15
movzbl (%rdx,%r15,8), %r15d
movl %r14d, %r12d
shrl $0xd, %r12d
andl %edi, %r12d
movzbl (%r12,%rdx), %r12d
movq (%r8,%r12,8), %r12
xorq (%rsi,%r15,8), %r12
movl %r14d, %r15d
shrl $0x8, %r15d
andl %r9d, %r15d
movzbl (%rdx,%r15,8), %r15d
xorq (%r10,%r15,8), %r12
andl %r9d, %r14d
movzbl (%rdx,%r14,8), %r14d
xorq (%r11,%r14,8), %r12
movq %r12, -0x10(%rbx)
movq -0x8(%rbx), %r14
movq %r14, %r15
shrq $0x18, %r15
movzbl (%rdx,%r15,8), %r15d
movl %r14d, %r12d
shrl $0xd, %r12d
andl %edi, %r12d
movzbl (%r12,%rdx), %r12d
movq (%r8,%r12,8), %r12
xorq (%rsi,%r15,8), %r12
movl %r14d, %r15d
shrl $0x8, %r15d
andl %r9d, %r15d
movzbl (%rdx,%r15,8), %r15d
xorq (%r10,%r15,8), %r12
andl %r9d, %r14d
movzbl (%rdx,%r14,8), %r14d
xorq (%r11,%r14,8), %r12
movq %r12, -0x8(%rbx)
movq (%rbx), %r14
movq %r14, %r15
shrq $0x18, %r15
movzbl (%rdx,%r15,8), %r15d
movl %r14d, %r12d
shrl $0xd, %r12d
andl %edi, %r12d
movzbl (%r12,%rdx), %r12d
movq (%r8,%r12,8), %r12
xorq (%rsi,%r15,8), %r12
movl %r14d, %r15d
shrl $0x8, %r15d
andl %r9d, %r15d
movzbl (%rdx,%r15,8), %r15d
xorq (%r10,%r15,8), %r12
andl %r9d, %r14d
movzbl (%rdx,%r14,8), %r14d
xorq (%r11,%r14,8), %r12
movq %r12, (%rbx)
addq $0x20, %rbx
decl %ecx
jne 0x2943
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq