// File: /workspace/github_c_makefile_star2_O0/snow1eo[P]IPsec_IKEv2/crypt/aes128.c
// Function: KeyExpansion
static void KeyExpansion(void)
{
  uint32_t i, j, k;
  uint8_t tempa[4]; // Used for the column/row operations
  
  // The first round key is the key itself.
  for(i = 0; i < Nk; ++i)
  {
    RoundKey[(i * 4) + 0] = Key[(i * 4) + 0];
    RoundKey[(i * 4) + 1] = Key[(i * 4) + 1];
    RoundKey[(i * 4) + 2] = Key[(i * 4) + 2];
    RoundKey[(i * 4) + 3] = Key[(i * 4) + 3];
  }

  // All other round keys are found from the previous round keys.
  for(; (i < (Nb * (Nr + 1))); ++i)
  {
    for(j = 0; j < 4; ++j)
    {
      tempa[j]=RoundKey[(i-1) * 4 + j];
    }
    if (i % Nk == 0)
    {
      // This function rotates the 4 bytes in a word to the left once.
      // [a0,a1,a2,a3] becomes [a1,a2,a3,a0]

      // Function RotWord()
      {
        k = tempa[0];
        tempa[0] = tempa[1];
        tempa[1] = tempa[2];
        tempa[2] = tempa[3];
        tempa[3] = k;
      }

      // SubWord() is a function that takes a four-byte input word and 
      // applies the S-box to each of the four bytes to produce an output word.

      // Function Subword()
      {
        tempa[0] = getSBoxValue(tempa[0]);
        tempa[1] = getSBoxValue(tempa[1]);
        tempa[2] = getSBoxValue(tempa[2]);
        tempa[3] = getSBoxValue(tempa[3]);
      }

      tempa[0] =  tempa[0] ^ Rcon[i/Nk];
    }
    else if (Nk > 6 && i % Nk == 4)
    {
      // Function Subword()
      {
        tempa[0] = getSBoxValue(tempa[0]);
        tempa[1] = getSBoxValue(tempa[1]);
        tempa[2] = getSBoxValue(tempa[2]);
        tempa[3] = getSBoxValue(tempa[3]);
      }
    }
    RoundKey[i * 4 + 0] = RoundKey[(i - Nk) * 4 + 0] ^ tempa[0];
    RoundKey[i * 4 + 1] = RoundKey[(i - Nk) * 4 + 1] ^ tempa[1];
    RoundKey[i * 4 + 2] = RoundKey[(i - Nk) * 4 + 2] ^ tempa[2];
    RoundKey[i * 4 + 3] = RoundKey[(i - Nk) * 4 + 3] ^ tempa[3];
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x4, -0x4(%rbp)
jae 0xb687
movq 0x7098(%rip), %rax      # 0x12668
movl -0x4(%rbp), %ecx
shll $0x2, %ecx
addl $0x0, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movl -0x4(%rbp), %eax
shll $0x2, %eax
addl $0x0, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x708e(%rip), %rax      # 0x12680
movb %dl, (%rax,%rcx)
movq 0x706c(%rip), %rax      # 0x12668
movl -0x4(%rbp), %ecx
shll $0x2, %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movl -0x4(%rbp), %eax
shll $0x2, %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x7062(%rip), %rax      # 0x12680
movb %dl, (%rax,%rcx)
movq 0x7040(%rip), %rax      # 0x12668
movl -0x4(%rbp), %ecx
shll $0x2, %ecx
addl $0x2, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movl -0x4(%rbp), %eax
shll $0x2, %eax
addl $0x2, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x7036(%rip), %rax      # 0x12680
movb %dl, (%rax,%rcx)
movq 0x7014(%rip), %rax      # 0x12668
movl -0x4(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movl -0x4(%rbp), %eax
shll $0x2, %eax
addl $0x3, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x700a(%rip), %rax      # 0x12680
movb %dl, (%rax,%rcx)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xb5bf
jmp 0xb689
cmpl $0x2c, -0x4(%rbp)
jae 0xb83e
movl $0x0, -0x8(%rbp)
cmpl $0x4, -0x8(%rbp)
jae 0xb6cc
movl -0x4(%rbp), %eax
subl $0x1, %eax
shll $0x2, %eax
addl -0x8(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x6fc9(%rip), %rax      # 0x12680
movb (%rax,%rcx), %cl
movl -0x8(%rbp), %eax
movb %cl, -0x10(%rbp,%rax)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0xb69a
movl -0x4(%rbp), %eax
andl $0x3, %eax
cmpl $0x0, %eax
jne 0xb746
movzbl -0x10(%rbp), %eax
movl %eax, -0xc(%rbp)
movb -0xf(%rbp), %al
movb %al, -0x10(%rbp)
movb -0xe(%rbp), %al
movb %al, -0xf(%rbp)
movb -0xd(%rbp), %al
movb %al, -0xe(%rbp)
movl -0xc(%rbp), %eax
movb %al, -0xd(%rbp)
movzbl -0x10(%rbp), %edi
callq 0xbbf0
movb %al, -0x10(%rbp)
movzbl -0xf(%rbp), %edi
callq 0xbbf0
movb %al, -0xf(%rbp)
movzbl -0xe(%rbp), %edi
callq 0xbbf0
movb %al, -0xe(%rbp)
movzbl -0xd(%rbp), %edi
callq 0xbbf0
movb %al, -0xd(%rbp)
movzbl -0x10(%rbp), %eax
movl -0x4(%rbp), %ecx
shrl $0x2, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x3a55(%rip), %rcx      # 0xf190
movzbl (%rcx,%rdx), %ecx
xorl %ecx, %eax
movb %al, -0x10(%rbp)
jmp 0xb748
jmp 0xb748
movl -0x4(%rbp), %eax
subl $0x4, %eax
shll $0x2, %eax
addl $0x0, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x6f21(%rip), %rax      # 0x12680
movzbl (%rax,%rcx), %eax
movzbl -0x10(%rbp), %ecx
xorl %ecx, %eax
movb %al, %dl
movl -0x4(%rbp), %eax
shll $0x2, %eax
addl $0x0, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x6f01(%rip), %rax      # 0x12680
movb %dl, (%rax,%rcx)
movl -0x4(%rbp), %eax
subl $0x4, %eax
shll $0x2, %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x6ee7(%rip), %rax      # 0x12680
movzbl (%rax,%rcx), %eax
movzbl -0xf(%rbp), %ecx
xorl %ecx, %eax
movb %al, %dl
movl -0x4(%rbp), %eax
shll $0x2, %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x6ec7(%rip), %rax      # 0x12680
movb %dl, (%rax,%rcx)
movl -0x4(%rbp), %eax
subl $0x4, %eax
shll $0x2, %eax
addl $0x2, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x6ead(%rip), %rax      # 0x12680
movzbl (%rax,%rcx), %eax
movzbl -0xe(%rbp), %ecx
xorl %ecx, %eax
movb %al, %dl
movl -0x4(%rbp), %eax
shll $0x2, %eax
addl $0x2, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x6e8d(%rip), %rax      # 0x12680
movb %dl, (%rax,%rcx)
movl -0x4(%rbp), %eax
subl $0x4, %eax
shll $0x2, %eax
addl $0x3, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x6e73(%rip), %rax      # 0x12680
movzbl (%rax,%rcx), %eax
movzbl -0xd(%rbp), %ecx
xorl %ecx, %eax
movb %al, %dl
movl -0x4(%rbp), %eax
shll $0x2, %eax
addl $0x3, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x6e53(%rip), %rax      # 0x12680
movb %dl, (%rax,%rcx)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xb689
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)