// File: adamiaonr[P]rid-analytics/src/rid-analytics.cpp
// Function: RID_Analytics::build_network(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int RID_Analytics::build_network(std::string nw_filename) {

    // read .scn file, structured as an xml file
    pugi::xml_document nw_doc;
    if (!(nw_doc.load_file(nw_filename.c_str()))) {

        std::cerr << "RID_Analytics::get_network() : [ERROR] .scn file (" 
            << nw_filename << ") not found." << std::endl;

        return -1;
    }

    pugi::xml_node topology = nw_doc.child("topology");

    // ***
    // *** extract the fwd table size (a unique table size for the complete topology)
    // ***
    std::cout << "RID_Analytics::build_network() : [INFO] table size: ";
    pugi::xml_node ts = topology.child("fwd_table_size");
    uint64_t table_size = ts.text().as_uint();
    std::cout << "\n\tSIZE = " << ts.text().as_uint() << " (" << table_size << ")" << std::endl;

    // ***
    // *** extract the ttl
    // ***
    std::cout << "RID_Analytics::build_network() : [INFO] ttl: ";
    pugi::xml_node ttl_block = topology.child("ttl");
    this->ttl = ttl_block.text().as_int();
    std::cout << "\n\tTTL = " << ttl_block.text().as_int() << " (" << ttl << ")" << std::endl;

    // ***
    // *** start building the topology by reading the info for each router
    // ***
    for (pugi::xml_node router = topology.child("router"); 
        router; 
        router = router.next_sibling("router")) {

        std::string router_id = std::string(router.attribute("id").value());
        std::cout << "RID_Analytics::build_network() : [INFO] installing router " << router_id << std::endl;

        // ***
        // *** extract iface nr. & entry distr. per iface
        // ***
        std::cout << "RID_Analytics::build_network() : [INFO] \% of entries per iface: ";
        // extract the nr. of ifaces by counting the number of fwd_dist xml nodes
        int iface_num = 0;
        // extract iface <-> map
        std::map<int, __float080> fwd_dist;
        for (pugi::xml_node dist = router.child("fwd_dist"); 
            dist; 
            dist = dist.next_sibling("fwd_dist")) {

            fwd_dist[(int) dist.attribute("iface").as_int()] = ((__float080) dist.text().as_double());
            // increment the number of ifaces here
            iface_num++;

            std::cout << "\n\tIFACE = " << dist.attribute("iface").as_int()
                << ", DISTR. = " << (__float080) dist.text().as_double() 
                    << " (" << fwd_dist[(int) dist.attribute("iface").as_int()] << ")";
        }
        std::cout << std::endl;

        std::cout << "RID_Analytics::build_network() : [INFO] iface_num = " << (int) iface_num << std::endl;

        // ***
        // *** create or initialize new RID router
        // ***
        RID_Router * new_router = NULL;
        RID_RouterMap::iterator rit;
        if ((rit = this->routers.find(router_id)) != this->routers.end()) {

            new_router = (*rit).second;
            new_router->init(
                router_id,
                table_size,                 // nr. of table entries for router
                iface_num,                  // nr. of ifaces (i.e. nr. of adjacent routers)
                this->request_size,         // max. request & forwarding entry size
                this->bf_size,              // BF size (of both requests and entries, in bit)
                this->mode);                // modes for multiple matches and error resolution

        } else {

            new_router = 
                new RID_Router(
                    router_id,
                    table_size,
                    (uint8_t) iface_num,
                    this->request_size,
                    this->bf_size,
                    this->mode);

            // add the router to the router map
            this->routers[router_id] = new_router;

            std::cout << "RID_Analytics::build_network() : [INFO] added new router : "
                << router_id << std::endl;
        }

        // ***
        // *** initialize router ifaces & add fwd entries
        // ***
        for (pugi::xml_node link = router.child("link"); 
            link; 
            link = link.next_sibling("link")) {

            // ***
            // *** extract fwd entry size distributions
            // ***
            std::map<int, __float080> size_dist;
            for (pugi::xml_node s_dist = link.child("fwd_size_dist"); 
                s_dist; 
                s_dist = s_dist.next_sibling("fwd_size_dist")) {

                size_dist[s_dist.attribute("size").as_uint()] = s_dist.text().as_double();
            }

            // ***
            // *** extract the tree bitmask : a bitmask which indicates which
            // *** sources are reachable from this iface 
            // ***
            std::map<int, std::vector<uint8_t> > tree_bitmasks;

            for (pugi::xml_node tree_bitmask_block = link.child("tree_bitmask"); 
                tree_bitmask_block; 
                tree_bitmask_block = tree_bitmask_block.next_sibling("tree_bitmask")) {

                std::string tree_bitmask_str = std::string(tree_bitmask_block.text().as_string());
                std::vector<uint8_t> tree_bitmask;

                for (unsigned int i = 0; i < tree_bitmask_str.size(); ) {

                    uint8_t higher_bits = (uint8_t) ((tree_bitmask_str[i] >= 'a') ? (tree_bitmask_str[i] - 'a' + 10) : (tree_bitmask_str[i] - '0'));
                    // std::cout << "RID_Analytics::build_network() : [INFO] tree_bitmask["
                    //     << router_id << "][" << link.attribute("local").as_int() << "] : "
                    //     << "\n\tstr (H4): " << tree_bitmask_str[i]
                    //     << "\n\tint (H4): " << (int) higher_bits << std::endl;

                    i++;

                    uint8_t lower_bits = (uint8_t) ((tree_bitmask_str[i] >= 'a') ? (tree_bitmask_str[i] - 'a' + 10) : (tree_bitmask_str[i] - '0'));
                    // std::cout << "RID_Analytics::build_network() : [INFO] tree_bitmask["
                    //     << router_id << "][" << link.attribute("local").as_int() << "] : "
                    //     << "\n\tstr (L4): " << tree_bitmask_str[i]
                    //     << "\n\tint (L4): " << (int) lower_bits
                    //     << "\n\tint (H4L4): " << (int) (((higher_bits << 4) & 0xF0) | (lower_bits & 0x0F)) << std::endl;

                    i++;

                    tree_bitmask.push_back(((higher_bits << 4) & 0xF0) | (lower_bits & 0x0F));
                }

                unsigned int tb_size = tree_bitmask_block.attribute("size").as_uint();
                tree_bitmasks[tb_size] = tree_bitmask;

                std::cout << "RID_Analytics::build_network() : [INFO] tree_bitmask["
                    << router_id << "][" << link.attribute("local").as_int() << "] : ";
                for (unsigned int i = 0; i < tree_bitmasks[tb_size].size(); i++)
                    std::cout << "[" << (int) tree_bitmasks[tb_size][i] << "] ";
                std::cout << std::endl;
            }
            
            std::string adjacent_router_id = std::string(link.attribute("rrouter").value());

            // if adjacent_router is already in the router map, fetch its 
            // pointer. otherwise, create a new RID_Router object.
            RID_Router * adjacent_router = NULL;
            RID_RouterMap::iterator rtr_map_it;       
            if ((rtr_map_it = this->routers.find(adjacent_router_id)) != this->routers.end()) {

                adjacent_router = (*rtr_map_it).second;

            } else {

                adjacent_router = new RID_Router();
                // add adj. router to the router map
                this->routers[adjacent_router_id] = adjacent_router;

                std::cout << "RID_Analytics::build_network() : [INFO] added new router : "
                    << adjacent_router_id << std::endl;
            }

            new_router->add_fwd_table_entry(
                link.attribute("local").as_int(),
                fwd_dist[link.attribute("local").as_uint()],
                &size_dist,
                &tree_bitmasks,
                adjacent_router, 
                link.attribute("remote").as_int());
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x830, %rsp            # imm = 0x830
movq %rsi, -0x430(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x438(%rbp)
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x428(%rbp)
callq 0xce80
movq -0x430(%rbp), %rdi
callq 0x51d0
movq -0x428(%rbp), %rsi
movq %rax, %rdx
leaq -0x100(%rbp), %rdi
movl $0x74, %ecx
xorl %r8d, %r8d
callq 0xd810
jmp 0x4b784
leaq -0x100(%rbp), %rdi
callq 0xcd20
movb %al, -0x439(%rbp)
jmp 0x4b798
movb -0x439(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x4b7a9
jmp 0x4b83f
movq 0x36840(%rip), %rdi     # 0x81ff0
leaq 0x18778(%rip), %rsi     # 0x63f2f
callq 0x5480
movq %rax, -0x448(%rbp)
jmp 0x4b7c5
movq -0x430(%rbp), %rsi
movq -0x448(%rbp), %rdi
callq 0x5430
movq %rax, -0x450(%rbp)
jmp 0x4b7e1
movq -0x450(%rbp), %rdi
leaq 0x18773(%rip), %rsi     # 0x63f62
callq 0x5480
movq %rax, -0x458(%rbp)
jmp 0x4b7fd
movq -0x458(%rbp), %rdi
movq 0x36785(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4b812
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x110(%rbp)
jmp 0x4cf02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x4cf1a
leaq 0x18729(%rip), %rsi     # 0x63f6f
leaq -0xe8(%rbp), %rdi
callq 0x7650
movq %rax, -0x460(%rbp)
jmp 0x4b85b
movq -0x460(%rbp), %rax
movq %rax, -0x118(%rbp)
movq 0x36748(%rip), %rdi     # 0x81fb8
leaq 0x18747(%rip), %rsi     # 0x63fbe
callq 0x5480
jmp 0x4b87e
leaq 0x1876e(%rip), %rsi     # 0x63ff3
leaq -0x118(%rbp), %rdi
callq 0x7650
movq %rax, -0x468(%rbp)
jmp 0x4b89a
movq -0x468(%rbp), %rax
movq %rax, -0x120(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x7f80
movq %rax, -0x470(%rbp)
jmp 0x4b8bd
movq -0x470(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
callq 0xbb30
movl %eax, -0x474(%rbp)
jmp 0x4b8e1
movl -0x474(%rbp), %eax
movl %eax, %eax
movq %rax, -0x128(%rbp)
movq 0x366c1(%rip), %rdi     # 0x81fb8
leaq 0x18704(%rip), %rsi     # 0x64002
callq 0x5480
movq %rax, -0x480(%rbp)
jmp 0x4b90c
leaq -0x120(%rbp), %rdi
callq 0x7f80
movq %rax, -0x488(%rbp)
jmp 0x4b921
movq -0x488(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq -0x138(%rbp), %rdi
xorl %esi, %esi
callq 0xbb30
movl %eax, -0x48c(%rbp)
jmp 0x4b945
movl -0x48c(%rbp), %esi
movq -0x480(%rbp), %rdi
callq 0x56c0
movq %rax, -0x498(%rbp)
jmp 0x4b960
movq -0x498(%rbp), %rdi
leaq 0x185f1(%rip), %rsi     # 0x63f5f
callq 0x5480
movq %rax, -0x4a0(%rbp)
jmp 0x4b97c
movq -0x4a0(%rbp), %rdi
movq -0x128(%rbp), %rsi
callq 0x5140
movq %rax, -0x4a8(%rbp)
jmp 0x4b998
movq -0x4a8(%rbp), %rdi
leaq 0x15558(%rip), %rsi     # 0x60efe
callq 0x5480
movq %rax, -0x4b0(%rbp)
jmp 0x4b9b4
movq -0x4b0(%rbp), %rdi
movq 0x365ce(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4b9c9
movq 0x365e8(%rip), %rdi     # 0x81fb8
leaq 0x18635(%rip), %rsi     # 0x6400c
callq 0x5480
jmp 0x4b9de
leaq 0x18655(%rip), %rsi     # 0x6403a
leaq -0x118(%rbp), %rdi
callq 0x7650
movq %rax, -0x4b8(%rbp)
jmp 0x4b9fa
movq -0x4b8(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x7f80
movq %rax, -0x4c0(%rbp)
jmp 0x4ba1d
movq -0x4c0(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0x148(%rbp), %rdi
xorl %esi, %esi
callq 0xbae0
movl %eax, -0x4c4(%rbp)
jmp 0x4ba41
movq -0x438(%rbp), %rax
movl -0x4c4(%rbp), %ecx
movl %ecx, 0x90(%rax)
movq 0x3655d(%rip), %rdi     # 0x81fb8
leaq 0x185dc(%rip), %rsi     # 0x6403e
callq 0x5480
movq %rax, -0x4d0(%rbp)
jmp 0x4ba70
leaq -0x140(%rbp), %rdi
callq 0x7f80
movq %rax, -0x4d8(%rbp)
jmp 0x4ba85
movq -0x4d8(%rbp), %rax
movq %rax, -0x150(%rbp)
leaq -0x150(%rbp), %rdi
xorl %esi, %esi
callq 0xbae0
movl %eax, -0x4dc(%rbp)
jmp 0x4baa9
movl -0x4dc(%rbp), %esi
movq -0x4d0(%rbp), %rdi
callq 0x58f0
movq %rax, -0x4e8(%rbp)
jmp 0x4bac4
movq -0x4e8(%rbp), %rdi
leaq 0x1848d(%rip), %rsi     # 0x63f5f
callq 0x5480
movq %rax, -0x4f0(%rbp)
jmp 0x4bae0
movq -0x4f0(%rbp), %rdi
movq -0x438(%rbp), %rax
movl 0x90(%rax), %esi
callq 0x58f0
movq %rax, -0x4f8(%rbp)
jmp 0x4bb02
movq -0x4f8(%rbp), %rdi
leaq 0x153ee(%rip), %rsi     # 0x60efe
callq 0x5480
movq %rax, -0x500(%rbp)
jmp 0x4bb1e
movq -0x500(%rbp), %rdi
movq 0x36464(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4bb33
leaq 0x1775f(%rip), %rsi     # 0x63299
leaq -0x118(%rbp), %rdi
callq 0x7650
movq %rax, -0x508(%rbp)
jmp 0x4bb4f
movq -0x508(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x73b0
movq %rax, -0x510(%rbp)
jmp 0x4bb72
movq -0x510(%rbp), %rax
cmpq $0x0, %rax
je 0x4cef1
leaq 0x18647(%rip), %rsi     # 0x641d1
leaq -0x158(%rbp), %rdi
callq 0x79e0
movq %rax, -0x518(%rbp)
jmp 0x4bb9f
movq -0x518(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x6750
movq %rax, -0x520(%rbp)
jmp 0x4bbc2
leaq -0x181(%rbp), %rdi
movq %rdi, -0x528(%rbp)
callq 0x5930
movq -0x520(%rbp), %rsi
movq -0x528(%rbp), %rdx
leaq -0x178(%rbp), %rdi
callq 0x30320
jmp 0x4bbf1
leaq -0x181(%rbp), %rdi
callq 0x5510
movq 0x363b4(%rip), %rdi     # 0x81fb8
leaq 0x1843c(%rip), %rsi     # 0x64047
callq 0x5480
movq %rax, -0x530(%rbp)
jmp 0x4bc19
movq -0x530(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x5430
movq %rax, -0x538(%rbp)
jmp 0x4bc35
movq -0x538(%rbp), %rdi
movq 0x3634d(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4bc4a
movq 0x36367(%rip), %rdi     # 0x81fb8
leaq 0x1842a(%rip), %rsi     # 0x64082
callq 0x5480
jmp 0x4bc5f
movl $0x0, -0x188(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x52370
leaq 0x18447(%rip), %rsi     # 0x640c3
leaq -0x158(%rbp), %rdi
callq 0x7650
movq %rax, -0x540(%rbp)
jmp 0x4bc91
movq -0x540(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x73b0
movq %rax, -0x548(%rbp)
jmp 0x4bcb4
movq -0x548(%rbp), %rax
cmpq $0x0, %rax
je 0x4bfed
leaq -0x1c0(%rbp), %rdi
callq 0x7f80
movq %rax, -0x550(%rbp)
jmp 0x4bcda
movq -0x550(%rbp), %rax
movq %rax, -0x1c8(%rbp)
leaq -0x1c8(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0xbb80
movsd %xmm0, -0x558(%rbp)
jmp 0x4bd01
movsd -0x558(%rbp), %xmm0
movsd %xmm0, -0x418(%rbp)
fldl -0x418(%rbp)
fstpt -0x56c(%rbp)
leaq 0x18294(%rip), %rsi     # 0x63fb8
leaq -0x1c0(%rbp), %rdi
callq 0x79e0
movq %rax, -0x560(%rbp)
jmp 0x4bd39
movq -0x560(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x1d8(%rbp), %rdi
xorl %esi, %esi
callq 0x62f0
movl %eax, -0x570(%rbp)
jmp 0x4bd5d
movl -0x570(%rbp), %eax
movl %eax, -0x1cc(%rbp)
leaq -0x1b8(%rbp), %rdi
leaq -0x1cc(%rbp), %rsi
callq 0x34b90
movq %rax, -0x578(%rbp)
jmp 0x4bd85
movq -0x578(%rbp), %rax
fldt -0x56c(%rbp)
fstpt (%rax)
movl -0x188(%rbp), %eax
incl %eax
movl %eax, -0x188(%rbp)
movq 0x3620f(%rip), %rdi     # 0x81fb8
leaq 0x1831c(%rip), %rsi     # 0x640cc
callq 0x5480
movq %rax, -0x580(%rbp)
jmp 0x4bdbe
leaq 0x181f3(%rip), %rsi     # 0x63fb8
leaq -0x1c0(%rbp), %rdi
callq 0x79e0
movq %rax, -0x588(%rbp)
jmp 0x4bdda
movq -0x588(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x1e0(%rbp), %rdi
xorl %esi, %esi
callq 0x62f0
movl %eax, -0x58c(%rbp)
jmp 0x4bdfe
movl -0x58c(%rbp), %esi
movq -0x580(%rbp), %rdi
callq 0x58f0
movq %rax, -0x598(%rbp)
jmp 0x4be19
movq -0x598(%rbp), %rdi
leaq 0x182b0(%rip), %rsi     # 0x640d7
callq 0x5480
movq %rax, -0x5a0(%rbp)
jmp 0x4be35
leaq -0x1c0(%rbp), %rdi
callq 0x7f80
movq %rax, -0x5a8(%rbp)
jmp 0x4be4a
movq -0x5a8(%rbp), %rax
movq %rax, -0x1e8(%rbp)
leaq -0x1e8(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0xbb80
movsd %xmm0, -0x5b0(%rbp)
jmp 0x4be71
movq -0x5a0(%rbp), %rdi
movsd -0x5b0(%rbp), %xmm0
movsd %xmm0, -0x420(%rbp)
fldl -0x420(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0x55b0
movq %rax, -0x5b8(%rbp)
jmp 0x4bea1
movq -0x5b8(%rbp), %rdi
leaq 0x180b0(%rip), %rsi     # 0x63f5f
callq 0x5480
movq %rax, -0x5c0(%rbp)
jmp 0x4bebd
leaq 0x180f4(%rip), %rsi     # 0x63fb8
leaq -0x1c0(%rbp), %rdi
callq 0x79e0
movq %rax, -0x5c8(%rbp)
jmp 0x4bed9
movq -0x5c8(%rbp), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x1f8(%rbp), %rdi
xorl %esi, %esi
callq 0x62f0
movl %eax, -0x5cc(%rbp)
jmp 0x4befd
movl -0x5cc(%rbp), %eax
movl %eax, -0x1ec(%rbp)
leaq -0x1b8(%rbp), %rdi
leaq -0x1ec(%rbp), %rsi
callq 0x34b90
movq %rax, -0x5d8(%rbp)
jmp 0x4bf25
movq -0x5c0(%rbp), %rdi
movq -0x5d8(%rbp), %rax
fldt (%rax)
movq %rsp, %rax
fstpt (%rax)
callq 0x55b0
movq %rax, -0x5e0(%rbp)
jmp 0x4bf48
movq -0x5e0(%rbp), %rdi
leaq 0x14fa8(%rip), %rsi     # 0x60efe
callq 0x5480
jmp 0x4bf5d
jmp 0x4bf5f
leaq 0x1815d(%rip), %rsi     # 0x640c3
leaq -0x1c0(%rbp), %rdi
callq 0x7a80
movq %rax, -0x5e8(%rbp)
jmp 0x4bf7b
movq -0x5e8(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x200(%rbp), %rax
movq %rax, -0x1c0(%rbp)
jmp 0x4bc9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x181(%rbp), %rdi
callq 0x5510
jmp 0x4cf1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x4cee3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x4ced7
movq 0x35fc4(%rip), %rdi     # 0x81fb8
movq 0x35f95(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4c002
movq 0x35faf(%rip), %rdi     # 0x81fb8
leaq 0x180d3(%rip), %rsi     # 0x640e3
callq 0x5480
movq %rax, -0x5f0(%rbp)
jmp 0x4c01e
movq -0x5f0(%rbp), %rdi
movl -0x188(%rbp), %esi
callq 0x58f0
movq %rax, -0x5f8(%rbp)
jmp 0x4c039
movq -0x5f8(%rbp), %rdi
movq 0x35f49(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4c04e
movq $0x0, -0x208(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x52390
movq -0x438(%rbp), %rdi
addq $0x50, %rdi
leaq -0x178(%rbp), %rsi
callq 0x523b0
movq %rax, -0x600(%rbp)
jmp 0x4c085
movq -0x438(%rbp), %rdi
movq -0x600(%rbp), %rax
movq %rax, -0x218(%rbp)
movq -0x218(%rbp), %rax
movq %rax, -0x210(%rbp)
addq $0x50, %rdi
callq 0x51c40
movq %rax, -0x220(%rbp)
leaq -0x210(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x51c10
testb $0x1, %al
jne 0x4c0d4
jmp 0x4c17d
leaq -0x210(%rbp), %rdi
callq 0x51c70
movq 0x20(%rax), %rax
movq %rax, -0x208(%rbp)
movq -0x208(%rbp), %rax
movq %rax, -0x608(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x51f0
jmp 0x4c10e
movq -0x608(%rbp), %rdi
movq -0x438(%rbp), %rax
movq -0x128(%rbp), %rdx
movzbl -0x188(%rbp), %ecx
movzbl (%rax), %r8d
movzwl 0x2(%rax), %r9d
movl 0x4(%rax), %esi
movq %rsp, %rax
movl %esi, (%rax)
leaq -0x240(%rbp), %rsi
callq 0x31fa0
jmp 0x4c149
leaq -0x240(%rbp), %rdi
callq 0x52f0
jmp 0x4c2e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x52f0
jmp 0x4ced7
movl $0xa8, %edi
callq 0x54a0
movq %rax, -0x610(%rbp)
jmp 0x4c190
movb $0x1, -0x261(%rbp)
leaq -0x260(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x51f0
jmp 0x4c1ac
movq -0x610(%rbp), %rdi
movq -0x438(%rbp), %rax
movq -0x128(%rbp), %rdx
movzbl -0x188(%rbp), %ecx
movzbl (%rax), %r8d
movzwl 0x2(%rax), %r9d
movl 0x4(%rax), %esi
movq %rsp, %rax
movl %esi, (%rax)
leaq -0x260(%rbp), %rsi
callq 0x32370
jmp 0x4c1e7
movq -0x610(%rbp), %rax
movb $0x0, -0x261(%rbp)
movq %rax, -0x208(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x52f0
movq -0x438(%rbp), %rdi
movq -0x208(%rbp), %rax
movq %rax, -0x620(%rbp)
addq $0x50, %rdi
leaq -0x178(%rbp), %rsi
callq 0x51a60
movq %rax, -0x618(%rbp)
jmp 0x4c236
movq -0x618(%rbp), %rax
movq -0x620(%rbp), %rcx
movq %rcx, (%rax)
movq 0x35d6a(%rip), %rdi     # 0x81fb8
leaq 0x17ec3(%rip), %rsi     # 0x64118
callq 0x5480
movq %rax, -0x628(%rbp)
jmp 0x4c263
movq -0x628(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x5430
movq %rax, -0x630(%rbp)
jmp 0x4c27f
movq -0x630(%rbp), %rdi
movq 0x35d03(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4c294
jmp 0x4c2e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x4c2c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x52f0
testb $0x1, -0x261(%rbp)
jne 0x4c2d3
jmp 0x4c2e4
movq -0x610(%rbp), %rdi
movl $0xa8, %esi
callq 0x54b0
jmp 0x4ced7
leaq 0x17e64(%rip), %rsi     # 0x64154
leaq -0x158(%rbp), %rdi
callq 0x7650
movq %rax, -0x638(%rbp)
jmp 0x4c305
movq -0x638(%rbp), %rax
movq %rax, -0x270(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x73b0
movq %rax, -0x640(%rbp)
jmp 0x4c328
movq -0x640(%rbp), %rax
cmpq $0x0, %rax
je 0x4ce82
leaq -0x2a0(%rbp), %rdi
callq 0x52370
leaq 0x17e0d(%rip), %rsi     # 0x64159
leaq -0x270(%rbp), %rdi
callq 0x7650
movq %rax, -0x648(%rbp)
jmp 0x4c361
movq -0x648(%rbp), %rax
movq %rax, -0x2a8(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x73b0
movq %rax, -0x650(%rbp)
jmp 0x4c384
movq -0x650(%rbp), %rax
cmpq $0x0, %rax
je 0x4c4b8
leaq -0x2a8(%rbp), %rdi
callq 0x7f80
movq %rax, -0x658(%rbp)
jmp 0x4c3aa
movq -0x658(%rbp), %rax
movq %rax, -0x2b0(%rbp)
leaq -0x2b0(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0xbb80
movsd %xmm0, -0x660(%rbp)
jmp 0x4c3d1
movsd -0x660(%rbp), %xmm0
movsd %xmm0, -0x410(%rbp)
fldl -0x410(%rbp)
fstpt -0x674(%rbp)
leaq 0x16d1f(%rip), %rsi     # 0x63113
leaq -0x2a8(%rbp), %rdi
callq 0x79e0
movq %rax, -0x668(%rbp)
jmp 0x4c409
movq -0x668(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x2c0(%rbp), %rdi
xorl %esi, %esi
callq 0x6370
movl %eax, -0x678(%rbp)
jmp 0x4c42d
movl -0x678(%rbp), %eax
movl %eax, -0x2b4(%rbp)
leaq -0x2a0(%rbp), %rdi
leaq -0x2b4(%rbp), %rsi
callq 0x34b90
movq %rax, -0x680(%rbp)
jmp 0x4c455
movq -0x680(%rbp), %rax
fldt -0x674(%rbp)
fstpt (%rax)
leaq 0x17cee(%rip), %rsi     # 0x64159
leaq -0x2a8(%rbp), %rdi
callq 0x7a80
movq %rax, -0x688(%rbp)
jmp 0x4c480
movq -0x688(%rbp), %rax
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rax
movq %rax, -0x2a8(%rbp)
jmp 0x4c36f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x4ce74
leaq -0x2f8(%rbp), %rdi
callq 0x38e60
leaq 0x17c9c(%rip), %rsi     # 0x64167
leaq -0x270(%rbp), %rdi
callq 0x7650
movq %rax, -0x690(%rbp)
jmp 0x4c4e0
movq -0x690(%rbp), %rax
movq %rax, -0x300(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x73b0
movq %rax, -0x698(%rbp)
jmp 0x4c503
movq -0x698(%rbp), %rax
cmpq $0x0, %rax
je 0x4ca75
leaq -0x300(%rbp), %rdi
callq 0x7f80
movq %rax, -0x6a0(%rbp)
jmp 0x4c529
movq -0x6a0(%rbp), %rax
movq %rax, -0x328(%rbp)
leaq 0x16fca(%rip), %rsi     # 0x63508
leaq -0x328(%rbp), %rdi
callq 0xba90
movq %rax, -0x6a8(%rbp)
jmp 0x4c553
leaq -0x329(%rbp), %rdi
movq %rdi, -0x6b0(%rbp)
callq 0x5930
movq -0x6a8(%rbp), %rsi
movq -0x6b0(%rbp), %rdx
leaq -0x320(%rbp), %rdi
callq 0x30320
jmp 0x4c582
leaq -0x329(%rbp), %rdi
callq 0x5510
leaq -0x348(%rbp), %rdi
callq 0x34900
movl $0x0, -0x34c(%rbp)
movl -0x34c(%rbp), %eax
movq %rax, -0x6b8(%rbp)
leaq -0x320(%rbp), %rdi
callq 0x5350
movq %rax, %rcx
movq -0x6b8(%rbp), %rax
cmpq %rcx, %rax
jae 0x4c7c5
movl -0x34c(%rbp), %eax
movl %eax, %esi
leaq -0x320(%rbp), %rdi
callq 0x5a40
movq %rax, -0x6c0(%rbp)
jmp 0x4c5ed
movq -0x6c0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jl 0x4c631
movl -0x34c(%rbp), %eax
movl %eax, %esi
leaq -0x320(%rbp), %rdi
callq 0x5a40
movq %rax, -0x6c8(%rbp)
jmp 0x4c619
movq -0x6c8(%rbp), %rax
movsbl (%rax), %eax
subl $0x61, %eax
addl $0xa, %eax
movl %eax, -0x6cc(%rbp)
jmp 0x4c661
movl -0x34c(%rbp), %eax
movl %eax, %esi
leaq -0x320(%rbp), %rdi
callq 0x5a40
movq %rax, -0x6d8(%rbp)
jmp 0x4c64e
movq -0x6d8(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
movl %eax, -0x6cc(%rbp)
movl -0x6cc(%rbp), %eax
movb %al, -0x34d(%rbp)
movl -0x34c(%rbp), %eax
incl %eax
movl %eax, -0x34c(%rbp)
movl -0x34c(%rbp), %eax
movl %eax, %esi
leaq -0x320(%rbp), %rdi
callq 0x5a40
movq %rax, -0x6e0(%rbp)
jmp 0x4c698
movq -0x6e0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jl 0x4c6dc
movl -0x34c(%rbp), %eax
movl %eax, %esi
leaq -0x320(%rbp), %rdi
callq 0x5a40
movq %rax, -0x6e8(%rbp)
jmp 0x4c6c4
movq -0x6e8(%rbp), %rax
movsbl (%rax), %eax
subl $0x61, %eax
addl $0xa, %eax
movl %eax, -0x6ec(%rbp)
jmp 0x4c70c
movl -0x34c(%rbp), %eax
movl %eax, %esi
leaq -0x320(%rbp), %rdi
callq 0x5a40
movq %rax, -0x6f8(%rbp)
jmp 0x4c6f9
movq -0x6f8(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
movl %eax, -0x6ec(%rbp)
movl -0x6ec(%rbp), %eax
movb %al, -0x34e(%rbp)
movl -0x34c(%rbp), %eax
incl %eax
movl %eax, -0x34c(%rbp)
movzbl -0x34d(%rbp), %eax
shll $0x4, %eax
movzbl -0x34e(%rbp), %ecx
andl $0xf, %ecx
orl %ecx, %eax
movb %al, -0x34f(%rbp)
leaq -0x348(%rbp), %rdi
leaq -0x34f(%rbp), %rsi
callq 0x523e0
jmp 0x4c757
jmp 0x4c5a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x4ce68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x329(%rbp), %rdi
callq 0x5510
jmp 0x4ce68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x348(%rbp), %rdi
callq 0x34960
leaq -0x320(%rbp), %rdi
callq 0x52f0
jmp 0x4ce68
leaq 0x16947(%rip), %rsi     # 0x63113
leaq -0x300(%rbp), %rdi
callq 0x79e0
movq %rax, -0x700(%rbp)
jmp 0x4c7e1
movq -0x700(%rbp), %rax
movq %rax, -0x360(%rbp)
leaq -0x360(%rbp), %rdi
xorl %esi, %esi
callq 0x6370
movl %eax, -0x704(%rbp)
jmp 0x4c805
movl -0x704(%rbp), %eax
movl %eax, -0x354(%rbp)
movl -0x354(%rbp), %eax
movl %eax, -0x364(%rbp)
leaq -0x2f8(%rbp), %rdi
leaq -0x364(%rbp), %rsi
callq 0x52410
movq %rax, -0x710(%rbp)
jmp 0x4c839
movq -0x710(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x520a0
jmp 0x4c84e
movq 0x35763(%rip), %rdi     # 0x81fb8
leaq 0x17918(%rip), %rsi     # 0x64174
callq 0x5480
movq %rax, -0x718(%rbp)
jmp 0x4c86a
movq -0x718(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x5430
movq %rax, -0x720(%rbp)
jmp 0x4c886
movq -0x720(%rbp), %rdi
leaq 0x17916(%rip), %rsi     # 0x641aa
callq 0x5480
movq %rax, -0x728(%rbp)
jmp 0x4c8a2
leaq 0x17904(%rip), %rsi     # 0x641ad
leaq -0x270(%rbp), %rdi
callq 0x79e0
movq %rax, -0x730(%rbp)
jmp 0x4c8be
movq -0x730(%rbp), %rax
movq %rax, -0x370(%rbp)
leaq -0x370(%rbp), %rdi
xorl %esi, %esi
callq 0x62f0
movl %eax, -0x734(%rbp)
jmp 0x4c8e2
movl -0x734(%rbp), %esi
movq -0x728(%rbp), %rdi
callq 0x58f0
movq %rax, -0x740(%rbp)
jmp 0x4c8fd
movq -0x740(%rbp), %rdi
leaq 0x178a8(%rip), %rsi     # 0x641b3
callq 0x5480
jmp 0x4c912
movl $0x0, -0x374(%rbp)
movl -0x374(%rbp), %eax
movq %rax, -0x750(%rbp)
movl -0x354(%rbp), %eax
movl %eax, -0x378(%rbp)
leaq -0x2f8(%rbp), %rdi
leaq -0x378(%rbp), %rsi
callq 0x52410
movq %rax, -0x748(%rbp)
jmp 0x4c951
movq -0x748(%rbp), %rdi
callq 0x35580
movq %rax, %rcx
movq -0x750(%rbp), %rax
cmpq %rcx, %rax
jae 0x4ca0b
movq 0x35641(%rip), %rdi     # 0x81fb8
leaq 0x17b0c(%rip), %rsi     # 0x6448a
callq 0x5480
movq %rax, -0x758(%rbp)
jmp 0x4c98c
movl -0x354(%rbp), %eax
movl %eax, -0x37c(%rbp)
leaq -0x2f8(%rbp), %rdi
leaq -0x37c(%rbp), %rsi
callq 0x52410
movq %rax, -0x760(%rbp)
jmp 0x4c9b4
movq -0x760(%rbp), %rdi
movl -0x374(%rbp), %eax
movl %eax, %esi
callq 0x34d30
movq -0x758(%rbp), %rdi
movzbl (%rax), %esi
callq 0x58f0
movq %rax, -0x768(%rbp)
jmp 0x4c9e0
movq -0x768(%rbp), %rdi
leaq 0x17906(%rip), %rsi     # 0x642f4
callq 0x5480
jmp 0x4c9f5
jmp 0x4c9f7
movl -0x374(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x374(%rbp)
jmp 0x4c91c
movq 0x355a6(%rip), %rdi     # 0x81fb8
movq 0x35577(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4ca20
leaq -0x348(%rbp), %rdi
callq 0x34960
leaq -0x320(%rbp), %rdi
callq 0x52f0
leaq 0x17728(%rip), %rsi     # 0x64167
leaq -0x300(%rbp), %rdi
callq 0x7a80
movq %rax, -0x770(%rbp)
jmp 0x4ca54
movq -0x770(%rbp), %rax
movq %rax, -0x388(%rbp)
movq -0x388(%rbp), %rax
movq %rax, -0x300(%rbp)
jmp 0x4c4ee
leaq 0x1773c(%rip), %rsi     # 0x641b8
leaq -0x270(%rbp), %rdi
callq 0x79e0
movq %rax, -0x778(%rbp)
jmp 0x4ca91
movq -0x778(%rbp), %rax
movq %rax, -0x3b0(%rbp)
leaq -0x3b0(%rbp), %rdi
callq 0x6750
movq %rax, -0x780(%rbp)
jmp 0x4cab4
leaq -0x3b1(%rbp), %rdi
movq %rdi, -0x788(%rbp)
callq 0x5930
movq -0x780(%rbp), %rsi
movq -0x788(%rbp), %rdx
leaq -0x3a8(%rbp), %rdi
callq 0x30320
jmp 0x4cae3
leaq -0x3b1(%rbp), %rdi
callq 0x5510
movq $0x0, -0x3c0(%rbp)
leaq -0x3c8(%rbp), %rdi
callq 0x52390
movq -0x438(%rbp), %rdi
addq $0x50, %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x523b0
movq %rax, -0x790(%rbp)
jmp 0x4cb26
movq -0x438(%rbp), %rdi
movq -0x790(%rbp), %rax
movq %rax, -0x3d0(%rbp)
movq -0x3d0(%rbp), %rax
movq %rax, -0x3c8(%rbp)
addq $0x50, %rdi
callq 0x51c40
movq %rax, -0x3d8(%rbp)
leaq -0x3c8(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
callq 0x51c10
testb $0x1, %al
jne 0x4cb72
jmp 0x4cbc8
leaq -0x3c8(%rbp), %rdi
callq 0x51c70
movq 0x20(%rax), %rax
movq %rax, -0x3c0(%rbp)
jmp 0x4ccad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x3b1(%rbp), %rdi
callq 0x5510
jmp 0x4ce68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x4ce5c
movl $0xa8, %edi
callq 0x54a0
movq %rax, -0x798(%rbp)
jmp 0x4cbdb
movq -0x798(%rbp), %rdi
callq 0x524f0
jmp 0x4cbe9
movq -0x438(%rbp), %rdi
movq -0x798(%rbp), %rax
movq %rax, -0x3c0(%rbp)
movq -0x3c0(%rbp), %rax
movq %rax, -0x7a8(%rbp)
addq $0x50, %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x51a60
movq %rax, -0x7a0(%rbp)
jmp 0x4cc25
movq -0x7a0(%rbp), %rax
movq -0x7a8(%rbp), %rcx
movq %rcx, (%rax)
movq 0x3537b(%rip), %rdi     # 0x81fb8
leaq 0x174d4(%rip), %rsi     # 0x64118
callq 0x5480
movq %rax, -0x7b0(%rbp)
jmp 0x4cc52
movq -0x7b0(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x5430
movq %rax, -0x7b8(%rbp)
jmp 0x4cc6e
movq -0x7b8(%rbp), %rdi
movq 0x35314(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4cc83
jmp 0x4ccad
movq -0x798(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
movl $0xa8, %esi
callq 0x54b0
jmp 0x4ce5c
movq -0x208(%rbp), %rax
movq %rax, -0x7c8(%rbp)
leaq 0x174eb(%rip), %rsi     # 0x641ad
leaq -0x270(%rbp), %rdi
callq 0x79e0
movq %rax, -0x7c0(%rbp)
jmp 0x4ccd7
movq -0x7c0(%rbp), %rax
movq %rax, -0x3e0(%rbp)
leaq -0x3e0(%rbp), %rdi
xorl %esi, %esi
callq 0x62f0
movl %eax, -0x7cc(%rbp)
jmp 0x4ccfb
leaq 0x174ab(%rip), %rsi     # 0x641ad
leaq -0x270(%rbp), %rdi
callq 0x79e0
movq %rax, -0x7d8(%rbp)
jmp 0x4cd17
movq -0x7d8(%rbp), %rax
movq %rax, -0x3f0(%rbp)
leaq -0x3f0(%rbp), %rdi
xorl %esi, %esi
callq 0x6370
movl %eax, -0x7dc(%rbp)
jmp 0x4cd3b
movl -0x7dc(%rbp), %eax
movl %eax, -0x3e4(%rbp)
leaq -0x1b8(%rbp), %rdi
leaq -0x3e4(%rbp), %rsi
callq 0x34b90
movq %rax, -0x7e8(%rbp)
jmp 0x4cd63
movq -0x7e8(%rbp), %rax
fldt (%rax)
fstpt -0x804(%rbp)
movq -0x3c0(%rbp), %rax
movq %rax, -0x7f8(%rbp)
leaq 0x17439(%rip), %rsi     # 0x641c0
leaq -0x270(%rbp), %rdi
callq 0x79e0
movq %rax, -0x7f0(%rbp)
jmp 0x4cd9c
movq -0x7f0(%rbp), %rax
movq %rax, -0x3f8(%rbp)
leaq -0x3f8(%rbp), %rdi
xorl %esi, %esi
callq 0x62f0
movl %eax, -0x808(%rbp)
jmp 0x4cdc0
movl -0x808(%rbp), %r9d
movq -0x7f8(%rbp), %r8
movl -0x7cc(%rbp), %esi
movq -0x7c8(%rbp), %rdi
fldt -0x804(%rbp)
movq %rsp, %rax
fstpt (%rax)
leaq -0x2a0(%rbp), %rdx
leaq -0x2f8(%rbp), %rcx
callq 0x32570
jmp 0x4cdfb
leaq -0x3a8(%rbp), %rdi
callq 0x52f0
leaq -0x2f8(%rbp), %rdi
callq 0x38fb0
leaq -0x2a0(%rbp), %rdi
callq 0x52550
leaq 0x1732e(%rip), %rsi     # 0x64154
leaq -0x270(%rbp), %rdi
callq 0x7a80
movq %rax, -0x810(%rbp)
jmp 0x4ce3b
movq -0x810(%rbp), %rax
movq %rax, -0x400(%rbp)
movq -0x400(%rbp), %rax
movq %rax, -0x270(%rbp)
jmp 0x4c313
leaq -0x3a8(%rbp), %rdi
callq 0x52f0
leaq -0x2f8(%rbp), %rdi
callq 0x38fb0
leaq -0x2a0(%rbp), %rdi
callq 0x52550
jmp 0x4ced7
leaq -0x1b8(%rbp), %rdi
callq 0x52550
leaq -0x178(%rbp), %rdi
callq 0x52f0
leaq 0x163f8(%rip), %rsi     # 0x63299
leaq -0x158(%rbp), %rdi
callq 0x7a80
movq %rax, -0x818(%rbp)
jmp 0x4ceb6
movq -0x818(%rbp), %rax
movq %rax, -0x408(%rbp)
movq -0x408(%rbp), %rax
movq %rax, -0x158(%rbp)
jmp 0x4bb5d
leaq -0x1b8(%rbp), %rdi
callq 0x52550
leaq -0x178(%rbp), %rdi
callq 0x52f0
jmp 0x4cf1a
movl $0x0, -0x4(%rbp)
movl $0x1, -0x110(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0xcfe0
movl -0x4(%rbp), %eax
addq $0x830, %rsp            # imm = 0x830
popq %rbp
retq
leaq -0xe8(%rbp), %rdi
callq 0xcfe0
movq -0x108(%rbp), %rdi
callq 0x5920
nopw %cs:(%rax,%rax)