// File: /workspace/github_c_makefile_star2_O3/skeeto[P]enchive/src/chacha.c
// Function: chacha_encrypt
void
chacha_encrypt(chacha_ctx *x, const uint8_t *m, uint8_t *c, uint32_t bytes)
{
  uint8_t output[64];
  uint32_t i;

  if (!bytes) return;
  for (;;) {
    salsa20_wordtobyte(output,x->input);
    x->input[12] = PLUSONE(x->input[12]);
    if (!x->input[12]) {
      x->input[13] = PLUSONE(x->input[13]);
      /* stopping at 2^70 bytes per nonce is user's responsibility */
    }
    if (bytes <= 64) {
      for (i = 0;i < bytes;++i) c[i] = m[i] ^ output[i];
      return;
    }
    for (i = 0;i < 64;++i) c[i] = m[i] ^ output[i];
    bytes -= 64;
    c += 64;
    m += 64;
  }
}

// Assembly:
testl %ecx, %ecx
je 0x550e
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, -0x74(%rsp)
movq %rsi, -0x28(%rsp)
movq %rdx, -0x20(%rsp)
movq %rdi, -0x18(%rsp)
movdqu (%rdi), %xmm0
movups 0x10(%rdi), %xmm1
movups 0x20(%rdi), %xmm2
movups 0x30(%rdi), %xmm3
movdqa %xmm0, -0x70(%rsp)
movaps %xmm1, -0x60(%rsp)
movaps %xmm3, -0x40(%rsp)
movaps %xmm2, -0x50(%rsp)
movl -0x70(%rsp), %eax
movl %eax, -0x7c(%rsp)
movl -0x6c(%rsp), %eax
movl %eax, -0x78(%rsp)
movl -0x60(%rsp), %ecx
movl -0x5c(%rsp), %r8d
movl -0x40(%rsp), %esi
movl -0x3c(%rsp), %r9d
movl -0x50(%rsp), %edi
movl -0x4c(%rsp), %eax
movl %eax, -0x80(%rsp)
movl -0x68(%rsp), %ebx
movl -0x58(%rsp), %ebp
movl -0x38(%rsp), %r14d
movl -0x48(%rsp), %r15d
movl -0x64(%rsp), %r12d
movl -0x54(%rsp), %r13d
movl -0x34(%rsp), %eax
movl $0xa, %r10d
movl -0x44(%rsp), %edx
movl %ebx, -0x30(%rsp)
movl %r10d, -0x2c(%rsp)
movl -0x7c(%rsp), %r11d
addl %ecx, %r11d
xorl %r11d, %esi
roll $0x10, %esi
addl %esi, %edi
xorl %edi, %ecx
roll $0xc, %ecx
addl %ecx, %r11d
xorl %r11d, %esi
roll $0x8, %esi
addl %esi, %edi
xorl %edi, %ecx
roll $0x7, %ecx
movl -0x78(%rsp), %r10d
addl %r8d, %r10d
xorl %r10d, %r9d
roll $0x10, %r9d
movl -0x80(%rsp), %ebx
addl %r9d, %ebx
xorl %ebx, %r8d
roll $0xc, %r8d
addl %r8d, %r10d
xorl %r10d, %r9d
roll $0x8, %r9d
addl %r9d, %ebx
movl %ebx, -0x80(%rsp)
xorl %ebx, %r8d
movl -0x30(%rsp), %ebx
roll $0x7, %r8d
addl %ebp, %ebx
xorl %ebx, %r14d
roll $0x10, %r14d
addl %r14d, %r15d
xorl %r15d, %ebp
roll $0xc, %ebp
addl %ebp, %ebx
xorl %ebx, %r14d
roll $0x8, %r14d
addl %r14d, %r15d
xorl %r15d, %ebp
roll $0x7, %ebp
addl %r13d, %r12d
xorl %r12d, %eax
roll $0x10, %eax
addl %eax, %edx
xorl %edx, %r13d
roll $0xc, %r13d
addl %r13d, %r12d
xorl %r12d, %eax
roll $0x8, %eax
addl %eax, %edx
xorl %edx, %r13d
roll $0x7, %r13d
addl %r8d, %r11d
xorl %r11d, %eax
roll $0x10, %eax
addl %eax, %r15d
xorl %r15d, %r8d
roll $0xc, %r8d
addl %r8d, %r11d
movl %r11d, -0x7c(%rsp)
xorl %r11d, %eax
roll $0x8, %eax
addl %eax, %r15d
xorl %r15d, %r8d
roll $0x7, %r8d
addl %ebp, %r10d
xorl %r10d, %esi
roll $0x10, %esi
addl %esi, %edx
xorl %edx, %ebp
roll $0xc, %ebp
addl %ebp, %r10d
movl %r10d, -0x78(%rsp)
xorl %r10d, %esi
movl -0x2c(%rsp), %r10d
roll $0x8, %esi
addl %esi, %edx
xorl %edx, %ebp
roll $0x7, %ebp
addl %r13d, %ebx
xorl %ebx, %r9d
roll $0x10, %r9d
addl %r9d, %edi
xorl %edi, %r13d
roll $0xc, %r13d
addl %r13d, %ebx
xorl %ebx, %r9d
roll $0x8, %r9d
addl %r9d, %edi
xorl %edi, %r13d
roll $0x7, %r13d
addl %ecx, %r12d
xorl %r12d, %r14d
roll $0x10, %r14d
movl -0x80(%rsp), %r11d
addl %r14d, %r11d
xorl %r11d, %ecx
roll $0xc, %ecx
addl %ecx, %r12d
xorl %r12d, %r14d
roll $0x8, %r14d
addl %r14d, %r11d
movl %r11d, -0x80(%rsp)
xorl %r11d, %ecx
roll $0x7, %ecx
addl $-0x2, %r10d
cmpl $0x2, %r10d
ja 0x52a3
movl -0x7c(%rsp), %r10d
movl %r10d, -0x70(%rsp)
movl %ecx, -0x60(%rsp)
movl %esi, -0x40(%rsp)
movl %edi, -0x50(%rsp)
movl -0x78(%rsp), %ecx
movl %ecx, -0x6c(%rsp)
movl %r8d, -0x5c(%rsp)
movl %r9d, -0x3c(%rsp)
movl -0x80(%rsp), %ecx
movl %ecx, -0x4c(%rsp)
movl %ebx, -0x68(%rsp)
movl %ebp, -0x58(%rsp)
movl %r14d, -0x38(%rsp)
movl %r15d, -0x48(%rsp)
movl %r12d, -0x64(%rsp)
movl %r13d, -0x54(%rsp)
movl %eax, -0x34(%rsp)
movl %edx, -0x44(%rsp)
xorl %eax, %eax
movq -0x18(%rsp), %rdi
movdqu (%rdi,%rax,4), %xmm0
paddd -0x70(%rsp,%rax,4), %xmm0
movdqa %xmm0, -0x70(%rsp,%rax,4)
addq $0x4, %rax
cmpq $0x10, %rax
jne 0x5468
xorl %eax, %eax
movq -0x20(%rsp), %rsi
movq -0x28(%rsp), %r8
movl -0x74(%rsp), %edx
movl -0x70(%rsp,%rax,4), %ecx
movl %ecx, -0x10(%rsp,%rax,4)
incq %rax
cmpq $0x10, %rax
jne 0x5493
incl 0x30(%rdi)
jne 0x54ac
incl 0x34(%rdi)
cmpl $0x41, %edx
jb 0x54e5
xorl %eax, %eax
movb -0x10(%rsp,%rax), %cl
xorb (%r8,%rax), %cl
movb %cl, (%rsi,%rax)
incq %rax
cmpq $0x40, %rax
jne 0x54b3
addl $-0x40, %edx
movl %edx, -0x74(%rsp)
addq $0x40, %rsi
movq %rsi, -0x20(%rsp)
addq $0x40, %r8
movq %r8, -0x28(%rsp)
jmp 0x5226
testl %edx, %edx
je 0x5500
movl %edx, %eax
xorl %ecx, %ecx
movb -0x10(%rsp,%rcx), %dl
xorb (%r8,%rcx), %dl
movb %dl, (%rsi,%rcx)
incq %rcx
cmpq %rax, %rcx
jb 0x54ed
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop