// File: /workspace/github_cpp_makefile_star2_O1/adamiaonr[P]rid-analytics/src/rid-analytics.cpp
// Function: RID_Analytics::make_fwd_decision(RID_Router*, Path_State*, unsigned char, std::vector<std::vector<long double, std::allocator<long double>>, std::allocator<std::vector<long double, std::allocator<long double>>>>, std::vector<std::vector<long double, std::allocator<long double>>, std::allocator<std::vector<long double, std::allocator<long double>>>>, std::vector<RID_Analytics::fwd_decision, std::allocator<RID_Analytics::fwd_decision>>&)
int RID_Analytics::make_fwd_decision(
    RID_Router * router,
    Path_State * prev_state,
    uint8_t in_iface,
    std::vector<std::vector<__float080> > iface_probs,
    std::vector<std::vector<__float080> > out_fptree_probs,
    std::vector<RID_Analytics::fwd_decision> & fwd_decisions) {

    // IMPORTANT: here's what the 3 values in iface_probs[i][] carry
    //  - iface_probs[i][0] : P(L_i >  L_{~i}), i.e. the probability of an 'exclusive'
    //                        match at iface i.
    //                        this should be used for Single Match (SM) events
    //  - iface_probs[i][1] : P(L_i >= L_{~i}), Multiple Match (MM) situations which 
    //                        *DO NOT* involve the choice of iface 0.
    //                        this is useful when evaluating the probability of 
    //                        'fallback' events, in which we want to distinguish 
    //                        MM situations which involve / not involve local 
    //                        matches.
    //  - iface_probs[i][2] : P(L_i >= L_{~i}), multiple match situations which 
    //                        consider the involvement of iface 0.
    //                        this should be the maximum value of all iface[i][].

    // array to save avg. nr of events
    std::vector<__float080> events(EVENT_NUM, 0.0);

    // handle LLM events (iface 0)
    handle_llm(router, iface_probs, events, prev_state);

    // FIXME: special vars for soft fallback handling
    __float080 max_prob[3] = {0.0, 0.0, 0.0};
    int origin_iface = 0;
    // handle other events (iface > 0)
    for (int i = 1; i < router->get_iface_num(); i++) {

        if (on_path_to_origin(router, i, std::stoi(this->origin_server->get_id())))
            origin_iface = i;

        // check if the packet's ttl goes below 0 : if it does, end the path here
        // without adding a forwarding decision
        if ((prev_state->get_ttl() - 1) < 0) { 
            if (iface_probs[i][2] > 0.0)
                handle_ttl_drop(router, iface_probs[i][2], prev_state);
            continue;
        }

        // update the path probability (P(R_n) in the paper)
        __float080 path_prob = 0.0;
        if (this->mode == MMH_FLOOD) {

            // MMH_FLOOD uses P(L_i >= L_{~i}), w/ local matches
            path_prob = iface_probs[i][2];
            // SM event only considers P(L_i > L_{~i})

            if (this->tp_sizes[router->get_id()][i] > 0) {
                events[EVENT_SLMC] += iface_probs[i][0];
            } else {
                events[EVENT_SLMI] += iface_probs[i][0];
            }

            // MM event refers to P(L_i == L_{~i}), as such we do:
            //  P(L_i >= L_{~i}) - P(L_i > L_{~i})
            // FIXME : this will be used to calculate the avg. nr. of links 
            // used in 'flood' mode
            events[EVENT_MLM] += iface_probs[i][2] - iface_probs[i][0];

        } else if (((this->mode & 0x03) == HARD_FALLBACK)
            || ((this->mode & 0x03) == SOFT_FALLBACK)) {

            // as an approximation for the MM event probability, 
            // we use the iface which outputs the max. value of iface_probs[i][1]
            // FIXME: how do we explain this?
            if (max_prob[1] < iface_probs[i][2]) {

                max_prob[0] = iface_probs[i][0];
                max_prob[1] = iface_probs[i][1];

                // FIXME: workaround to get correct value of max_prob at start router
                if ((*router->get_blocked_ifaces())[0])
                    max_prob[2] = iface_probs[i][1];
                else
                    max_prob[2] = iface_probs[i][2];
            }

            // otherwise, use iface_probs[i][0]
            path_prob = iface_probs[i][0];
            if (this->tp_sizes[router->get_id()][i] > 0)
                events[EVENT_SLMC] += iface_probs[i][0];
            else
                events[EVENT_SLMI] += iface_probs[i][0];
        }

        // if path prob = 0.0, skip the addition of a fwd decision
        if (path_prob == 0.0) continue;

        // create a new path state
        Path_State * next_state = new Path_State(router, this->request_size);
        next_state->set_length(prev_state->get_length() + 1);
        // now, we deal with probabilities:
        //
        //  -# in_fptree_probs : the prob of having the packet 
        //     bound to a prefix tree of size s (no TP info)
        //
        //  -# in_iface_probs : the prob of having a packet 
        //     flow through iface i (takes TPs into account)
        //
        next_state->set_in_fptree_prob(&out_fptree_probs[i], this->request_size);
        next_state->set_path_prob(path_prob);
        next_state->set_in_iface_prob(path_prob);
        next_state->set_ttl(prev_state->get_ttl() - 1);

        // finally, we continue with the request path get the next hop router by iface
        RID_Router::nw_address next_hop = router->get_next_hop(i);
        // set the path's tree bitmask (by extracting the bitmask from the router's iface)
        next_state->set_tree_bitmasks(router->get_tree_bitmasks(i));

        // this can still happen (or can it?)
        // FIXME: this subtle condition is the one that actually terminates the run. 
        // FIXME: this could be the source of trouble.
        if (next_hop.router == router || i == in_iface) {
            std::cout << "RID_Analytics::make_fwd_decision() : [INFO] "
                << "found magic stopping condition" << std::endl;

            delete next_state;
            continue;
        }

        // add fwd_decision to fwd decision vector
        std::cout << "RID_Analytics::make_fwd_decision() : [INFO] saving fwd decision :"
            << "\n\tout[" << router->get_id() << "][" << i << "] -> in[" << next_hop.router->get_id() << "][" << (int) next_hop.iface << "]"
            << "\n\tpath prob = " << path_prob
            << "\n\tttl = " << (int) next_state->get_ttl() << std::endl;

        RID_Analytics::fwd_decision fd = {router, next_hop.router, i, next_hop.iface, next_state};
        fwd_decisions.push_back(fd);
    }

    // FIXME: special handling of SOFT_FALLBACK case
    if (this->mode == MMH_FLOOD) {

        events[EVENT_FPD] = std::max(
            (__float080) 0.0, 
            (prev_state->get_in_iface_prob() - events[EVENT_SLMC] - events[EVENT_SLMI] - iface_probs[0][0]));

    } else if ((this->mode & 0x03) == SOFT_FALLBACK) {

        bool updated = false;
        for (unsigned int k = 0; k < fwd_decisions.size(); k++) {

            if (fwd_decisions[k].out_iface == origin_iface) {

                // update fwd_decision on fwd decision vector
                fwd_decisions[k].state->set_path_prob(max_prob[1]);
                fwd_decisions[k].state->set_in_iface_prob(max_prob[1]);
                std::cout << "RID_Analytics::make_fwd_decision() : [INFO] updating fwd decision :"
                    << "\n\tout[" << router->get_id() << "][" << origin_iface << "] -> in[" << fwd_decisions[k].next_router->get_id() << "][" << (int) fwd_decisions[k].in_iface << "]"
                    << "\n\tpath prob = " << max_prob[1]
                    << "\n\tpath length = " << fwd_decisions[k].state->get_length()
                    << "\n\tttl = " << (int) fwd_decisions[k].state->get_ttl() << std::endl;

                // mark fwd decision over origin iface as 'updated'
                updated = true;

                // add 'soft fallback fwd' outcome w/ probability P(L_i == L_{~i})
                if ((max_prob[1] - max_prob[0]) > 0.0)
                    add_outcome(
                        router, 
                        OUTCOME_SOFT_FALLBACK_FWD, 
                        (max_prob[1] - max_prob[0]), 
                        prev_state->get_length());

                events[EVENT_MLM] += (max_prob[2] - max_prob[0]);
            }
        }

        // in case a fwd decision isn't updated above, add a new fwd decision
        if ((!updated) && (max_prob[1] > 0.0)) {
            add_fwd_decision(router, prev_state, out_fptree_probs, origin_iface, max_prob[1], 1, fwd_decisions);
        }

        // handle the case of having the request incorrectly delivered and 
        // recovered w/ a soft fallback (w/ +2 latency penalty)
        if ((!(this->tp_sizes[router->get_id()][0] > 0)) && ((max_prob[2] - max_prob[1]) > 0.0) && (iface_probs[0][2] > 0.0)) {
            add_fwd_decision(router, prev_state, out_fptree_probs, origin_iface, max_prob[2] - max_prob[1], 2, fwd_decisions);
        }

    } else if ((this->mode & 0x03) == HARD_FALLBACK) {

        __float080 mm_prob = std::max(
            (__float080) 0.0, 
            (prev_state->get_in_iface_prob() - events[EVENT_SLMC] - events[EVENT_SLMI] - iface_probs[0][2]));
        
        events[EVENT_FPD] = mm_prob;

        if (mm_prob > 0.0) {

            // 1) add correct delivery 
            add_outcome(
                router, 
                OUTCOME_CORRECT_DELIVERY, 
                (mm_prob), 
                prev_state->get_length() + get_origin_distance(router));

            // 2) register hard fallback activation
            add_outcome(
                router, 
                OUTCOME_HARD_FALLBACK_DELIVERY, 
                (mm_prob), 
                get_origin_distance(router));

            events[EVENT_MLM] += mm_prob;
        }

        if ((iface_probs[0][2] > 0.0) && (router->get_id() != origin_server->get_id()) && (!(this->tp_sizes[router->get_id()][0] > 0))) {

            events[EVENT_SLMI] += iface_probs[0][2];

            // 1) add correct delivery 
            add_outcome(
                router, 
                OUTCOME_CORRECT_DELIVERY, 
                iface_probs[0][2], 
                prev_state->get_length() + 1 + get_origin_distance(router));

            // 2) register hard fallback activation
            add_outcome(
                router, 
                OUTCOME_HARD_FALLBACK_DELIVERY, 
                iface_probs[0][2], 
                get_origin_distance(router));
        }
    }

    // // add fwd record to results
    // add_fwd(router, in_iface, prev_state, fwd_decisions);
    //  - add events probs to results
    add_events(router, events);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %r9, 0xd8(%rsp)
movq %r8, 0x68(%rsp)
movl %ecx, %r15d
movq %rdx, 0x70(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdi, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movq $0x0, 0xc0(%rsp)
movl $0x60, %edi
callq 0x4390
movq %rax, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
movq %rax, %rdx
addq $0x60, %rdx
movq %rdx, 0xc0(%rsp)
xorl %ecx, %ecx
fldz
fld %st(0)
fstpt (%rax,%rcx)
addq $0x10, %rcx
cmpq $0x60, %rcx
jne 0x26926
fstpt 0xec(%rsp)
leaq 0xb0(%rsp), %rcx
movq %rdx, 0x8(%rcx)
movq 0x20(%rsp), %rdi
movq 0x58(%rsp), %rbx
movq %rbx, %rsi
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %r8
callq 0x2632a
movl $0x0, 0x4c(%rsp)
cmpb $0x2, 0x24(%rbx)
fldz
fld %st(0)
fstpt 0x84(%rsp)
fstpt 0x10c(%rsp)
jb 0x27054
movq 0x20(%rsp), %rax
addq $0x20, %rax
movq %rax, 0xe0(%rsp)
movzbl %r15b, %eax
leaq (%rax,%rax,2), %rax
leaq -0x18(,%rax,8), %rax
movq %rax, 0x118(%rsp)
xorl %ebx, %ebx
fldz
movl $0x1, %r13d
movl $0x138, %ebp            # imm = 0x138
leaq 0x28(%rsp), %rdi
fld %st(0)
fstpt 0x10c(%rsp)
fld %st(0)
fstpt 0x84(%rsp)
fstpt 0xec(%rsp)
movl $0x0, 0x4c(%rsp)
movq 0x20(%rsp), %rax
movq 0x80(%rax), %rax
leaq 0x38(%rsp), %rcx
movq %rcx, 0x28(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
callq 0x1c27c
movq 0x28(%rsp), %r14
callq 0x4060
movq %rax, %r15
movl (%rax), %r12d
movl $0x0, (%rax)
movq %r14, %rdi
leaq 0x90(%rsp), %rsi
movl $0xa, %edx
callq 0x4520
cmpq %r14, 0x90(%rsp)
je 0x2791d
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x27929
movl (%r15), %ecx
cmpl $0x22, %ecx
je 0x27929
testl %ecx, %ecx
jne 0x26a63
movl %r12d, (%r15)
movq 0x58(%rsp), %r15
movq %r15, %rdi
movl %r13d, %esi
movl %eax, %edx
callq 0x25e23
movl %eax, %r14d
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x26a94
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %r14b, %r14b
movl 0x4c(%rsp), %eax
cmovnel %r13d, %eax
movl %eax, 0x4c(%rsp)
movq 0x70(%rsp), %rdi
callq 0x1f452
testl %eax, %eax
jle 0x26ad0
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
testl %eax, %eax
je 0x26b08
testb $0x2, %al
jne 0x26bbc
fldz
fstpt 0x78(%rsp)
jmp 0x26c93
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax,%rbx), %rax
fldt 0x20(%rax)
fldz
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jbe 0x26c82
fstpt (%rsp)
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movq 0x70(%rsp), %rdx
callq 0x26476
jmp 0x27033
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax,%rbx), %rax
fldt 0x20(%rax)
fstpt 0x78(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x1c27c
movq 0xe0(%rsp), %rdi
movq %r14, %rsi
callq 0x287bc
movq (%rax), %rax
movb (%rax,%r13), %r14b
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x26b70
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
xorl %eax, %eax
testb %r14b, %r14b
sete %al
movq 0x68(%rsp), %rdx
movq (%rdx), %rcx
movq 0x18(%rcx,%rbx), %rcx
fldt (%rcx)
movq 0xb0(%rsp), %rcx
shll $0x4, %eax
fldt 0x30(%rax,%rcx)
faddp %st, %st(1)
fstpt 0x30(%rax,%rcx)
movq (%rdx), %rax
movq 0x18(%rax,%rbx), %rax
fldt 0x20(%rax)
fldt (%rax)
fsubrp %st, %st(1)
movq 0xb0(%rsp), %rax
addq $0x10, %rax
jmp 0x26c8d
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax,%rbx), %rax
fldt 0x20(%rax)
fldt 0x84(%rsp)
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jbe 0x26c04
fldt (%rax)
fstpt 0x10c(%rsp)
fldt 0x10(%rax)
movq 0x60(%r15), %rcx
testb $0x1, (%rcx)
fld %st(0)
fstpt 0x84(%rsp)
fcmove %st(1), %st
fstp %st(1)
fstpt 0xec(%rsp)
fldz
fstp %st(0)
fldt (%rax)
fstpt 0x78(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x1c27c
movq 0xe0(%rsp), %rdi
movq %r14, %rsi
callq 0x287bc
movq (%rax), %rax
movb (%rax,%r13), %r14b
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x26c60
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax,%rbx), %rax
fldt (%rax)
movq 0xb0(%rsp), %rax
testb %r14b, %r14b
je 0x26c89
addq $0x30, %rax
jmp 0x26c8d
fstp %st(0)
jmp 0x27033
addq $0x40, %rax
fldt (%rax)
faddp %st, %st(1)
fstpt (%rax)
fldz
fldt 0x78(%rsp)
fucompi %st(1), %st
fstp %st(0)
jne 0x26ca5
jnp 0x27033
movl $0x90, %edi
callq 0x4390
movq %rax, %r12
movq 0x20(%rsp), %rax
movzbl (%rax), %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x1f2ec
movq 0x70(%rsp), %rdi
callq 0x1f3a2
incl %eax
movq %r12, %rdi
movl %eax, %esi
callq 0x1f39e
movq 0xd8(%rsp), %rax
movq (%rax), %rax
leaq (%rax,%rbx), %rsi
addq $0x18, %rsi
movq 0x20(%rsp), %rax
movzbl (%rax), %edx
movq %r12, %rdi
callq 0x1f3ba
fldt 0x78(%rsp)
fstpt (%rsp)
movq %r12, %rdi
callq 0x1f3ae
fldt 0x78(%rsp)
fstpt (%rsp)
movq %r12, %rdi
callq 0x1f3fe
movq 0x70(%rsp), %rdi
callq 0x1f452
decl %eax
movq %r12, %rdi
movl %eax, %esi
callq 0x1f44a
movq 0x30(%r15), %rax
leaq (%rax,%rbp), %rsi
addq $-0x38, %rsi
movq 0x30(%rsi), %r15
movzbl 0x38(%rsi), %r14d
movq %r12, %rdi
callq 0x1f43a
cmpq %rbx, 0x118(%rsp)
je 0x26f9c
cmpq 0x58(%rsp), %r15
je 0x26f9c
movl $0x41, %edx
movq 0x19244(%rip), %rdi     # 0x3ffb8
leaq 0xb6b4(%rip), %rsi      # 0x3242f
callq 0x4400
movl $0x6, %edx
movq 0x1922c(%rip), %rdi     # 0x3ffb8
leaq 0xb617(%rip), %rsi      # 0x323aa
callq 0x4400
movl %r14d, 0xd4(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x1c27c
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x191e4(%rip), %rdi     # 0x3ffb8
callq 0x4400
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
leaq 0xb4d8(%rip), %rsi      # 0x322c3
callq 0x4400
movq %r14, %rdi
movl %r13d, %esi
callq 0x46d0
movq %rax, %r14
movl $0x8, %edx
movq %rax, %rdi
leaq 0xb5a4(%rip), %rsi      # 0x323b1
callq 0x4400
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0x1c27c
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq %r14, %rdi
callq 0x4400
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
leaq 0xb460(%rip), %rsi      # 0x322c3
callq 0x4400
movq %r14, %rdi
movl 0xd4(%rsp), %esi
callq 0x46d0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x79a5(%rip), %rsi      # 0x2e82e
callq 0x4400
movl $0xe, %edx
movq %r14, %rdi
leaq 0xb51d(%rip), %rsi      # 0x323ba
callq 0x4400
fldt 0x78(%rsp)
fstpt (%rsp)
movq %r14, %rdi
callq 0x41f0
movq %rax, %r14
movl $0x8, %edx
movq %rax, %rdi
leaq 0xb517(%rip), %rsi      # 0x323da
callq 0x4400
movq %r12, %rdi
callq 0x1f452
movq %r14, %rdi
movl %eax, %esi
callq 0x46d0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42a0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x26f29
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
movl 0xd4(%rsp), %r14d
je 0x26f4d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x58(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %r15, 0x30(%rsp)
movl %r13d, 0x38(%rsp)
movl %r14d, 0x3c(%rsp)
movq %r12, 0x40(%rsp)
movq 0x1c0(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x27024
movups 0x28(%rsp), %xmm0
movups 0x38(%rsp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, 0x8(%rdi)
jmp 0x2702e
movl $0x2c, %edx
movq 0x19010(%rip), %rdi     # 0x3ffb8
leaq 0xb434(%rip), %rsi      # 0x323e3
callq 0x4400
movl $0x1e, %edx
movq 0x18ff8(%rip), %rdi     # 0x3ffb8
leaq 0xb449(%rip), %rsi      # 0x32410
callq 0x4400
movq 0x18fe5(%rip), %rcx     # 0x3ffb8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq 0x18fc7(%rip), %rdi     # 0x3ffb8
callq 0x4040
movq %rax, %rdi
callq 0x42a0
movq 0x50(%r12), %rdi
testq %rdi, %rdi
je 0x27015
movq 0x60(%r12), %rsi
subq %rdi, %rsi
callq 0x43a0
movl $0x90, %esi
movq %r12, %rdi
callq 0x43a0
jmp 0x2702e
leaq 0x28(%rsp), %rdx
callq 0x29c38
movq 0x58(%rsp), %r15
incq %r13
movzbl 0x24(%r15), %eax
addq $0xa0, %rbp
addq $0x18, %rbx
cmpq %rax, %r13
leaq 0x28(%rsp), %rdi
jb 0x269e6
movq 0x20(%rsp), %rax
movl 0x4(%rax), %eax
testl %eax, %eax
je 0x273c2
andl $0x3, %eax
cmpl $0x3, %eax
movq 0x58(%rsp), %r15
je 0x27406
cmpl $0x2, %eax
jne 0x278a5
movq 0x1c0(%rsp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0x275d2
fldt 0x84(%rsp)
fldt 0x10c(%rsp)
fsubr %st, %st(1)
fxch %st(1)
fstpt 0x78(%rsp)
fldt 0xec(%rsp)
fsubp %st, %st(1)
fstpt 0xe0(%rsp)
movl $0x1, %ebp
xorl %ebx, %ebx
movq 0x18ef1(%rip), %r15     # 0x3ffb8
leaq 0xb1f5(%rip), %r13      # 0x322c3
xorl %ecx, %ecx
shlq $0x5, %rbx
movl 0x4c(%rsp), %edx
cmpl %edx, 0x10(%rax,%rbx)
jne 0x27395
addq %rbx, %rax
movq 0x18(%rax), %rdi
fldt 0x84(%rsp)
fstpt (%rsp)
callq 0x1f3ae
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax,%rbx), %rdi
fldt 0x84(%rsp)
fstpt (%rsp)
callq 0x1f3fe
movl $0x43, %edx
movq %r15, %rdi
leaq 0xb34b(%rip), %rsi      # 0x32471
callq 0x4400
movl $0x6, %edx
movq %r15, %rdi
leaq 0xb270(%rip), %rsi      # 0x323aa
callq 0x4400
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x1c27c
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r15, %rdi
callq 0x4400
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x4400
movq %r14, %rdi
movl 0x4c(%rsp), %esi
callq 0x46d0
movq %rax, %r12
movl $0x8, %edx
movq %rax, %rdi
leaq 0xb20c(%rip), %rsi      # 0x323b1
callq 0x4400
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax,%rbx), %rax
leaq 0xa0(%rsp), %rcx
movq %rcx, 0x90(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0x1c27c
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq %r12, %rdi
callq 0x4400
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x4400
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movl 0x14(%rax,%rbx), %esi
movq %r14, %rdi
callq 0x46d0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x75f9(%rip), %rsi      # 0x2e82e
callq 0x4400
movl $0xe, %edx
movq %r14, %rdi
leaq 0xb171(%rip), %rsi      # 0x323ba
callq 0x4400
fldt 0x84(%rsp)
fstpt (%rsp)
movq %r14, %rdi
callq 0x41f0
movq %rax, %r14
movl $0x10, %edx
movq %rax, %rdi
leaq 0xb157(%rip), %rsi      # 0x323c9
callq 0x4400
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax,%rbx), %rdi
callq 0x1f3a2
movq %r14, %rdi
movl %eax, %esi
callq 0x46d0
movq %rax, %r14
movl $0x8, %edx
movq %rax, %rdi
leaq 0xb132(%rip), %rsi      # 0x323da
callq 0x4400
movq 0x1c0(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax,%rbx), %rdi
callq 0x1f452
movq %r14, %rdi
movl %eax, %esi
callq 0x46d0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42a0
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x2731b
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x27337
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
fldt 0x78(%rsp)
fldz
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x2737c
movq 0x70(%rsp), %rdi
callq 0x1f3a2
movl %eax, 0xf8(%rsp)
fildl 0xf8(%rsp)
fstpt 0x10(%rsp)
fldt 0x78(%rsp)
fstpt (%rsp)
movq 0x20(%rsp), %rdi
movq 0x58(%rsp), %rsi
movl $0xa, %edx
callq 0x25c58
movq 0xb0(%rsp), %rax
fldt 0x10(%rax)
fldt 0xe0(%rsp)
faddp %st, %st(1)
fstpt 0x10(%rax)
movb $0x1, %cl
movl %ebp, %ebx
movq 0x1c0(%rsp), %rdx
movq (%rdx), %rax
movq 0x8(%rdx), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
incl %ebp
cmpq %rbx, %rdx
ja 0x270d0
movq 0x58(%rsp), %r15
jmp 0x275d4
movq 0x70(%rsp), %rdi
callq 0x1f418
movq 0x58(%rsp), %r15
movq 0xb0(%rsp), %rax
fldt 0x30(%rax)
fsubrp %st, %st(1)
fldt 0x40(%rax)
fsubrp %st, %st(1)
movq 0x68(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
fldt (%rcx)
fsubrp %st, %st(1)
fldz
fxch %st(1)
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
fstpt 0x50(%rax)
jmp 0x278a5
movq 0x70(%rsp), %rdi
callq 0x1f418
movq 0xb0(%rsp), %rax
fldt 0x30(%rax)
fsubrp %st, %st(1)
fldt 0x40(%rax)
fsubrp %st, %st(1)
movq 0x68(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rcx
fldt 0x20(%rcx)
fsubrp %st, %st(1)
fldz
fxch %st(1)
fucomi %st(1), %st
fxch %st(1)
fcmovnbe %st(1), %st
fstp %st(1)
fld %st(0)
fstpt 0x4c(%rsp)
fstpt 0x50(%rax)
jbe 0x274dc
movq 0x70(%rsp), %rdi
callq 0x1f3a2
movl %eax, %ebp
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x2589e
addl %ebp, %eax
movl %eax, 0x108(%rsp)
fildl 0x108(%rsp)
fldt 0x4c(%rsp)
fstpt (%rsp)
fstpt 0x10(%rsp)
movq 0x20(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x25c58
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x2589e
movl %eax, 0x104(%rsp)
fildl 0x104(%rsp)
fstpt 0x10(%rsp)
fldt 0x4c(%rsp)
fstpt (%rsp)
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x25c58
movq 0xb0(%rsp), %rax
fldt 0x10(%rax)
fldt 0x4c(%rsp)
faddp %st, %st(1)
fstpt 0x10(%rax)
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
fldt 0x20(%rax)
fldz
fxch %st(1)
fucomi %st(1), %st
fstp %st(1)
jbe 0x275c9
fstpt 0x4c(%rsp)
leaq 0x38(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x1c27c
movq 0x20(%rsp), %rax
movq 0x80(%rax), %rax
leaq 0xa0(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0x1c27c
movq 0x30(%rsp), %rdx
cmpq 0x98(%rsp), %rdx
jne 0x2757a
testq %rdx, %rdx
je 0x27767
movq 0x90(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x43b0
testl %eax, %eax
je 0x27767
leaq 0x148(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x58(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x138(%rsp), %rdi
callq 0x1c27c
movq 0x20(%rsp), %rax
leaq 0x20(%rax), %rdi
leaq 0x138(%rsp), %rsi
callq 0x287bc
movq (%rax), %rax
cmpb $0x0, (%rax)
sete %bl
movb $0x1, %al
jmp 0x2776b
xorl %eax, %eax
xorl %ebx, %ebx
jmp 0x27774
xorl %ecx, %ecx
testb $0x1, %cl
jne 0x27646
fldz
fldt 0x84(%rsp)
fucompi %st(1), %st
fstp %st(0)
jbe 0x27646
leaq 0x170(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x28838
movq 0x1c0(%rsp), %rax
movq %rax, 0x10(%rsp)
fldt 0x84(%rsp)
fstpt (%rsp)
leaq 0x170(%rsp), %rcx
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movq 0x70(%rsp), %rdx
movl 0x4c(%rsp), %r8d
movl $0x1, %r9d
callq 0x2650e
leaq 0x170(%rsp), %rdi
callq 0x1e1ae
leaq 0x38(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x1c27c
movq 0x20(%rsp), %rax
leaq 0x20(%rax), %rdi
leaq 0x28(%rsp), %rsi
callq 0x287bc
movq (%rax), %rax
cmpb $0x0, (%rax)
fldz
jne 0x27745
fstp %st(0)
fldt 0xec(%rsp)
fldt 0x84(%rsp)
fsubrp %st, %st(1)
fldz
fld %st(1)
fstpt 0x58(%rsp)
fxch %st(1)
fucompi %st(1), %st
jbe 0x27745
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
fldt 0x20(%rax)
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x276db
fstp %st(1)
movq 0x38(%rsp), %rsi
incq %rsi
fstpt 0x78(%rsp)
callq 0x43a0
fldt 0x78(%rsp)
fldz
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x278a5
leaq 0x158(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x28838
movq 0x1c0(%rsp), %rax
movq %rax, 0x10(%rsp)
fldt 0x58(%rsp)
fstpt (%rsp)
leaq 0x158(%rsp), %rcx
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movq 0x70(%rsp), %rdx
movl 0x4c(%rsp), %r8d
movl $0x2, %r9d
callq 0x2650e
leaq 0x158(%rsp), %rdi
callq 0x1e1ae
jmp 0x278a5
fstp %st(0)
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
je 0x278a5
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x278a5
xorl %eax, %eax
xorl %ebx, %ebx
movq 0x58(%rsp), %r15
fldt 0x4c(%rsp)
testb %al, %al
je 0x277a1
leaq 0x148(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x277a1
movq 0x148(%rsp), %rsi
incq %rsi
fstpt 0x4c(%rsp)
callq 0x43a0
fldt 0x4c(%rsp)
fldz
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x277e7
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x277cc
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x43a0
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x277e7
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
testb %bl, %bl
je 0x278a5
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
fldt 0x20(%rax)
movq 0xb0(%rsp), %rcx
fldt 0x40(%rcx)
faddp %st, %st(1)
fstpt 0x40(%rcx)
fldt 0x20(%rax)
fstpt 0x4c(%rsp)
movq 0x70(%rsp), %rdi
callq 0x1f3a2
movl %eax, %r14d
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x2589e
addl %r14d, %eax
incl %eax
movl %eax, 0x100(%rsp)
fildl 0x100(%rsp)
fldt 0x4c(%rsp)
fstpt (%rsp)
fstpt 0x10(%rsp)
movq 0x20(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x25c58
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rax
fldt 0x20(%rax)
fstpt 0x4c(%rsp)
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x2589e
movl %eax, 0xfc(%rsp)
fildl 0xfc(%rsp)
fstpt 0x10(%rsp)
fldt 0x4c(%rsp)
fstpt (%rsp)
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x25c58
leaq 0x120(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x1e548
leaq 0x120(%rsp), %rdx
movq 0x20(%rsp), %rdi
movq %r15, %rsi
callq 0x25e88
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x278ec
movq 0x130(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x27909
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
xorl %eax, %eax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9d16(%rip), %rdi      # 0x3163a
callq 0x4250
leaq 0x9d0a(%rip), %rdi      # 0x3163a
callq 0x4580
movq %rax, %r14
leaq 0x158(%rsp), %rdi
jmp 0x27991
movq %rax, %r14
movq 0x138(%rsp), %rdi
cmpq %r12, %rdi
je 0x27967
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x27967
movq %rax, %r14
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x279a4
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x279a4
movq %rax, %r14
leaq 0x170(%rsp), %rdi
callq 0x1e1ae
jmp 0x27a74
jmp 0x279a1
jmp 0x27a1d
jmp 0x27a1d
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %rbx, %rdi
jne 0x27a67
jmp 0x27a74
jmp 0x27a1d
fstp %st(0)
jmp 0x27a1d
fstp %st(0)
jmp 0x27a1d
jmp 0x27a1d
movq %rax, %r14
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x27a74
movq 0x130(%rsp), %rsi
subq %rdi, %rsi
jmp 0x27a6f
jmp 0x27a1d
jmp 0x27a1d
jmp 0x27a1d
jmp 0x27a12
jmp 0x27a1d
jmp 0x27a1d
jmp 0x27a12
jmp 0x27a1d
jmp 0x27a12
movq %rax, %r14
movl $0x90, %esi
movq %r12, %rdi
jmp 0x27a6f
jmp 0x27a12
jmp 0x27a1d
jmp 0x27a12
jmp 0x27a12
jmp 0x27a1d
jmp 0x27a1d
movq %rax, %r14
jmp 0x27a58
jmp 0x27a1d
jmp 0x27a1d
jmp 0x27a22
movq %rax, %r14
jmp 0x27a74
movq %rax, %r14
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x27a58
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x27a58
movq %rax, %r14
cmpl $0x0, (%r15)
jne 0x27a58
movl %r12d, (%r15)
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x27a74
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x27a91
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
movq %r14, %rdi
callq 0x4700
nop