// File: /workspace/github_cpp_makefile_star2_O2/bonetblai[P]mdp-engine/wet/main.cc
// Function: main
int main(int argc, const char **argv) {
    size_t size = 0;
    float p = 0.0;
    unsigned num_trials = 1;

    vector<string> requests;

    float start_time = Utils::read_time_in_seconds();
    cout << fixed;

    // parse arguments
    for( ++argv, --argc; (argc > 1) && (**argv == '-'); ++argv, --argc ) {
        if( string(*argv) == "--no-colors" ) {
            Utils::g_use_colors = false;
        } else if( ((*argv)[1] == 'r') || (string(*argv) == "--request") ) {
            requests.push_back(argv[1]);
            ++argv;
            --argc;
        } else if( ((*argv)[1] == 's') || (string(*argv) == "--seed") ) {
            Algorithm::g_seed = strtoul(argv[1], 0, 0);
            Online::g_seed = Algorithm::g_seed;
            ++argv;
            --argc;
        } else if( ((*argv)[1] == 't') || (string(*argv) == "--trials") ) {
            num_trials = strtoul(argv[1], 0, 0);
            ++argv;
            --argc;
        } else if( ((*argv)[1] == 'x') || (string(*argv) == "--version-x") ) {
                version += 1;
        } else if( ((*argv)[1] == 'y') || (string(*argv) == "--version-y") ) {
                version += 2;
        } else if( ((*argv)[1] == 'z') || (string(*argv) == "--version-z") ) {
                version += 4;
        } else {
            usage(cout);
            exit(-1);
        }
    }

    // check version modifiers
    if( ZVER && YVER ) {
        cout << "Y and Z cannot be used simultaneously." << endl;
        exit(-1);
    }

    // read problem parameters
    if( argc == 2 ) {
        size = strtoul(argv[0], 0, 0);
        p = strtod(argv[1], 0);
    } else {
        usage(cout);
        exit(-1);
    }

    // build problem instances
    cout << "main: seed=" << Algorithm::g_seed << endl;
    Random::set_seed(Algorithm::g_seed);
    state_t init(Random::random(size), Random::random(size));
    state_t goal(Random::random(size), Random::random(size));
    problem_t problem(size, p, init, goal);
    //problem.print(cout);

    // build requests
    vector<pair<string, Online::Policy::policy_t<state_t>*> > policies;
    vector<pair<string, Algorithm::algorithm_t<state_t>*> > algorithms;
    Dispatcher::dispatcher_t<state_t> dispatcher;
    for( int i = 0; i < int(requests.size()); ++i ) {
        const string &request_str = requests[i];
        std::multimap<std::string, std::string> request;
        Utils::tokenize(request_str, request);
        for( std::multimap<std::string, std::string>::const_iterator it = request.begin(); it != request.end(); ++it ) {
            dispatcher.create_request(problem, it->first, it->second);
            if( it->first == "algorithm" ) {
                Algorithm::algorithm_t<state_t> *algorithm = dispatcher.fetch_algorithm(it->second);
                if( algorithm != 0 ) algorithms.push_back(make_pair(it->second, algorithm));
            } else if( it->first == "policy" ) {
                Online::Policy::policy_t<state_t> *policy = dispatcher.fetch_policy(it->second);
                if( policy != 0 ) policies.push_back(make_pair(it->second, policy));
            }
        }
    }

    // solve problems with requested algorithms
    vector<Dispatcher::dispatcher_t<state_t>::solve_result_t> solve_results;
    for( int i = 0; i < int(algorithms.size()); ++i ) {
        const string &request = algorithms[i].first;
        const Algorithm::algorithm_t<state_t> &algorithm = *algorithms[i].second;
        Dispatcher::dispatcher_t<state_t>::solve_result_t result;
        dispatcher.solve(request, algorithm, problem.init(), result);
        solve_results.push_back(result);
    }

    cout << Utils::warning() << "the following stats may aggregate figures when elements are shared among algorithms" << endl;
    if( !solve_results.empty() ) {
        for( int i = 0; i < int(solve_results.size()); ++i ) {
            dispatcher.print_stats(cout, solve_results[i]);
        }
    }

    // evaluate requested policies
    vector<Dispatcher::dispatcher_t<state_t>::evaluate_result_t> evaluate_results;
    for( int i = 0; i < int(policies.size()); ++i ) {
        const string &request = policies[i].first;
        const Online::Policy::policy_t<state_t> &policy = *policies[i].second;
        Dispatcher::dispatcher_t<state_t>::evaluate_result_t result;
        dispatcher.evaluate(request, policy, problem.init(), result, num_trials, 100, true);
        evaluate_results.push_back(result);
    }

    cout << Utils::warning() << "the following stats may aggregate figures when elements are shared among policies" << endl;
    if( !evaluate_results.empty() ) {
        for( int i = 0; i < int(evaluate_results.size()); ++i ) {
            dispatcher.print_stats(cout, evaluate_results[i]);
        }
    }

    cout << "main: total-time=" << Utils::read_time_in_seconds() - start_time << endl;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rsi, %r12
movl %edi, %r14d
xorps %xmm0, %xmm0
leaq 0x100(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
callq 0x5ec2
movss %xmm0, 0x60(%rsp)
movq 0x27a6a(%rip), %rax     # 0x2cfd8
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl $0xfffffefb, %edx       # imm = 0xFFFFFEFB
andl 0x18(%rax,%rcx), %edx
orl $0x4, %edx
movl %edx, 0x18(%rax,%rcx)
pushq $0x1
popq %rax
movq %rax, 0x68(%rsp)
leaq 0x160(%rsp), %r15
leal -0x1(%r14), %r13d
cmpl $0x3, %r14d
jl 0x57cf
leaq 0x8(%r12), %rbp
movq (%rbp), %rsi
cmpb $0x2d, (%rsi)
jne 0x57cf
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x50b0
movq %r15, %rdi
leaq 0x16bbe(%rip), %rsi     # 0x1c18a
callq 0x5f27
movl %eax, %ebx
movq %r15, %rdi
callq 0x50e0
testb %bl, %bl
je 0x55ee
movb $0x0, 0x27c52(%rip)     # 0x2d238
movq %rbp, %r12
movl %r13d, %r14d
jmp 0x5595
movq (%rbp), %rsi
cmpb $0x72, 0x1(%rsi)
je 0x5622
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x50b0
movq %r15, %rdi
leaq 0x16b87(%rip), %rsi     # 0x1c196
callq 0x5f27
movl %eax, %ebx
movq %r15, %rdi
callq 0x50e0
testb %bl, %bl
je 0x5659
movq 0x10(%r12), %rsi
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x50b0
leaq 0x100(%rsp), %rdi
movq %r15, %rsi
callq 0x8366
addq $0x10, %r12
movq %r15, %rdi
callq 0x50e0
addl $-0x2, %r14d
jmp 0x5595
movq (%rbp), %rsi
cmpb $0x73, 0x1(%rsi)
je 0x568d
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x50b0
movq %r15, %rdi
leaq 0x16b26(%rip), %rsi     # 0x1c1a0
callq 0x5f27
movl %eax, %ebx
movq %r15, %rdi
callq 0x50e0
testb %bl, %bl
je 0x56b4
movq 0x10(%r12), %rdi
addq $0x10, %r12
xorl %esi, %esi
xorl %edx, %edx
callq 0x5090
movl %eax, 0x27bbb(%rip)     # 0x2d260
movl %eax, 0x27bb9(%rip)     # 0x2d264
addl $-0x2, %r14d
jmp 0x5595
movq (%rbp), %rsi
cmpb $0x74, 0x1(%rsi)
je 0x576b
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x50b0
movq %r15, %rdi
leaq 0x16ace(%rip), %rsi     # 0x1c1a7
callq 0x5f27
movl %eax, %ebx
movq %r15, %rdi
callq 0x50e0
testb %bl, %bl
jne 0x576b
movq (%rbp), %rsi
cmpb $0x78, 0x1(%rsi)
je 0x5720
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x50b0
movq %r15, %rdi
leaq 0x16aa3(%rip), %rsi     # 0x1c1b0
callq 0x5f27
movl %eax, %ebx
movq %r15, %rdi
callq 0x50e0
testb %bl, %bl
je 0x572b
incl 0x27b2e(%rip)           # 0x2d254
jmp 0x55e6
movq (%rbp), %rsi
cmpb $0x79, 0x1(%rsi)
je 0x575f
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x50b0
movq %r15, %rdi
leaq 0x16a70(%rip), %rsi     # 0x1c1bc
callq 0x5f27
movl %eax, %ebx
movq %r15, %rdi
callq 0x50e0
testb %bl, %bl
je 0x578b
addl $0x2, 0x27aee(%rip)     # 0x2d254
jmp 0x55e6
movq 0x10(%r12), %rdi
addq $0x10, %r12
xorl %esi, %esi
xorl %edx, %edx
callq 0x5090
movq %rax, 0x68(%rsp)
addl $-0x2, %r14d
jmp 0x5595
movq (%rbp), %rsi
cmpb $0x7a, 0x1(%rsi)
je 0x57c3
movq %r15, %rdi
leaq 0x10(%rsp), %rdx
callq 0x50b0
movq %r15, %rdi
leaq 0x16a1c(%rip), %rsi     # 0x1c1c8
callq 0x5f27
movl %eax, %ebx
movq %r15, %rdi
callq 0x50e0
testb %bl, %bl
je 0x5dbf
addl $0x4, 0x27a8a(%rip)     # 0x2d254
jmp 0x55e6
movl 0x27a7f(%rip), %eax     # 0x2d254
notl %eax
testb $0x6, %al
je 0x5d8e
cmpl $0x2, %r13d
jne 0x5dab
movq 0x8(%r12), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5090
movq %rax, %rbx
movq 0x10(%r12), %rdi
xorl %esi, %esi
callq 0x51b0
movsd %xmm0, 0x8(%rsp)
movq 0x277c5(%rip), %rdi     # 0x2cfd8
leaq 0x169e1(%rip), %rsi     # 0x1c1fb
callq 0x5230
movl 0x27a3b(%rip), %esi     # 0x2d260
movq %rax, %rdi
callq 0x5160
movq %rax, %rdi
callq 0x50f0
movl 0x27a25(%rip), %edi     # 0x2d260
callq 0x5f34
movl %ebx, %edi
callq 0x5f5f
movl %eax, %ebp
movl %ebx, %edi
callq 0x5f5f
imull 0x27a01(%rip), %ebp     # 0x2d258
addl %eax, %ebp
movl %ebp, 0x64(%rsp)
movl %ebx, %edi
callq 0x5f5f
movl %eax, %ebp
movl %ebx, %edi
callq 0x5f5f
cvtsd2ss 0x8(%rsp), %xmm0
imull 0x279de(%rip), %ebp     # 0x2d258
addl %eax, %ebp
leaq 0x124(%rsp), %rcx
movl %ebp, (%rcx)
leaq 0x128(%rsp), %rdi
leaq 0x64(%rsp), %rdx
movq %rbx, %rsi
callq 0x5f98
leaq 0xe0(%rsp), %rdx
andq $0x0, 0x10(%rdx)
leaq 0xc0(%rsp), %rsi
andq $0x0, 0x10(%rsi)
leaq 0x267a4(%rip), %rax     # 0x2c060
leaq 0x170(%rsp), %rcx
movq %rax, -0x10(%rcx)
andl $0x0, (%rcx)
andq $0x0, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
andq $0x0, 0x20(%rcx)
leaq 0x1a0(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x1d0(%rsp), %rax
andl $0x0, (%rax)
xorps %xmm0, %xmm0
andq $0x0, 0x8(%rax)
movaps %xmm0, (%rdx)
movaps %xmm0, (%rsi)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x18(%rsp), %rbp
xorl %ecx, %ecx
leaq 0x10(%rsp), %rbx
leaq 0x160(%rsp), %r13
leaq 0x70(%rsp), %r12
movq 0x100(%rsp), %rdi
movq 0x108(%rsp), %rax
subq %rdi, %rax
shrq $0x5, %rax
cltq
cmpq %rax, %rcx
jge 0x5a82
movq %rcx, 0x8(%rsp)
movq %rcx, %rax
shlq $0x5, %rax
addq %rax, %rdi
andl $0x0, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movq %rbp, 0x28(%rsp)
movq %rbp, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
movq %rbx, %rsi
pushq $0x2c
popq %rdx
callq 0x604a
movq 0x28(%rsp), %r15
cmpq %rbp, %r15
je 0x5a68
leaq 0x20(%r15), %rbx
leaq 0x40(%r15), %r14
movq %r13, %rdi
leaq 0x128(%rsp), %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x621a
movq %rbx, %rdi
leaq 0x16841(%rip), %rsi     # 0x1c207
callq 0x5f27
testb %al, %al
je 0x5a07
movq %r13, %rdi
movq %r14, %rsi
callq 0x6b7a
movq %rax, %rbx
testq %rax, %rax
je 0x5a58
movq %r12, %rdi
movq %r14, %rsi
callq 0x52f0
movq %rbx, 0x90(%rsp)
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x1a26a
jmp 0x5a50
movq %rbx, %rdi
leaq 0x16800(%rip), %rsi     # 0x1c211
callq 0x5f27
testb %al, %al
je 0x5a58
movq %r13, %rdi
movq %r14, %rsi
callq 0x6b9a
movq %rax, %rbx
testq %rax, %rax
je 0x5a58
movq %r12, %rdi
movq %r14, %rsi
callq 0x52f0
movq %rbx, 0x90(%rsp)
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x1a4c6
movq %r12, %rdi
callq 0x50e0
movq %r15, %rdi
callq 0x5270
movq %rax, %r15
jmp 0x5995
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x82e8
movq 0x8(%rsp), %rcx
incq %rcx
jmp 0x5939
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rbx
movaps %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0x28(%rsp), %r14
xorl %ebp, %ebp
leaq 0x160(%rsp), %r12
leaq 0x10(%rsp), %r13
xorl %r15d, %r15d
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rax
subq %rsi, %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
cltq
cmpq %rax, %r15
jge 0x5b19
movq 0x20(%rsi,%rbp), %rdx
addq %rbp, %rsi
andl $0x0, 0x10(%rsp)
movq %r14, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
movq %r12, %rdi
leaq 0x148(%rsp), %rcx
movq %r13, %r8
callq 0x6bba
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6cb8
leaq 0x18(%rsp), %rdi
callq 0x50e0
incq %r15
addq $0x28, %rbp
jmp 0x5aa9
leaq 0x10(%rsp), %rdi
callq 0x6ce4
movq 0x274ae(%rip), %rdi     # 0x2cfd8
leaq 0x10(%rsp), %rsi
callq 0x51f0
leaq 0x166dd(%rip), %rsi     # 0x1c218
movq %rax, %rdi
callq 0x5230
movq %rax, %rdi
callq 0x50f0
leaq 0x10(%rsp), %rdi
callq 0x50e0
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rax
cmpq %rax, %rcx
je 0x5bb0
xorl %r14d, %r14d
pushq $0x50
popq %r12
movq 0x27466(%rip), %rbx     # 0x2cfd8
leaq 0x160(%rsp), %r15
xorl %r13d, %r13d
subq %rcx, %rax
cqto
idivq %r12
cltq
cmpq %rax, %r13
jge 0x5bb0
addq %r14, %rcx
movq %r15, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
callq 0x6d18
incq %r13
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rax
addq $0x50, %r14
jmp 0x5b7d
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rbx
movaps %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0x20(%rsp), %r13
xorl %r14d, %r14d
leaq 0x160(%rsp), %r15
leaq 0x10(%rsp), %r12
xorl %ebp, %ebp
movq 0xe0(%rsp), %rsi
movq 0xe8(%rsp), %rax
subq %rsi, %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
cltq
cmpq %rax, %rbp
jge 0x5c4e
movq 0x20(%rsi,%r14), %rdx
addq %r14, %rsi
movq %r13, 0x10(%rsp)
andq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq %r15, %rdi
leaq 0x148(%rsp), %rcx
movq %r12, %r8
movq 0x68(%rsp), %r9
pushq $0x1
pushq $0x64
callq 0x7272
popq %rax
popq %rcx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7332
movq %r12, %rdi
callq 0x50e0
incq %rbp
addq $0x28, %r14
jmp 0x5bda
leaq 0x10(%rsp), %rdi
callq 0x6ce4
movq 0x27379(%rip), %rdi     # 0x2cfd8
leaq 0x10(%rsp), %rsi
callq 0x51f0
leaq 0x165fc(%rip), %rsi     # 0x1c26c
movq %rax, %rdi
callq 0x5230
movq %rax, %rdi
callq 0x50f0
leaq 0x10(%rsp), %rdi
callq 0x50e0
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %rax
cmpq %rax, %rcx
je 0x5cf1
xorl %r15d, %r15d
pushq $0x48
popq %r12
movq 0x2732b(%rip), %rbx     # 0x2cfd8
leaq 0x160(%rsp), %r14
xorl %r13d, %r13d
subq %rcx, %rax
cqto
idivq %r12
cltq
cmpq %rax, %r13
jge 0x5cf1
addq %r15, %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
callq 0x735e
incq %r13
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %rax
addq $0x48, %r15
jmp 0x5cb8
movq 0x272e0(%rip), %rdi     # 0x2cfd8
leaq 0x165bf(%rip), %rsi     # 0x1c2be
callq 0x5230
movq %rax, %rbx
callq 0x5ec2
subss 0x60(%rsp), %xmm0
movq %rbx, %rdi
callq 0x5190
movq %rax, %rdi
callq 0x50f0
leaq 0xa0(%rsp), %rdi
callq 0x75b2
leaq 0x70(%rsp), %rdi
callq 0x75d4
leaq 0x160(%rsp), %rdi
callq 0x75f6
leaq 0xc0(%rsp), %rdi
callq 0x76ac
leaq 0xe0(%rsp), %rdi
callq 0x76ce
leaq 0x128(%rsp), %rdi
callq 0x76f0
leaq 0x100(%rsp), %rdi
callq 0x7708
xorl %eax, %eax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x27243(%rip), %rdi     # 0x2cfd8
leaq 0x16438(%rip), %rsi     # 0x1c1d4
callq 0x5230
movq %rax, %rdi
callq 0x50f0
jmp 0x5db7
movq 0x27226(%rip), %rdi     # 0x2cfd8
callq 0x551c
pushq $-0x1
popq %rdi
callq 0x5290
movq 0x27212(%rip), %rdi     # 0x2cfd8
callq 0x551c
jmp 0x5db7
jmp 0x5e0a
jmp 0x5e0a
jmp 0x5e0a
jmp 0x5e0a
jmp 0x5e0a
jmp 0x5e12
jmp 0x5e17
jmp 0x5e0a
jmp 0x5e0a
jmp 0x5e0a
jmp 0x5e12
jmp 0x5e1e
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x5e42
jmp 0x5e0a
jmp 0x5e0a
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
callq 0x50e0
jmp 0x5ead
jmp 0x5e0a
movq %rax, %rbx
jmp 0x5ead
movq %rax, %rbx
jmp 0x5e2b
movq %rax, %rbx
jmp 0x5e47
jmp 0x5e6c
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x50e0
leaq 0xa0(%rsp), %rdi
callq 0x75b2
jmp 0x5e47
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x50e0
leaq 0x70(%rsp), %rdi
callq 0x75d4
jmp 0x5e79
jmp 0x5e59
jmp 0x5e6c
jmp 0x5e6c
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x50e0
jmp 0x5e6f
jmp 0x5e6c
jmp 0x5e6c
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x82e8
leaq 0x160(%rsp), %rdi
callq 0x75f6
leaq 0xc0(%rsp), %rdi
callq 0x76ac
leaq 0xe0(%rsp), %rdi
callq 0x76ce
leaq 0x128(%rsp), %rdi
callq 0x76f0
leaq 0x100(%rsp), %rdi
callq 0x7708
movq %rbx, %rdi
callq 0x5390