// File: /workspace/github_cpp_makefile_star2_O3/adamiaonr[P]rid-analytics/src/rid-analytics.cpp
// Function: RID_Analytics::init_output(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void RID_Analytics::init_output(
    std::string label,
    std::string output_dir) {

    // we create 4 .tsv files:
    //  -# events.tsv       : probs of events (LLM, SLM, NLM, MLM) per router
    //  -# outcomes.tsv     : probs + latency + router of outcome
    //  -# forwarding.tsv   : description of fwding events, including next router probs
    //  -# ifaces.tsv       : description of fwding events, including iface probs per router

    // file names follow the convention <type>.<label>.<unix-timestamp>.tsv
    // this->output_file = std::vector<std::ofstream> (3);
    // std::string filename[3] = {"events", "outcomes", "forwarding"};
    // for (int i = 0; i < 3; i++) {
    //     filename[i] += std::string(".") + label + std::string(".") + get_unix_timestamp() + std::string(".tsv");
    //     this->output_file[i].open(output_dir + std::string("/") + filename[i]);
    // }
    this->output_file = std::vector<std::ofstream> (2);
    std::string filename[2] = {"events", "outcomes"};
    for (int i = 0; i < 2; i++) {
        filename[i] += std::string(".") + label + std::string(".") + get_unix_timestamp() + std::string(".tsv");
        this->output_file[i].open(output_dir + std::string("/") + filename[i]);
    }

    // events header
    this->output_file[0] << "router\tnlm\tmlm\tllm\tslmc\tslmi\tfpd\n";
    // outcome header
    this->output_file[1] << "router\ttype\tprob\tlatency\n";
    // // forwarding header
    // this->output_file[2] << "from\tinprob\tinto";
    // for (auto const& r : this->routers)
    //     this->output_file[2] << "\t" << r.second->get_id();
    // this->output_file[2] << "\n";
    
    // ifaces header
    // determine router w/ largest iface_num
    uint8_t iface_num = 0;
    for (auto const& r : this->routers) {
        iface_num = std::max(iface_num, r.second->get_iface_num());
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdx, 0x110(%rsp)
movq %rsi, 0x118(%rsp)
movq %rdi, %rbx
leaq 0x20(%rsp), %r12
leaq 0x48(%rsp), %rdx
movl $0x2, %esi
movq %r12, %rdi
callq 0x27f54
movq 0xa8(%rbx), %rax
movaps (%r12), %xmm0
movq 0x10(%r12), %rcx
movq %rcx, 0xa8(%rbx)
movups 0x98(%rbx), %xmm1
movq %rbx, 0xc8(%rsp)
movups %xmm0, 0x98(%rbx)
leaq 0x120(%rsp), %rdi
movaps %xmm1, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%r12)
movq $0x0, 0x10(%r12)
callq 0x27f0a
movq %r12, %rdi
callq 0x27f0a
leaq 0x130(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xc3ae(%rip), %rsi      # 0x30dd5
leaq 0xc3ad(%rip), %rdx      # 0x30ddb
leaq 0x120(%rsp), %r12
movq %r12, %rdi
callq 0x18bc0
leaq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0xc383(%rip), %rsi      # 0x30ddc
leaq 0xc384(%rip), %rdx      # 0x30de4
callq 0x18bc0
movb $0x1, %r13b
xorl %ebp, %ebp
leaq 0xf0(%rsp), %r14
leaq 0x100(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq %r14, %rdi
leaq 0xb879(%rip), %rsi      # 0x30305
leaq 0xb873(%rip), %rdx      # 0x30306
callq 0x18bc0
movq 0x118(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r14, %rdi
callq 0x4150
leaq 0x78(%rsp), %rsi
movq %rsi, 0x68(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq 0x58(%rsp), %r15
je 0x24adc
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0x24ae2
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x70(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xb8(%rsp), %rax
movq %rax, 0xa8(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0xb7ec(%rip), %rsi      # 0x30305
leaq 0xb7e6(%rip), %rdx      # 0x30306
callq 0x18bc0
movq 0x68(%rsp), %rcx
movl $0xf, %edi
leaq 0x78(%rsp), %rax
cmpq %rax, %rcx
je 0x24b3e
movq 0x78(%rsp), %rdi
movq 0x70(%rsp), %r8
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x24b7b
movl $0xf, %edi
leaq 0xb8(%rsp), %r9
cmpq %r9, %rsi
je 0x24b76
movq 0xb8(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x24b87
leaq 0x68(%rsp), %rdi
callq 0x4150
jmp 0x24b98
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x43f0
leaq 0x10(%rsp), %rsi
movq %rsi, (%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x24bbb
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x24bc1
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0xd0(%rsp), %rdi
callq 0x252fa
movq (%rsp), %rcx
movl $0xf, %edi
leaq 0x10(%rsp), %rax
cmpq %rax, %rcx
je 0x24c03
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
movq 0xd0(%rsp), %rsi
movq 0xd8(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x24c40
movl $0xf, %edi
leaq 0xe0(%rsp), %r9
cmpq %r9, %rsi
je 0x24c3b
movq 0xe0(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x24c4a
movq %rsp, %rdi
callq 0x4150
jmp 0x24c5b
leaq 0xd0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x43f0
movq %r15, 0x48(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x24c7b
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x24c82
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0xc127(%rip), %rsi      # 0x30de5
leaq 0xc124(%rip), %rdx      # 0x30de9
callq 0x18bc0
movq 0x48(%rsp), %rcx
movl $0xf, %edi
cmpq %r15, %rcx
je 0x24cde
movq 0x58(%rsp), %rdi
movq 0x50(%rsp), %r8
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x24d1b
movl $0xf, %edi
leaq 0x98(%rsp), %r9
cmpq %r9, %rsi
je 0x24d16
movq 0x98(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x24d27
leaq 0x48(%rsp), %rdi
callq 0x4150
jmp 0x24d38
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x43f0
leaq 0x30(%rsp), %rsi
movq %rsi, 0x20(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x24d5d
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x24d63
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %r12, %rdi
callq 0x4150
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x24dae
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x24dd3
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x24dea
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x24e0f
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x43a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x24e2a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x24e4f
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x24e6b
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x43a0
movl %r13d, %r14d
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x24e93
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x43a0
shlq $0x9, %rbp
movq 0xc8(%rsp), %rax
addq 0x98(%rax), %rbp
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %rsp, %r13
movq %r13, %rdi
leaq 0xbf2e(%rip), %rsi      # 0x30dea
leaq 0xbf28(%rip), %rdx      # 0x30deb
callq 0x18bc0
movq 0x110(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %r8
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x43f0
movq %r15, 0x48(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x24f06
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x24f0d
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
leaq 0x48(%rsp), %rdi
callq 0x4150
leaq 0x30(%rsp), %r12
movq %r12, 0x20(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x24f60
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x24f68
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
movl $0x10, %edx
callq 0x41c0
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
leaq 0x10(%rsp), %r12
je 0x24fae
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x24fc5
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x43a0
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x24fdb
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
movl $0x1, %ebp
leaq 0x140(%rsp), %r12
testb $0x1, %r14b
movl $0x0, %r13d
leaq 0xf0(%rsp), %r14
jne 0x24a72
movq 0xc8(%rsp), %r14
movq 0x98(%r14), %rdi
leaq 0xbdd6(%rip), %rsi      # 0x30dec
movl $0x21, %edx
callq 0x4400
movl $0x200, %edi            # imm = 0x200
addq 0x98(%r14), %rdi
leaq 0xbddb(%rip), %rsi      # 0x30e0e
movl $0x19, %edx
callq 0x4400
movq $-0x40, %r14
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0x25058
movq (%rbx), %rsi
incq %rsi
callq 0x43a0
addq $-0x20, %rbx
addq $0x20, %r14
jne 0x25044
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
movq 0x120(%rsp), %rdi
cmpq %r14, %rdi
je 0x25262
movq 0x130(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x25262
jmp 0x251d6
jmp 0x251d6
movq %rax, %r12
jmp 0x251b7
movq %rax, %r12
jmp 0x2519b
movq %rax, %r12
jmp 0x25176
movq %rax, %r12
jmp 0x2515b
movq %rax, %r12
jmp 0x25136
movq %rax, %r12
jmp 0x2511a
movq %rax, %r12
jmp 0x250f5
movq %rax, %r12
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x250f5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x2511a
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x25136
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x2515b
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x43a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x25176
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x2519b
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x251b7
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x25239
movq 0x100(%rsp), %rsi
jmp 0x25231
movq %rax, %r12
jmp 0x25239
movq %rax, %r12
jmp 0x2521e
movq %rax, %r12
jmp 0x25202
movq %r12, %rcx
movq %rax, %r12
movq 0x20(%rsp), %rdi
cmpq %rcx, %rdi
je 0x25202
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2521e
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x43a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x25239
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x43a0
xorl %r14d, %r14d
movq 0x140(%rsp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0x25258
movq (%rax), %rsi
incq %rsi
callq 0x43a0
addq $-0x20, %r14
cmpq $-0x40, %r14
jne 0x2523c
movq %r12, %rdi
callq 0x4700