// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movq %rsi, %rdx
movl %edi, %esi
leaq 0xd8(%rsp), %rbx
movq %rbx, %rdi
callq 0xac93
cmpb $0x1, 0xdc(%rsp)
jne 0xba66
callq 0xb844
jmp 0xbd9d
movq %rbx, 0x40(%rsp)
movl 0xd8(%rsp), %eax
cmpl $0x2, %eax
je 0xbc06
cmpl $0x1, %eax
je 0xbb99
testl %eax, %eax
jne 0xbd9d
movzbl 0xdf(%rsp), %edx
leaq 0x48(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xbf98
movl 0xe0(%rsp), %esi
leaq 0x20(%rsp), %rdi
callq 0xc5ff
movaps 0x20(%rsp), %xmm0
leaq 0xb0(%rsp), %r15
movaps %xmm0, -0x10(%r15)
movq 0x30(%rsp), %rax
movq %rax, (%r15)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
leaq 0x180(%rsp), %rdx
leaq 0x68(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
leaq 0x48(%rsp), %rcx
callq 0xaa6a
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0xbb1b
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
cmpb $0x1, 0xdd(%rsp)
jne 0xbd3d
movq %rsp, %rdi
leaq 0x68(%rsp), %rsi
callq 0xc6f4
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x6472(%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 0xbd6f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0xbd6f
leaq 0x48(%rsp), %rdi
leaq 0x40(%rsp), %rsi
xorl %edx, %edx
callq 0xbf98
movl 0xe0(%rsp), %esi
cmpb $0x1, 0xdd(%rsp)
jne 0xbc87
leaq 0xb8(%rsp), %rdi
callq 0xc3ad
movq %rsp, %rdi
leaq 0xb8(%rsp), %rsi
callq 0xa1ed
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbc8f
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0xbc8f
movzbl 0xdf(%rsp), %edx
movq %rsp, %rdi
leaq 0x40(%rsp), %rsi
callq 0xbf98
leaq 0x48(%rsp), %rdi
movq %rsp, %rsi
callq 0xc8ed
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x637f(%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 0xbd9d
movq 0x58(%rsp), %rsi
incq %rsi
jmp 0xbd98
movq %rsp, %rdi
callq 0xc5ff
movaps (%rsp), %xmm0
leaq 0x80(%rsp), %rsi
movaps %xmm0, (%rsi)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rsi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0xabb7
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xbce3
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x20(%rsp), %r15
movq 0x28(%rsp), %rsi
cmpq %r15, %rsi
je 0xbd18
movq 0x62bf(%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 0xce0c
testq %r15, %r15
je 0xbd2d
movq 0x30(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x21f0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xbd9d
movq 0x10(%rsp), %rsi
jmp 0xbd95
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rsi
cmpq %rdi, %rsi
je 0xbd74
movq 0x6265(%rip), %rax      # 0x11fb8
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq 0xe8(%rax,%rcx), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
sete %cl
callq 0xce0c
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbd86
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xbd9d
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
cmpb $0x1, 0x178(%rsp)
jne 0xbdcc
leaq 0x168(%rsp), %rax
movb $0x0, 0x10(%rax)
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbdcc
movq 0x168(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpb $0x1, 0x128(%rsp)
jne 0xbdfb
leaq 0x118(%rsp), %rax
movb $0x0, 0x10(%rax)
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbdfb
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x21f0
xorl %eax, %eax
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %r15
retq
jmp 0xbe0c
movq %rdx, %r14
movq %rax, %rbx
jmp 0xbed4
movq %rdx, %r14
movq %rax, %rbx
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbf2d
movq 0xc8(%rsp), %rsi
jmp 0xbf1d
jmp 0xbf27
jmp 0xbf27
movq %rdx, %r14
movq %rax, %rbx
testq %r15, %r15
je 0xbe84
movq 0x30(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
jmp 0xbe7f
movq %rdx, %r14
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0xbe84
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21f0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0xbf2d
movq 0x10(%rsp), %rsi
jmp 0xbefd
movq %rdx, %r14
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
jne 0xbee3
jmp 0xbeee
jmp 0xbf27
jmp 0xbf27
jmp 0xbf27
movq %rdx, %r14
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbed4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0xbeee
leaq 0x78(%rsp), %r15
movq (%r15), %rsi
subq %rdi, %rsi
callq 0x21f0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xbf2d
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
jmp 0xbf20
jmp 0xbf27
movq %rdx, %r14
movq %rax, %rbx
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xbf2d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0xbf2d
movq %rdx, %r14
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0xc5a8
jmp 0xbf42
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0xbf87
movq %rbx, %rdi
callq 0x20c0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x6088(%rip), %rdi      # 0x11fe8
movq %rax, %rsi
callq 0x21c0
movq %rax, %rdi
callq 0x20e0
callq 0x2340
movl $0x1, %eax
jmp 0xbdfd
movq %rax, %rbx
callq 0x2340
movq %rbx, %rdi
callq 0x2380
movq %rax, %rdi
callq 0xc4bb
nop