// File: /workspace/github_cpp_makefile_star2_O1/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 0xbaa4
movq (%rbx), %rdx
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
movl $0x74, %ecx
xorl %r8d, %r8d
callq 0xc61c
leaq 0x38(%rsp), %rdi
callq 0xba7c
testb %al, %al
je 0x24b35
leaq 0xd6d2(%rip), %rsi      # 0x32088
leaq 0x98(%rsp), %rdi
callq 0x6a76
movq %rax, 0x78(%rsp)
movq 0x18(%rsp), %rbx
movzbl (%rbx), %esi
fldz
fstpt 0x20(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x20(%rsp), %rdx
leaq 0x68(%rsp), %rcx
callq 0x1ddb8
leaq 0x8(%rbx), %rdi
leaq 0x38(%rsp), %rbx
movq %rdi, 0x60(%rsp)
movq %rbx, %rsi
callq 0x1ed30
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x24a15
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
leaq 0xd675(%rip), %rsi      # 0x32091
leaq 0x78(%rsp), %rdi
callq 0x6a76
leaq 0x38(%rsp), %rbx
leaq 0x20(%rsp), %r12
movq 0x1b581(%rip), %r13     # 0x3ffb8
movq %rax, 0x38(%rsp)
movq %rbx, %rdi
callq 0x69c6
testq %rax, %rax
je 0x24ba8
movq %rbx, %rdi
leaq 0xd643(%rip), %rsi      # 0x3209a
callq 0x6bb8
movq %rax, 0x20(%rsp)
movq %r12, %rdi
xorl %esi, %esi
callq 0x5f62
movl %eax, %r15d
movq %rbx, %rdi
callq 0x6dd0
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movq %r12, %rdi
callq 0xb280
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 0xd5e5(%rip), %rsi      # 0x3209f
callq 0x4400
movq %r13, %rdi
movl %r15d, %esi
callq 0x46d0
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
leaq 0xd5ed(%rip), %rsi      # 0x320c9
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 0xd566(%rip), %rsi      # 0x32091
callq 0x6bfe
jmp 0x24a37
movq 0x1b4b4(%rip), %rdi     # 0x3fff0
leaq 0xd505(%rip), %rsi      # 0x32048
movl $0x32, %edx
callq 0x4400
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x1b495(%rip), %rdi     # 0x3fff0
callq 0x4400
movq %rax, %rbx
leaq 0xd511(%rip), %rsi      # 0x3207b
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 0x24da4
leaq 0xc94a(%rip), %rsi      # 0x314f9
leaq 0x78(%rsp), %rdi
callq 0x6a76
movq 0x18(%rsp), %rcx
leaq 0x50(%rcx), %rdx
movq %rdx, 0x58(%rsp)
addq $0x20, %rcx
movq %rcx, 0x18(%rsp)
leaq 0x68(%rsp), %r14
leaq 0x20(%rsp), %r13
leaq 0x70(%rsp), %rbx
leaq 0x90(%rsp), %rbp
leaq 0xd4e0(%rip), %r12      # 0x320ce
movq %rax, 0x68(%rsp)
movq %r14, %rdi
callq 0x69c6
testq %rax, %rax
je 0x24da2
movq %r14, %rdi
leaq 0xd6dc(%rip), %rsi      # 0x322ea
callq 0x6bb8
movq %rax, 0x20(%rsp)
movq %r13, %rdi
callq 0x6094
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x21d02
movq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0x28380
movq (%rax), %rax
movzbl 0x24(%rax), %esi
movb $0x0, 0x70(%rsp)
movq %r13, %rdi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0x284ce
movq %r14, %rdi
movq %r12, %rsi
callq 0x6a76
movq %rax, 0x70(%rsp)
movq %rbx, %rdi
callq 0x69c6
testq %rax, %rax
je 0x24cd2
movq %rbx, %rdi
callq 0x6dd0
movq %rax, 0x90(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
callq 0xb258
movl %eax, %r14d
movq %rbx, %rdi
leaq 0xd433(%rip), %rsi      # 0x320d1
callq 0x6bb8
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
callq 0x5f86
movl %eax, %eax
movq 0x20(%rsp), %rcx
movb %r14b, (%rcx,%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6bfe
jmp 0x24c65
movq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x2852e
movq %rax, %rdi
movq %r13, %rsi
callq 0x285aa
movq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x28380
movq (%rax), %rdi
addq $0x48, %rdi
movq %r13, %rsi
callq 0x285aa
movq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x28380
movq (%rax), %r14
cmpb $0x0, 0x24(%r14)
je 0x24d51
movl $0x38, %r13d
xorl %r15d, %r15d
movq 0x30(%r14), %rdi
addq %r13, %rdi
movq 0x60(%rsp), %rsi
callq 0x1dea0
incq %r15
movzbl 0x24(%r14), %eax
addq $0xa0, %r13
cmpq %rax, %r15
jb 0x24d2c
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x24d68
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
leaq 0x68(%rsp), %r14
leaq 0x20(%rsp), %r13
je 0x24d8e
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %r14, %rdi
leaq 0xc761(%rip), %rsi      # 0x314f9
callq 0x6bfe
jmp 0x24bee
xorl %ebx, %ebx
leaq 0x98(%rsp), %rdi
callq 0xbb32
movl %ebx, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x24dec
jmp 0x24dec
jmp 0x24dec
jmp 0x24dec
jmp 0x24dec
jmp 0x24dec
jmp 0x24dec
jmp 0x24dec
jmp 0x24dd7
movq %rax, %rbx
jmp 0x24e13
jmp 0x24df9
jmp 0x24dec
jmp 0x24dec
jmp 0x24dec
jmp 0x24dec
jmp 0x24dec
jmp 0x24dec
jmp 0x24df9
movq %rax, %rbx
jmp 0x24e2f
jmp 0x24df9
jmp 0x24df9
jmp 0x24df9
jmp 0x24df9
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x24e13
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x24e2f
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x43a0
leaq 0x98(%rsp), %rdi
callq 0xbb32
movq %rbx, %rdi
callq 0x4700