// File: adamiaonr[P]rid-analytics/src/rid-router.cpp
// Function: RID_Router::init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, unsigned long, unsigned char, unsigned char, unsigned short, int)
int RID_Router::init(
    std::string router_id,
    uint64_t fwd_table_size,
    uint8_t iface_num,
    uint8_t req_size,
    uint16_t bf_size,
    int mode) {

    if (this->initialized)
        return 0;

    this->id = router_id;

    this->req_size = req_size;
    this->bf_size = bf_size;
    // fwd table parameters
    std::cout << "RID_Router::init() : [INFO] iface_num = " << (int) iface_num << std::endl;
    this->iface_num = iface_num;
    this->fwd_table_size = fwd_table_size;
    // initialize forwarding table w/ 1 row per iface
    this->fwd_table = std::vector<RID_Router::fwd_table_row>(iface_num);
    // blocked ifaces initialized to false
    this->blocked_ifaces = std::vector<bool>(iface_num, false);
    // initialize iface on fp tree of size t array
    this->iface_on_fptree = std::vector< std::vector<bool> >(this->iface_num, std::vector<bool>(req_size, false));

    // initialize router's probability module
    this->prob_mod = new Prob((__float080) this->bf_size, (__float080) this->req_size, this->iface_num);

    // mark the router as initialized
    this->initialized = true;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movl %r8d, -0xf8(%rbp)
movl %ecx, %eax
movl -0xf8(%rbp), %ecx
movl %eax, -0xf4(%rbp)
movq %rdx, %rax
movl -0xf4(%rbp), %edx
movq %rax, -0xf0(%rbp)
movq %rsi, %rax
movq -0xf0(%rbp), %rsi
movq %rax, -0xe8(%rbp)
movq %rdi, %r8
movq -0xe8(%rbp), %rdi
movw %r9w, %ax
movl 0x10(%rbp), %r9d
movq %r8, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movb %dl, -0x21(%rbp)
movb %cl, -0x22(%rbp)
movw %ax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
testb $0x1, 0x20(%rax)
je 0x32026
movl $0x0, -0x4(%rbp)
jmp 0x32358
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x5070
movq -0xe0(%rbp), %rax
movb -0x22(%rbp), %cl
movb %cl, 0x21(%rax)
movw -0x24(%rbp), %cx
movw %cx, 0x22(%rax)
movq 0x4ff63(%rip), %rdi     # 0x81fb8
leaq 0x31609(%rip), %rsi     # 0x63665
callq 0x5480
movq %rax, %rdi
movzbl -0x21(%rbp), %esi
callq 0x58f0
movq %rax, %rdi
movq 0x4ff19(%rip), %rsi     # 0x81f90
callq 0x54f0
movq -0xe0(%rbp), %rax
movb -0x21(%rbp), %cl
movb %cl, 0x24(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x28(%rax)
movzbl -0x21(%rbp), %eax
movq %rax, -0x108(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x34070
movq -0x108(%rbp), %rsi
movq -0x100(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x34090
jmp 0x320c5
movq -0xe0(%rbp), %rdi
addq $0x30, %rdi
leaq -0x40(%rbp), %rsi
movq %rsi, -0x120(%rbp)
callq 0x34100
movq -0x120(%rbp), %rdi
callq 0x34130
leaq -0x41(%rbp), %rdi
callq 0x34190
movzbl -0x21(%rbp), %eax
movq %rax, -0x118(%rbp)
movb $0x0, -0x81(%rbp)
leaq -0x82(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x341b0
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rcx
leaq -0x80(%rbp), %rdi
leaq -0x81(%rbp), %rdx
callq 0x341d0
jmp 0x3213a
movq -0xe0(%rbp), %rdi
addq $0x60, %rdi
leaq -0x80(%rbp), %rsi
movq %rsi, -0x140(%rbp)
callq 0x34250
movq -0x140(%rbp), %rdi
callq 0x342c0
leaq -0x82(%rbp), %rdi
callq 0x342e0
movq -0xe0(%rbp), %rax
movzbl 0x24(%rax), %eax
movq %rax, -0x138(%rbp)
movzbl -0x22(%rbp), %eax
movq %rax, -0x130(%rbp)
movb $0x0, -0xc9(%rbp)
leaq -0xca(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x341b0
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rcx
leaq -0xc8(%rbp), %rdi
leaq -0xc9(%rbp), %rdx
callq 0x341d0
jmp 0x321c7
leaq -0xcb(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x34300
movq -0x138(%rbp), %rsi
movq -0x148(%rbp), %rcx
leaq -0xa0(%rbp), %rdi
leaq -0xc8(%rbp), %rdx
callq 0x34320
jmp 0x321fd
movq -0xe0(%rbp), %rdi
addq $0x88, %rdi
leaq -0xa0(%rbp), %rsi
movq %rsi, -0x158(%rbp)
callq 0x343a0
movq -0x158(%rbp), %rdi
callq 0x343d0
leaq -0xcb(%rbp), %rdi
callq 0x34430
leaq -0xc8(%rbp), %rdi
callq 0x342c0
leaq -0xca(%rbp), %rdi
callq 0x342e0
movl $0xc0, %edi
callq 0x54a0
movq %rax, %rdi
movq -0xe0(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x150(%rbp)
movzwl 0x22(%rax), %ecx
movl %ecx, -0xd4(%rbp)
fildl -0xd4(%rbp)
movzbl 0x21(%rax), %ecx
movw %cx, -0xce(%rbp)
filds -0xce(%rbp)
movzbl 0x24(%rax), %esi
movq %rsp, %rax
fstpt 0x10(%rax)
fstpt (%rax)
callq 0x34450
jmp 0x322a0
movq -0xe0(%rbp), %rax
movq -0x150(%rbp), %rcx
movq %rcx, 0xa0(%rax)
movb $0x1, 0x20(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x32358
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x34190
jmp 0x32364
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x82(%rbp), %rdi
callq 0x342e0
jmp 0x32364
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3232b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xcb(%rbp), %rdi
callq 0x34430
leaq -0xc8(%rbp), %rdi
callq 0x342c0
leaq -0xca(%rbp), %rdi
callq 0x342e0
jmp 0x32364
movq -0x150(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
movl $0xc0, %esi
callq 0x54b0
jmp 0x32364
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x5920
nopl (%rax)