// File: /workspace/github_cpp_makefile_star2_O1/occivink[P]pyct/pyct.cpp
// Function: main
int main(int argc, char** argv) {
    try {
        const auto args = parse_args(argc, argv);
        if (args.help) {
            print_help();
            return 0;
        }
        auto get_hash = [&args](bool confirm) {
            if (args.hash)
                return *args.hash;
            string password;
            if (args.password)
                password =  *args.password;
            else if (args.interactive)
                password = ask_pass(confirm);
            else
                throw invalid_argument{"Either hash or password must be provided in non-interactive mode"};
            const auto salt = args.salt.value_or("86627104");
            return hash_password(password, salt,
                args.iterations.value_or((u64)10),
                args.work_area_size.value_or((u64)1024*1024*128));
        };

        if (args.operation == Args::Operation::Encrypt) {
            const auto hash = get_hash(args.confirm);
            auto input = read_from_fd<vector<u8>>(args.input_data_fd);
            const auto encrypted = encrypt(move(input), args.padded_length, hash);
            if (args.base64) {
                cout << to_base_64(encrypted) << endl;
            } else {
                copy_n(reinterpret_cast<const u8*>(encrypted.data()), encrypted.size(), ostreambuf_iterator<char>(cout));
            }
        } else if (args.operation == Args::Operation::Decrypt) {
            const auto hash = get_hash(false);
            vector<u8> input = args.base64 ?
                from_base_64(read_from_fd<string>(args.input_data_fd)) :
                read_from_fd<vector<u8>>(args.input_data_fd);
            const auto decrypted = decrypt(move(input), hash);
            copy_n(reinterpret_cast<const u8*>(decrypted.data()), decrypted.size(), ostreambuf_iterator<char>(cout));
        } else if (args.operation == Args::Operation::Hash) {
            cout << to_base_64(get_hash(args.confirm)) << endl;
        }
    } catch (const exception& e) {
        cerr << e.what() << endl;
        return 1;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %rdx
movl %edi, %esi
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
callq 0xaa80
cmpb $0x1, 0xd4(%rsp)
jne 0xb8c1
callq 0xb69e
jmp 0xbbfe
movq %rbx, 0x40(%rsp)
movl 0xd0(%rsp), %eax
cmpl $0x2, %eax
je 0xba41
cmpl $0x1, %eax
je 0xb9f5
testl %eax, %eax
jne 0xbbfe
movzbl 0xd7(%rsp), %edx
leaq 0x48(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xbdfe
movl 0xd8(%rsp), %esi
leaq 0x20(%rsp), %rdi
callq 0xc4cd
movq 0x20(%rsp), %rax
leaq 0xa8(%rsp), %r15
movq %rax, -0x10(%r15)
movups 0x28(%rsp), %xmm0
movups %xmm0, -0x8(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
leaq 0x178(%rsp), %rdx
leaq 0x68(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x48(%rsp), %rcx
callq 0xa842
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0xb977
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
cmpb $0x1, 0xd5(%rsp)
jne 0xbb9e
movq %rsp, %rdi
leaq 0x68(%rsp), %rsi
callq 0xc628
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x6616(%rip), %rdi      # 0x11fb8
callq 0x2250
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbbd0
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0xbbd0
leaq 0x48(%rsp), %rdi
leaq 0x40(%rsp), %rsi
xorl %edx, %edx
callq 0xbdfe
movb 0xd5(%rsp), %bpl
movl 0xd8(%rsp), %esi
cmpb $0x1, %bpl
jne 0xbac2
leaq 0xb0(%rsp), %rdi
callq 0xc217
movq %rsp, %rdi
leaq 0xb0(%rsp), %rsi
callq 0xa003
jmp 0xbaca
movzbl 0xd7(%rsp), %edx
movq %rsp, %rdi
leaq 0x40(%rsp), %rsi
callq 0xbdfe
leaq 0x48(%rsp), %rdi
movq %rsp, %rsi
callq 0xc830
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x6544(%rip), %rdi      # 0x11fb8
callq 0x2250
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbbfe
movq 0x58(%rsp), %rsi
incq %rsi
jmp 0xbbf9
movq %rsp, %rdi
callq 0xc4cd
testb %bpl, %bpl
je 0xbaf0
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbaf0
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x21f0
movq (%rsp), %rax
leaq 0x80(%rsp), %rsi
movq %rax, (%rsi)
movups 0x8(%rsp), %xmm0
movups %xmm0, 0x8(%rsi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0xa99d
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xbb44
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x20(%rsp), %r15
movq 0x28(%rsp), %rsi
cmpq %r15, %rsi
je 0xbb79
movq 0x645e(%rip), %rax      # 0x11fb8
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq 0xe8(%rax,%rcx), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
sete %cl
movq %r15, %rdi
callq 0xcd48
testq %r15, %r15
je 0xbb8e
movq 0x30(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x21f0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xbbfe
movq 0x10(%rsp), %rsi
jmp 0xbbf6
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rsi
cmpq %rdi, %rsi
je 0xbbd0
movq 0x6404(%rip), %rax      # 0x11fb8
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq 0xe8(%rax,%rcx), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
sete %cl
callq 0xcd48
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbbe7
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xbbfe
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
cmpb $0x1, 0x170(%rsp)
jne 0xbc2d
leaq 0x160(%rsp), %rax
movb $0x0, 0x10(%rax)
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbc2d
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpb $0x1, 0x120(%rsp)
jne 0xbc5c
leaq 0x110(%rsp), %rax
movb $0x0, 0x10(%rax)
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbc5c
movq 0x110(%rsp), %rsi
incq %rsi
callq 0x21f0
xorl %eax, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0xbc6e
movq %rdx, %r14
movq %rax, %rbx
jmp 0xbd3a
jmp 0xbd8d
movq %rdx, %r14
movq %rax, %rbx
testq %r15, %r15
je 0xbcb9
movq 0x30(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
jmp 0xbcb4
movq %rdx, %r14
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xbcb9
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xbd93
movq 0x10(%rsp), %rsi
jmp 0xbd63
movq %rdx, %r14
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
jne 0xbd49
jmp 0xbd54
movq %rdx, %r14
movq %rax, %rbx
testb %bpl, %bpl
je 0xbd93
leaq 0xc0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbd93
movq 0xc0(%rsp), %rsi
jmp 0xbd83
jmp 0xbd8d
jmp 0xbd8d
jmp 0xbd8d
movq %rdx, %r14
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbd3a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbd54
leaq 0x78(%rsp), %r15
movq (%r15), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xbd93
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
jmp 0xbd86
jmp 0xbd8d
movq %rdx, %r14
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbd93
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0xbd93
movq %rdx, %r14
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0xc476
jmp 0xbda8
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0xbded
movq %rbx, %rdi
callq 0x20c0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x6222(%rip), %rdi      # 0x11fe8
movq %rax, %rsi
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
callq 0x2340
movl $0x1, %eax
jmp 0xbc5e
movq %rax, %rbx
callq 0x2340
movq %rbx, %rdi
callq 0x2380
movq %rax, %rdi
callq 0xc388
nop