// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rsi, %rdx
movl %edi, %esi
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
callq 0x9d98
cmpb $0x1, 0xf4(%rsp)
jne 0xa83a
callq 0xa68e
jmp 0xaa9e
movq %rbx, 0x8(%rsp)
movl 0xf0(%rsp), %eax
cmpl $0x2, %eax
je 0xa972
cmpl $0x1, %eax
je 0xa922
testl %eax, %eax
jne 0xaa9e
movzbl 0xf7(%rsp), %edx
leaq 0x58(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xabb2
movl 0xf8(%rsp), %esi
leaq 0x10(%rsp), %rdi
callq 0xb0bf
movaps 0x10(%rsp), %xmm0
leaq 0xd0(%rsp), %r15
movaps %xmm0, (%r15)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
leaq 0x198(%rsp), %rdx
leaq 0x78(%rsp), %r12
leaq 0x58(%rsp), %rcx
movq %r12, %rdi
movq %r15, %rsi
callq 0x9b83
leaq 0xd0(%rsp), %rdi
callq 0xb73e
cmpb $0x1, 0xf5(%rsp)
jne 0xaa57
leaq 0x30(%rsp), %rdi
leaq 0x78(%rsp), %r15
movq %r15, %rsi
callq 0xb1a1
movq 0x76a7(%rip), %rdi      # 0x11fa8
leaq 0x30(%rsp), %rsi
callq 0x21a0
movq %rax, %rdi
callq 0x20f0
leaq 0x30(%rsp), %rdi
callq 0x20e0
jmp 0xaa8a
leaq 0x58(%rsp), %rdi
leaq 0x8(%rsp), %rsi
xorl %edx, %edx
callq 0xabb2
movl 0xf8(%rsp), %esi
cmpb $0x1, 0xf5(%rsp)
jne 0xa9c0
leaq 0x90(%rsp), %rdi
callq 0xaf18
leaq 0x30(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x93db
leaq 0x90(%rsp), %rdi
callq 0x20e0
jmp 0xa9ca
movzbl 0xf7(%rsp), %edx
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xabb2
leaq 0x58(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xb396
movq 0x7609(%rip), %rdi      # 0x11fa8
leaq 0x58(%rsp), %rsi
callq 0x21a0
movq %rax, %rdi
callq 0x20f0
leaq 0x58(%rsp), %rdi
callq 0x20e0
jmp 0xaa9e
leaq 0x30(%rsp), %rdi
callq 0xb0bf
movaps 0x30(%rsp), %xmm0
leaq 0xb0(%rsp), %r12
movaps %xmm0, (%r12)
movq 0x40(%rsp), %rax
movq %rax, 0x10(%r12)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
leaq 0x10(%rsp), %r15
leaq 0x58(%rsp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x9cc3
leaq 0xb0(%rsp), %rdi
callq 0xb73e
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
movq 0x757e(%rip), %rax      # 0x11fa8
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq 0xe8(%rax,%rcx), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
sete %cl
callq 0xb376
leaq 0x10(%rsp), %rdi
callq 0xb73e
leaq 0x30(%rsp), %rdi
jmp 0xaa99
movq 0x78(%rsp), %rdi
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
movq 0x753a(%rip), %rax      # 0x11fa8
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq 0xe8(%rax,%rcx), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
sete %cl
callq 0xb376
leaq 0x78(%rsp), %rdi
callq 0xb73e
leaq 0x10(%rsp), %rdi
callq 0xb73e
leaq 0xf0(%rsp), %rdi
callq 0xb0a2
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rdx, %r14
movq %rax, %rbx
movq %r12, %r15
jmp 0xab15
jmp 0xab0f
movq %rdx, %r14
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0xab3a
jmp 0xab43
jmp 0xab43
movq %rdx, %r14
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x20e0
jmp 0xab15
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %r12
jmp 0xab00
movq %rdx, %r14
movq %rax, %rbx
movq %r12, %rdi
callq 0xb73e
leaq 0x30(%rsp), %rdi
jmp 0xab22
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0xb73e
leaq 0x10(%rsp), %rdi
callq 0xb73e
jmp 0xab49
jmp 0xab43
jmp 0xab43
jmp 0xab43
movq %rdx, %r14
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x20e0
jmp 0xab49
jmp 0xab43
movq %rdx, %r14
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0xb0a2
jmp 0xab5e
movq %rdx, %r14
movq %rax, %rbx
cmpl $0x1, %r14d
jne 0xaba1
movq %rbx, %rdi
callq 0x20a0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x746c(%rip), %rdi      # 0x11fe8
movq %rax, %rsi
callq 0x21c0
movq %rax, %rdi
callq 0x20f0
callq 0x2340
pushq $0x1
popq %rax
jmp 0xaaad
movq %rax, %rbx
callq 0x2340
movq %rbx, %rdi
callq 0x2380
movq %rax, %rdi
callq 0xafff
nop