// File: 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
movq %rsp, %rbp
subq $0x370, %rsp            # imm = 0x370
movq %rsi, -0x208(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0xce80
movq -0x208(%rbp), %rdi
callq 0x51d0
movq -0x200(%rbp), %rsi
movq %rax, %rdx
leaq -0x100(%rbp), %rdi
movl $0x74, %ecx
xorl %r8d, %r8d
callq 0xd810
jmp 0x4cfa4
leaq -0x100(%rbp), %rdi
callq 0xcd20
movb %al, -0x211(%rbp)
jmp 0x4cfb8
movb -0x211(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x4cfc9
jmp 0x4d05f
movq 0x35020(%rip), %rdi     # 0x81ff0
leaq 0x16f58(%rip), %rsi     # 0x63f2f
callq 0x5480
movq %rax, -0x220(%rbp)
jmp 0x4cfe5
movq -0x208(%rbp), %rsi
movq -0x220(%rbp), %rdi
callq 0x5430
movq %rax, -0x228(%rbp)
jmp 0x4d001
movq -0x228(%rbp), %rdi
leaq 0x16f53(%rip), %rsi     # 0x63f62
callq 0x5480
movq %rax, -0x230(%rbp)
jmp 0x4d01d
movq -0x230(%rbp), %rdi
movq 0x34f65(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4d032
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x110(%rbp)
jmp 0x4d747
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x4d75f
leaq 0x16f09(%rip), %rsi     # 0x63f6f
leaq -0xe8(%rbp), %rdi
callq 0x7650
movq %rax, -0x238(%rbp)
jmp 0x4d07b
movq -0x210(%rbp), %rax
movq -0x238(%rbp), %rcx
movq %rcx, -0x118(%rbp)
movzbl (%rax), %eax
movq %rax, -0x248(%rbp)
fldz
fstpt -0x140(%rbp)
leaq -0x141(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x34a40
movq -0x248(%rbp), %rsi
movq -0x240(%rbp), %rcx
leaq -0x130(%rbp), %rdi
leaq -0x140(%rbp), %rdx
callq 0x34a60
jmp 0x4d0d8
movq -0x210(%rbp), %rdi
addq $0x8, %rdi
leaq -0x130(%rbp), %rsi
movq %rsi, -0x258(%rbp)
callq 0x34ae0
movq -0x258(%rbp), %rdi
callq 0x34b10
leaq -0x141(%rbp), %rdi
callq 0x34b70
leaq 0x16e63(%rip), %rsi     # 0x63f78
leaq -0x118(%rbp), %rdi
callq 0x7650
movq %rax, -0x250(%rbp)
jmp 0x4d12a
movq -0x250(%rbp), %rax
movq %rax, -0x150(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x73b0
movq %rax, -0x260(%rbp)
jmp 0x4d14d
movq -0x260(%rbp), %rax
cmpq $0x0, %rax
je 0x4d320
leaq 0x16e1c(%rip), %rsi     # 0x63f81
leaq -0x150(%rbp), %rdi
callq 0x79e0
movq %rax, -0x268(%rbp)
jmp 0x4d17a
movq -0x268(%rbp), %rax
movq %rax, -0x160(%rbp)
leaq -0x160(%rbp), %rdi
xorl %esi, %esi
callq 0x62f0
movl %eax, -0x26c(%rbp)
jmp 0x4d19e
movl -0x26c(%rbp), %eax
decl %eax
movl %eax, -0x154(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x7f80
movq %rax, -0x278(%rbp)
jmp 0x4d1c1
movq -0x278(%rbp), %rax
movq %rax, -0x168(%rbp)
leaq -0x168(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0xbb80
movsd %xmm0, -0x280(%rbp)
jmp 0x4d1e8
movq -0x210(%rbp), %rdi
movsd -0x280(%rbp), %xmm0
movsd %xmm0, -0x1f8(%rbp)
fldl -0x1f8(%rbp)
fstpt -0x294(%rbp)
addq $0x8, %rdi
movslq -0x154(%rbp), %rsi
callq 0x34c70
fldt -0x294(%rbp)
fstpt (%rax)
movq 0x34d8e(%rip), %rdi     # 0x81fb8
leaq 0x16d55(%rip), %rsi     # 0x63f86
callq 0x5480
movq %rax, -0x288(%rbp)
jmp 0x4d23f
movq -0x288(%rbp), %rdi
movl -0x154(%rbp), %esi
callq 0x58f0
movq %rax, -0x2a0(%rbp)
jmp 0x4d25a
movq -0x2a0(%rbp), %rdi
leaq 0x16d48(%rip), %rsi     # 0x63fb0
callq 0x5480
movq %rax, -0x2a8(%rbp)
jmp 0x4d276
movq -0x210(%rbp), %rdi
addq $0x8, %rdi
movslq -0x154(%rbp), %rsi
callq 0x34c70
movq -0x2a8(%rbp), %rdi
fldt (%rax)
movq %rsp, %rax
fstpt (%rax)
callq 0x55b0
movq %rax, -0x2b0(%rbp)
jmp 0x4d2a9
movq -0x2b0(%rbp), %rdi
movq 0x34cd9(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4d2be
jmp 0x4d2c0
leaq 0x16cb1(%rip), %rsi     # 0x63f78
leaq -0x150(%rbp), %rdi
callq 0x7a80
movq %rax, -0x2b8(%rbp)
jmp 0x4d2dc
movq -0x2b8(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
movq %rax, -0x150(%rbp)
jmp 0x4d138
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x141(%rbp), %rdi
callq 0x34b70
jmp 0x4d75f
leaq 0x15f72(%rip), %rsi     # 0x63299
leaq -0x118(%rbp), %rdi
callq 0x7650
movq %rax, -0x2c0(%rbp)
jmp 0x4d33c
movq -0x2c0(%rbp), %rax
movq %rax, -0x178(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x73b0
movq %rax, -0x2c8(%rbp)
jmp 0x4d35f
movq -0x2c8(%rbp), %rax
cmpq $0x0, %rax
je 0x4d736
leaq 0x16e5a(%rip), %rsi     # 0x641d1
leaq -0x178(%rbp), %rdi
callq 0x79e0
movq %rax, -0x2d0(%rbp)
jmp 0x4d38c
movq -0x2d0(%rbp), %rax
movq %rax, -0x1a0(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x6750
movq %rax, -0x2d8(%rbp)
jmp 0x4d3af
leaq -0x1a1(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x5930
movq -0x2d8(%rbp), %rsi
movq -0x2e0(%rbp), %rdx
leaq -0x198(%rbp), %rdi
callq 0x30320
jmp 0x4d3de
leaq -0x1a1(%rbp), %rdi
callq 0x5510
movq -0x210(%rbp), %rdi
addq $0x50, %rdi
leaq -0x198(%rbp), %rsi
callq 0x51a60
movq %rax, -0x2e8(%rbp)
jmp 0x4d40a
movq -0x2e8(%rbp), %rax
movq (%rax), %rdi
callq 0x51e10
movb %al, -0x2e9(%rbp)
jmp 0x4d421
movb -0x2e9(%rbp), %al
movzbl %al, %eax
movq %rax, -0x300(%rbp)
movb $0x0, -0x1c1(%rbp)
leaq -0x1c2(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x37860
movq -0x300(%rbp), %rsi
movq -0x2f8(%rbp), %rcx
leaq -0x1c0(%rbp), %rdi
leaq -0x1c1(%rbp), %rdx
callq 0x51f40
jmp 0x4d46e
leaq -0x1c2(%rbp), %rdi
callq 0x385c0
leaq 0x16b34(%rip), %rsi     # 0x63fb5
leaq -0x178(%rbp), %rdi
callq 0x7650
movq %rax, -0x308(%rbp)
jmp 0x4d496
movq -0x308(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x73b0
movq %rax, -0x310(%rbp)
jmp 0x4d4b9
movq -0x310(%rbp), %rax
cmpq $0x0, %rax
je 0x4d62a
leaq -0x1d0(%rbp), %rdi
callq 0x7f80
movq %rax, -0x318(%rbp)
jmp 0x4d4df
movq -0x318(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x1d8(%rbp), %rdi
xorl %esi, %esi
callq 0xbb30
movl %eax, -0x31c(%rbp)
jmp 0x4d503
movl -0x31c(%rbp), %eax
movb %al, -0x329(%rbp)
leaq 0x16aa2(%rip), %rsi     # 0x63fb8
leaq -0x1d0(%rbp), %rdi
callq 0x79e0
movq %rax, -0x328(%rbp)
jmp 0x4d52b
movq -0x328(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0x1e0(%rbp), %rdi
xorl %esi, %esi
callq 0x6370
movl %eax, -0x330(%rbp)
jmp 0x4d54f
movl -0x330(%rbp), %eax
movl %eax, %eax
movl %eax, %esi
leaq -0x1c0(%rbp), %rdi
callq 0x34d30
movb -0x329(%rbp), %cl
movb %cl, (%rax)
leaq 0x16a41(%rip), %rsi     # 0x63fb5
leaq -0x1d0(%rbp), %rdi
callq 0x7a80
movq %rax, -0x338(%rbp)
jmp 0x4d589
movq -0x338(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x1e8(%rbp), %rax
movq %rax, -0x1d0(%rbp)
jmp 0x4d4a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x1a1(%rbp), %rdi
callq 0x5510
jmp 0x4d75f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x4d728
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x1c2(%rbp), %rdi
callq 0x385c0
jmp 0x4d728
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x34960
jmp 0x4d728
movq -0x210(%rbp), %rdi
addq $0x20, %rdi
leaq -0x198(%rbp), %rsi
callq 0x51fc0
movq %rax, -0x340(%rbp)
jmp 0x4d64a
movq -0x340(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x520a0
jmp 0x4d65f
movq -0x210(%rbp), %rdi
addq $0x50, %rdi
leaq -0x198(%rbp), %rsi
callq 0x51a60
movq %rax, -0x348(%rbp)
jmp 0x4d67f
movq -0x348(%rbp), %rax
movq (%rax), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x522d0
jmp 0x4d697
movq -0x210(%rbp), %rdi
addq $0x50, %rdi
leaq -0x198(%rbp), %rsi
callq 0x51a60
movq %rax, -0x350(%rbp)
jmp 0x4d6b7
movq -0x210(%rbp), %rsi
movq -0x350(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rsi
callq 0x52300
jmp 0x4d6d3
leaq -0x1c0(%rbp), %rdi
callq 0x34960
leaq -0x198(%rbp), %rdi
callq 0x52f0
leaq 0x15ba7(%rip), %rsi     # 0x63299
leaq -0x178(%rbp), %rdi
callq 0x7a80
movq %rax, -0x358(%rbp)
jmp 0x4d707
movq -0x358(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq -0x1f0(%rbp), %rax
movq %rax, -0x178(%rbp)
jmp 0x4d34a
leaq -0x198(%rbp), %rdi
callq 0x52f0
jmp 0x4d75f
movl $0x0, -0x4(%rbp)
movl $0x1, -0x110(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0xcfe0
movl -0x4(%rbp), %eax
addq $0x370, %rsp            # imm = 0x370
popq %rbp
retq
leaq -0xe8(%rbp), %rdi
callq 0xcfe0
movq -0x108(%rbp), %rdi
callq 0x5920
nopw (%rax,%rax)