// File: /workspace/github_cpp_makefile_star2_O2/bonetblai[P]mdp-engine/tree/main.cc
// Function: main
int main(int argc, const char **argv) {
    unsigned size = 0;
    float q = 0.5;
    float r = 0.0;
    float p = 1.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 {
            usage(cout);
            exit(-1);
        }
    }

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

    // build problem instances
    cout << "main: seed=" << Algorithm::g_seed << endl;
    Random::set_seed(Algorithm::g_seed);
    problem_t problem(size, p, q, r);

    // 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 $0x218, %rsp            # imm = 0x218
movq %rsi, %r15
movl %edi, %ebp
xorps %xmm0, %xmm0
leaq 0x100(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
callq 0x5dcb
movss %xmm0, 0x14(%rsp)
movq 0x28a7b(%rip), %rax     # 0x2dfd8
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 0x118(%rsp), %r12
leaq 0x1b0(%rsp), %r13
leaq 0x8(%r15), %r14
cmpl $0x3, %ebp
jl 0x56e8
movq (%r14), %rsi
cmpb $0x2d, (%rsi)
jne 0x56f4
movq %r12, %rdi
movq %r13, %rdx
callq 0x50a0
movq %r12, %rdi
leaq 0x16b85(%rip), %rsi     # 0x1c13f
callq 0x5e30
movl %eax, %ebx
movq %r12, %rdi
callq 0x50d0
testb %bl, %bl
je 0x55db
decl %ebp
movb $0x0, 0x28c22(%rip)     # 0x2e1f8
movq %r14, %r15
jmp 0x558c
movq (%r14), %rsi
cmpb $0x72, 0x1(%rsi)
je 0x560c
movq %r12, %rdi
movq %r13, %rdx
callq 0x50a0
movq %r12, %rdi
leaq 0x16b52(%rip), %rsi     # 0x1c14b
callq 0x5e30
movl %eax, %ebx
movq %r12, %rdi
callq 0x50d0
testb %bl, %bl
je 0x563f
movq 0x10(%r15), %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x50a0
leaq 0x100(%rsp), %rdi
movq %r12, %rsi
callq 0x8d1a
addq $0x10, %r15
movq %r12, %rdi
callq 0x50d0
addl $-0x2, %ebp
jmp 0x558c
movq (%r14), %rsi
cmpb $0x73, 0x1(%rsi)
je 0x5670
movq %r12, %rdi
movq %r13, %rdx
callq 0x50a0
movq %r12, %rdi
leaq 0x16af8(%rip), %rsi     # 0x1c155
callq 0x5e30
movl %eax, %ebx
movq %r12, %rdi
callq 0x50d0
testb %bl, %bl
je 0x5695
movq 0x10(%r15), %rdi
addq $0x10, %r15
xorl %esi, %esi
xorl %edx, %edx
callq 0x5080
movl %eax, 0x28b89(%rip)     # 0x2e210
movl %eax, 0x28b87(%rip)     # 0x2e214
addl $-0x2, %ebp
jmp 0x558c
movq (%r14), %rsi
cmpb $0x74, 0x1(%rsi)
je 0x56ca
movq %r12, %rdi
movq %r13, %rdx
callq 0x50a0
movq %r12, %rdi
leaq 0x16aa9(%rip), %rsi     # 0x1c15c
callq 0x5e30
movl %eax, %ebx
movq %r12, %rdi
callq 0x50d0
testb %bl, %bl
je 0x5cd2
movq 0x10(%r15), %rdi
addq $0x10, %r15
xorl %esi, %esi
xorl %edx, %edx
callq 0x5080
movq %rax, 0x68(%rsp)
addl $-0x2, %ebp
jmp 0x558c
cmpl $0x2, %ebp
jne 0x5cbe
movq (%r14), %rsi
movq %rsi, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x5080
movq %rax, %rbx
xorps %xmm0, %xmm0
movss %xmm0, 0x4(%rsp)
movss 0x168f4(%rip), %xmm0    # 0x1c008
movss %xmm0, 0x8(%rsp)
cmpl $0x2, %ebp
jne 0x572e
movss 0x168dd(%rip), %xmm0    # 0x1c004
movss %xmm0, (%rsp)
jmp 0x5776
movq 0x10(%r15), %rdi
xorl %esi, %esi
callq 0x51a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsp)
cmpl $0x4, %ebp
jb 0x5776
movq 0x18(%r15), %rdi
xorl %esi, %esi
callq 0x51a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x8(%rsp)
cmpl $0x4, %ebp
je 0x5776
movq 0x20(%r15), %rdi
xorl %esi, %esi
callq 0x51a0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x4(%rsp)
movq 0x2885b(%rip), %rdi     # 0x2dfd8
leaq 0x169e1(%rip), %rsi     # 0x1c165
callq 0x5220
movl 0x28a81(%rip), %esi     # 0x2e210
movq %rax, %rdi
callq 0x5150
movq %rax, %rdi
callq 0x50e0
movl 0x28a6b(%rip), %edi     # 0x2e210
callq 0x5e3d
leaq 0x1b0(%rsp), %rdi
movl %ebx, %esi
movss (%rsp), %xmm0
movss 0x8(%rsp), %xmm1
movss 0x4(%rsp), %xmm2
callq 0x5e68
leaq 0xe0(%rsp), %rdx
andq $0x0, 0x10(%rdx)
leaq 0xc0(%rsp), %rsi
andq $0x0, 0x10(%rsi)
leaq 0x27925(%rip), %rax     # 0x2d110
leaq 0x128(%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 0x158(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x188(%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 0x20(%rsp), %rbp
xorl %ecx, %ecx
leaq 0x18(%rsp), %rbx
leaq 0x118(%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 0x59b1
movq %rcx, 0x8(%rsp)
movq %rcx, %rax
shlq $0x5, %rax
addq %rax, %rdi
andl $0x0, 0x20(%rsp)
andq $0x0, 0x28(%rsp)
movq %rbp, 0x30(%rsp)
movq %rbp, 0x38(%rsp)
andq $0x0, 0x40(%rsp)
movq %rbx, %rsi
pushq $0x2c
popq %rdx
callq 0x5ee5
movq 0x30(%rsp), %r15
cmpq %rbp, %r15
je 0x5997
leaq 0x20(%r15), %rbx
leaq 0x40(%r15), %r14
movq %r13, %rdi
leaq 0x1b0(%rsp), %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x60b4
movq %rbx, %rdi
leaq 0x1687c(%rip), %rsi     # 0x1c171
callq 0x5e30
testb %al, %al
je 0x5936
movq %r13, %rdi
movq %r14, %rsi
callq 0x6a14
movq %rax, %rbx
testq %rax, %rax
je 0x5987
movq %r12, %rdi
movq %r14, %rsi
callq 0x52d0
movq %rbx, 0x90(%rsp)
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x1a73c
jmp 0x597f
movq %rbx, %rdi
leaq 0x1683b(%rip), %rsi     # 0x1c17b
callq 0x5e30
testb %al, %al
je 0x5987
movq %r13, %rdi
movq %r14, %rsi
callq 0x6a34
movq %rax, %rbx
testq %rax, %rax
je 0x5987
movq %r12, %rdi
movq %r14, %rsi
callq 0x52d0
movq %rbx, 0x90(%rsp)
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x1a998
movq %r12, %rdi
callq 0x50d0
movq %r15, %rdi
callq 0x5260
movq %rax, %r15
jmp 0x58c4
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x8c9c
movq 0x8(%rsp), %rcx
incq %rcx
jmp 0x5868
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rbx
movaps %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0x30(%rsp), %r14
xorl %ebp, %ebp
leaq 0x118(%rsp), %r12
leaq 0x18(%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 0x5a49
movq 0x20(%rsi,%rbp), %rdx
addq %rbp, %rsi
andq $0x0, 0x18(%rsp)
movq %r14, 0x20(%rsp)
andq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq %r12, %rdi
leaq 0x1d8(%rsp), %rcx
movq %r13, %r8
callq 0x6a54
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6b54
leaq 0x20(%rsp), %rdi
callq 0x50d0
incq %r15
addq $0x28, %rbp
jmp 0x59d8
leaq 0x18(%rsp), %rdi
callq 0x6b80
movq 0x2857e(%rip), %rdi     # 0x2dfd8
leaq 0x18(%rsp), %rsi
callq 0x51e0
leaq 0x16717(%rip), %rsi     # 0x1c182
movq %rax, %rdi
callq 0x5220
movq %rax, %rdi
callq 0x50e0
leaq 0x18(%rsp), %rdi
callq 0x50d0
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rax
cmpq %rax, %rcx
je 0x5ae0
xorl %r14d, %r14d
pushq $0x50
popq %r12
movq 0x28536(%rip), %rbx     # 0x2dfd8
leaq 0x118(%rsp), %r15
xorl %r13d, %r13d
subq %rcx, %rax
cqto
idivq %r12
cltq
cmpq %rax, %r13
jge 0x5ae0
addq %r14, %rcx
movq %r15, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
callq 0x6bb4
incq %r13
movq 0x70(%rsp), %rcx
movq 0x78(%rsp), %rax
addq $0x50, %r14
jmp 0x5aad
xorps %xmm0, %xmm0
leaq 0xa0(%rsp), %rbx
movaps %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0x28(%rsp), %r13
xorl %r14d, %r14d
leaq 0x118(%rsp), %r15
leaq 0x18(%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 0x5b7e
movq 0x20(%rsi,%r14), %rdx
addq %r14, %rsi
movq %r13, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
movq %r15, %rdi
leaq 0x1d8(%rsp), %rcx
movq %r12, %r8
movq 0x68(%rsp), %r9
pushq $0x1
pushq $0x64
callq 0x710e
popq %rax
popq %rcx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x71ce
movq %r12, %rdi
callq 0x50d0
incq %rbp
addq $0x28, %r14
jmp 0x5b0a
leaq 0x18(%rsp), %rdi
callq 0x6b80
movq 0x28449(%rip), %rdi     # 0x2dfd8
leaq 0x18(%rsp), %rsi
callq 0x51e0
leaq 0x16636(%rip), %rsi     # 0x1c1d6
movq %rax, %rdi
callq 0x5220
movq %rax, %rdi
callq 0x50e0
leaq 0x18(%rsp), %rdi
callq 0x50d0
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %rax
cmpq %rax, %rcx
je 0x5c21
xorl %r15d, %r15d
pushq $0x48
popq %r12
movq 0x283fb(%rip), %rbx     # 0x2dfd8
leaq 0x118(%rsp), %r14
xorl %r13d, %r13d
subq %rcx, %rax
cqto
idivq %r12
cltq
cmpq %rax, %r13
jge 0x5c21
addq %r15, %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq %rcx, %rdx
callq 0x71fa
incq %r13
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %rax
addq $0x48, %r15
jmp 0x5be8
movq 0x283b0(%rip), %rdi     # 0x2dfd8
leaq 0x165f9(%rip), %rsi     # 0x1c228
callq 0x5220
movq %rax, %rbx
callq 0x5dcb
subss 0x14(%rsp), %xmm0
movq %rbx, %rdi
callq 0x5180
movq %rax, %rdi
callq 0x50e0
leaq 0xa0(%rsp), %rdi
callq 0x744e
leaq 0x70(%rsp), %rdi
callq 0x7470
leaq 0x118(%rsp), %rdi
callq 0x7492
leaq 0xc0(%rsp), %rdi
callq 0x7548
leaq 0xe0(%rsp), %rdi
callq 0x756a
leaq 0x1b0(%rsp), %rdi
callq 0x758c
leaq 0x100(%rsp), %rdi
callq 0x75a0
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28313(%rip), %rdi     # 0x2dfd8
callq 0x550c
pushq $-0x1
popq %rdi
callq 0x5280
movq 0x282ff(%rip), %rdi     # 0x2dfd8
callq 0x550c
jmp 0x5cca
jmp 0x5d13
jmp 0x5d13
jmp 0x5d1b
jmp 0x5d20
jmp 0x5d13
jmp 0x5d1b
jmp 0x5d27
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x5d4b
jmp 0x5d13
jmp 0x5d13
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x50d0
jmp 0x5db6
jmp 0x5d13
movq %rax, %rbx
jmp 0x5db6
movq %rax, %rbx
jmp 0x5d34
movq %rax, %rbx
jmp 0x5d50
jmp 0x5d75
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x50d0
leaq 0xa0(%rsp), %rdi
callq 0x744e
jmp 0x5d50
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x50d0
leaq 0x70(%rsp), %rdi
callq 0x7470
jmp 0x5d82
jmp 0x5d62
jmp 0x5d75
jmp 0x5d75
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x50d0
jmp 0x5d78
jmp 0x5d75
jmp 0x5d75
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x8c9c
leaq 0x118(%rsp), %rdi
callq 0x7492
leaq 0xc0(%rsp), %rdi
callq 0x7548
leaq 0xe0(%rsp), %rdi
callq 0x756a
leaq 0x1b0(%rsp), %rdi
callq 0x758c
leaq 0x100(%rsp), %rdi
callq 0x75a0
movq %rbx, %rdi
callq 0x5380