// File: 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
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x158(%rbp)
movb %sil, %al
movq %rdi, %rcx
movq %rcx, -0x150(%rbp)
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
leaq 0x8f4d(%rip), %rdi      # 0x1d13c
leaq 0x8f4f(%rip), %rsi      # 0x1d145
callq 0x3390
movq %rax, -0x18(%rbp)
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x144c0
movq -0x18(%rbp), %rdi
callq 0x3330
movl %eax, %edi
leaq -0x6c(%rbp), %rsi
callq 0x3380
movq -0x18(%rbp), %rax
movq %rax, -0x100(%rbp)
movups -0x6c(%rbp), %xmm0
movups -0x5c(%rbp), %xmm1
movups -0x4c(%rbp), %xmm2
movups -0x40(%rbp), %xmm3
movups %xmm3, -0xcc(%rbp)
movups %xmm2, -0xd8(%rbp)
movups %xmm1, -0xe8(%rbp)
movups %xmm0, -0xf8(%rbp)
movq -0xc0(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x40(%rax)
movups -0x100(%rbp), %xmm0
movups -0xf0(%rbp), %xmm1
movups -0xe0(%rbp), %xmm2
movups -0xd0(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0xb8(%rbp), %rdi
callq 0x14500
jmp 0x142aa
movb -0x60(%rbp), %al
andb $-0x9, %al
movb %al, -0x60(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3330
movl %eax, %edi
xorl %esi, %esi
leaq -0x6c(%rbp), %rdx
callq 0x33c0
movq -0x158(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x118(%rbp)
movb $0x0, -0x121(%rbp)
leaq 0x8e55(%rip), %rdx      # 0x1d148
leaq -0x120(%rbp), %rsi
callq 0x14570
jmp 0x14301
testb $0x1, -0x9(%rbp)
je 0x14452
leaq 0x8e40(%rip), %rdx      # 0x1d152
leaq -0x148(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x14570
jmp 0x14327
movq -0x158(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x17270
testb $0x1, %al
jne 0x14343
jmp 0x14400
movl $0x10, %edi
callq 0x3140
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x160(%rbp)
leaq 0x8e03(%rip), %rsi      # 0x1d164
callq 0x30c0
jmp 0x14368
movq -0x160(%rbp), %rdi
movq 0xfc7a(%rip), %rsi      # 0x23ff0
movq 0xfc23(%rip), %rdx      # 0x23fa0
callq 0x34c0
jmp 0x144c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x144ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x1449f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x14493
movq -0x160(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
callq 0x3200
jmp 0x14444
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x14444
xorl %eax, %eax
movl %eax, %esi
leaq -0x148(%rbp), %rdi
callq 0x3560
movq %rax, -0x168(%rbp)
jmp 0x14419
leaq -0x148(%rbp), %rdi
callq 0x31e0
movq -0x168(%rbp), %rdi
movq %rax, %rsi
callq 0x3890
jmp 0x14436
leaq -0x148(%rbp), %rdi
callq 0x31b0
jmp 0x14452
leaq -0x148(%rbp), %rdi
callq 0x31b0
jmp 0x14493
movb $0x1, -0x121(%rbp)
testb $0x1, -0x121(%rbp)
jne 0x1446e
movq -0x158(%rbp), %rdi
callq 0x31b0
leaq -0xb8(%rbp), %rdi
callq 0x14650
leaq -0x28(%rbp), %rdi
callq 0x14680
movq -0x150(%rbp), %rax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq -0x158(%rbp), %rdi
callq 0x31b0
leaq -0xb8(%rbp), %rdi
callq 0x14650
leaq -0x28(%rbp), %rdi
callq 0x14680
movq -0x108(%rbp), %rdi
callq 0x34f0