// File: /workspace/github_c_makefile_star2_O2/LoupVaillant[P]Monocypher-Utils/src/hash.c
// Function: hash_input
void hash_input(int algorithm, int tag, FILE *input, const char *file_name,
                size_t digest_size, const uint8_t *key, size_t key_size)
{
    uint8_t digest[64];
    uint8_t block[BLOCK_SIZE];
    if (algorithm == BLAKE2B) {
        crypto_blake2b_ctx blake2b_ctx;
        crypto_blake2b_general_init(&blake2b_ctx, digest_size, key, key_size);
        HASH(blake2b);
    }
    if (algorithm == SHA512) {
        crypto_sha512_ctx  sha512_ctx;
        crypto_sha512_init(&sha512_ctx);
        HASH(sha512);
    }

    if (!tag) {
        print_buffer(digest, digest_size);
        printf(" %s\n", file_name);
    } else {
        if (algorithm == BLAKE2B) printf("BLAKE2b");
        if (algorithm == SHA512 ) printf("SHA512" );
        if (digest_size != 64) {
            printf("-%u", (unsigned)digest_size * 8);
        }
        printf(" (%s) = ", file_name);
        print_buffer(digest, digest_size);
        printf("\n");
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x13b8, %rsp           # imm = 0x13B8
movq %r8, %r14
movq %rcx, %rbx
movq %rdx, %r12
movl %edi, %ebp
testl %edi, %edi
jne 0x12db
movl %esi, 0x4(%rsp)
movq %rbx, 0x8(%rsp)
movq 0x13f0(%rsp), %rcx
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r9, %rdx
callq 0x2203
leaq 0x3b0(%rsp), %rbx
pushq $0x1
popq %r15
movq %r12, %rdi
callq 0x10c0
testl %eax, %eax
jne 0x12ab
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
jne 0x12ab
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x1060
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2290
jmp 0x1270
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
je 0x12c3
leaq 0x7d62(%rip), %rdi      # 0x9020
callq 0x837e
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x23a7
movq 0x8(%rsp), %rbx
movl 0x4(%rsp), %esi
cmpl $0x1, %ebp
jne 0x1371
movl %esi, 0x4(%rsp)
movq %rbx, 0x8(%rsp)
leaq 0x58(%rsp), %r13
movq %r13, %rdi
callq 0x7ca4
leaq 0x3b0(%rsp), %rbx
pushq $0x1
popq %r15
movq %r12, %rdi
callq 0x10c0
testl %eax, %eax
jne 0x1341
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
jne 0x1341
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x1060
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x7d3f
jmp 0x1306
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
je 0x1359
leaq 0x7ccc(%rip), %rdi      # 0x9020
callq 0x837e
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7e5c
movq 0x8(%rsp), %rbx
movl 0x4(%rsp), %esi
testl %esi, %esi
je 0x13d9
cmpl $0x1, %ebp
ja 0x1395
testl %ebp, %ebp
leaq 0x7cc7(%rip), %rax      # 0x904a
leaq 0x7cc8(%rip), %rdi      # 0x9052
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x1080
cmpq $0x40, %r14
je 0x13b1
leal (,%r14,8), %esi
leaq 0x7caf(%rip), %rdi      # 0x9059
xorl %eax, %eax
callq 0x1080
leaq 0x7ca5(%rip), %rdi      # 0x905d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1080
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x8476
pushq $0xa
popq %rdi
callq 0x1040
jmp 0x13f7
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x8476
leaq 0x7c58(%rip), %rdi      # 0x9045
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1080
addq $0x13b8, %rsp           # imm = 0x13B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq