// File: /workspace/github_cpp_makefile_star2_O1/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 $0xa8, %rsp
movl %esi, %ebp
movq %rdi, %r14
leaq 0x3c0a(%rip), %rdi      # 0xe08c
leaq 0x3c0c(%rip), %rsi      # 0xe095
callq 0x2260
movq %rax, %rbx
movq %rax, %rdi
callq 0x2220
leaq 0x6c(%rsp), %r12
movl %eax, %edi
movq %r12, %rsi
callq 0x2230
leaq 0x28(%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 0x3b9c(%rip), %rdi      # 0xe098
movq %rbx, %rsi
callq 0x2240
leaq 0x10(%r14), %r13
movq %r13, (%r14)
movq $0x0, 0x8(%r14)
movb $0x0, 0x10(%r14)
movq %rbx, %rdi
callq 0x2310
cmpl $-0x1, %eax
je 0xa537
cmpl $0xa, %eax
je 0xa537
movsbl %al, %esi
movq %r14, %rdi
callq 0x2180
jmp 0xa518
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2280
testb %bpl, %bpl
je 0xa5e5
leaq 0x3b4e(%rip), %rdi      # 0xe0a2
movq %rbx, %rsi
callq 0x2240
leaq 0x10(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq $0x0, -0x8(%rbp)
movb $0x0, (%rbp)
movq %rsp, %r12
movq %rbx, %rdi
callq 0x2310
cmpl $-0x1, %eax
je 0xa593
cmpl $0xa, %eax
je 0xa593
movsbl %al, %esi
movq %r12, %rdi
callq 0x2180
jmp 0xa574
movl $0xa, %edi
movq %rbx, %rsi
callq 0x2280
movq 0x8(%r14), %rdx
movq 0x8(%rsp), %r12
cmpq %r12, %rdx
jne 0xa618
testq %rdx, %rdx
je 0xa5c3
movq (%rsp), %rsi
movq (%r14), %rdi
callq 0x2200
testl %eax, %eax
jne 0xa618
movq (%rsp), %rdi
movq %r12, %rsi
callq 0x2603
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0xa5e5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x20(%rsp), %rdi
callq 0x2220
movl %eax, %edi
xorl %esi, %esi
movq %r15, %rdx
callq 0x2290
movq %rbx, %rdi
callq 0x21d0
movq %r14, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x20f0
movq %rax, %r12
leaq 0x3a88(%rip), %rsi      # 0xe0b4
movq %rax, %rdi
callq 0x20b0
movq 0x79b5(%rip), %rsi      # 0x11ff0
movq 0x796e(%rip), %rdx      # 0x11fb0
movq %r12, %rdi
callq 0x2360
movq %rax, %r15
movq %r12, %rdi
callq 0x2160
jmp 0xa65c
jmp 0xa659
movq %rax, %r15
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0xa677
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0xa677
movq %rax, %r15
movq (%r14), %rdi
cmpq %r13, %rdi
je 0xa68b
movq (%r13), %rsi
incq %rsi
callq 0x21f0
leaq 0x20(%rsp), %rdi
callq 0xa6a6
movq %rbx, %rdi
callq 0x21d0
movq %r15, %rdi
callq 0x2380
nop