// File: /workspace/github_cpp_makefile_star2_O2/ynilu[P]elastic/simulator.cpp
// Function: main
int main(int argc, char *argv[])
{
    if( argc > 6 )
    {
        cout << "\nToo many arguments,EX: simulation labmda rquest_number" << "\n";
        return 1;
    }
    if( argc > 1 )
    {
        if( atoi( argv[ 1 ] ) > 0 )
        {
            traffic_lambda = atoi( argv[ 1 ] );
        }
        else
        {
            cout << "\nError parameter: 1" << "\n";
            return 1;
        }
    }
    if( argc > 2 )
    {
        if( atoi( argv[ 2 ] ) > 0 )
        {
            num_requests = atoi( argv[ 2 ] );
        }
        else
        {
            cout << "\nError parameter: 2" << "\n";
            return 1;
        }
    }
    if( argc > 3 )
    {
        if( atoi( argv[ 3 ] ) == 0 )
        {
            enable_OTDM = 0;
        }
    }
    if( argc > 4 )
    {
        if( atoi( argv[ 4 ] ) > 0 )
        {
            num_transceiver = atoi( argv[ 4 ] );
        }
        else
        {
            cout << "\nError parameter: 4" << "\n";
            return 1;
        }
    }
    if( argc > 5 )
    {
        switch( atoi( argv[5] ) )
        {
        case 1:
            graph_file = (char*) "USnet.txt";
            source_file = (char*) "USnet_source.txt";
            traffic_file = (char*) "USnet_traffic.txt";
            break;
        default:
            break;
        }
    }

    if(num_transceiver < 800)
    {
        OEO_weight = hop_limit;
    }

    if(enable_OTDM)
    {
        num_OFDM_transceiver = num_transceiver / 2;
        num_OTDM_transceiver = num_transceiver / 2;
    }
    else
    {
        num_OFDM_transceiver = num_transceiver;
        num_OTDM_transceiver = 0;
    }

    start_clk = clock();

    accepted_requests_BM.resize(num_batch, 0);
    blocked_requests_BM.resize(num_batch, 0);
    blocked_bandwidth_BM.resize(num_batch, 0);
    num_OEO_BM.resize(num_batch, 0);
    num_OFDM_lightpath_use_BM.resize(num_batch, 0);
    num_OTDM_lightpath_use_BM.resize(num_batch, 0);

    Graph_info g_info;
    g_info.graph_file = graph_file;
    g_info.num_slots = num_slots;
    g_info.num_OTDM_transceiver = num_OTDM_transceiver;
    g_info.num_OFDM_transceiver = num_OFDM_transceiver;
    g_info.slot_capacity = slot_capacity;
    g_info.transceiver_slot_limit = transceiver_slot_limit;
    g_info.transceiver_connection_limit = transceiver_connection_limit;
    g_info.transmission_distance_16QAM = transmission_distance_16QAM;
    g_info.transmission_distance_8QAM = transmission_distance_8QAM;
    g_info.transmission_distance_QPSK = transmission_distance_QPSK;

    Phy_graph p_graph(g_info);

    cout << "num_nodes : " << p_graph.node_list.size() << "\n";
    num_nodes = p_graph.node_list.size();

    Traffic_info t_info;
    t_info.source_file = source_file;
    t_info.traffic_file = traffic_file;
    t_info.num_nodes = p_graph.node_list.size();
    t_info.num_requests = num_requests;
    t_info.OC1_share = OC1_share;
    t_info.OC3_share = OC3_share;
    t_info.OC9_share = OC9_share;
    t_info.OC12_share = OC12_share;
    t_info.OC18_share = OC18_share;
    t_info.OC24_share = OC24_share;
    t_info.OC36_share = OC36_share;
    t_info.OC48_share = OC48_share;
    t_info.OC192_share = OC192_share;
    t_info.OC768_share = OC768_share;
    t_info.OC3072_share = OC3072_share;
    t_info.traffic_lambda = traffic_lambda;
    t_info.traffic_mu = traffic_mu;
    t_info.unicast_percentage = unicast_percentage;

    t_info.aTime_seed = aTime_seed;
    t_info.hTime_seed = hTime_seed;
    t_info.s_seed = s_seed;
    t_info.d_seed = d_seed;
    t_info.numD_seed = numD_seed;
    t_info.b_seed = b_seed;

    Traffic traffic (t_info);

    request2lightpath.resize(num_requests);

    Auxiliary_info a_info;
    a_info.num_nodes = num_nodes;
    a_info.num_slots = num_slots;
    a_info.transceiver_weight = transceiver_weight;
    a_info.used_transceiver_weight = used_transceiver_weight;
    a_info.OFDM_transceiver_weight = OFDM_transceiver_weight;
    a_info.used_OFDM_transceiver_weight = used_OFDM_transceiver_weight;
    a_info.OEO_weight = OEO_weight;
    Aux_graph a_graph(a_info);


    while( !traffic.empty() )
    {
        Event event = traffic.next_event();
        if(event.type == Event::arrival)
        {
            cout << "arrival :\nid = " << event.request_id << "\nsource = " << event.source << "\ndest = " << *event.destination.begin() << "\nbandwidth = " << event.bandwidth << "\narrivaltime = " << event.arrival_time << "\n\n";
            start_clk_construction = clock();
            construct_candidate_path(event, p_graph, a_graph);
            construct_exist_path(event, p_graph, a_graph);
            clk_construction += (double) ( clock() - start_clk_construction ) / CLOCKS_PER_SEC;
            start_clk_finding = clock();
            Aux_node* aux_source = a_graph.get_adding_node(event.source);
            Aux_node* aux_destination = a_graph.get_dropping_node(*(event.destination.begin()));
            Aux_node2Aux_link result = BellmanFordSP(aux_source);
            clk_finding += (double) ( clock() - start_clk_finding ) / CLOCKS_PER_SEC;
            start_clk_parsing = clock();
            if(result[aux_destination] != NULL) // Accepted
            {
                path_parsing(p_graph, result, aux_source, aux_destination, event);
                accepted_requests++;
                accepted_requests_BM[(int)event.request_id/(num_requests/num_batch)]++;
            }
            else
            {
                blocked_requests++;
                blocked_requests_BM[(int)event.request_id/(num_requests/num_batch)]++;
                blocked_bandwidth += event.bandwidth;
                blocked_bandwidth_BM[(int)event.request_id/(num_requests/num_batch)] += event.bandwidth;
            }
            clk_parsing += (double) ( clock() - start_clk_parsing ) / CLOCKS_PER_SEC;
            total_bandwidth += event.bandwidth;
            start_clk_construction = clock();
            reset_auxiliary_graph();
            clk_construction += (double) ( clock() - start_clk_construction ) / CLOCKS_PER_SEC;
        }
        else // if(event.type == Event::departure)
        {
            cout << "departure :\nid = " << event.request_id << "\nsource = " << event.source << "\ndest = " << *event.destination.begin() << "\nbandwidth = " << event.bandwidth << "\narrivaltime = " << event.arrival_time << "\n\n";
            for(auto &lp : request2lightpath[event.request_id])
            {
                lp->requests.erase(event.request_id);
                if(lp->requests.empty())
                {
                    int slot_st;
                    int slot_ed;
                    Path& path = lp->p_path;
                    switch(lp->type)
                    {
                    case LightPath::OTDM:
                        slot_st = lp->spectrum.slot_st;
                        slot_ed = lp->spectrum.slot_ed;

                        for(unsigned int node_i = 0; node_i < path.size() - 1; node_i++)
                        {
                            int from = path[node_i];
                            int to = path[node_i + 1];
                            Phy_link& link = p_graph.get_link(from, to);

                            for(int i = slot_st; i <= slot_ed; i++)
                            {
                                link.slot[i] = -1;
                            }
                        }

                        for(unsigned int i = 0; i < lp->transmitter_index.size(); i++)
                        {
                            if(lp->transmitter_index[i] != -1)
                            {
                                p_graph.get_node(path[i]).num_available_transmitter++;
                            }
                        }

                        for(unsigned int i = 0; i < lp->receiver_index.size(); i++)
                        {
                            if(lp->receiver_index[i] != -1)
                            {
                                p_graph.get_node(path[i]).num_available_receiver++;
                            }
                        }
                        delete lp;
                        exist_OTDM_light_path_list.remove(lp);
                        break;
                    case LightPath::OFDM_WOB:
                    case LightPath::OFDM_WB:
                    case LightPath::OFDM:
                        slot_st = lp->spectrum.slot_st;
                        slot_ed = lp->spectrum.slot_ed;

                        Phy_node& src_node = p_graph.get_node(path.front());
                        Phy_node& dst_node = p_graph.get_node(path.back());
                        src_node.OFDMtransmitter[lp->transmitter_index.front()].num_available_sub_transceiver++;
                        dst_node.OFDMreceiver[lp->receiver_index.back()].num_available_sub_transceiver++;

                        for(unsigned int node_i = 0; node_i < path.size() - 1; node_i++)
                        {
                            int from = path[node_i];
                            int to = path[node_i + 1];
                            Phy_link& link = p_graph.get_link(from, to);

                            for(int i = slot_st; i <= slot_ed; i++)
                            {
                                link.slot[i] = -1;
                            }
                        }

                        if(src_node.OFDMtransmitter[lp->transmitter_index.front()].num_available_sub_transceiver >= transceiver_connection_limit)
                        {
                            src_node.OFDMtransmitter[lp->transmitter_index.front()].spectrum.slot_st = -1;
                            src_node.OFDMtransmitter[lp->transmitter_index.front()].spectrum.slot_ed = -1;
                            src_node.OFDMtransmitter[lp->transmitter_index.front()].in_used = false;
                            src_node.OFDMtransmitter[lp->transmitter_index.front()].num_available_sub_transceiver = transceiver_connection_limit;
                            src_node.num_available_OFDM_transmitter++;
                        }

                        if(dst_node.OFDMreceiver[lp->receiver_index.back()].num_available_sub_transceiver >= transceiver_connection_limit)
                        {
                            dst_node.OFDMreceiver[lp->receiver_index.back()].spectrum.slot_st = -1;
                            dst_node.OFDMreceiver[lp->receiver_index.back()].spectrum.slot_ed = -1;
                            dst_node.OFDMreceiver[lp->receiver_index.back()].in_used = false;
                            dst_node.OFDMreceiver[lp->receiver_index.back()].num_available_sub_transceiver = transceiver_connection_limit;
                            dst_node.num_available_OFDM_receiver++;
                        }
                        delete lp;
                        exist_OFDM_light_path_list.remove(lp);
                        break;
                    }
                }
                else
                {
                    lp->available_bitrate += event.bandwidth;
                }
            }
            end_time = event.arrival_time;
        }
    }
    total_network_bandwidth = slot_capacity * num_slots * p_graph.link_list.size();
    print_result(traffic);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5b8, %rsp            # imm = 0x5B8
cmpl $0x7, %edi
jl 0x275c
movq 0x15897(%rip), %rdi     # 0x17fd0
leaq 0xc9b0(%rip), %rsi      # 0xf0f0
callq 0x21e0
leaq 0xca95(%rip), %rsi      # 0xf1e1
movq %rax, %rdi
callq 0x21e0
pushq $0x1
popq %rax
jmp 0x31ef
movl %edi, %ebp
cmpl $0x2, %edi
jl 0x27bb
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x22b0
testl %eax, %eax
jle 0x3201
movl %eax, 0x15a4f(%rip)     # 0x181cc
cmpl $0x2, %ebp
je 0x27bb
movq 0x10(%rbx), %rdi
callq 0x22b0
testl %eax, %eax
jle 0x3214
movl %eax, 0x15a2b(%rip)     # 0x181c4
cmpl $0x4, %ebp
jb 0x27bb
movq 0x18(%rbx), %rdi
callq 0x22b0
testl %eax, %eax
jne 0x27b2
andl $0x0, 0x15a3e(%rip)     # 0x181f0
cmpl $0x4, %ebp
jne 0x3227
movl 0x15a13(%rip), %ecx     # 0x181d4
cmpl $0x31f, %ecx            # imm = 0x31F
jg 0x27d9
cvtsi2sdl 0x159eb(%rip), %xmm0 # 0x181bc
movsd %xmm0, 0x15c0f(%rip)    # 0x183e8
movl 0x15a11(%rip), %esi     # 0x181f0
pushq $0x2
popq %rdi
movl %ecx, %eax
cltd
idivl %edi
testl %esi, %esi
cmovnel %eax, %ecx
cmovel %esi, %eax
movl %ecx, 0x159e7(%rip)     # 0x181dc
movl %eax, 0x159dd(%rip)     # 0x181d8
callq 0x2140
movq %rax, 0x15a99(%rip)     # 0x182a0
movslq 0x159aa(%rip), %rsi     # 0x181b8
leaq 0x138(%rsp), %rbx
andl $0x0, (%rbx)
leaq 0x15af0(%rip), %rdi     # 0x18310
movq %rbx, %rdx
callq 0x65c0
movslq 0x15989(%rip), %rsi     # 0x181b8
andl $0x0, (%rbx)
leaq 0x15aef(%rip), %rdi     # 0x18328
leaq 0x138(%rsp), %rbx
movq %rbx, %rdx
callq 0x65c0
movslq 0x15968(%rip), %rsi     # 0x181b8
andl $0x0, (%rbx)
leaq 0x15ae6(%rip), %rdi     # 0x18340
leaq 0x138(%rsp), %rbx
movq %rbx, %rdx
callq 0x65c0
movslq 0x15947(%rip), %rsi     # 0x181b8
andl $0x0, (%rbx)
leaq 0x15add(%rip), %rdi     # 0x18358
leaq 0x138(%rsp), %rbx
movq %rbx, %rdx
callq 0x65c0
movslq 0x15926(%rip), %rsi     # 0x181b8
andl $0x0, (%rbx)
leaq 0x15ad4(%rip), %rdi     # 0x18370
leaq 0x138(%rsp), %rbx
movq %rbx, %rdx
callq 0x65c0
movslq 0x15905(%rip), %rsi     # 0x181b8
andl $0x0, (%rbx)
leaq 0x15acb(%rip), %rdi     # 0x18388
leaq 0x138(%rsp), %rdx
callq 0x65c0
movq 0x1599f(%rip), %rax     # 0x18270
leaq 0x3b0(%rsp), %rsi
movq %rax, (%rsi)
movl 0x158e6(%rip), %eax     # 0x181c8
movl %eax, 0x8(%rsi)
movl 0x158ed(%rip), %eax     # 0x181d8
movl %eax, 0xc(%rsi)
movl 0x158e8(%rip), %eax     # 0x181dc
movl %eax, 0x10(%rsi)
movl 0x158e3(%rip), %eax     # 0x181e0
movl %eax, 0x14(%rsi)
movl 0x158de(%rip), %eax     # 0x181e4
movl %eax, 0x18(%rsi)
movl 0x158d9(%rip), %eax     # 0x181e8
movl %eax, 0x1c(%rsi)
movl 0x158e0(%rip), %eax     # 0x181f8
movl %eax, 0x20(%rsi)
movl 0x158db(%rip), %eax     # 0x181fc
movl %eax, 0x24(%rsi)
movl 0x158d6(%rip), %eax     # 0x18200
movl %eax, 0x28(%rsi)
leaq 0x70(%rsp), %rdi
callq 0x9164
movq 0x15692(%rip), %rdi     # 0x17fd0
leaq 0xc84c(%rip), %rsi      # 0xf191
callq 0x21e0
movq %rax, %rdi
movq 0x80(%rsp), %rax
subq 0x78(%rsp), %rax
movl $0x98, %ecx
cqto
idivq %rcx
movq %rax, %rsi
callq 0x2150
leaq 0xc86e(%rip), %rsi      # 0xf1e1
movq %rax, %rdi
callq 0x21e0
movq 0x80(%rsp), %rax
subq 0x78(%rsp), %rax
movl $0x98, %ecx
cqto
idivq %rcx
movl %eax, 0x15940(%rip)     # 0x182d8
movq 0x158d9(%rip), %rcx     # 0x18278
leaq 0x530(%rsp), %rsi
movq %rcx, (%rsi)
movq 0x158cf(%rip), %rcx     # 0x18280
movq %rcx, 0x8(%rsi)
movl %eax, 0x10(%rsi)
movl 0x15806(%rip), %eax     # 0x181c4
movl %eax, 0x14(%rsi)
movl 0x15915(%rip), %eax     # 0x182dc
movl %eax, 0x58(%rsi)
movl 0x15910(%rip), %eax     # 0x182e0
movl %eax, 0x5c(%rsi)
movl 0x1590b(%rip), %eax     # 0x182e4
movl %eax, 0x60(%rsi)
movl 0x15906(%rip), %eax     # 0x182e8
movl %eax, 0x64(%rsi)
movl 0x15819(%rip), %eax     # 0x18204
movl %eax, 0x68(%rsi)
movl 0x15814(%rip), %eax     # 0x18208
movl %eax, 0x6c(%rsi)
movl 0x1580f(%rip), %eax     # 0x1820c
movl %eax, 0x70(%rsi)
movl 0x1580a(%rip), %eax     # 0x18210
movl %eax, 0x74(%rsi)
movl 0x15805(%rip), %eax     # 0x18214
movl %eax, 0x78(%rsi)
movl 0x15800(%rip), %eax     # 0x18218
movl %eax, 0x7c(%rsi)
movl 0x157fb(%rip), %eax     # 0x1821c
movl %eax, 0x80(%rsi)
movl 0x1579f(%rip), %eax     # 0x181cc
movl %eax, 0x18(%rsi)
movl 0x1579a(%rip), %eax     # 0x181d0
movl %eax, 0x1c(%rsi)
movss 0x1577f(%rip), %xmm0    # 0x181c0
movss %xmm0, 0x20(%rsi)
movq 0x157d3(%rip), %rax     # 0x18220
movq %rax, 0x28(%rsi)
movq 0x157d0(%rip), %rax     # 0x18228
movq %rax, 0x30(%rsi)
movq 0x157cd(%rip), %rax     # 0x18230
movq %rax, 0x38(%rsi)
movq 0x157ca(%rip), %rax     # 0x18238
movq %rax, 0x40(%rsi)
movq 0x157c7(%rip), %rax     # 0x18240
movq %rax, 0x48(%rsi)
movq 0x157c4(%rip), %rax     # 0x18248
movq %rax, 0x50(%rsi)
leaq 0x138(%rsp), %rdi
callq 0xc214
movslq 0x15728(%rip), %rsi     # 0x181c4
leaq 0x15995(%rip), %rdi     # 0x18438
callq 0x65f4
movl 0x1582a(%rip), %eax     # 0x182d8
leaq 0x380(%rsp), %rsi
movl %eax, 0x4(%rsi)
movl 0x15709(%rip), %eax     # 0x181c8
movl %eax, (%rsi)
movsd 0x158ff(%rip), %xmm0    # 0x183c8
movsd %xmm0, 0x8(%rsi)
movsd 0x158fa(%rip), %xmm0    # 0x183d0
movsd %xmm0, 0x10(%rsi)
movsd 0x158f5(%rip), %xmm0    # 0x183d8
movsd %xmm0, 0x18(%rsi)
movsd 0x158f0(%rip), %xmm0    # 0x183e0
movsd %xmm0, 0x20(%rsi)
movsd 0x158eb(%rip), %xmm0    # 0x183e8
movsd %xmm0, 0x28(%rsi)
leaq 0x288(%rsp), %rdi
callq 0xd89a
leaq 0x14(%rsp), %rbp
leaq 0x138(%rsp), %rbx
leaq 0x70(%rsp), %r12
leaq 0x288(%rsp), %r14
leaq 0x100(%rsp), %r13
movq %rbx, %rdi
callq 0xcac6
testb %al, %al
jne 0x317f
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0xcad2
cmpl $0x0, 0x10(%rsp)
je 0x2ef2
movq 0x15470(%rip), %rdi     # 0x17fd0
leaq 0xc67c(%rip), %rsi      # 0xf1e3
callq 0x21e0
movl 0x14(%rsp), %esi
movq %rax, %rdi
callq 0x2310
movq %rax, %rdi
leaq 0xc62c(%rip), %rsi      # 0xf1ae
callq 0x21e0
movl 0x18(%rsp), %esi
movq %rax, %rdi
callq 0x2310
movq %rax, %rdi
leaq 0xc61c(%rip), %rsi      # 0xf1b9
callq 0x21e0
movq 0x38(%rsp), %rcx
movl 0x20(%rcx), %esi
movq %rax, %rdi
callq 0x2310
movq %rax, %rdi
leaq 0xc606(%rip), %rsi      # 0xf1c2
callq 0x21e0
movl 0x54(%rsp), %esi
movq %rax, %rdi
callq 0x2310
movq %rax, %rdi
leaq 0xc5f9(%rip), %rsi      # 0xf1d0
callq 0x21e0
movss 0x58(%rsp), %xmm0
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xc5ec(%rip), %rsi      # 0xf1e0
callq 0x21e0
movslq 0x14(%rsp), %rax
movq 0x15833(%rip), %rcx     # 0x18438
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rbx
movq 0x8(%rcx,%rax), %rax
movq %rax, 0x68(%rsp)
cmpq 0x68(%rsp), %rbx
je 0x2edf
movq (%rbx), %rdi
addq $0x10, %rdi
movq %rbp, %rsi
callq 0x7df2
movq (%rbx), %r15
cmpq $0x0, 0x38(%r15)
je 0x2c48
movl 0x54(%rsp), %eax
addl %eax, 0x44(%r15)
jmp 0x2ed6
movl 0x8(%r15), %eax
leal -0x1(%rax), %ecx
cmpl $0x3, %ecx
jae 0x2dd1
movslq 0x58(%r15), %r14
movslq 0x5c(%r15), %rbp
movq 0x68(%r15), %rax
movl (%rax), %esi
movq %r12, %rdi
callq 0x98a8
movq %rax, %r13
movq 0x70(%r15), %rax
movl -0x4(%rax), %esi
movq %r12, %rdi
callq 0x98a8
movq (%rbx), %rsi
movq 0xc8(%rsi), %rcx
movslq (%rcx), %rcx
movq 0x68(%r13), %rdx
imulq $0x58, %rcx, %rcx
incl 0xc(%rdx,%rcx)
movq 0xe8(%rsi), %rcx
movslq -0x4(%rcx), %rdx
movq %rax, 0x60(%rsp)
movq 0x80(%rax), %rcx
imulq $0x58, %rdx, %rax
incl 0xc(%rcx,%rax)
xorl %r12d, %r12d
movl %r12d, %ecx
movq 0x68(%r15), %rax
movq 0x70(%r15), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
decq %rdx
cmpq %rcx, %rdx
jbe 0x2cff
movl (%rax,%rcx,4), %esi
leal 0x1(%rcx), %r12d
movl (%rax,%r12,4), %edx
leaq 0x70(%rsp), %rdi
callq 0x9148
movq 0x18(%rax), %rax
movq %r14, %rcx
cmpq %rbp, %rcx
jg 0x2cbb
orl $-0x1, (%rax,%rcx,4)
incq %rcx
jmp 0x2cf1
movq (%rbx), %rdi
movq 0xc8(%rdi), %rcx
movslq (%rcx), %rdx
movq 0x68(%r13), %rax
imulq $0x58, %rdx, %rsi
movl 0x154ce(%rip), %edx     # 0x181e8
cmpl %edx, 0xc(%rax,%rsi)
jl 0x2d4d
addq %rax, %rsi
orl $-0x1, 0x48(%rsi)
movslq (%rcx), %rdx
imulq $0x58, %rdx, %rdx
orl $-0x1, 0x4c(%rax,%rdx)
movslq (%rcx), %rcx
imulq $0x58, %rcx, %rcx
movb $0x0, 0x8(%rax,%rcx)
movl 0x154a3(%rip), %edx     # 0x181e8
movl %edx, 0xc(%rax,%rcx)
incl 0x2c(%r13)
movq 0xe8(%rdi), %rcx
movslq -0x4(%rcx), %rsi
movq 0x60(%rsp), %r8
movq 0x80(%r8), %rax
imulq $0x58, %rsi, %rsi
cmpl %edx, 0xc(%rax,%rsi)
leaq 0x14(%rsp), %rbp
leaq 0x70(%rsp), %r12
leaq 0x288(%rsp), %r14
jl 0x2daf
addq %rax, %rsi
orl $-0x1, 0x48(%rsi)
movslq -0x4(%rcx), %rdx
imulq $0x58, %rdx, %rdx
orl $-0x1, 0x4c(%rax,%rdx)
movslq -0x4(%rcx), %rcx
imulq $0x58, %rcx, %rcx
movb $0x0, 0x8(%rax,%rcx)
movl 0x15441(%rip), %edx     # 0x181e8
movl %edx, 0xc(%rax,%rcx)
incl 0x34(%r8)
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x15664(%rip), %rdi     # 0x18420
movq %rbx, %rsi
callq 0x662a
leaq 0x100(%rsp), %r13
jmp 0x2ed6
testl %eax, %eax
jne 0x2ed6
movslq 0x58(%r15), %r14
movslq 0x5c(%r15), %r12
xorl %r13d, %r13d
movl %r13d, %ecx
movq 0x68(%r15), %rax
movq 0x70(%r15), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
decq %rdx
cmpq %rcx, %rdx
jbe 0x2e28
movl (%rax,%rcx,4), %esi
leal 0x1(%rcx), %r13d
movl (%rax,%r13,4), %edx
leaq 0x70(%rsp), %rdi
callq 0x9148
movq 0x18(%rax), %rax
movq %r14, %rcx
cmpq %r12, %rcx
jg 0x2de4
orl $-0x1, (%rax,%rcx,4)
incq %rcx
jmp 0x2e1a
xorl %r14d, %r14d
leaq 0x70(%rsp), %r12
leaq 0x100(%rsp), %r13
movl %r14d, %r14d
movq (%rbx), %rdi
movq 0xc8(%rdi), %rax
movq 0xd0(%rdi), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0x2e77
cmpl $-0x1, (%rax,%r14,4)
je 0x2e72
movq 0x68(%r15), %rax
movl (%rax,%r14,4), %esi
movq %r12, %rdi
callq 0x98a8
incl 0x28(%rax)
incl %r14d
jmp 0x2e38
xorl %r14d, %r14d
movl %r14d, %r14d
movq 0xe0(%rdi), %rax
movq 0xe8(%rdi), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0x2eb9
cmpl $-0x1, (%rax,%r14,4)
je 0x2eb4
movq 0x68(%r15), %rax
movl (%rax,%r14,4), %esi
movq %r12, %rdi
callq 0x98a8
incl 0x30(%rax)
movq (%rbx), %rdi
incl %r14d
jmp 0x2e7a
movq (%rdi), %rax
callq *0x8(%rax)
leaq 0x15542(%rip), %rdi     # 0x18408
movq %rbx, %rsi
callq 0x662a
leaq 0x288(%rsp), %r14
addq $0x8, %rbx
jmp 0x2c17
cvtss2sd 0x58(%rsp), %xmm0
movsd %xmm0, 0x154d3(%rip)    # 0x183c0
jmp 0x3168
movq 0x150d7(%rip), %rdi     # 0x17fd0
leaq 0xc29e(%rip), %rsi      # 0xf19e
callq 0x21e0
movl 0x14(%rsp), %esi
movq %rax, %rdi
callq 0x2310
movq %rax, %rdi
leaq 0xc293(%rip), %rsi      # 0xf1ae
callq 0x21e0
movl 0x18(%rsp), %esi
movq %rax, %rdi
callq 0x2310
movq %rax, %rdi
leaq 0xc283(%rip), %rsi      # 0xf1b9
callq 0x21e0
movq 0x38(%rsp), %rcx
movl 0x20(%rcx), %esi
movq %rax, %rdi
callq 0x2310
movq %rax, %rdi
leaq 0xc26d(%rip), %rsi      # 0xf1c2
callq 0x21e0
movl 0x54(%rsp), %esi
movq %rax, %rdi
callq 0x2310
movq %rax, %rdi
leaq 0xc260(%rip), %rsi      # 0xf1d0
callq 0x21e0
movss 0x58(%rsp), %xmm0
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
leaq 0xc253(%rip), %rsi      # 0xf1e0
callq 0x21e0
callq 0x2140
movq %rax, 0x1531a(%rip)     # 0x182b8
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x3325
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x33ea
callq 0x2140
subq 0x152ee(%rip), %rax     # 0x182b8
cvtsi2sd %rax, %xmm0
divsd 0xc031(%rip), %xmm0     # 0xf008
addsd 0x152e1(%rip), %xmm0    # 0x182c0
movsd %xmm0, 0x152d9(%rip)    # 0x182c0
callq 0x2140
movq %rax, 0x152b5(%rip)     # 0x182a8
movl 0x18(%rsp), %esi
movq %r14, %rdi
callq 0xdf74
movq %rax, %rbx
movq 0x38(%rsp), %rax
movl 0x20(%rax), %esi
movq %r14, %rdi
callq 0xdf80
movq %rax, (%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x371a
callq 0x2140
subq 0x1527b(%rip), %rax     # 0x182a8
cvtsi2sd %rax, %xmm0
divsd 0xbfce(%rip), %xmm0     # 0xf008
addsd 0x1526e(%rip), %xmm0    # 0x182b0
movsd %xmm0, 0x15266(%rip)    # 0x182b0
callq 0x2140
movq %rax, 0x15272(%rip)     # 0x182c8
movq %r13, %rdi
movq %rsp, %rsi
callq 0x7a7a
cmpq $0x0, (%rax)
je 0x3091
movq (%rsp), %rcx
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
leaq 0x8(%rsp), %r8
callq 0x3891
leaq 0x15267(%rip), %rax     # 0x182ec
pushq $0x1
popq %rdi
leaq 0x15281(%rip), %r8      # 0x18310
jmp 0x30cd
incl 0x15259(%rip)           # 0x182f0
movl 0x14(%rsp), %ecx
movl 0x15123(%rip), %eax     # 0x181c4
cltd
idivl 0x15110(%rip)           # 0x181b8
movl %eax, %esi
movl %ecx, %eax
cltd
idivl %esi
cltq
movq 0x15270(%rip), %rcx     # 0x18328
incl (%rcx,%rax,4)
movl 0x54(%rsp), %edi
leaq 0x1522e(%rip), %rax     # 0x182f4
leaq 0x15273(%rip), %r8      # 0x18340
addl %edi, (%rax)
movl 0x14(%rsp), %ecx
movl 0x150eb(%rip), %eax     # 0x181c4
cltd
idivl 0x150d8(%rip)           # 0x181b8
movl %eax, %esi
movl %ecx, %eax
cltd
idivl %esi
cltq
movq (%r8), %rcx
addl %edi, (%rcx,%rax,4)
callq 0x2140
subq 0x151cd(%rip), %rax     # 0x182c8
cvtsi2sd %rax, %xmm0
movsd 0xbf00(%rip), %xmm1     # 0xf008
divsd %xmm1, %xmm0
addsd 0x151bc(%rip), %xmm0    # 0x182d0
movsd %xmm0, 0x151b4(%rip)    # 0x182d0
movl 0x54(%rsp), %eax
addl %eax, 0x151de(%rip)     # 0x18304
callq 0x2140
movq %rax, 0x15186(%rip)     # 0x182b8
callq 0x3bd8
callq 0x2140
subq 0x15175(%rip), %rax     # 0x182b8
cvtsi2sd %rax, %xmm0
divsd 0xbeb8(%rip), %xmm0     # 0xf008
addsd 0x15168(%rip), %xmm0    # 0x182c0
movsd %xmm0, 0x15160(%rip)    # 0x182c0
movq %r13, %rdi
callq 0x69c4
leaq 0x8(%rsp), %rdi
callq 0xce3e
leaq 0x138(%rsp), %rbx
jmp 0x2b31
movl 0x15043(%rip), %eax     # 0x181c8
imull 0x15054(%rip), %eax     # 0x181e0
imull 0xb8(%rsp), %eax
movl %eax, 0x1516e(%rip)     # 0x18308
leaq 0x3e0(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x6688
leaq 0x3e0(%rsp), %rdi
callq 0x3cfa
leaq 0x3e0(%rsp), %rdi
callq 0xca6e
leaq 0x288(%rsp), %rdi
callq 0xdcdc
leaq 0x138(%rsp), %rdi
callq 0xca6e
leaq 0x70(%rsp), %rdi
callq 0x960e
xorl %eax, %eax
addq $0x5b8, %rsp            # imm = 0x5B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x14dc8(%rip), %rdi     # 0x17fd0
leaq 0xbf19(%rip), %rsi      # 0xf128
jmp 0x2740
movq 0x14db5(%rip), %rdi     # 0x17fd0
leaq 0xbf1a(%rip), %rsi      # 0xf13c
jmp 0x2740
movq 0x20(%rbx), %rdi
callq 0x22b0
testl %eax, %eax
jle 0x3286
movl %eax, %ecx
movl %eax, 0x14f98(%rip)     # 0x181d4
cmpl $0x6, %ebp
jne 0x27c1
movq 0x28(%rbx), %rdi
callq 0x22b0
cmpl $0x1, %eax
jne 0x27bb
leaq 0xbf06(%rip), %rax      # 0xf164
movq %rax, 0x1500b(%rip)     # 0x18270
leaq 0xbf02(%rip), %rax      # 0xf16e
movq %rax, 0x15005(%rip)     # 0x18278
leaq 0xbf05(%rip), %rax      # 0xf17f
movq %rax, 0x14fff(%rip)     # 0x18280
jmp 0x27bb
movq 0x14d43(%rip), %rdi     # 0x17fd0
leaq 0xbebc(%rip), %rsi      # 0xf150
jmp 0x2740
movq %rax, %rbx
leaq 0x3e0(%rsp), %rdi
callq 0xca6e
jmp 0x32f9
jmp 0x32d5
jmp 0x32af
movq %rax, %rbx
jmp 0x3306
jmp 0x32b6
movq %rax, %rbx
jmp 0x3313
jmp 0x32ec
jmp 0x32ec
jmp 0x32ec
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x69c4
jmp 0x32ef
jmp 0x32d5
movq %rax, %rbx
jmp 0x32f9
jmp 0x32ec
jmp 0x32ec
jmp 0x32ec
jmp 0x32ec
jmp 0x32ec
jmp 0x32ec
jmp 0x32ec
jmp 0x32ec
jmp 0x32ec
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xce3e
leaq 0x288(%rsp), %rdi
callq 0xdcdc
leaq 0x138(%rsp), %rdi
callq 0xca6e
leaq 0x70(%rsp), %rdi
callq 0x960e
movq %rbx, %rdi
callq 0x2320