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

  // Add the First round key to the state before starting the rounds.
  AddRoundKey(0, 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 = 1; round < Nr; ++round)
  {
    SubBytes(state);
    ShiftRows(state);
    MixColumns(state);
    AddRoundKey(round, state, RoundKey);
  }
  
  // The last round is given below.
  // The MixColumns function is not here in the last round.
  SubBytes(state);
  ShiftRows(state);
  AddRoundKey(Nr, state, RoundKey);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
xorl %eax, %eax
movq %rsi, %rcx
movq %rdi, %rdx
xorl %esi, %esi
movb (%rcx,%rsi), %dil
xorb %dil, (%rdx,%rsi)
incq %rsi
cmpq $0x4, %rsi
jne 0x239f
incq %rax
addq $0x4, %rdx
addq $0x4, %rcx
cmpq $0x4, %rax
jne 0x239d
leaq 0x10(%rbx), %r12
movl $0x1, %r13d
leaq 0x5c5e(%rip), %r15      # 0x8030
movq %r14, %rax
xorl %ecx, %ecx
xorl %edx, %edx
movzbl (%rax,%rdx,4), %esi
movb (%rsi,%r15), %sil
movb %sil, (%rax,%rdx,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x23d9
incq %rcx
incq %rax
cmpq $0x4, %rcx
jne 0x23d7
movq %r14, %rdi
callq 0x2b28
movzbl (%r14), %eax
movzbl 0x4(%r14), %ecx
movzbl 0x8(%r14), %edx
shll $0x8, %ecx
orl %eax, %ecx
shll $0x10, %edx
orl %ecx, %edx
movzbl 0xc(%r14), %eax
shll $0x18, %eax
orl %edx, %eax
movd %eax, %xmm0
movzbl 0x1(%r14), %eax
movzbl 0x5(%r14), %ecx
movzbl 0x9(%r14), %edx
shll $0x8, %ecx
orl %eax, %ecx
shll $0x10, %edx
orl %ecx, %edx
movzbl 0xd(%r14), %eax
shll $0x18, %eax
orl %edx, %eax
movd %eax, %xmm2
movzbl 0x2(%r14), %eax
movzbl 0x6(%r14), %ecx
movzbl 0xa(%r14), %edx
shll $0x8, %ecx
orl %eax, %ecx
shll $0x10, %edx
orl %ecx, %edx
movzbl 0xe(%r14), %eax
shll $0x18, %eax
orl %edx, %eax
movd %eax, %xmm5
movzbl 0x3(%r14), %eax
movzbl 0x7(%r14), %ecx
movzbl 0xb(%r14), %edx
shll $0x8, %ecx
orl %eax, %ecx
shll $0x10, %edx
orl %ecx, %edx
movzbl 0xf(%r14), %eax
shll $0x18, %eax
orl %edx, %eax
movd %eax, %xmm4
movdqa %xmm4, %xmm1
pxor %xmm5, %xmm1
movdqa %xmm1, %xmm3
pxor %xmm6, %xmm6
pcmpgtb %xmm1, %xmm6
paddb %xmm1, %xmm1
pxor %xmm5, %xmm1
pxor %xmm2, %xmm5
pxor %xmm7, %xmm7
pcmpgtb %xmm5, %xmm7
paddb %xmm5, %xmm5
pxor %xmm2, %xmm5
pxor %xmm0, %xmm2
pxor %xmm2, %xmm3
pxor %xmm8, %xmm8
pcmpgtb %xmm2, %xmm8
paddb %xmm2, %xmm2
movdqa 0x5b24(%rip), %xmm9     # 0x8010
pand %xmm9, %xmm8
pxor %xmm0, %xmm2
pxor %xmm8, %xmm2
pxor %xmm3, %xmm2
pand %xmm9, %xmm7
pxor %xmm7, %xmm5
pxor %xmm3, %xmm5
punpckldq %xmm5, %xmm2    # xmm2 = xmm2[0],xmm5[0],xmm2[1],xmm5[1]
pand %xmm9, %xmm6
pxor %xmm6, %xmm1
pxor %xmm3, %xmm1
pxor %xmm4, %xmm0
pxor %xmm5, %xmm5
pcmpgtb %xmm0, %xmm5
paddb %xmm0, %xmm0
pand %xmm9, %xmm5
pxor %xmm4, %xmm0
pxor %xmm5, %xmm0
pxor %xmm3, %xmm0
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
pxor %xmm3, %xmm3
punpcklbw %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1],xmm1[2],xmm3[2],xmm1[3],xmm3[3],xmm1[4],xmm3[4],xmm1[5],xmm3[5],xmm1[6],xmm3[6],xmm1[7],xmm3[7]
pshufd $0xd7, %xmm1, %xmm0     # xmm0 = xmm1[3,1,1,3]
pshuflw $0x24, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,0,4,5,6,7]
pshufhw $0xd4, %xmm0, %xmm0     # xmm0 = xmm0[0,1,2,3,4,5,5,7]
pshufd $0x28, %xmm1, %xmm1     # xmm1 = xmm1[0,2,2,0]
pshuflw $0x84, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,2,4,5,6,7]
pshufhw $0x74, %xmm1, %xmm1     # xmm1 = xmm1[0,1,2,3,4,5,7,5]
packuswb %xmm0, %xmm1
movdqa 0x5aad(%rip), %xmm4     # 0x8020
movdqa %xmm4, %xmm0
pandn %xmm1, %xmm0
punpcklbw %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1],xmm2[2],xmm3[2],xmm2[3],xmm3[3],xmm2[4],xmm3[4],xmm2[5],xmm3[5],xmm2[6],xmm3[6],xmm2[7],xmm3[7]
pshufd $0xd7, %xmm2, %xmm1     # xmm1 = xmm2[3,1,1,3]
pshuflw $0xe2, %xmm1, %xmm1     # xmm1 = xmm1[2,0,2,3,4,5,6,7]
pshufhw $0xed, %xmm1, %xmm1     # xmm1 = xmm1[0,1,2,3,5,7,6,7]
pshufd $0x28, %xmm2, %xmm2     # xmm2 = xmm2[0,2,2,0]
pshuflw $0xe8, %xmm2, %xmm2     # xmm2 = xmm2[0,2,2,3,4,5,6,7]
pshufhw $0xe7, %xmm2, %xmm2     # xmm2 = xmm2[0,1,2,3,7,5,6,7]
packuswb %xmm1, %xmm2
pand %xmm4, %xmm2
por %xmm0, %xmm2
movdqu %xmm2, (%r14)
movq %r12, %rax
movq %r14, %rcx
xorl %edx, %edx
xorl %esi, %esi
movb (%rax,%rsi), %dil
xorb %dil, (%rcx,%rsi)
incq %rsi
cmpq $0x4, %rsi
jne 0x25b8
incq %rdx
addq $0x4, %rcx
addq $0x4, %rax
cmpq $0x4, %rdx
jne 0x25b6
incq %r13
addq $0x10, %r12
cmpq $0xa, %r13
jne 0x23d2
xorl %eax, %eax
movq %r14, %rcx
xorl %edx, %edx
movzbl (%rcx,%rdx,4), %esi
movb (%rsi,%r15), %sil
movb %sil, (%rcx,%rdx,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x25f2
incq %rax
incq %rcx
cmpq $0x4, %rax
jne 0x25f0
movq %r14, %rdi
callq 0x2b28
addq $0xa0, %rbx
xorl %eax, %eax
xorl %ecx, %ecx
movb (%rbx,%rcx), %dl
xorb %dl, (%r14,%rcx)
incq %rcx
cmpq $0x4, %rcx
jne 0x2626
incq %rax
addq $0x4, %r14
addq $0x4, %rbx
cmpq $0x4, %rax
jne 0x2624
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq