// File: /workspace/github_c_makefile_star2_O1/jogolden[P]ps4flashtool/aes.c
// Function: InvCipher
static void InvCipher(state_t* state,uint8_t* RoundKey)
{
  uint8_t round = 0;

  // Add the First round key to the state before starting the rounds.
  AddRoundKey(Nr, state, RoundKey); 

  // There will be Nr rounds.
  // The first Nr-1 rounds are identical.
  // These Nr-1 rounds are executed in the loop below.
  for (round = (Nr - 1); round > 0; --round)
  {
    InvShiftRows(state);
    InvSubBytes(state);
    AddRoundKey(round, state, RoundKey);
    InvMixColumns(state);
  }
  
  // The last round is given below.
  // The MixColumns function is not here in the last round.
  InvShiftRows(state);
  InvSubBytes(state);
  AddRoundKey(0, state, RoundKey);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0xa0(%rsi), %rax
xorl %ecx, %ecx
movq %rdi, %rdx
xorl %r8d, %r8d
movb (%rax,%r8), %dil
xorb %dil, (%rdx,%r8)
incq %r8
cmpq $0x4, %r8
jne 0x2565
incq %rcx
addq $0x4, %rdx
addq $0x4, %rax
cmpq $0x4, %rcx
jne 0x2562
movq %rsi, 0x8(%rsp)
leaq 0x90(%rsi), %r15
movl $0x9, %eax
leaq 0x5b81(%rip), %r14      # 0x8120
movq %rbx, (%rsp)
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x2920
movq %rbx, %rax
xorl %ecx, %ecx
xorl %edx, %edx
movzbl (%rax,%rdx,4), %esi
movb (%rsi,%r14), %sil
movb %sil, (%rax,%rdx,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x25b7
incq %rcx
incq %rax
cmpq $0x4, %rcx
jne 0x25b5
movq %r15, %rax
movq %rbx, %rcx
xorl %edx, %edx
xorl %esi, %esi
movb (%rax,%rsi), %dil
xorb %dil, (%rcx,%rsi)
incq %rsi
cmpq $0x4, %rsi
jne 0x25e2
incq %rdx
addq $0x4, %rcx
addq $0x4, %rax
cmpq $0x4, %rdx
jne 0x25e0
movq %r15, 0x18(%rsp)
movl $0x3, %ecx
movb -0x3(%rbx,%rcx), %r10b
movb -0x2(%rbx,%rcx), %al
movb -0x1(%rbx,%rcx), %r8b
movb (%rbx,%rcx), %dil
leal (%r10,%r10), %edx
leal (%rax,%rax), %esi
movl %eax, %r9d
movl %r8d, %r11d
xorb %al, %r11b
movl %r8d, %ebp
xorb %r10b, %bpl
xorb %r10b, %al
movq %rax, 0x20(%rsp)
sarb $0x7, %r10b
andb $0x1b, %r10b
xorb %dl, %r10b
leal (%r10,%r10), %r13d
sarb $0x7, %dl
andb $0x1b, %dl
xorb %r13b, %dl
leal (%rdx,%rdx), %ebx
sarb $0x7, %r13b
andb $0x1b, %r13b
xorb %bl, %r13b
sarb $0x7, %r9b
andb $0x1b, %r9b
xorb %sil, %r9b
leal (%r9,%r9), %r14d
sarb $0x7, %sil
andb $0x1b, %sil
xorb %r14b, %sil
leal (%rsi,%rsi), %ebx
sarb $0x7, %r14b
andb $0x1b, %r14b
xorb %bl, %r14b
leal (%r8,%r8), %r12d
xorb %dil, %r11b
xorb %r10b, %r11b
xorb %r8b, %r10b
sarb $0x7, %r8b
andb $0x1b, %r8b
xorb %r12b, %r8b
leal (%r8,%r8), %ebx
sarb $0x7, %r12b
andb $0x1b, %r12b
xorb %bl, %r12b
leal (%r12,%r12), %r15d
sarb $0x7, %bl
andb $0x1b, %bl
xorb %r15b, %bl
xorb %r14b, %bl
leal (%rdi,%rdi), %r14d
xorb %dil, %bpl
xorb %r9b, %bpl
xorb %r8b, %bpl
xorb %dil, %r8b
movl %edi, %r15d
sarb $0x7, %r15b
andb $0x1b, %r15b
xorb %r14b, %r15b
leal (%r15,%r15), %edi
sarb $0x7, %r14b
andb $0x1b, %r14b
xorb %dil, %r14b
leal (%r14,%r14), %eax
sarb $0x7, %dil
andb $0x1b, %dil
xorb %al, %dil
xorb %r9b, %r11b
movq 0x20(%rsp), %rax
xorb %r15b, %al
xorb %dl, %r11b
xorb %al, %r8b
movq %rax, %r9
xorb %dl, %r8b
xorb %r12b, %r11b
xorb %r12b, %r8b
xorb %r13b, %r11b
xorb %bl, %r11b
xorb %dil, %r11b
movq (%rsp), %rax
movb %r11b, -0x3(%rax,%rcx)
xorb %sil, %bpl
xorb %r14b, %bpl
xorb %r13b, %bpl
xorb %bl, %bpl
xorb %dil, %bpl
movq (%rsp), %rax
movb %bpl, -0x2(%rax,%rcx)
xorb %r13b, %r8b
xorb %bl, %r8b
xorb %dil, %r8b
movq (%rsp), %rax
movb %r8b, -0x1(%rax,%rcx)
xorb %r9b, %r10b
xorb %sil, %r10b
xorb %r14b, %r10b
xorb %r13b, %r10b
xorb %bl, %r10b
movq (%rsp), %rbx
xorb %dil, %r10b
movb %r10b, (%rbx,%rcx)
addq $0x4, %rcx
cmpq $0x13, %rcx
jne 0x260e
movq 0x18(%rsp), %r15
addq $-0x10, %r15
movq 0x10(%rsp), %rax
decq %rax
leaq 0x5988(%rip), %r14      # 0x8120
jne 0x25a3
movq %rbx, %rdi
callq 0x2920
xorl %eax, %eax
movq %rbx, %rcx
xorl %edx, %edx
movzbl (%rcx,%rdx,4), %esi
movb (%rsi,%r14), %sil
movb %sil, (%rcx,%rdx,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x27ad
incq %rax
incq %rcx
cmpq $0x4, %rax
jne 0x27ab
xorl %eax, %eax
movq 0x8(%rsp), %rsi
xorl %ecx, %ecx
movb (%rsi,%rcx), %dl
xorb %dl, (%rbx,%rcx)
incq %rcx
cmpq $0x4, %rcx
jne 0x27d7
incq %rax
addq $0x4, %rbx
addq $0x4, %rsi
cmpq $0x4, %rax
jne 0x27d5
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq