// File: /workspace/github_cpp_makefile_star2_O3/occivink[P]pyct/pyct.cpp
// Function: ask_pass[abi:cxx11](bool)
string ask_pass(bool confirm) {
    FILE* in;
    FILE* out;
    out = in = fopen("/dev/tty", "w+");
    auto close = on_scope_end([in] { fclose(in); });

    // literally caveman-tier shit
    termios t;
    tcgetattr(fileno(in), &t);
    auto show_input = on_scope_end([in, t] { tcsetattr(fileno(in), TCSANOW, &t); });
    t.c_lflag &= ~ECHO;
    tcsetattr(fileno(in), TCSANOW, &t);

    auto get_pass = [in, out](const char* prompt){
        fprintf(out, "%s", prompt);
        string s;
        while (true) {
            auto c = fgetc(in);
            if (c == '\n' or c == EOF)
                break;
            s.push_back(static_cast<char>(c));
        }
        fprintf(out, "\n");
        return s;
    };
    auto pass = get_pass("Password:");
    if (confirm) {
        auto pass2 = get_pass("Confirm password:");
        if (pass != pass2)
            throw runtime_error{"Passwords do not match"};
        crypto_wipe(&pass2[0], pass2.size());
    }
    return pass;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %esi, %ebp
movq %rdi, %r14
leaq 0x3a11(%rip), %rdi      # 0xe09c
leaq 0x3a13(%rip), %rsi      # 0xe0a5
callq 0x2260
movq %rax, %rbx
movq %rax, %rdi
callq 0x2220
leaq 0x7c(%rsp), %r12
movl %eax, %edi
movq %r12, %rsi
callq 0x2230
leaq 0x38(%rsp), %r15
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups 0x20(%r12), %xmm2
movups 0x2c(%r12), %xmm3
movups %xmm3, 0x2c(%r15)
movups %xmm2, 0x20(%r15)
movups %xmm1, 0x10(%r15)
movups %xmm0, (%r15)
movq %rbx, -0x8(%r15)
andb $-0x9, 0xc(%r12)
movq %rbx, %rdi
callq 0x2220
movl %eax, %edi
xorl %esi, %esi
movq %r12, %rdx
callq 0x2290
leaq 0x39a3(%rip), %rdi      # 0xe0a8
movq %rbx, %rsi
callq 0x2240
leaq 0x10(%r14), %r12
movq %r12, (%r14)
movq $0x0, 0x8(%r14)
movb $0x0, 0x10(%r14)
movq %rbx, %rdi
callq 0x2310
cmpl $-0x1, %eax
je 0xa740
cmpl $0xa, %eax
je 0xa740
movsbl %al, %esi
movq %r14, %rdi
callq 0x2180
jmp 0xa721
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2280
testb %bpl, %bpl
je 0xa7f9
movq %r12, 0x8(%rsp)
leaq 0x3950(%rip), %rdi      # 0xe0b2
movq %rbx, %rsi
callq 0x2240
leaq 0x20(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq $0x0, -0x8(%rbp)
movb $0x0, (%rbp)
leaq 0x10(%rsp), %r12
movq %rbx, %rdi
callq 0x2310
cmpl $-0x1, %eax
je 0xa7a3
cmpl $0xa, %eax
je 0xa7a3
movsbl %al, %esi
movq %r12, %rdi
callq 0x2180
jmp 0xa784
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2280
movq 0x8(%r14), %r12
cmpq 0x18(%rsp), %r12
jne 0xa82c
movq 0x10(%rsp), %r13
testq %r12, %r12
je 0xa7d7
movq (%r14), %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2200
testl %eax, %eax
jne 0xa82c
movq %r13, %rdi
movq %r12, %rsi
callq 0x25ae
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0xa7f9
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x30(%rsp), %rdi
callq 0x2220
movl %eax, %edi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2290
movq %rbx, %rdi
callq 0x21d0
movq %r14, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x20f0
movq %rax, %r12
leaq 0x3884(%rip), %rsi      # 0xe0c4
movq %rax, %rdi
callq 0x20b0
movq 0x77a1(%rip), %rsi      # 0x11ff0
movq 0x775a(%rip), %rdx      # 0x11fb0
movq %r12, %rdi
callq 0x2360
movq %rax, %r15
movq %r12, %rdi
callq 0x2160
jmp 0xa870
jmp 0xa86d
movq %rax, %r15
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0xa887
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
movq (%r14), %rdi
cmpq 0x8(%rsp), %rdi
jne 0xa8a3
jmp 0xa8b3
movq %rax, %r15
movq (%r14), %rdi
movq %r12, 0x8(%rsp)
cmpq %r12, %rdi
je 0xa8b3
movq 0x8(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x21f0
leaq 0x30(%rsp), %rdi
callq 0xa8ce
movq %rbx, %rdi
callq 0x21d0
movq %r15, %rdi
callq 0x2380
nop