// File: /workspace/github_c_makefile_star2_O3/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 0x13a0
movq %rbx, 0x8(%rsp)
movq 0x13f0(%rsp), %rcx
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
movq %r9, %rdx
callq 0x2379
movq %r12, %rdi
callq 0x10d0
testl %eax, %eax
jne 0x1374
leaq 0x3b0(%rsp), %r13
leaq 0x58(%rsp), %rbx
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
jne 0x1374
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 0x2417
movq %r12, %rdi
callq 0x10d0
testl %eax, %eax
je 0x1339
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
je 0x138c
leaq 0x8c99(%rip), %rdi      # 0xa020
callq 0x8e93
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x25d9
movq 0x8(%rsp), %rbx
cmpl $0x1, %ebp
jne 0x1438
movq %rbx, 0x8(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x8760
movq %r12, %rdi
callq 0x10d0
testl %eax, %eax
jne 0x140c
leaq 0x3b0(%rsp), %r13
leaq 0x58(%rsp), %rbx
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
jne 0x140c
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 0x87fe
movq %r12, %rdi
callq 0x10d0
testl %eax, %eax
je 0x13d1
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
je 0x1424
leaq 0x8c01(%rip), %rdi      # 0xa020
callq 0x8e93
leaq 0x58(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x897c
movq 0x8(%rsp), %rbx
testl %r15d, %r15d
je 0x14a3
cmpl $0x1, %ebp
ja 0x145d
testl %ebp, %ebp
leaq 0x8bff(%rip), %rax      # 0xa04a
leaq 0x8c00(%rip), %rdi      # 0xa052
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x1080
cmpq $0x40, %r14
je 0x1479
leal (,%r14,8), %esi
leaq 0x8be7(%rip), %rdi      # 0xa059
xorl %eax, %eax
callq 0x1080
leaq 0x8bdd(%rip), %rdi      # 0xa05d
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1080
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x8f75
movl $0xa, %edi
callq 0x1040
jmp 0x14c1
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x8f75
leaq 0x8b8e(%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