// File: /workspace/github_c_makefile_star2_O0/agl[P]obstcp/libobstcp.c
// Function: obs_encrypt
static void
obs_encrypt(struct obstcp_half_connection *hc, uint8_t *out,
        const uint8_t *in, size_t len) {
  size_t l = len, j = 0, i;

  if (hc->used < 64) {
    const size_t m = min_t(size_t, 64u - hc->used, l);
    xor(out, in, hc->keystream + hc->used, m);
    l -= m;
    hc->used += m;
    j += m;
  }
  const unsigned chunks = l >> 6;
  if (chunks) {
    for (i = 0; i < chunks; ++i) {
      salsa208(hc->keystream, hc->block_ctr, hc->key, sigma);
      block_ctr_inc(hc->block_ctr);
      xor(out + j, in + j, hc->keystream, 64);
      l -= 64;
      j += 64;
    }
  }
  if (l) {
    salsa208(hc->keystream, hc->block_ctr, hc->key, sigma);
    block_ctr_inc(hc->block_ctr);
    xor(out + j, in + j, hc->keystream, l);
    hc->used = l;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x40, 0x40(%rax)
jae 0x2e49
movq -0x8(%rbp), %rcx
movl $0x40, %eax
subl 0x40(%rcx), %eax
movl %eax, %eax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x2de4
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x2dec
movq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x8(%rbp), %rdx
movq -0x8(%rbp), %rax
movl 0x40(%rax), %eax
addq %rax, %rdx
movq -0x40(%rbp), %rax
movl %eax, %ecx
callq 0x50d0
movq -0x40(%rbp), %rcx
movq -0x28(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rdx
movq -0x8(%rbp), %rax
movl 0x40(%rax), %ecx
addq %rdx, %rcx
movl %ecx, 0x40(%rax)
movq -0x40(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
shrq $0x6, %rax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x2ee5
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl -0x5c(%rbp), %ecx
cmpq %rcx, %rax
jae 0x2ee3
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x64, %rsi
movq -0x8(%rbp), %rdx
addq $0x44, %rdx
leaq 0x9263(%rip), %rcx      # 0xc0f0
callq 0x5420
movq -0x8(%rbp), %rdi
addq $0x64, %rdi
callq 0x51a0
movq -0x10(%rbp), %rdi
addq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq -0x30(%rbp), %rsi
movq -0x8(%rbp), %rdx
movl $0x40, %ecx
callq 0x50d0
movq -0x28(%rbp), %rax
subq $0x40, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2e66
jmp 0x2ee5
cmpq $0x0, -0x28(%rbp)
je 0x2f45
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x64, %rsi
movq -0x8(%rbp), %rdx
addq $0x44, %rdx
leaq 0x91e9(%rip), %rcx      # 0xc0f0
callq 0x5420
movq -0x8(%rbp), %rdi
addq $0x64, %rdi
callq 0x51a0
movq -0x10(%rbp), %rdi
addq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq -0x30(%rbp), %rsi
movq -0x8(%rbp), %rdx
movq -0x28(%rbp), %rax
movl %eax, %ecx
callq 0x50d0
movq -0x28(%rbp), %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x40(%rax)
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)