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

    // extract the TP size map and |F\R| distr. from 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");

    this->f_r_distribution = std::vector<__float080>(this->request_size, 0.0);
    for (pugi::xml_node f_r_dist = topology.child("f_r_dist"); 
        f_r_dist; 
        f_r_dist = f_r_dist.next_sibling("f_r_dist")) {

        int i = (f_r_dist.attribute("diff").as_int() - 1);
        this->f_r_distribution[i] = (__float080) f_r_dist.text().as_double();

        std::cout << "RID_Analytics::read_scn() : [INFO] |F\\R|[" 
            << i << "] = " << this->f_r_distribution[i] << std::endl;
    }

    // tp sizes per 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());

        // int * _tp_sizes = (int *) calloc(routers[router_id]->get_iface_num(), sizeof(int));
        std::vector<uint8_t> _tp_sizes(routers[router_id]->get_iface_num(), 0);
        for (pugi::xml_node tp = router.child("tp"); 
            tp; 
            tp = tp.next_sibling("tp")) {

            _tp_sizes[tp.attribute("iface").as_uint()] = tp.text().as_uint();
        }

        // we keep tp sizes in a map router_id <-> tp sizes (per iface)
        this->tp_sizes[router_id] = _tp_sizes;
        this->routers[router_id]->set_tp_sizes(&(_tp_sizes));
        this->routers[router_id]->set_f_r_distr(&(this->f_r_distribution));
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rsi, %rbx
movq %rdi, 0x18(%rsp)
leaq 0x98(%rsp), %r14
movq %r14, %rdi
callq 0x949c
movq (%rbx), %rdx
leaq 0x58(%rsp), %rdi
pushq $0x74
popq %rcx
movq %r14, %rsi
xorl %r8d, %r8d
callq 0x9e8a
leaq 0x58(%rsp), %rdi
callq 0x9474
testb %al, %al
je 0x1f1c0
leaq 0xbfb0(%rip), %rsi      # 0x2b028
leaq 0x98(%rsp), %rdi
callq 0x5544
movq %rax, 0x78(%rsp)
movq 0x18(%rsp), %rbx
movzbl (%rbx), %esi
fldz
fstpt 0x20(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x20(%rsp), %rdx
leaq 0x10(%rsp), %rcx
callq 0x18df8
leaq 0x8(%rbx), %rdi
leaq 0x58(%rsp), %rbx
movq %rdi, 0x48(%rsp)
movq %rbx, %rsi
callq 0x1a1fc
movq %rbx, %rdi
callq 0x195d0
leaq 0xbf60(%rip), %rsi      # 0x2b031
leaq 0x78(%rsp), %rdi
callq 0x5544
leaq 0x58(%rsp), %rbx
leaq 0x20(%rsp), %r15
leaq 0xbf7d(%rip), %rbp      # 0x2b069
leaq 0xbf3e(%rip), %r14      # 0x2b031
movq %rax, 0x58(%rsp)
movq %rbx, %rdi
callq 0x549a
testq %rax, %rax
je 0x1f1fd
movq %rbx, %rdi
leaq 0xbf27(%rip), %rsi      # 0x2b03a
callq 0x5680
movq %rax, 0x20(%rsp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x4bb4
movl %eax, %r12d
movq %rbx, %rdi
callq 0x58b2
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movq %r15, %rdi
callq 0x8d14
decl %r12d
movsd %xmm0, 0x80(%rsp)
fldl 0x80(%rsp)
movslq %r12d, %r13
movq 0x48(%rsp), %rax
movq (%rax), %rax
shlq $0x4, %r13
fstpt (%rax,%r13)
movq 0x1be41(%rip), %rdi     # 0x3afb0
leaq 0xbec9(%rip), %rsi      # 0x2b03f
callq 0x43a0
movq %rax, %rdi
movl %r12d, %esi
callq 0x46d0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x43a0
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
fldt (%rcx,%r13)
fstpt (%rsp)
movq %rax, %rdi
callq 0x4220
movq %rax, %rdi
callq 0x41e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x56c4
jmp 0x1f0f3
movq 0x1be29(%rip), %rdi     # 0x3aff0
leaq 0xbe1a(%rip), %rsi      # 0x2afe8
callq 0x43a0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4360
leaq 0xbe36(%rip), %rsi      # 0x2b01b
movq %rax, %rdi
callq 0x43a0
movq %rax, %rdi
callq 0x41e0
pushq $-0x1
popq %rbx
jmp 0x1f3b7
leaq 0xb295(%rip), %rsi      # 0x2a499
leaq 0x78(%rsp), %rdi
callq 0x5544
movq 0x18(%rsp), %rcx
leaq 0x50(%rcx), %rdx
movq %rdx, 0x40(%rsp)
addq $0x20, %rcx
movq %rcx, 0x18(%rsp)
leaq 0x10(%rsp), %r13
leaq 0x50(%rsp), %rbx
leaq 0x90(%rsp), %r14
leaq 0xbe30(%rip), %r12      # 0x2b06e
leaq 0xbe2c(%rip), %rbp      # 0x2b071
leaq 0x88(%rsp), %r15
movq %rax, 0x10(%rsp)
movq %r13, %rdi
callq 0x549a
testq %rax, %rax
je 0x1f3b5
leaq 0x10(%rsp), %rdi
leaq 0xc01b(%rip), %rsi      # 0x2b28a
callq 0x5680
movq %rax, 0x20(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x4cde
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x16c66
movq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0x2167c
movq (%rax), %rax
movzbl 0x24(%rax), %esi
movb $0x0, 0x50(%rsp)
leaq 0x20(%rsp), %rdi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x217ce
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x5544
movq %rax, 0x50(%rsp)
movq %rbx, %rdi
callq 0x549a
testq %rax, %rax
je 0x1f330
movq %rbx, %rdi
callq 0x58b2
movq %rax, 0x90(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0x8cf4
movl %eax, %r13d
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x5680
movq %rax, 0x88(%rsp)
movq %r15, %rdi
xorl %esi, %esi
callq 0x4bd8
movl %eax, %eax
movq 0x20(%rsp), %rcx
movb %r13b, (%rcx,%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x56c4
jmp 0x1f2cc
movq 0x18(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2182c
movq %rax, %rdi
leaq 0x20(%rsp), %rsi
callq 0x21892
movq 0x40(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2167c
movq (%rax), %rdi
addq $0x48, %rdi
leaq 0x20(%rsp), %rsi
callq 0x21892
movq 0x40(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2167c
movq (%rax), %rdi
movq 0x48(%rsp), %rsi
callq 0x21954
leaq 0x20(%rsp), %rdi
callq 0x19a7c
leaq 0x58(%rsp), %rdi
callq 0x41c0
leaq 0x10(%rsp), %r13
movq %r13, %rdi
leaq 0xb0ee(%rip), %rsi      # 0x2a499
callq 0x56c4
jmp 0x1f24d
xorl %ebx, %ebx
leaq 0x98(%rsp), %rdi
callq 0x9526
movl %ebx, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1f3fd
jmp 0x1f3fd
jmp 0x1f3fd
jmp 0x1f3fd
jmp 0x1f3fd
jmp 0x1f3fd
jmp 0x1f3fd
jmp 0x1f3ec
jmp 0x1f40a
jmp 0x1f3fd
movq %rax, %rbx
jmp 0x1f417
jmp 0x1f3fd
jmp 0x1f3fd
jmp 0x1f3fd
jmp 0x1f3fd
jmp 0x1f3fd
jmp 0x1f3fd
movq %rax, %rbx
jmp 0x1f421
jmp 0x1f40a
jmp 0x1f40a
jmp 0x1f40a
jmp 0x1f40a
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x19a7c
leaq 0x58(%rsp), %rdi
callq 0x41c0
leaq 0x98(%rsp), %rdi
callq 0x9526
movq %rbx, %rdi
callq 0x4700