// File: /workspace/github_c_makefile_star2_O0/LoupVaillant[P]Monocypher-Utils/src/hash.c
// Function: main
int main(int argc, char* argv[])
{
    int     algorithm   = BLAKE2B;
    int     tag         = 0;
    uint8_t key[64];
    size_t  key_size    = 0;
    size_t  digest_size = 64;

    set_usage_string(
        "Usage: hash [OPTION]... [FILE]... \n"
        "With no FILE, or when FILE is -, read standard input\n"
        "\n"
        "-a --algorithm      blake2b or sha512 (blake2b by default)\n"
        "-l --digest-length  digest length (8-512 bits, 512 bits by default)\n"
        "-k --key            secret key (in hexadecimal, no key by default)\n"
        "-t --tag            create a BSD-style checksum\n"
        "-? --help           display this help and exit\n");

    // Parse and validate arguments
    getopt_ctx ctx;
    OPT_BEGIN(ctx, argc, argv);
    OPT('t', "tag"        );  tag         = 1;
    OPT('a', "algorithm"  );  algorithm   = parse_algorithm  (&ctx     );
    OPT('l', "digest-size");  digest_size = parse_digest_size(&ctx     );
    OPT('k', "key"        );  key_size    = parse_key        (&ctx, key);
    OPT('?', "help"       );  usage();
    OPT_END;
    if (algorithm == SHA512) {
        if (key_size    !=  0) error("sha512 does not use secret keys");
        if (digest_size != 64) error("sha512 digests are 512 bits");
    }

    // parse input from stdin if no file is given
    if (ctx.argc == 0) {
        if(freopen(0, "rb", stdin) != stdin) {
            panic("Could not reopen standard input in binary mode");
        }
        hash_input(algorithm, tag, stdin, "-", digest_size, key, key_size);
    }

    // Read each input file in succession (if any)
    for (int i = 0; i < ctx.argc; i++) {
        FILE *input = fopen(ctx.argv[i], "rb");
        if (input == 0) {
            fprintf(stderr, "Could not open \"%s\": ", ctx.argv[i]);
            panic(0);
        }
        hash_input(algorithm, tag, input, ctx.argv[i],
                   digest_size, key, key_size);
        if (fclose(input)) {
            fprintf(stderr, "Could not close \"%s\": ", ctx.argv[i]);
            panic(0);
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x40, -0x70(%rbp)
leaq 0x10bbc(%rip), %rdi     # 0x1205a
callq 0x11ef0
movl -0x8(%rbp), %esi
movq -0x10(%rbp), %rdx
leaq -0x88(%rbp), %rdi
callq 0x11500
leaq -0x88(%rbp), %rdi
callq 0x11550
movl %eax, -0x8c(%rbp)
cmpl $-0x1, %eax
je 0x16a4
cmpl $0x2d, -0x8c(%rbp)
jne 0x14ef
leaq -0x88(%rbp), %rdi
callq 0x117f0
movq %rax, -0xb0(%rbp)
jmp 0x14fa
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0x14fa
movq -0xb0(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpl $0x74, -0x8c(%rbp)
je 0x1532
cmpl $0x2d, -0x8c(%rbp)
jne 0x1542
movq -0x98(%rbp), %rdi
leaq 0x10cad(%rip), %rsi     # 0x121d5
callq 0x119a0
cmpl $0x0, %eax
je 0x1542
jmp 0x1534
jmp 0x1536
movl $0x1, -0x18(%rbp)
jmp 0x14b6
cmpl $0x61, -0x8c(%rbp)
je 0x156c
cmpl $0x2d, -0x8c(%rbp)
jne 0x1584
movq -0x98(%rbp), %rdi
leaq 0x10d5a(%rip), %rsi     # 0x122bc
callq 0x119a0
cmpl $0x0, %eax
je 0x1584
jmp 0x156e
jmp 0x1570
leaq -0x88(%rbp), %rdi
callq 0x1850
movl %eax, -0x14(%rbp)
jmp 0x14b6
cmpl $0x6c, -0x8c(%rbp)
je 0x15ae
cmpl $0x2d, -0x8c(%rbp)
jne 0x15c7
movq -0x98(%rbp), %rdi
leaq 0x10c35(%rip), %rsi     # 0x121d9
callq 0x119a0
cmpl $0x0, %eax
je 0x15c7
jmp 0x15b0
jmp 0x15b2
leaq -0x88(%rbp), %rdi
callq 0x18e0
movq %rax, -0x70(%rbp)
jmp 0x14b6
cmpl $0x6b, -0x8c(%rbp)
je 0x15f1
cmpl $0x2d, -0x8c(%rbp)
jne 0x1610
movq -0x98(%rbp), %rdi
leaq 0x10da3(%rip), %rsi     # 0x1238a
callq 0x119a0
cmpl $0x0, %eax
je 0x1610
jmp 0x15f3
jmp 0x15f5
leaq -0x60(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x1980
cltq
movq %rax, -0x68(%rbp)
jmp 0x14b6
cmpl $0x3f, -0x8c(%rbp)
je 0x163a
cmpl $0x2d, -0x8c(%rbp)
jne 0x164a
movq -0x98(%rbp), %rdi
leaq 0x10bb5(%rip), %rsi     # 0x121e5
callq 0x119a0
cmpl $0x0, %eax
je 0x164a
jmp 0x163c
jmp 0x163e
movb $0x0, %al
callq 0x11f10
jmp 0x14b6
cmpq $0x0, -0x98(%rbp)
je 0x1675
movq 0x1499d(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
movq -0x98(%rbp), %rdx
leaq 0x10b7e(%rip), %rsi     # 0x121ea
movb $0x0, %al
callq 0x1090
jmp 0x1693
movq 0x1497c(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
movl -0x8c(%rbp), %edx
leaq 0x10b73(%rip), %rsi     # 0x121ff
movb $0x0, %al
callq 0x1090
leaq 0x11baa(%rip), %rdi     # 0x13244
callq 0x11f30
jmp 0x14b6
jmp 0x16a6
jmp 0x16a8
cmpl $0x1, -0x14(%rbp)
jne 0x16d6
cmpq $0x0, -0x68(%rbp)
je 0x16c1
leaq 0x10b57(%rip), %rdi     # 0x12213
callq 0x11f30
cmpq $0x40, -0x70(%rbp)
je 0x16d4
leaq 0x10b64(%rip), %rdi     # 0x12233
callq 0x11f30
jmp 0x16d6
cmpl $0x0, -0x88(%rbp)
jne 0x173d
movq 0x148f2(%rip), %rax     # 0x15fd8
movq (%rax), %rdx
xorl %eax, %eax
movl %eax, %edi
leaq 0x10b5b(%rip), %rsi     # 0x1224f
callq 0x1080
movq 0x148d8(%rip), %rcx     # 0x15fd8
cmpq (%rcx), %rax
je 0x1711
leaq 0x10b46(%rip), %rdi     # 0x12252
callq 0x11900
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movq 0x148ba(%rip), %rax     # 0x15fd8
movq (%rax), %rdx
movq -0x70(%rbp), %r8
leaq -0x60(%rbp), %r9
movq -0x68(%rbp), %rax
leaq 0x10b4d(%rip), %rcx     # 0x12281
movq %rax, (%rsp)
callq 0x1210
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x88(%rbp), %eax
jge 0x183d
movq -0x80(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x10ae0(%rip), %rsi     # 0x1224f
callq 0x10e0
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0xa8(%rbp)
jne 0x17b5
movq 0x1486c(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
movq -0x80(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x10ade(%rip), %rsi     # 0x12283
movb $0x0, %al
callq 0x1090
xorl %eax, %eax
movl %eax, %edi
callq 0x11900
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movq -0xa8(%rbp), %rdx
movq -0x80(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x70(%rbp), %r8
leaq -0x60(%rbp), %r9
movq -0x68(%rbp), %rax
movq %rax, (%rsp)
callq 0x1210
movq -0xa8(%rbp), %rdi
callq 0x1060
cmpl $0x0, %eax
je 0x1827
movq 0x147fa(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
movq -0x80(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x10a82(%rip), %rsi     # 0x12299
movb $0x0, %al
callq 0x1090
xorl %eax, %eax
movl %eax, %edi
callq 0x11900
jmp 0x1829
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x1747
xorl %eax, %eax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)