// File: /workspace/github_c_makefile_star2_O0/LoupVaillant[P]Monocypher-Utils/src/monocypher.c
// Function: crypto_chacha20_encrypt
void crypto_chacha20_encrypt(crypto_chacha_ctx *ctx,
                             u8                *cipher_text,
                             const u8          *plain_text,
                             size_t             text_size)
{
    // Align ourselves with block boundaries
    size_t align = MIN(ALIGN(ctx->pool_idx, 64), text_size);
    chacha20_encrypt(ctx, cipher_text, plain_text, align);
    if (plain_text != 0) {
        plain_text += align;
    }
    cipher_text += align;
    text_size   -= align;

    // Process the message block by block
    FOR (i, 0, text_size >> 6) {  // number of blocks
        chacha20_refill_pool(ctx);
        if (plain_text != 0) {
            FOR (j, 0, 16) {
                u32 plain = load32_le(plain_text);
                store32_le(cipher_text, ctx->pool[j] ^ plain);
                plain_text  += 4;
                cipher_text += 4;
            }
        } else {
            FOR (j, 0, 16) {
                store32_le(cipher_text, ctx->pool[j]);
                cipher_text += 4;
            }
        }
        ctx->pool_idx = 64;
    }
    text_size &= 63;

    // remaining bytes
    chacha20_encrypt(ctx, cipher_text, plain_text, text_size);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
xorq $-0x1, %rax
addq $0x1, %rax
andq $0x3f, %rax
cmpq -0x20(%rbp), %rax
ja 0x2462
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rax
xorq $-0x1, %rax
addq $0x1, %rax
andq $0x3f, %rax
movq %rax, -0x50(%rbp)
jmp 0x246a
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x25d0
cmpq $0x0, -0x18(%rbp)
je 0x249a
movq -0x28(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x28(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
shrq $0x6, %rcx
cmpq %rcx, %rax
jae 0x259d
movq -0x8(%rbp), %rdi
callq 0x2670
cmpq $0x0, -0x18(%rbp)
je 0x253d
movq $0x0, -0x38(%rbp)
cmpq $0x10, -0x38(%rbp)
jae 0x253b
movq -0x18(%rbp), %rdi
callq 0x1d70
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq -0x38(%rbp), %rcx
movl 0x40(%rax,%rcx,4), %esi
xorl -0x3c(%rbp), %esi
callq 0x22b0
movq -0x18(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x10(%rbp)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x24ea
jmp 0x257d
movq $0x0, -0x48(%rbp)
cmpq $0x10, -0x48(%rbp)
jae 0x257b
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq -0x48(%rbp), %rcx
movl 0x40(%rax,%rcx,4), %esi
callq 0x22b0
movq -0x10(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x10(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x2545
jmp 0x257d
movq -0x8(%rbp), %rax
movq $0x40, 0x80(%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x24bd
movq -0x20(%rbp), %rax
andq $0x3f, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x25d0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)