// File: /workspace/github_cpp_makefile_star2_O3/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 0xb972
movq (%rbx), %rdx
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
movl $0x74, %ecx
xorl %r8d, %r8d
callq 0xc434
leaq 0x20(%rsp), %rdi
callq 0xb94a
testb %al, %al
je 0x2466f
leaq 0xc9aa(%rip), %rsi      # 0x30e68
leaq 0x98(%rsp), %rdi
callq 0x6c70
movq %rax, 0x78(%rsp)
movq 0x18(%rsp), %rbx
movzbl (%rbx), %esi
fldz
fstpt 0x40(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x68(%rsp), %rcx
callq 0x1d906
movq 0x8(%rbx), %rdi
movq 0x18(%rbx), %rsi
movaps 0x20(%rsp), %xmm0
movups %xmm0, 0x8(%rbx)
movq 0x30(%rsp), %rax
movq %rax, 0x18(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testq %rdi, %rdi
je 0x24541
subq %rdi, %rsi
callq 0x43a0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x24541
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
leaq 0xc929(%rip), %rsi      # 0x30e71
leaq 0x78(%rsp), %rdi
callq 0x6c70
movq 0x18(%rsp), %rcx
addq $0x8, %rcx
movq %rcx, 0x60(%rsp)
leaq 0x20(%rsp), %rbx
leaq 0x40(%rsp), %r12
movq 0x1aa47(%rip), %r13     # 0x3efb8
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
callq 0x6bc0
testq %rax, %rax
je 0x246e2
movq %rbx, %rdi
leaq 0xc8e9(%rip), %rsi      # 0x30e7a
callq 0x6db0
movq %rax, 0x40(%rsp)
movq %r12, %rdi
xorl %esi, %esi
callq 0x6152
movl %eax, %r15d
movq %rbx, %rdi
callq 0x6fc6
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movq %r12, %rdi
callq 0xb116
decl %r15d
movsd %xmm0, 0x80(%rsp)
fldl 0x80(%rsp)
movslq %r15d, %rbp
movq 0x60(%rsp), %rax
movq (%rax), %rax
shlq $0x4, %rbp
fstpt (%rax,%rbp)
movl $0x29, %edx
movq %r13, %rdi
leaq 0xc88b(%rip), %rsi      # 0x30e7f
callq 0x4400
movq %r13, %rdi
movl %r15d, %esi
callq 0x46d0
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
leaq 0xc893(%rip), %rsi      # 0x30ea9
callq 0x4400
movq 0x60(%rsp), %rax
movq (%rax), %rax
fldt (%rax,%rbp)
fstpt (%rsp)
movq %r14, %rdi
callq 0x41f0
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 %rbx, %rdi
leaq 0xc80c(%rip), %rsi      # 0x30e71
callq 0x6df4
jmp 0x24571
movq 0x1a97a(%rip), %rdi     # 0x3eff0
leaq 0xc7ab(%rip), %rsi      # 0x30e28
movl $0x32, %edx
callq 0x4400
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x1a95b(%rip), %rdi     # 0x3eff0
callq 0x4400
movq %rax, %rbx
leaq 0xc7b7(%rip), %rsi      # 0x30e5b
movl $0xc, %edx
movq %rax, %rdi
callq 0x4400
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x42a0
jmp 0x248de
leaq 0xbbf0(%rip), %rsi      # 0x302d9
leaq 0x78(%rsp), %rdi
callq 0x6c70
movq 0x18(%rsp), %rcx
leaq 0x50(%rcx), %rdx
movq %rdx, 0x58(%rsp)
addq $0x20, %rcx
movq %rcx, 0x18(%rsp)
leaq 0x68(%rsp), %r14
leaq 0x40(%rsp), %r13
leaq 0x70(%rsp), %rbx
leaq 0x90(%rsp), %rbp
leaq 0xc786(%rip), %r12      # 0x30eae
movq %rax, 0x68(%rsp)
movq %r14, %rdi
callq 0x6bc0
testq %rax, %rax
je 0x248dc
movq %r14, %rdi
leaq 0xc982(%rip), %rsi      # 0x310ca
callq 0x6db0
movq %rax, 0x40(%rsp)
movq %r13, %rdi
callq 0x6284
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x2182c
movq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0x27e8e
movq (%rax), %rax
movzbl 0x24(%rax), %esi
movb $0x0, 0x70(%rsp)
movq %r13, %rdi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x27fe2
movq %r14, %rdi
movq %r12, %rsi
callq 0x6c70
movq %rax, 0x70(%rsp)
movq %rbx, %rdi
callq 0x6bc0
testq %rax, %rax
je 0x2480c
movq %rbx, %rdi
callq 0x6fc6
movq %rax, 0x90(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
callq 0xb0ee
movl %eax, %r14d
movq %rbx, %rdi
leaq 0xc6d9(%rip), %rsi      # 0x30eb1
callq 0x6db0
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
callq 0x6176
movl %eax, %eax
movq 0x40(%rsp), %rcx
movb %r14b, (%rcx,%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6df4
jmp 0x2479f
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x28042
movq %rax, %rdi
movq %r13, %rsi
callq 0x280be
movq 0x58(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x27e8e
movq (%rax), %rdi
addq $0x48, %rdi
movq %r13, %rsi
callq 0x280be
movq 0x58(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x27e8e
movq (%rax), %r14
cmpb $0x0, 0x24(%r14)
je 0x2488b
movl $0x38, %r13d
xorl %r15d, %r15d
movq 0x30(%r14), %rdi
addq %r13, %rdi
movq 0x60(%rsp), %rsi
callq 0x1d9fa
incq %r15
movzbl 0x24(%r14), %eax
addq $0xa0, %r13
cmpq %rax, %r15
jb 0x24866
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x248a2
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
leaq 0x68(%rsp), %r14
leaq 0x40(%rsp), %r13
je 0x248c8
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %r14, %rdi
leaq 0xba07(%rip), %rsi      # 0x302d9
callq 0x6df4
jmp 0x24728
xorl %ebx, %ebx
leaq 0x98(%rsp), %rdi
callq 0xb9fe
movl %ebx, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x24926
jmp 0x24926
jmp 0x24926
jmp 0x24926
jmp 0x24926
jmp 0x24926
jmp 0x24926
jmp 0x24926
jmp 0x24911
movq %rax, %rbx
jmp 0x2494d
jmp 0x24933
jmp 0x24926
jmp 0x24926
jmp 0x24926
jmp 0x24926
jmp 0x24926
jmp 0x24926
jmp 0x24933
movq %rax, %rbx
jmp 0x24969
jmp 0x24933
jmp 0x24933
jmp 0x24933
jmp 0x24933
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2494d
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x24969
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
leaq 0x98(%rsp), %rdi
callq 0xb9fe
movq %rbx, %rdi
callq 0x4700