// File: /workspace/github_cpp_makefile_star2_O1/occivink[P]pyct/pyct.cpp
// Function: parse_args(int, char**)
Args parse_args(int argc, char** argv) {
    argc--;
    argv++;
    Args args;
    if (argc == 0)
        throw invalid_argument{"Missing operation"};
    string op(argv[0]);
    if (op == "-h" or op == "--help") {
        args.help = true;
        return args;
    }
    const auto is_prefix = [](const string& pre, const string& s) {
        return pre.size() <= s.size() and equal(pre.begin(), pre.end(), s.begin());
    };
    if (is_prefix(op, "encrypt"))
        args.operation = Args::Operation::Encrypt;
    else if (is_prefix(op, "decrypt"))
        args.operation = Args::Operation::Decrypt;
    else if (is_prefix(op, "hash"))
        args.operation = Args::Operation::Hash;
    else
        throw invalid_argument{"Invalid operation"};

    auto option_value = [argc, argv](int i) {
        if (i >= argc)
            throw invalid_argument{"Missing option value"};
        return string(argv[i]);
    };
    for (int i = 1; i < argc; ++i) {
        string arg(argv[i]);
        if (arg == "-h" or arg == "--help") {
            args.help = true;
        } else if (arg == "-b" or arg == "--base-64") {
            args.base64 = true;
        } else if (arg == "--non-interactive") {
            args.interactive = false;
        } else if (arg == "--no-confirm") {
            args.confirm = false;
        } else if (arg == "--iterations") {
            args.iterations = stoi(option_value(++i));
        } else if (arg == "--work-area-size") {
            args.work_area_size = size_to_number(option_value(++i));
        } else if (arg == "--hash-fd") {
            auto fd = stoi(option_value(++i));
            vector<u8> hash;
            try {
                hash = from_base_64(read_from_fd<string>(fd));
            } catch(...) {
                throw invalid_argument{"Invalid hash"};
            }
            if (hash.size() != 32)
                throw invalid_argument{"Hash is not the correct size"};
            args.hash.emplace();
            copy(hash.begin(), hash.end(), args.hash->begin());
        } else if (arg == "--pass-fd") {
            auto fd = stoi(option_value(++i));
            args.password = read_from_fd<string>(fd);
        } else if (arg == "--input-data-fd") {
            auto fd = stoi(option_value(++i));
            args.input_data_fd = fd;
        } else if (arg == "-s" or arg == "--salt") {
            args.salt = option_value(++i);
            if (args.salt->size() < 8)
                throw invalid_argument{"Salt is too small"};
        } else if (arg == "-l" or arg == "--padded-length") {
            args.padded_length = size_to_number(option_value(++i));
        } else {
            throw invalid_argument{"Unrecognized argument: " + arg};
        }
    }
    if (args.hash and args.password)
        throw invalid_argument{"Can only provide one of hash and password at once"};
    else if (args.operation != Args::Operation::Encrypt and args.padded_length)
        throw invalid_argument{"Can only pad when encrypting"};
    return args;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %r12
xorl %eax, %eax
movl %esi, %ebx
movq $0x1010000, 0x4(%rdi)   # imm = 0x1010000
movb %al, 0x18(%rdi)
movb %al, 0x28(%rdi)
movb %al, 0x50(%rdi)
movb %al, 0x78(%rdi)
movb %al, 0xa0(%rdi)
movb %al, 0xb0(%rdi)
decl %ebx
je 0xb225
movq %rdx, %r14
movl %esi, %ebp
addq $0x8, %r14
movq (%r14), %rsi
leaq 0x70(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0xc148
leaq 0x3695(%rip), %rsi      # 0xe177
leaq 0x70(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0xab37
leaq 0x3683(%rip), %rsi      # 0xe17a
leaq 0x70(%rsp), %rdi
callq 0x2070
testl %eax, %eax
je 0xab37
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x366c(%rip), %rsi      # 0xe181
leaq 0x366c(%rip), %rdx      # 0xe188
leaq 0x30(%rsp), %rdi
callq 0xc96e
movq 0x78(%rsp), %rdx
cmpq 0x38(%rsp), %rdx
jbe 0xab42
xorl %r15d, %r15d
jmp 0xab61
movb $0x1, 0x4(%r12)
jmp 0xb1ef
testq %rdx, %rdx
je 0xab5e
movq 0x70(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x2200
testl %eax, %eax
sete %r15b
jmp 0xab61
movb $0x1, %r15b
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xab7d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
xorl %eax, %eax
testb %r15b, %r15b
jne 0xac78
leaq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
movq %rax, (%rdi)
leaq 0x35ed(%rip), %rsi      # 0xe189
leaq 0x35ed(%rip), %rdx      # 0xe190
callq 0xc96e
movq 0x78(%rsp), %rdx
cmpq 0x38(%rsp), %rdx
jbe 0xabb9
xorl %r15d, %r15d
jmp 0xabd8
testq %rdx, %rdx
je 0xabd5
movq 0x70(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x2200
testl %eax, %eax
sete %r15b
jmp 0xabd8
movb $0x1, %r15b
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xabf4
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
movl $0x1, %eax
testb %r15b, %r15b
jne 0xac78
leaq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
movq %rax, (%rdi)
leaq 0x35ed(%rip), %rsi      # 0xe1ff
leaq 0x35ea(%rip), %rdx      # 0xe203
callq 0xc96e
movq 0x78(%rsp), %rdx
cmpq 0x38(%rsp), %rdx
jbe 0xac2f
xorl %r15d, %r15d
jmp 0xac4e
testq %rdx, %rdx
je 0xac4b
movq 0x70(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x2200
testl %eax, %eax
sete %r15b
jmp 0xac4e
movb $0x1, %r15b
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xac6a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
movl $0x2, %eax
testb %r15b, %r15b
je 0xb305
movl %eax, (%r12)
movl %ebx, 0x50(%rsp)
movq %r14, 0x58(%rsp)
cmpl $0x3, %ebp
jl 0xb1c9
leaq 0x80(%r12), %rax
movq %rax, 0x98(%rsp)
leaq 0x30(%r12), %rax
movq %rax, 0xa0(%rsp)
leaq 0x58(%r12), %rax
movq %rax, 0x90(%rsp)
movl $0x1, %ebp
leaq 0x30(%rsp), %r15
movq %r12, 0x28(%rsp)
movslq %ebp, %rax
movq (%r14,%rax,8), %rsi
movq %r15, %rdi
movq %rsp, %rdx
callq 0xc148
movq %r15, %rdi
leaq 0x3494(%rip), %rsi      # 0xe177
callq 0x2070
testl %eax, %eax
je 0xae60
movq %r15, %rdi
leaq 0x3480(%rip), %rsi      # 0xe17a
callq 0x2070
testl %eax, %eax
je 0xae60
movq %r15, %rdi
leaq 0x3492(%rip), %rsi      # 0xe1a3
callq 0x2070
testl %eax, %eax
je 0xae68
movq %r15, %rdi
leaq 0x347e(%rip), %rsi      # 0xe1a6
callq 0x2070
testl %eax, %eax
je 0xae68
movq %r15, %rdi
leaq 0x3471(%rip), %rsi      # 0xe1b0
callq 0x2070
testl %eax, %eax
je 0xae99
movq %r15, %rdi
leaq 0x346c(%rip), %rsi      # 0xe1c2
callq 0x2070
testl %eax, %eax
je 0xaea1
movq %r15, %rdi
leaq 0x3462(%rip), %rsi      # 0xe1cf
callq 0x2070
testl %eax, %eax
je 0xaea9
movq %r15, %rdi
leaq 0x3458(%rip), %rsi      # 0xe1dc
callq 0x2070
testl %eax, %eax
je 0xaf4d
movq %r15, %rdi
leaq 0x3452(%rip), %rsi      # 0xe1ed
callq 0x2070
testl %eax, %eax
je 0xaf8d
movq %r15, %rdi
leaq 0x346f(%rip), %rsi      # 0xe221
callq 0x2070
testl %eax, %eax
je 0xb0ab
movq %r15, %rdi
leaq 0x3462(%rip), %rsi      # 0xe22b
callq 0x2070
testl %eax, %eax
je 0xb17e
movq %r15, %rdi
leaq 0x345b(%rip), %rsi      # 0xe23b
callq 0x2070
testl %eax, %eax
je 0xb12b
movq %r15, %rdi
leaq 0x3447(%rip), %rsi      # 0xe23e
callq 0x2070
testl %eax, %eax
je 0xb12b
movq %r15, %rdi
leaq 0x3449(%rip), %rsi      # 0xe257
callq 0x2070
testl %eax, %eax
je 0xae2e
movq %r15, %rdi
leaq 0x3439(%rip), %rsi      # 0xe25a
callq 0x2070
testl %eax, %eax
jne 0xb3e4
incl %ebp
movq %rsp, %r13
movq %r13, %rdi
leaq 0x50(%rsp), %rsi
movl %ebp, %edx
callq 0xb62e
movq %r13, %rdi
callq 0x9cc4
movq %rax, 0xa8(%r12)
movb $0x1, 0xb0(%r12)
jmp 0xb107
movb $0x1, 0x4(%r12)
jmp 0xae6e
movb $0x1, 0x5(%r12)
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xae8a
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
incl %ebp
cmpl %ebx, %ebp
jl 0xacc7
jmp 0xb1c9
movb $0x0, 0x6(%r12)
jmp 0xae6e
movb $0x0, 0x7(%r12)
jmp 0xae6e
incl %ebp
cmpl %ebp, 0x50(%rsp)
jle 0xb2bb
movq 0x58(%rsp), %rax
movslq %ebp, %rcx
movq (%rax,%rcx,8), %rsi
movq %rsp, %rdi
leaq 0x68(%rsp), %rdx
callq 0xc148
movq (%rsp), %r12
callq 0x2040
movq %rax, %r13
movl (%rax), %eax
movl %eax, 0x60(%rsp)
movl $0x0, (%r13)
movq %r12, %rdi
leaq 0x68(%rsp), %rsi
movl $0xa, %edx
callq 0x22c0
cmpq %r12, 0x68(%rsp)
je 0xb2f9
movslq %eax, %rcx
cmpq %rax, %rcx
movq 0x28(%rsp), %r12
jne 0xb2ed
movl (%r13), %ecx
cmpl $0x22, %ecx
je 0xb2ed
testl %ecx, %ecx
jne 0xaf2f
movl 0x60(%rsp), %ecx
movl %ecx, (%r13)
cltq
movq %rax, 0x10(%r12)
cmpb $0x0, 0x18(%r12)
jne 0xb107
movb $0x1, 0x18(%r12)
jmp 0xb107
incl %ebp
cmpl %ebp, 0x50(%rsp)
jle 0xb341
movq 0x58(%rsp), %rax
movslq %ebp, %rcx
movq (%rax,%rcx,8), %rsi
movq %rsp, %r13
movq %r13, %rdi
leaq 0x68(%rsp), %rdx
callq 0xc148
movq %r13, %rdi
callq 0x9cc4
movq %rax, 0x20(%r12)
movb $0x1, 0x28(%r12)
jmp 0xb107
incl %ebp
movq %rsp, %r13
movq %r13, %rdi
leaq 0x50(%rsp), %rsi
movl %ebp, %edx
callq 0xb62e
movq %r13, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0xc185
movl %eax, %r13d
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xafce
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0xa8(%rsp), %rdi
movl %r13d, %esi
callq 0xc217
movq %rsp, %rdi
leaq 0xa8(%rsp), %rsi
callq 0xa003
movq (%rsp), %rsi
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r13
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xb041
movq %r13, 0x60(%rsp)
movq %rsi, %r13
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %r13, %rsi
movq 0x60(%rsp), %r13
movq %r12, %rdx
subq %rsi, %rdx
cmpq $0x20, %rdx
jne 0xb373
movq 0x28(%rsp), %rax
cmpb $0x1, 0x78(%rax)
movq 0x90(%rsp), %rcx
jne 0xb068
movb $0x0, 0x78(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rcx)
movups %xmm0, (%rcx)
movb $0x1, 0x78(%rax)
cmpq %rsi, %r12
je 0xb08e
movq 0x90(%rsp), %rdi
movq %rsi, %r12
callq 0x2330
movq %r12, %rsi
testq %rsi, %rsi
je 0xb0a1
subq %rsi, %r13
movq %rsi, %rdi
movq %r13, %rsi
callq 0x21f0
movq 0x28(%rsp), %r12
jmp 0xae6e
incl %ebp
movq %rsp, %r13
movq %r13, %rdi
leaq 0x50(%rsp), %rsi
movl %ebp, %edx
callq 0xb62e
movq %r13, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0xc185
movl %eax, %r13d
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xb0ec
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rsp, %rdi
movl %r13d, %esi
callq 0xc217
movq 0xa0(%rsp), %rdi
movq %rsp, %rsi
callq 0xc394
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xae6e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0xae6e
incl %ebp
movq %rsp, %r13
movq %r13, %rdi
leaq 0x50(%rsp), %rsi
movl %ebp, %edx
callq 0xb62e
movq 0x98(%rsp), %rdi
movq %r13, %rsi
callq 0xc394
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xb16a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpq $0x7, 0x88(%r12)
ja 0xae6e
jmp 0xb3ad
incl %ebp
movq %rsp, %r13
movq %r13, %rdi
leaq 0x50(%rsp), %rsi
movl %ebp, %edx
callq 0xb62e
movq %r13, %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0xc185
movl %eax, %r13d
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xb1bf
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movl %r13d, 0x8(%r12)
jmp 0xae6e
cmpb $0x0, 0x78(%r12)
je 0xb1dd
cmpb $0x1, 0x50(%r12)
je 0xb284
cmpl $0x0, (%r12)
je 0xb1ef
cmpb $0x1, 0xb0(%r12)
je 0xb261
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb210
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %r12, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, 0x28(%rsp)
movl $0x10, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x2f27(%rip), %rsi      # 0xe165
movq %rax, %rdi
callq 0x23a0
movq 0x6d83(%rip), %rsi      # 0x11fd0
movq 0x6d6c(%rip), %rdx      # 0x11fc0
movq %r15, %rdi
callq 0x2360
jmp 0xb526
movq %r12, 0x28(%rsp)
movl $0x10, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x303a(%rip), %rsi      # 0xe2b4
movq %rax, %rdi
callq 0x23a0
jmp 0xb2a5
movq %r12, 0x28(%rsp)
movl $0x10, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x2fe5(%rip), %rsi      # 0xe282
movq %rax, %rdi
callq 0x23a0
movq 0x6d24(%rip), %rsi      # 0x11fd0
movq 0x6d0d(%rip), %rdx      # 0x11fc0
movq %r15, %rdi
callq 0x2360
movl $0x10, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x35f3(%rip), %rsi      # 0xe8c2
movq %rax, %rdi
callq 0x23a0
movq 0x6cf2(%rip), %rsi      # 0x11fd0
movq 0x6cdb(%rip), %rdx      # 0x11fc0
movq %r15, %rdi
callq 0x2360
leaq 0x35c9(%rip), %rdi      # 0xe8bd
callq 0x22e0
leaq 0x35bd(%rip), %rdi      # 0xe8bd
callq 0x2130
movq %r12, 0x28(%rsp)
movl $0x10, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x2e73(%rip), %rsi      # 0xe191
movq %rax, %rdi
callq 0x23a0
movq 0x6ca3(%rip), %rsi      # 0x11fd0
movq 0x6c8c(%rip), %rdx      # 0x11fc0
movq %r15, %rdi
callq 0x2360
jmp 0xb526
movl $0x10, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x356d(%rip), %rsi      # 0xe8c2
movq %rax, %rdi
callq 0x23a0
movq 0x6c6c(%rip), %rsi      # 0x11fd0
movq 0x6c55(%rip), %rdx      # 0x11fc0
movq %r15, %rdi
callq 0x2360
movq %rsi, %rbx
movl $0x10, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x2e7a(%rip), %rsi      # 0xe204
movq %rax, %rdi
callq 0x23a0
movq 0x6c37(%rip), %rsi      # 0x11fd0
movq 0x6c20(%rip), %rdx      # 0x11fc0
movq %r15, %rdi
callq 0x2360
jmp 0xb526
movl $0x10, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x2e84(%rip), %rsi      # 0xe245
movq %rax, %rdi
callq 0x23a0
movq 0x6c00(%rip), %rsi      # 0x11fd0
movq 0x6be9(%rip), %rdx      # 0x11fc0
movq %r15, %rdi
callq 0x2360
jmp 0xb526
movl $0x10, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x2e72(%rip), %rsi      # 0xe26a
movq %rsp, %rdi
leaq 0x30(%rsp), %rdx
callq 0xc3ed
movb $0x1, %bl
movq %rsp, %rsi
movq %r15, %rdi
callq 0x2370
xorl %ebx, %ebx
movq 0x6bb5(%rip), %rsi      # 0x11fd0
movq 0x6b9e(%rip), %rdx      # 0x11fc0
movq %r15, %rdi
callq 0x2360
jmp 0xb526
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xb454
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0xb454
movq %rax, %r14
movb $0x1, %bl
testb %bl, %bl
jne 0xb561
jmp 0xb5b9
jmp 0xb583
jmp 0xb55e
jmp 0xb56b
jmp 0xb583
jmp 0xb56b
jmp 0xb583
jmp 0xb583
movq %rax, %r14
jmp 0xb540
movq %rax, %r14
movq %r15, %rdi
callq 0x2160
jmp 0xb540
jmp 0xb583
jmp 0xb56b
jmp 0xb583
jmp 0xb583
jmp 0xb55e
jmp 0xb5f7
jmp 0xb576
movq %rax, %r14
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xb4ec
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0xb4ec
movq %rax, %r14
movq %r14, %rdi
callq 0x20c0
movl $0x10, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x2cef(%rip), %rsi      # 0xe1f7
movq %rax, %rdi
callq 0x23a0
movq 0x6ab9(%rip), %rsi      # 0x11fd0
movq 0x6aa2(%rip), %rdx      # 0x11fc0
movq %r15, %rdi
callq 0x2360
movq %rax, %r14
jmp 0xb536
movq %rax, %r14
movq %r15, %rdi
callq 0x2160
callq 0x2340
xorl %r13d, %r13d
xorl %ebx, %ebx
testq %rbx, %rbx
je 0xb5b9
movq %rbx, %rdi
subq %rbx, %r13
movq %r13, %rsi
jmp 0xb5b4
movq %rax, %rdi
callq 0xc388
jmp 0xb56b
jmp 0xb583
jmp 0xb583
movq %rax, %r14
movq %r15, %rdi
callq 0x2160
jmp 0xb5b9
movq %rax, %r14
jmp 0xb59e
jmp 0xb583
jmp 0xb576
jmp 0xb5d7
movq %rax, %r14
movq %r15, %rdi
callq 0x2160
jmp 0xb5fa
movq %rax, %r14
jmp 0xb5b9
jmp 0xb5d7
jmp 0xb5f7
movq %rax, %r14
cmpl $0x0, (%r13)
jne 0xb59e
movl 0x60(%rsp), %eax
movl %eax, (%r13)
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0xb5b9
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb5fa
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0xb5fa
movq %r12, 0x28(%rsp)
jmp 0xb5f7
jmp 0xb5f2
movq %rax, %r14
movq %r15, %rdi
callq 0x2160
jmp 0xb61b
movq %r12, 0x28(%rsp)
movq %rax, %r14
jmp 0xb61b
movq %rax, %r14
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb61b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x28(%rsp), %rdi
callq 0xc476
movq %r14, %rdi
callq 0x2380
nop