// File: /workspace/github_c_makefile_star2_O2/LoupVaillant[P]Monocypher-Utils/src/pwhash.c
// Function: main
int main(int argc, char* argv[])
{
    size_t   digest_size   = 64;
    uint32_t nb_iterations = 3;
    uint32_t nb_kibybytes  = 102400; // 100 Mib
    vector   key           = new_vector();
    vector   ad            = new_vector();
    int      rpp_flags     = 0;

    set_usage_string(
        "Usage: pwhash [OPTION]... salt\n"
        "Read the password from standard input\n"
        "The salt must be at least 8 bytes long (16 hex digits)\n"
        "\n"
        "-l --digest-size      digest length in bytes (32 bytes by default)\n"
        "-t --nb-iterations    number of iterations (default 3)\n"
        "-m --nb-kilobytes     memory usage in KiB (default 100MiB)\n"
        "-k --key              secret key (hexadecimal, default none)\n"
        "-a --additional-data  additionnal data (hexadecimal, default none)\n"
        "-i --stdin            read password from stdin"
        "-? --help             display this help and exit\n");

    // Parse and validate arguments
    getopt_ctx ctx;
    OPT_BEGIN(ctx, argc, argv);
    OPT('l', "digest-size"    );  digest_size   = parse_digest(&ctx);
    OPT('t', "nb-iterations"  );  nb_iterations = parse_nb_it (&ctx);
    OPT('k', "nb-kilobytes"   );  nb_kibybytes  = parse_kib   (&ctx);
    OPT('k', "key"            );  key           = parse_key   (&ctx);
    OPT('a', "additional-data");  ad            = parse_ad    (&ctx);
    OPT('i', "stdin"          );  rpp_flags    |= RPP_STDIN;
    OPT('?', "help"           );  usage();
    OPT_END;
    vector   salt      = parse_salt(&ctx);
    size_t   work_size = 1024 * nb_kibybytes;
    void    *work_area = alloc(work_size);
    uint8_t *digest    = alloc(digest_size);

    // read password
    if (readpassphrase("Passphrase: ", work_area, work_size, rpp_flags) == 0) {
        panic("Could not read password");
    }
    size_t password_size = strlen(work_area);

    // hash password
    crypto_argon2i_general(digest, digest_size,
                           work_area, nb_kibybytes,
                           nb_iterations,
                           work_area  , password_size,
                           salt.buffer, salt.size,
                           key .buffer, key .size,
                           ad  .buffer, ad  .size);

    // free resources
    free(work_area);
    free_vector(&key );
    free_vector(&ad  );
    free_vector(&salt);

    // print password
    print_buffer(digest, digest_size);
    printf("\n");

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbx
movl %edi, %ebp
xorl %eax, %eax
callq 0x8408
movq %rax, 0x28(%rsp)
movq %rax, 0x50(%rsp)
movq %rdx, 0x20(%rsp)
movq %rdx, 0x58(%rsp)
xorl %eax, %eax
callq 0x8408
movq %rax, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq %rdx, 0x30(%rsp)
movq %rdx, 0x48(%rsp)
leaq 0x7dd5(%rip), %rdi      # 0x9004
callq 0x8474
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x8068
pushq $0x40
popq %r15
pushq $0x3
popq %rbp
movl $0x19000, %ebx          # imm = 0x19000
movl $0x0, 0x1c(%rsp)
movq %r14, %rdi
callq 0x807a
movl %eax, %r12d
cmpl $0x2d, %eax
je 0x12d2
cmpl $0x3f, %r12d
je 0x14e5
cmpl $0x61, %r12d
je 0x1462
cmpl $0x69, %r12d
je 0x14c8
cmpl $0x6b, %r12d
je 0x1369
cmpl $0x6c, %r12d
je 0x12f0
cmpl $0x74, %r12d
jne 0x13b3
movq %r14, %rdi
callq 0x8165
movq %rax, %rdi
callq 0x828a
movl %eax, %ebp
cmpl $-0x3, %eax
jb 0x125a
movslq %ebp, %rax
leaq 0x8295(%rip), %rcx      # 0x9558
movslq 0xc(%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x8499
jmp 0x125a
movq %r14, %rdi
callq 0x8165
movq %rax, %r13
movq %rax, %rdi
leaq 0x7f2f(%rip), %rsi      # 0x9216
callq 0x8257
testl %eax, %eax
je 0x133b
movq %r14, %rdi
callq 0x8165
movq %rax, %rdi
callq 0x828a
movl %eax, %r12d
cmpl $-0x4, %eax
jbe 0x1321
movslq %r12d, %rax
leaq 0x823a(%rip), %rcx      # 0x954c
movslq 0xc(%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x8499
jmp 0x1327
cmpl $0x4, %r12d
jge 0x1333
leaq 0x7fca(%rip), %rdi      # 0x92f8
callq 0x8499
movslq %r12d, %r15
jmp 0x125a
movq %r13, %rdi
leaq 0x7edd(%rip), %rsi      # 0x9222
callq 0x8257
testl %eax, %eax
jne 0x12a2
movq %r13, %rdi
leaq 0x7ed4(%rip), %rsi      # 0x9230
callq 0x8257
testl %eax, %eax
je 0x13e9
movq %r14, %rdi
callq 0x8165
movq %rax, %rdi
callq 0x828a
movl %eax, %ebx
cmpl $-0x4, %eax
jbe 0x1399
movslq %ebx, %rax
leaq 0x81da(%rip), %rcx      # 0x9564
movslq 0xc(%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x8499
jmp 0x13a2
cmpl $0x8, %ebx
jge 0x125a
leaq 0x8032(%rip), %rdi      # 0x93db
callq 0x8499
jmp 0x125a
cmpl $-0x1, %r12d
je 0x151a
movq 0xcc34(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x7e9f(%rip), %rsi      # 0x926d
movl %r12d, %edx
xorl %eax, %eax
callq 0x1080
leaq 0x8f75(%rip), %rdi      # 0xa354
callq 0x8499
jmp 0x125a
movq %r13, %rdi
leaq 0x8010(%rip), %rsi      # 0x9403
callq 0x8257
testl %eax, %eax
je 0x144f
movq %r14, %rdi
callq 0x8165
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x840d
cmpl $-0x4, %eax
jb 0x142c
addl $0x4, %eax
leaq 0x8150(%rip), %rcx      # 0x9570
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x8499
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, 0x28(%rsp)
movq %rax, 0x50(%rsp)
movq %rcx, 0x20(%rsp)
movq %rcx, 0x58(%rsp)
jmp 0x125a
movq %r13, %rdi
leaq 0x7de4(%rip), %rsi      # 0x923d
callq 0x8257
testl %eax, %eax
je 0x14b5
movq %r14, %rdi
callq 0x8165
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x840d
cmpl $-0x4, %eax
jb 0x1492
addl $0x4, %eax
leaq 0x80fa(%rip), %rcx      # 0x9580
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x8499
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, 0x38(%rsp)
movq %rax, 0x40(%rsp)
movq %rcx, 0x30(%rsp)
movq %rcx, 0x48(%rsp)
jmp 0x125a
movq %r13, %rdi
leaq 0x7d8e(%rip), %rsi      # 0x924d
callq 0x8257
testl %eax, %eax
je 0x14d2
orl $0x20, 0x1c(%rsp)
jmp 0x125a
movq %r13, %rdi
leaq 0x7d77(%rip), %rsi      # 0x9253
callq 0x8257
testl %eax, %eax
je 0x14f1
xorl %eax, %eax
callq 0x847c
jmp 0x125a
testq %r13, %r13
je 0x13bd
movq 0xcaf7(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x7d4d(%rip), %rsi      # 0x9258
movq %r13, %rdx
xorl %eax, %eax
callq 0x1080
jmp 0x13d8
movl 0x70(%rsp), %eax
testl %eax, %eax
jne 0x1532
leaq 0x7faa(%rip), %rdi      # 0x94d3
callq 0x8499
movl 0x70(%rsp), %eax
testl %eax, %eax
jg 0x1542
leaq 0x7fa3(%rip), %rdi      # 0x94e0
callq 0x8499
movq 0x78(%rsp), %rax
movq (%rax), %rsi
leaq 0x8(%rsp), %rdi
callq 0x840d
addl $0x4, %eax
cmpl $0x2, %eax
ja 0x1571
movl %eax, %eax
leaq 0x802b(%rip), %rcx      # 0x9590
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x8499
movq 0x10(%rsp), %r14
cmpq $0x7, %r14
ja 0x158d
leaq 0x7fb9(%rip), %rdi      # 0x953c
callq 0x8499
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %rax
movq %rax, 0x60(%rsp)
movq %rax, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movl %ebx, %r13d
shll $0xa, %r13d
movq %r13, %rdi
callq 0x81b0
movq %rax, %r12
movq %r15, %rdi
callq 0x81b0
movq %rax, 0x68(%rsp)
leaq 0x7cba(%rip), %rdi      # 0x9281
movq %r12, %rsi
movq %r13, %rdx
movl 0x1c(%rsp), %ecx
callq 0x1070
testq %rax, %rax
jne 0x15e7
leaq 0x7cac(%rip), %rdi      # 0x928e
callq 0x81ee
movq %r12, %rdi
callq 0x1050
subq $0x8, %rsp
movq 0x70(%rsp), %r13
movq %r13, %rdi
movl %r15d, %esi
movq %r12, %rdx
movl %ebx, %ecx
movl %ebp, %r8d
movq %r12, %r9
pushq 0x38(%rsp)
pushq 0x48(%rsp)
pushq 0x38(%rsp)
pushq 0x48(%rsp)
pushq %r14
pushq 0x90(%rsp)
pushq %rax
callq 0x39f3
addq $0x40, %rsp
movq %r12, %rdi
callq 0x1030
leaq 0x50(%rsp), %rdi
callq 0x8458
leaq 0x40(%rsp), %rdi
callq 0x8458
leaq 0x8(%rsp), %rdi
callq 0x8458
movq %r13, %rdi
movq %r15, %rsi
callq 0x82e6
pushq $0xa
popq %rdi
callq 0x1040
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)