// File: /workspace/github_cpp_makefile_star2_O1/twekkel[P]mzpq/libzpaq.cpp
// Function: libzpaq::AES_CTR::encrypt(unsigned int, unsigned int, unsigned int, unsigned int, unsigned char*)
void AES_CTR::encrypt(U32 s0, U32 s1, U32 s2, U32 s3, unsigned char* ct) {
  int r = Nr >> 1;
  U32 *rk = &ek[0];
  U32 t0=0, t1=0, t2=0, t3=0;
  s0 ^= rk[0];
  s1 ^= rk[1];
  s2 ^= rk[2];
  s3 ^= rk[3];
  for (;;) {
    t0 =
      Te0[byte(s0, 3)] ^
      Te1[byte(s1, 2)] ^
      Te2[byte(s2, 1)] ^
      Te3[byte(s3, 0)] ^
      rk[4];
    t1 =
      Te0[byte(s1, 3)] ^
      Te1[byte(s2, 2)] ^
      Te2[byte(s3, 1)] ^
      Te3[byte(s0, 0)] ^
      rk[5];
    t2 =
      Te0[byte(s2, 3)] ^
      Te1[byte(s3, 2)] ^
      Te2[byte(s0, 1)] ^
      Te3[byte(s1, 0)] ^
      rk[6];
    t3 =
      Te0[byte(s3, 3)] ^
      Te1[byte(s0, 2)] ^
      Te2[byte(s1, 1)] ^
      Te3[byte(s2, 0)] ^
      rk[7];

    rk += 8;
    if (--r == 0) {
      break;
    }

    s0 =
      Te0[byte(t0, 3)] ^
      Te1[byte(t1, 2)] ^
      Te2[byte(t2, 1)] ^
      Te3[byte(t3, 0)] ^
      rk[0];
    s1 =
      Te0[byte(t1, 3)] ^
      Te1[byte(t2, 2)] ^
      Te2[byte(t3, 1)] ^
      Te3[byte(t0, 0)] ^
      rk[1];
    s2 =
      Te0[byte(t2, 3)] ^
      Te1[byte(t3, 2)] ^
      Te2[byte(t0, 1)] ^
      Te3[byte(t1, 0)] ^
      rk[2];
    s3 =
      Te0[byte(t3, 3)] ^
      Te1[byte(t0, 2)] ^
      Te2[byte(t1, 1)] ^
      Te3[byte(t2, 0)] ^
      rk[3];
  }

  // apply last round and map cipher state to byte array block:
  s0 =
    (Te4_3[byte(t0, 3)]) ^
    (Te4_2[byte(t1, 2)]) ^
    (Te4_1[byte(t2, 1)]) ^
    (Te4_0[byte(t3, 0)]) ^
    rk[0];
  STORE32H(s0, ct);
  s1 =
    (Te4_3[byte(t1, 3)]) ^
    (Te4_2[byte(t2, 2)]) ^
    (Te4_1[byte(t3, 1)]) ^
    (Te4_0[byte(t0, 0)]) ^
    rk[1];
  STORE32H(s1, ct+4);
  s2 =
    (Te4_3[byte(t2, 3)]) ^
    (Te4_2[byte(t3, 2)]) ^
    (Te4_1[byte(t0, 1)]) ^
    (Te4_0[byte(t1, 0)]) ^
    rk[2];
  STORE32H(s2, ct+8);
  s3 =
    (Te4_3[byte(t3, 3)]) ^
    (Te4_2[byte(t0, 2)]) ^
    (Te4_1[byte(t1, 1)]) ^
    (Te4_0[byte(t2, 0)]) ^ 
    rk[3];
  STORE32H(s3, ct+12);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl 0x14f0(%rdi), %ebp
sarl %ebp
xorl 0x1400(%rdi), %esi
xorl 0x1404(%rdi), %edx
xorl 0x1408(%rdi), %ecx
xorl 0x140c(%rdi), %r8d
decl %ebp
leaq 0x142c(%rdi), %rax
movl $0x3fc, %r14d           # imm = 0x3FC
movl $0xff, %r15d
movl %esi, %r11d
shrl $0x18, %r11d
movl %edx, %r10d
shrl $0xe, %r10d
andl %r14d, %r10d
movl 0x400(%rdi,%r10), %r10d
xorl (%rdi,%r11,4), %r10d
movl %ecx, %r11d
shrl $0x8, %r11d
andl %r15d, %r11d
xorl 0x800(%rdi,%r11,4), %r10d
movl %r8d, %r11d
andl %r15d, %r11d
xorl 0xc00(%rdi,%r11,4), %r10d
xorl -0x1c(%rax), %r10d
movl %edx, %ebx
shrl $0x18, %ebx
movl %ecx, %r11d
shrl $0xe, %r11d
andl %r14d, %r11d
movl 0x400(%rdi,%r11), %r11d
xorl (%rdi,%rbx,4), %r11d
movl %r8d, %ebx
shrl $0x8, %ebx
andl %r15d, %ebx
xorl 0x800(%rdi,%rbx,4), %r11d
movl %esi, %ebx
andl %r15d, %ebx
xorl 0xc00(%rdi,%rbx,4), %r11d
xorl -0x18(%rax), %r11d
movl %ecx, %r12d
shrl $0x18, %r12d
movl %r8d, %ebx
shrl $0xe, %ebx
andl %r14d, %ebx
movl 0x400(%rdi,%rbx), %ebx
xorl (%rdi,%r12,4), %ebx
movl %esi, %r12d
shrl $0x8, %r12d
andl %r15d, %r12d
xorl 0x800(%rdi,%r12,4), %ebx
movl %edx, %r12d
andl %r15d, %r12d
xorl 0xc00(%rdi,%r12,4), %ebx
xorl -0x14(%rax), %ebx
shrl $0x18, %r8d
shrl $0xe, %esi
andl %r14d, %esi
movl 0x400(%rdi,%rsi), %r12d
xorl (%rdi,%r8,4), %r12d
shrl $0x8, %edx
andl %r15d, %edx
xorl 0x800(%rdi,%rdx,4), %r12d
andl %r15d, %ecx
xorl 0xc00(%rdi,%rcx,4), %r12d
xorl -0x10(%rax), %r12d
movl %r10d, %ecx
shrl $0x18, %ecx
subl $0x1, %ebp
jb 0x9019
movl %r11d, %edx
shrl $0xe, %edx
andl %r14d, %edx
movl 0x400(%rdi,%rdx), %esi
xorl (%rdi,%rcx,4), %esi
movl %ebx, %ecx
shrl $0x8, %ecx
andl %r15d, %ecx
xorl 0x800(%rdi,%rcx,4), %esi
movl %r12d, %ecx
andl %r15d, %ecx
xorl 0xc00(%rdi,%rcx,4), %esi
xorl -0xc(%rax), %esi
movl %r11d, %ecx
shrl $0x18, %ecx
movl %ebx, %edx
shrl $0xe, %edx
andl %r14d, %edx
movl 0x400(%rdi,%rdx), %edx
xorl (%rdi,%rcx,4), %edx
movl %r12d, %ecx
shrl $0x8, %ecx
andl %r15d, %ecx
xorl 0x800(%rdi,%rcx,4), %edx
movl %r10d, %ecx
andl %r15d, %ecx
xorl 0xc00(%rdi,%rcx,4), %edx
xorl -0x8(%rax), %edx
movl %ebx, %r8d
shrl $0x18, %r8d
movl %r12d, %ecx
shrl $0xe, %ecx
andl %r14d, %ecx
movl 0x400(%rdi,%rcx), %ecx
xorl (%rdi,%r8,4), %ecx
movl %r10d, %r8d
shrl $0x8, %r8d
andl %r15d, %r8d
xorl 0x800(%rdi,%r8,4), %ecx
movl %r11d, %r8d
andl %r15d, %r8d
xorl 0xc00(%rdi,%r8,4), %ecx
xorl -0x4(%rax), %ecx
shrl $0x18, %r12d
shrl $0xe, %r10d
andl %r14d, %r10d
movl 0x400(%rdi,%r10), %r8d
xorl (%rdi,%r12,4), %r8d
shrl $0x8, %r11d
andl %r15d, %r11d
xorl 0x800(%rdi,%r11,4), %r8d
andl %r15d, %ebx
xorl 0xc00(%rdi,%rbx,4), %r8d
xorl (%rax), %r8d
addq $0x20, %rax
jmp 0x8e36
movzbl 0x1003(%rdi,%rcx,4), %ecx
shll $0x18, %ecx
movl %r11d, %esi
shrl $0xe, %esi
movl $0x3fc, %edx            # imm = 0x3FC
andl %edx, %esi
movzbl 0x1002(%rdi,%rsi), %esi
shll $0x10, %esi
orl %ecx, %esi
movl %ebx, %r8d
shrl $0x8, %r8d
movl $0xff, %ecx
andl %ecx, %r8d
movzbl 0x1001(%rdi,%r8,4), %r8d
shll $0x8, %r8d
orl %esi, %r8d
movl %r12d, %esi
andl %ecx, %esi
movzbl 0x1000(%rdi,%rsi,4), %esi
orl %r8d, %esi
xorl -0xc(%rax), %esi
bswapl %esi
movl %esi, (%r9)
movl %r11d, %esi
shrl $0x18, %esi
movzbl 0x1003(%rdi,%rsi,4), %esi
shll $0x18, %esi
movl %ebx, %r8d
shrl $0xe, %r8d
andl %edx, %r8d
movzbl 0x1002(%rdi,%r8), %r8d
shll $0x10, %r8d
orl %esi, %r8d
movl %r12d, %esi
shrl $0x8, %esi
andl %ecx, %esi
movzbl 0x1001(%rdi,%rsi,4), %esi
shll $0x8, %esi
orl %r8d, %esi
movl %r10d, %r8d
andl %ecx, %r8d
movzbl 0x1000(%rdi,%r8,4), %r8d
orl %esi, %r8d
xorl -0x8(%rax), %r8d
bswapl %r8d
movl %r8d, 0x4(%r9)
movl %ebx, %esi
shrl $0x18, %esi
movzbl 0x1003(%rdi,%rsi,4), %esi
shll $0x18, %esi
movl %r12d, %r8d
shrl $0xe, %r8d
andl %edx, %r8d
movzbl 0x1002(%rdi,%r8), %r8d
shll $0x10, %r8d
orl %esi, %r8d
movl %r10d, %esi
shrl $0x8, %esi
andl %ecx, %esi
movzbl 0x1001(%rdi,%rsi,4), %esi
shll $0x8, %esi
orl %r8d, %esi
movl %r11d, %r8d
andl %ecx, %r8d
movzbl 0x1000(%rdi,%r8,4), %r8d
orl %esi, %r8d
xorl -0x4(%rax), %r8d
bswapl %r8d
movl %r8d, 0x8(%r9)
shrl $0x18, %r12d
movzbl 0x1003(%rdi,%r12,4), %esi
shll $0x18, %esi
shrl $0xe, %r10d
andl %edx, %r10d
movzbl 0x1002(%rdi,%r10), %edx
shll $0x10, %edx
orl %esi, %edx
shrl $0x8, %r11d
andl %ecx, %r11d
movzbl 0x1001(%rdi,%r11,4), %esi
shll $0x8, %esi
orl %edx, %esi
andl %ecx, %ebx
movzbl 0x1000(%rdi,%rbx,4), %ecx
orl %esi, %ecx
xorl (%rax), %ecx
bswapl %ecx
movl %ecx, 0xc(%r9)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop