// File: /workspace/github_c_makefile_star2_O1/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 %esi, %r15d
movl %edi, %ebp
testl %edi, %edi
jne 0x13d0
movq %rbx, 0x8(%rsp)
movq 0x13f0(%rsp), %rcx
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
movq %r9, %rdx
callq 0x23d2
movq %r12, %rdi
callq 0x10d0
testl %eax, %eax
jne 0x13a4
leaq 0x3b0(%rsp), %r13
leaq 0x58(%rsp), %rbx
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
jne 0x13a4
movl $0x1, %esi
movl $0x1000, %edx           # imm = 0x1000
movq %r13, %rdi
movq %r12, %rcx
callq 0x1060
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x2465
movq %r12, %rdi
callq 0x10d0
testl %eax, %eax
je 0x1369
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
je 0x13bc
leaq 0x8c69(%rip), %rdi      # 0xa020
callq 0x8e8b
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2634
movq 0x8(%rsp), %rbx
cmpl $0x1, %ebp
jne 0x1468
movq %rbx, 0x8(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x8758
movq %r12, %rdi
callq 0x10d0
testl %eax, %eax
jne 0x143c
leaq 0x3b0(%rsp), %r13
leaq 0x58(%rsp), %rbx
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
jne 0x143c
movl $0x1, %esi
movl $0x1000, %edx           # imm = 0x1000
movq %r13, %rdi
movq %r12, %rcx
callq 0x1060
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x87f6
movq %r12, %rdi
callq 0x10d0
testl %eax, %eax
je 0x1401
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
je 0x1454
leaq 0x8bd1(%rip), %rdi      # 0xa020
callq 0x8e8b
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x897c
movq 0x8(%rsp), %rbx
testl %r15d, %r15d
je 0x14d8
testl %ebp, %ebp
jne 0x147f
leaq 0x8bd2(%rip), %rdi      # 0xa04a
xorl %eax, %eax
callq 0x1080
cmpl $0x1, %ebp
jne 0x1492
leaq 0x8bc7(%rip), %rdi      # 0xa052
xorl %eax, %eax
callq 0x1080
cmpq $0x40, %r14
je 0x14ae
leal (,%r14,8), %esi
leaq 0x8bb2(%rip), %rdi      # 0xa059
xorl %eax, %eax
callq 0x1080
leaq 0x8ba8(%rip), %rdi      # 0xa05d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1080
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x8f80
movl $0xa, %edi
callq 0x1040
jmp 0x14f6
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x8f80
leaq 0x8b59(%rip), %rdi      # 0xa045
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