// File: /workspace/github_cpp_makefile_star2_O2/vsklad[P]cgen/main.cpp
// Function: main
int main(int argc, const char * argv[]) {
    try {
        CGenCommandInfo info;
        CGenCommandLineReader command_line_reader(argc, argv);
        command_line_reader.parse(info);
        
        switch(info.command) {
            case cmdNone:
                std::cout << ERROR_COMMAND_NONE << std::endl;
                print_help();
            case cmdEncode:
                if (info.algorithm == algNone) {
                    throw std::invalid_argument(ERROR_MISSING_ALGORITHM);
                };
                
                generate_output_file_name(info);
                if (info.output_file_name.empty()) {
                    throw std::invalid_argument(ERROR_MISSING_OUTPUT_FILE_NAME);
                };
                
                _assert_level_1(info.b_formula_type_specified);
                std::cout << "Encoding " << (info.algorithm == algSHA1 ? "SHA-1" : "SHA-256");
                std::cout << " into " << get_formula_type_title(info.formula_type) << std::endl;
                
                if (info.formula_type == ftCnf) {
                    encode_cnf(info.algorithm, info.rounds,
                               info.variables_map,
                               info.add_max_args, info.xor_max_args,
                               info.output_file_name.c_str(),
                               info.output_format, info.trace_format,
                               info.b_reindex_variables,
                               info.b_normalize_variables_specified,
                               info.b_assign_after_encoding,
                               info.mode);
                } else if (info.formula_type == ftAnf) {
                    encode_anf(info.algorithm, info.rounds,
                               info.variables_map,
                               info.add_max_args, info.xor_max_args,
                               info.output_file_name.c_str(),
                               info.output_format, info.trace_format,
                               info.b_reindex_variables,
                               info.b_normalize_variables_specified,
                               info.b_assign_after_encoding,
                               info.mode);
                } else {
                    _assert_level_1(false);
                };
                break;
            case cmdProcess:
                _assert_level_1(info.b_formula_type_specified);
                generate_output_file_name(info);
                std::cout << "Processing " << get_formula_type_title(info.formula_type) << " formula" << std::endl;
                if (info.formula_type == ftCnf) {
                    process_cnf(info.variables_map,
                                info.input_file_name.data(), info.output_file_name.data(),
                                info.output_format, info.trace_format,
                                info.b_reindex_variables, info.b_normalize_variables_specified, info.mode);
                } else if (info.formula_type == ftAnf) {
                    process_anf(info.variables_map,
                                info.input_file_name.data(), info.output_file_name.data(),
                                info.output_format, info.trace_format,
                                info.b_reindex_variables, info.b_normalize_variables_specified, info.mode);
                } else {
                    _assert_level_1(false);
                };
                break;
            case cmdHelp:
                print_help();
                break;
            case cmdVersion:
                print_version();
                break;
        };
    }
    catch (TextReaderException e) {
        std::cerr << ERROR_COMMAND_LINE_PARSE << ": " << e.get_line() << std::endl;
        std::cerr << "Position " << e.get_pos() << ": " << e.get_message() << std::endl;
        std::cerr << "See --help for reference" << std::endl;
        return 1;
    }
    catch (std::invalid_argument e) {
        std::cerr << ERROR_INVALID_ARGUMENT << ": " << e.what() << std::endl;
        return 1;
    }
    catch (std::out_of_range e) {
        std::cerr << ERROR_OUT_OF_RANGE << ": " << e.what() << std::endl;
        return 1;
    };
    
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movaps 0xe590(%rip), %xmm0     # 0x3da90
leaq -0xa0(%rbp), %rax
movups %xmm0, -0x20(%rax)
andl $0x0, -0x10(%rax)
andl $0x0, (%rax)
movq %rsi, %rdx
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
leaq -0x58(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, -0x28(%rax)
andl $0x0, -0x18(%rax)
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movl %edi, %esi
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
movl $0x10000, 0x10(%rax)    # imm = 0x10000
movb %cl, 0x14(%rax)
movl $0x2, 0x18(%rax)
leaq -0x128(%rbp), %rdi
callq 0x2fb62
leaq -0x128(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x1719a
movl -0xc0(%rbp), %eax
cmpq $0x4, %rax
ja 0x2f818
leaq 0xe50a(%rip), %rcx      # 0x3daa0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x21a0a(%rip), %rdi     # 0x50fb0
leaq 0xe98d(%rip), %rsi      # 0x3df3a
callq 0xc290
movq %rax, %rdi
callq 0xc120
callq 0x2f11e
cmpl $0x0, -0xbc(%rbp)
je 0x2f840
leaq -0xc0(%rbp), %rdi
callq 0x2f2c2
cmpq $0x0, -0x40(%rbp)
je 0x2f85c
cmpb $0x0, -0x28(%rbp)
je 0x2f88c
movq 0x219bc(%rip), %rdi     # 0x50fb0
leaq 0xe9d6(%rip), %rsi      # 0x3dfd1
callq 0xc290
cmpl $0x1, -0xbc(%rbp)
leaq 0xb53e(%rip), %rcx      # 0x3ab4c
leaq 0xc705(%rip), %rsi      # 0x3bd1a
cmoveq %rcx, %rsi
movq %rax, %rdi
callq 0xc290
movq 0x21988(%rip), %rdi     # 0x50fb0
leaq 0xe9ac(%rip), %rsi      # 0x3dfdb
callq 0xc290
cmpl $0x0, -0xb8(%rbp)
leaq 0x8208(%rip), %rcx      # 0x3784a
leaq 0x81fd(%rip), %rsi      # 0x37846
cmoveq %rcx, %rsi
movq %rax, %rdi
callq 0xc290
movq %rax, %rdi
callq 0xc120
movl -0xb8(%rbp), %eax
cmpl $0x1, %eax
je 0x2f790
testl %eax, %eax
jne 0x2f8c8
leaq -0xa8(%rbp), %rdx
movl 0x30(%rdx), %esi
movl 0x34(%rdx), %ecx
movl 0x38(%rdx), %r8d
movq 0x60(%rdx), %r9
movl -0x14(%rdx), %edi
movl -0xc(%rdx), %eax
movl -0x8(%rdx), %r10d
movzbl 0x82(%rdx), %r11d
movzbl 0x83(%rdx), %ebx
movzbl 0x81(%rdx), %r14d
movl 0x88(%rdx), %r15d
pushq %r15
pushq %r14
pushq %rbx
pushq %r11
pushq %r10
pushq %rax
callq 0x1b88d
addq $0x30, %rsp
jmp 0x2f818
callq 0x2f0e0
jmp 0x2f818
cmpb $0x0, -0x28(%rbp)
je 0x2f8a9
leaq -0xc0(%rbp), %rdi
callq 0x2f2c2
movq 0x218c0(%rip), %rdi     # 0x50fb0
leaq 0xe8eb(%rip), %rsi      # 0x3dfe2
callq 0xc290
cmpl $0x0, -0xb8(%rbp)
leaq 0x8140(%rip), %rcx      # 0x3784a
leaq 0x8135(%rip), %rsi      # 0x37846
cmoveq %rcx, %rsi
movq %rax, %rdi
callq 0xc290
leaq 0x843a(%rip), %rsi      # 0x37b5e
movq %rax, %rdi
callq 0xc290
movq %rax, %rdi
callq 0xc120
movl -0xb8(%rbp), %eax
cmpl $0x1, %eax
je 0x2f7e2
testl %eax, %eax
jne 0x2f8e7
leaq -0xa8(%rbp), %rdi
movq 0x40(%rdi), %rsi
movq 0x60(%rdi), %rdx
movl -0xc(%rdi), %ecx
movl -0x8(%rdi), %r8d
movzbl 0x82(%rdi), %r9d
movzbl 0x83(%rdi), %eax
movl 0x88(%rdi), %r10d
pushq %r10
pushq %rax
callq 0x1bc34
popq %rax
popq %rcx
jmp 0x2f818
callq 0x2f11e
jmp 0x2f818
leaq -0xa8(%rbp), %rdx
movl 0x30(%rdx), %esi
movl 0x34(%rdx), %ecx
movl 0x38(%rdx), %r8d
movq 0x60(%rdx), %r9
movl -0x14(%rdx), %edi
movl -0xc(%rdx), %eax
movl -0x8(%rdx), %r10d
movzbl 0x82(%rdx), %r11d
movzbl 0x83(%rdx), %ebx
movzbl 0x81(%rdx), %r14d
movl 0x88(%rdx), %r15d
pushq %r15
pushq %r14
pushq %rbx
pushq %r11
pushq %r10
pushq %rax
callq 0x1b54f
addq $0x30, %rsp
jmp 0x2f818
leaq -0xa8(%rbp), %rdi
movq 0x40(%rdi), %rsi
movq 0x60(%rdi), %rdx
movl -0xc(%rdi), %ecx
movl -0x8(%rdi), %r8d
movzbl 0x82(%rdi), %r9d
movzbl 0x83(%rdi), %eax
movl 0x88(%rdi), %r10d
pushq %r10
pushq %rax
callq 0x1bb26
popq %rax
popq %rcx
leaq -0x108(%rbp), %rdi
callq 0x2d1e6
leaq -0xc0(%rbp), %rdi
callq 0x2fbb6
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0xc130
movq %rax, %r15
leaq 0xe6fd(%rip), %rsi      # 0x3df4f
movq %rax, %rdi
callq 0xc4e0
jmp 0x2f876
pushq $0x10
popq %rdi
callq 0xc130
movq %rax, %r15
leaq 0xe706(%rip), %rsi      # 0x3df74
movq %rax, %rdi
callq 0xc4e0
movq 0x2175b(%rip), %rsi     # 0x50fd8
movq 0x2173c(%rip), %rdx     # 0x50fc0
movq %r15, %rdi
callq 0xc490
leaq 0xe703(%rip), %rdi      # 0x3df96
leaq 0xe64d(%rip), %rsi      # 0x3dee7
leaq 0xe713(%rip), %rcx      # 0x3dfb4
pushq $0x77
popq %rdx
callq 0xc180
leaq 0xe6e6(%rip), %rdi      # 0x3df96
leaq 0xe630(%rip), %rsi      # 0x3dee7
leaq 0xe6f6(%rip), %rcx      # 0x3dfb4
movl $0x94, %edx
callq 0xc180
leaq 0xa4ec(%rip), %rdi      # 0x39dbb
leaq 0xe611(%rip), %rsi      # 0x3dee7
leaq 0xe6d7(%rip), %rcx      # 0x3dfb4
movl $0x90, %edx
callq 0xc180
leaq 0xa4cd(%rip), %rdi      # 0x39dbb
leaq 0xe5f2(%rip), %rsi      # 0x3dee7
leaq 0xe6b8(%rip), %rcx      # 0x3dfb4
movl $0xa2, %edx
callq 0xc180
jmp 0x2f908
movq %rdx, %r14
movq %rax, %rbx
movq %r15, %rdi
callq 0xc1d0
jmp 0x2f926
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2f932
movq %rdx, %r14
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
callq 0x2d1e6
leaq -0xc0(%rbp), %rdi
callq 0x2fbb6
cmpl $0x3, %r14d
jne 0x2fa14
movq %rbx, %rdi
callq 0xc330
leaq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0x2d0c6
movq %rbx, %rdi
callq 0xc0f0
movq 0x21682(%rip), %rdi     # 0x50ff0
leaq 0xe68c(%rip), %rsi      # 0x3e001
callq 0xc290
leaq 0x8988(%rip), %rsi      # 0x38309
movq %rax, %rdi
callq 0xc290
movq -0xb0(%rbp), %rsi
movq %rax, %rdi
callq 0xc290
movq %rax, %rdi
callq 0xc120
movq 0x21649(%rip), %rdi     # 0x50ff0
leaq 0xe66e(%rip), %rsi      # 0x3e01c
callq 0xc290
movq -0xb8(%rbp), %rsi
movq %rax, %rdi
callq 0xc190
leaq 0x8940(%rip), %rsi      # 0x38309
movq %rax, %rdi
callq 0xc290
movq -0x90(%rbp), %rsi
movq %rax, %rdi
callq 0xc290
movq %rax, %rdi
callq 0xc120
movq 0x21601(%rip), %rdi     # 0x50ff0
leaq 0xe630(%rip), %rsi      # 0x3e026
callq 0xc290
movq %rax, %rdi
callq 0xc120
leaq -0xc0(%rbp), %rdi
callq 0x19796
jmp 0x2fb04
cmpl $0x2, %r14d
jne 0x2fa8b
movq %rbx, %rdi
callq 0xc330
leaq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0x2fc08
movq %rbx, %rdi
callq 0xc0f0
movq 0x215b0(%rip), %rdi     # 0x50ff0
leaq 0xe5b4(%rip), %rsi      # 0x3dffb
callq 0xc290
leaq 0x88b6(%rip), %rsi      # 0x38309
movq %rax, %rdi
callq 0xc290
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0xc3b0
movq %rbx, %rdi
movq %rax, %rsi
callq 0xc290
movq %rax, %rdi
callq 0xc120
leaq -0xc0(%rbp), %rdi
callq 0xc530
jmp 0x2fb04
cmpl $0x1, %r14d
jne 0x2fb51
movq %rbx, %rdi
callq 0xc330
leaq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0x2fbe4
movq %rbx, %rdi
callq 0xc0f0
movq 0x21535(%rip), %rdi     # 0x50ff0
leaq 0xe52c(%rip), %rsi      # 0x3dfee
callq 0xc290
leaq 0x883b(%rip), %rsi      # 0x38309
movq %rax, %rdi
callq 0xc290
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0xc3b0
movq %rbx, %rdi
movq %rax, %rsi
callq 0xc290
movq %rax, %rdi
callq 0xc120
leaq -0xc0(%rbp), %rdi
callq 0xc528
callq 0xc450
pushq $0x1
popq %rax
jmp 0x2f832
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0xc528
callq 0xc450
jmp 0x2fb51
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0xc530
callq 0xc450
jmp 0x2fb51
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x19796
callq 0xc450
movq %rbx, %rdi
callq 0xc4c0
movq %rax, %rdi
callq 0x11f91
nop