// File: /workspace/github_cpp_makefile_star2_O3/bitwiseshiftleft[P]crandom/chacha.c
// Function: crandom_chacha_expand
extern_c void
crandom_chacha_expand(u_int64_t iv,
                      u_int64_t ctr,
                      int nr,
                      int output_size,
                      const unsigned char *key_,
                      unsigned char *output_) {
# if MIGHT_HAVE_SSE2
  if (HAVE(SSE2)) {
    ssereg *key = (ssereg *)key_;
    ssereg *output = (ssereg *)output_;
                     
    ssereg a1 = key[0], a2 = a1, aa = a1,
           b1 = key[1], b2 = b1, bb = b1,
           c1 = {iv, ctr}, c2 = {iv, ctr+1}, cc = c1,
           d1 = {0x3320646e61707865ull, 0x6b20657479622d32ull}, d2 = d1, dd = d1,
           p = {0, 1};
     
    int i,r;
#   if (NEED_XOP)
      if (HAVE(XOP)) {
        for (i=0; i<output_size; i+=128) {
          for (r=nr; r>0; r-=2)
            DOUBLE_ROUND(quarter_round_xop);
          OUTPUT_FUNCTION;
        }
        return;
      }
#   endif
#   if (NEED_SSSE3)
      if (HAVE(SSSE3)) {
        for (i=0; i<output_size; i+=128) {
          for (r=nr; r>0; r-=2)
            DOUBLE_ROUND(quarter_round_ssse3);
          OUTPUT_FUNCTION;
        }
        return;
      }
#   endif
#   if (NEED_SSE2)
      if (HAVE(SSE2)) {
        for (i=0; i<output_size; i+=128) {
          for (r=nr; r>0; r-=2)
            DOUBLE_ROUND(quarter_round_sse2);
          OUTPUT_FUNCTION;
        }
        return;
      }
#   endif
  }
# endif

# if NEED_CONV
  {
    const u_int32_t *key = (const u_int32_t *)key_;
    u_int32_t
      x[16],
      input[16] = {
        key[0], key[1], key[2], key[3],
        key[4], key[5], key[6], key[7],
        iv, iv>>32, ctr, ctr>>32,
        0x61707865, 0x3320646e, 0x79622d32, 0x6b206574
      },
      *output = (u_int32_t *)output_;
    int i, r;
  
    for (i=0; i<output_size; i+= 64) {
      for (r=0; r<16; r++) {
        x[r] = input[r];
      }
      for (r=nr; r>0; r-=2) {
        quarter_round(&x[0], &x[4],  &x[8], &x[12]);
        quarter_round(&x[1], &x[5],  &x[9], &x[13]);
        quarter_round(&x[2], &x[6], &x[10], &x[14]);
        quarter_round(&x[3], &x[7], &x[11], &x[15]);
        
        quarter_round(&x[0], &x[5], &x[10], &x[15]);
        quarter_round(&x[1], &x[6], &x[11], &x[12]);
        quarter_round(&x[2], &x[7],  &x[8], &x[13]);
        quarter_round(&x[3], &x[4],  &x[9], &x[14]);
      }
      for (r=0; r<16; r++) {
        output[r] = x[r] + input[r];
      }
      
      output += 16;
      input[11] ++;
      if (!input[11]) input[12]++;
    }
  }
  
#endif // NEED_CONV
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r9, %r14
movq %r8, %r12
movl %ecx, %ebp
movl %edx, %r15d
movq %rdi, %r13
leaq 0x4896(%rip), %rbx      # 0x94f0
movl (%rbx), %eax
testl %eax, %eax
je 0x533b
testb $0x2, %al
jne 0x4fb2
movups (%r12), %xmm0
movaps %xmm0, 0x90(%rsp)
movups 0x10(%r12), %xmm0
movaps %xmm0, 0xa0(%rsp)
movl %r13d, 0xb0(%rsp)
shrq $0x20, %r13
movl %r13d, 0xb4(%rsp)
movl %esi, 0xb8(%rsp)
shrq $0x20, %rsi
movl %esi, 0xbc(%rsp)
movdqa 0x16cb(%rip), %xmm0     # 0x6380
movdqa %xmm0, 0xc0(%rsp)
testl %ebp, %ebp
jle 0x5329
leal 0x2(%r15), %eax
movl %eax, 0x6c(%rsp)
movl $0x61707865, 0x1c(%rsp) # imm = 0x61707865
xorl %ecx, %ecx
movl %ebp, 0x70(%rsp)
movq %r15, 0x78(%rsp)
movdqa 0x90(%rsp), %xmm0
movdqa 0xa0(%rsp), %xmm1
movdqa 0xb0(%rsp), %xmm2
movdqa 0xc0(%rsp), %xmm3
movdqa %xmm3, 0x50(%rsp)
movdqa %xmm2, 0x40(%rsp)
movdqa %xmm1, 0x30(%rsp)
movdqa %xmm0, 0x20(%rsp)
testl %r15d, %r15d
jle 0x4f61
movq %rcx, 0x80(%rsp)
movq %rsi, 0x60(%rsp)
movq %r14, 0x88(%rsp)
movl 0x20(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x14(%rsp)
movl 0x30(%rsp), %esi
movl 0x50(%rsp), %ebx
movl 0x40(%rsp), %edx
movl 0x34(%rsp), %r15d
movl 0x54(%rsp), %ecx
movl 0x44(%rsp), %ebp
movl 0x28(%rsp), %r14d
movl 0x38(%rsp), %eax
movl 0x58(%rsp), %r13d
movl 0x48(%rsp), %r12d
movl 0x2c(%rsp), %r11d
movl 0x3c(%rsp), %r10d
movl 0x5c(%rsp), %r9d
movl 0x4c(%rsp), %edi
movl %edi, 0xc(%rsp)
movl 0x6c(%rsp), %edi
movl %edi, 0x74(%rsp)
movl 0x10(%rsp), %r8d
addl %esi, %r8d
xorl %r8d, %ebx
roll $0x10, %ebx
addl %ebx, %edx
xorl %edx, %esi
roll $0xc, %esi
addl %esi, %r8d
xorl %r8d, %ebx
roll $0x8, %ebx
addl %ebx, %edx
xorl %edx, %esi
roll $0x7, %esi
movl 0x14(%rsp), %edi
addl %r15d, %edi
xorl %edi, %ecx
roll $0x10, %ecx
addl %ecx, %ebp
xorl %ebp, %r15d
roll $0xc, %r15d
addl %r15d, %edi
xorl %edi, %ecx
roll $0x8, %ecx
addl %ecx, %ebp
xorl %ebp, %r15d
roll $0x7, %r15d
addl %eax, %r14d
xorl %r14d, %r13d
roll $0x10, %r13d
addl %r13d, %r12d
xorl %r12d, %eax
roll $0xc, %eax
addl %eax, %r14d
xorl %r14d, %r13d
roll $0x8, %r13d
addl %r13d, %r12d
xorl %r12d, %eax
roll $0x7, %eax
addl %r10d, %r11d
movl %r11d, 0x18(%rsp)
xorl %r11d, %r9d
roll $0x10, %r9d
movl 0xc(%rsp), %r11d
addl %r9d, %r11d
xorl %r11d, %r10d
roll $0xc, %r10d
addl %r10d, 0x18(%rsp)
xorl 0x18(%rsp), %r9d
roll $0x8, %r9d
addl %r9d, %r11d
xorl %r11d, %r10d
roll $0x7, %r10d
addl %r15d, %r8d
xorl %r8d, %r9d
roll $0x10, %r9d
addl %r9d, %r12d
xorl %r12d, %r15d
roll $0xc, %r15d
addl %r15d, %r8d
movl %r8d, 0x10(%rsp)
xorl %r8d, %r9d
roll $0x8, %r9d
addl %r9d, %r12d
xorl %r12d, %r15d
roll $0x7, %r15d
addl %eax, %edi
xorl %edi, %ebx
roll $0x10, %ebx
addl %ebx, %r11d
xorl %r11d, %eax
roll $0xc, %eax
addl %eax, %edi
movl %edi, 0x14(%rsp)
xorl %edi, %ebx
movl 0x74(%rsp), %edi
roll $0x8, %ebx
addl %ebx, %r11d
movl %r11d, 0xc(%rsp)
xorl %r11d, %eax
movl 0x18(%rsp), %r11d
roll $0x7, %eax
addl %r10d, %r14d
xorl %r14d, %ecx
roll $0x10, %ecx
addl %ecx, %edx
xorl %edx, %r10d
roll $0xc, %r10d
addl %r10d, %r14d
xorl %r14d, %ecx
roll $0x8, %ecx
addl %ecx, %edx
xorl %edx, %r10d
roll $0x7, %r10d
addl %esi, %r11d
xorl %r11d, %r13d
roll $0x10, %r13d
addl %r13d, %ebp
xorl %ebp, %esi
roll $0xc, %esi
addl %esi, %r11d
xorl %r11d, %r13d
roll $0x8, %r13d
addl %r13d, %ebp
xorl %ebp, %esi
roll $0x7, %esi
addl $-0x2, %edi
cmpl $0x2, %edi
ja 0x4d92
movl %esi, 0x30(%rsp)
movl 0x10(%rsp), %esi
movl %esi, 0x20(%rsp)
movl %ebx, 0x50(%rsp)
movl %edx, 0x40(%rsp)
movl 0x14(%rsp), %edx
movl %edx, 0x24(%rsp)
movl %r15d, 0x34(%rsp)
movl %ecx, 0x54(%rsp)
movl %ebp, 0x44(%rsp)
movl %r14d, 0x28(%rsp)
movl %eax, 0x38(%rsp)
movl %r13d, 0x58(%rsp)
movl %r12d, 0x48(%rsp)
movl %r11d, 0x2c(%rsp)
movl %r10d, 0x3c(%rsp)
movl %r9d, 0x5c(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x4c(%rsp)
movq 0x88(%rsp), %r14
movl 0x70(%rsp), %ebp
movq 0x78(%rsp), %r15
movq 0x60(%rsp), %rsi
movq 0x80(%rsp), %rcx
xorl %eax, %eax
movdqa 0x90(%rsp,%rax,4), %xmm0
paddd 0x20(%rsp,%rax,4), %xmm0
movdqu %xmm0, (%r14,%rax,4)
addq $0x4, %rax
cmpq $0x10, %rax
jne 0x4f63
incl %esi
movl %esi, 0xbc(%rsp)
jne 0x4f9e
movl 0x1c(%rsp), %eax
incl %eax
movl %eax, 0x1c(%rsp)
movl %eax, 0xc0(%rsp)
addq $0x40, %r14
addl $0x40, %ecx
cmpl %ebp, %ecx
jl 0x4ce1
jmp 0x5329
testl %ebp, %ebp
jle 0x5329
movq %r13, %xmm0
leaq 0x1(%rsi), %rax
movq %rax, %xmm1
movdqa %xmm0, %xmm10
punpcklqdq %xmm1, %xmm10   # xmm10 = xmm10[0],xmm1[0]
movq %rsi, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movdqa (%r12), %xmm1
movdqa 0x10(%r12), %xmm2
leal 0x2(%r15), %eax
xorl %ecx, %ecx
movdqa 0x138a(%rip), %xmm4     # 0x6380
movdqa 0x1322(%rip), %xmm5     # 0x6320
movdqa 0x138a(%rip), %xmm6     # 0x6390
movdqa 0x1392(%rip), %xmm7     # 0x63a0
testl %r15d, %r15d
jle 0x528c
movl %eax, %edx
movdqa %xmm4, %xmm11
movdqa %xmm4, %xmm13
movdqa %xmm0, %xmm14
movdqa %xmm2, %xmm12
movdqa %xmm2, %xmm15
movdqa %xmm1, %xmm8
movdqa %xmm1, %xmm9
paddd %xmm15, %xmm9
pxor %xmm9, %xmm13
movdqa %xmm13, %xmm3
psrld $0x10, %xmm3
pslld $0x10, %xmm13
por %xmm3, %xmm13
paddd %xmm13, %xmm14
pxor %xmm14, %xmm15
movdqa %xmm15, %xmm3
psrld $0x14, %xmm3
pslld $0xc, %xmm15
por %xmm3, %xmm15
paddd %xmm15, %xmm9
pxor %xmm9, %xmm13
movdqa %xmm13, %xmm3
psrld $0x18, %xmm3
pslld $0x8, %xmm13
por %xmm3, %xmm13
paddd %xmm13, %xmm14
pxor %xmm14, %xmm15
movdqa %xmm15, %xmm3
psrld $0x19, %xmm3
pslld $0x7, %xmm15
por %xmm3, %xmm15
paddd %xmm12, %xmm8
pxor %xmm8, %xmm11
movdqa %xmm11, %xmm3
psrld $0x10, %xmm3
pslld $0x10, %xmm11
por %xmm3, %xmm11
paddd %xmm11, %xmm10
pxor %xmm10, %xmm12
movdqa %xmm12, %xmm3
psrld $0x14, %xmm3
pslld $0xc, %xmm12
por %xmm3, %xmm12
paddd %xmm12, %xmm8
pxor %xmm8, %xmm11
movdqa %xmm11, %xmm3
psrld $0x18, %xmm3
pslld $0x8, %xmm11
por %xmm3, %xmm11
paddd %xmm11, %xmm10
pxor %xmm10, %xmm12
movdqa %xmm12, %xmm3
psrld $0x19, %xmm3
pslld $0x7, %xmm12
por %xmm3, %xmm12
pshufd $0x39, %xmm15, %xmm15   # xmm15 = xmm15[1,2,3,0]
pshufd $0x4e, %xmm14, %xmm14   # xmm14 = xmm14[2,3,0,1]
pshufd $0x93, %xmm13, %xmm13   # xmm13 = xmm13[3,0,1,2]
pshufd $0x39, %xmm12, %xmm12   # xmm12 = xmm12[1,2,3,0]
pshufd $0x4e, %xmm10, %xmm10   # xmm10 = xmm10[2,3,0,1]
pshufd $0x93, %xmm11, %xmm11   # xmm11 = xmm11[3,0,1,2]
paddd %xmm15, %xmm9
pxor %xmm9, %xmm13
movdqa %xmm13, %xmm3
psrld $0x10, %xmm3
pslld $0x10, %xmm13
por %xmm3, %xmm13
paddd %xmm13, %xmm14
pxor %xmm14, %xmm15
movdqa %xmm15, %xmm3
psrld $0x14, %xmm3
pslld $0xc, %xmm15
por %xmm3, %xmm15
paddd %xmm15, %xmm9
pxor %xmm9, %xmm13
movdqa %xmm13, %xmm3
psrld $0x18, %xmm3
pslld $0x8, %xmm13
por %xmm3, %xmm13
paddd %xmm13, %xmm14
pxor %xmm14, %xmm15
movdqa %xmm15, %xmm3
psrld $0x19, %xmm3
pslld $0x7, %xmm15
por %xmm3, %xmm15
paddd %xmm12, %xmm8
pxor %xmm8, %xmm11
movdqa %xmm11, %xmm3
psrld $0x10, %xmm3
pslld $0x10, %xmm11
por %xmm3, %xmm11
paddd %xmm11, %xmm10
pxor %xmm10, %xmm12
movdqa %xmm12, %xmm3
psrld $0x14, %xmm3
pslld $0xc, %xmm12
por %xmm3, %xmm12
paddd %xmm12, %xmm8
pxor %xmm8, %xmm11
movdqa %xmm11, %xmm3
psrld $0x18, %xmm3
pslld $0x8, %xmm11
por %xmm3, %xmm11
paddd %xmm11, %xmm10
pxor %xmm10, %xmm12
movdqa %xmm12, %xmm3
psrld $0x19, %xmm3
pslld $0x7, %xmm12
por %xmm3, %xmm12
pshufd $0x93, %xmm15, %xmm15   # xmm15 = xmm15[3,0,1,2]
pshufd $0x4e, %xmm14, %xmm14   # xmm14 = xmm14[2,3,0,1]
pshufd $0x39, %xmm13, %xmm13   # xmm13 = xmm13[1,2,3,0]
pshufd $0x93, %xmm12, %xmm12   # xmm12 = xmm12[3,0,1,2]
pshufd $0x4e, %xmm10, %xmm10   # xmm10 = xmm10[2,3,0,1]
pshufd $0x39, %xmm11, %xmm11   # xmm11 = xmm11[1,2,3,0]
addl $-0x2, %edx
cmpl $0x2, %edx
ja 0x503c
paddd %xmm4, %xmm13
paddd %xmm4, %xmm11
jmp 0x52b3
movdqa %xmm2, %xmm12
movdqa %xmm1, %xmm8
movdqa %xmm2, %xmm15
movdqa %xmm1, %xmm9
movdqa %xmm0, %xmm14
movdqa 0x10c2(%rip), %xmm11    # 0x6370
movdqa %xmm11, %xmm13
paddd %xmm1, %xmm9
movdqa %xmm9, (%r14)
paddd %xmm2, %xmm15
movdqa %xmm15, 0x10(%r14)
paddd %xmm0, %xmm14
movdqa %xmm14, 0x20(%r14)
movdqa %xmm13, 0x30(%r14)
paddd %xmm1, %xmm8
movdqa %xmm8, 0x40(%r14)
paddd %xmm2, %xmm12
movdqa %xmm12, 0x50(%r14)
paddd %xmm0, %xmm10
paddd %xmm5, %xmm10
movdqa %xmm10, 0x60(%r14)
movdqa %xmm11, 0x70(%r14)
subq $-0x80, %r14
movdqa %xmm0, %xmm3
paddq %xmm6, %xmm3
paddq %xmm7, %xmm0
subl $-0x80, %ecx
movdqa %xmm0, %xmm10
movdqa %xmm3, %xmm0
cmpl %ebp, %ecx
jl 0x500e
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
movq %rsi, 0x60(%rsp)
callq 0x5adc
movq 0x60(%rsp), %rsi
movl %eax, (%rbx)
jmp 0x4c64
nop