// File: /workspace/github_cpp_makefile_star2_O1/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 0x28(%rsp), %r12
leaq 0x8(%rsp), %rdx
movl $0x2, %esi
movq %r12, %rdi
callq 0x28440
xorps %xmm0, %xmm0
leaq 0x120(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x98(%rbx), %rax
movups 0xa0(%rbx), %xmm0
movq (%r12), %rcx
movq %rcx, 0x98(%rbx)
movq 0x8(%r12), %rcx
movq %rcx, 0xa0(%rbx)
movq 0x10(%r12), %rcx
movq %rcx, 0xa8(%rbx)
movq (%rdi), %rcx
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rsi
movq %rax, (%rdi)
movups %xmm0, 0x8(%rdi)
movq %rcx, (%r12)
movq %rdx, 0x8(%r12)
movq %rsi, 0x10(%r12)
callq 0x283fc
movq %r12, %rdi
callq 0x283fc
leaq 0x130(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xd0ef(%rip), %rsi      # 0x31ff5
leaq 0xd0ee(%rip), %rdx      # 0x31ffb
leaq 0x120(%rsp), %r13
movq %r13, %rdi
callq 0x19074
movq %rbx, 0xe8(%rsp)
leaq 0x140(%rsp), %r12
leaq 0x150(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0xd0bc(%rip), %rsi      # 0x31ffc
leaq 0xd0bd(%rip), %rdx      # 0x32004
movq %r12, %rdi
callq 0x19074
leaq 0x78(%rsp), %r14
leaq 0x58(%rsp), %r15
leaq 0x120(%rsp), %r12
xorl %ebp, %ebp
leaq 0xf0(%rsp), %r13
leaq 0x100(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq %r13, %rdi
leaq 0xc5a0(%rip), %rsi      # 0x31525
leaq 0xc59a(%rip), %rdx      # 0x31526
callq 0x19074
movq 0x118(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r13, %rdi
callq 0x4150
movq %r14, 0x68(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x24fcb
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0x24fd2
movups (%rcx), %xmm0
movups %xmm0, (%r14)
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 0xc51c(%rip), %rsi      # 0x31525
leaq 0xc516(%rip), %rdx      # 0x31526
callq 0x19074
movq 0x68(%rsp), %rcx
movl $0xf, %esi
cmpq %r14, %rcx
je 0x25029
movq 0x78(%rsp), %rsi
movq 0x70(%rsp), %r8
movq 0xb0(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
jbe 0x25063
movl $0xf, %esi
leaq 0xb8(%rsp), %rdi
cmpq %rdi, 0xa8(%rsp)
je 0x2505e
movq 0xb8(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x25077
movq 0xa8(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x4150
jmp 0x25088
leaq 0xa8(%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 0x250a8
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x250af
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 0xc8(%rsp), %rdi
callq 0x25814
movq 0x48(%rsp), %rcx
movl $0xf, %esi
cmpq %r15, %rcx
je 0x250ed
movq 0x58(%rsp), %rsi
movq 0x50(%rsp), %r8
movq 0xd0(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
leaq 0x18(%rsp), %r14
jbe 0x2512c
movl $0xf, %esi
leaq 0xd8(%rsp), %rdi
cmpq %rdi, 0xc8(%rsp)
je 0x25127
movq 0xd8(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x25140
movq 0xc8(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x4150
jmp 0x25151
leaq 0xc8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x43f0
movq %r14, 0x8(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x25171
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x25178
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0xce51(%rip), %rsi      # 0x32005
leaq 0xce4e(%rip), %rdx      # 0x32009
callq 0x19074
movq 0x8(%rsp), %rcx
movl $0xf, %esi
cmpq %r14, %rcx
je 0x251d4
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %r8
movq 0x90(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
jbe 0x2520e
movl $0xf, %esi
leaq 0x98(%rsp), %rdi
cmpq %rdi, 0x88(%rsp)
je 0x25209
movq 0x98(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x25222
movq 0x88(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x4150
jmp 0x25233
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x43f0
leaq 0x38(%rsp), %rsi
movq %rsi, 0x28(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x25258
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x2525e
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq %r12, %rdi
callq 0x4150
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x252a9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x252ce
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0x252e5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x2530a
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x25321
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x25346
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x43a0
movq %r15, %r14
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x25365
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
leaq 0x48(%rsp), %r15
je 0x2538f
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xe8(%rsp), %rax
movq 0x98(%rax), %r13
addq %rbp, %r13
movq %r14, 0x48(%rsp)
movq %r15, %rdi
leaq 0xcc5a(%rip), %rsi      # 0x3200a
leaq 0xcc54(%rip), %rdx      # 0x3200b
callq 0x19074
movq 0x110(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %r8
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x43f0
leaq 0x18(%rsp), %rsi
movq %rsi, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x253ff
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x25405
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
leaq 0x8(%rsp), %rdi
callq 0x4150
leaq 0x38(%rsp), %rsi
movq %rsi, 0x28(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x25458
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x2545e
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r13, %rdi
leaq 0x28(%rsp), %rsi
movl $0x10, %edx
callq 0x41c0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x254a4
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
movq %r14, %r15
je 0x254c3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
leaq 0x78(%rsp), %r14
je 0x254df
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x43a0
movl $0x200, %eax            # imm = 0x200
addq %rax, %rbp
addq $0x20, %r12
cmpq %rax, %rbp
leaq 0xf0(%rsp), %r13
je 0x24f6b
movq 0xe8(%rsp), %r14
movq 0x98(%r14), %rdi
leaq 0xcafa(%rip), %rsi      # 0x3200c
movl $0x21, %edx
callq 0x4400
movl $0x200, %edi            # imm = 0x200
addq 0x98(%r14), %rdi
leaq 0xcaff(%rip), %rsi      # 0x3202e
movl $0x19, %edx
callq 0x4400
movq $-0x40, %r14
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0x25554
movq (%rbx), %rsi
incq %rsi
callq 0x43a0
addq $-0x20, %rbx
addq $0x20, %r14
jne 0x25540
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbp
jmp 0x2557b
movq %rax, %rbp
movq %r13, %r12
cmpq %r12, %r13
je 0x2577b
addq $-0x10, %r12
leaq 0x120(%rsp), %rbx
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x255a6
movq (%r12), %rsi
incq %rsi
callq 0x43a0
leaq -0x20(%r12), %rax
addq $-0x10, %r12
cmpq %rbx, %r12
movq %rax, %r12
jne 0x25590
jmp 0x2577b
jmp 0x256f1
jmp 0x256f1
movq %rax, %rbp
jmp 0x256d2
movq %rax, %rbp
jmp 0x256bb
movq %rax, %rbp
jmp 0x25696
movq %rax, %rbp
jmp 0x2567f
movq %rax, %rbp
jmp 0x25655
movq %rax, %rbp
jmp 0x25639
movq %rax, %rbp
jmp 0x25614
movq %rax, %rbp
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x25614
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x25639
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x25655
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0x2567a
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x43a0
leaq 0x78(%rsp), %r14
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x25696
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x256bb
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x256d2
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0xf0(%rsp), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x25752
movq 0x100(%rsp), %rsi
jmp 0x2574a
movq %rax, %rbp
jmp 0x25752
movq %rax, %rbp
jmp 0x2573b
movq %rax, %rbp
jmp 0x2571f
movq %rax, %rbp
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2571f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2573b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x25752
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x43a0
xorl %r14d, %r14d
movq 0x140(%rsp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0x25771
movq (%rax), %rsi
incq %rsi
callq 0x43a0
addq $-0x20, %r14
cmpq $-0x40, %r14
jne 0x25755
movq %rbp, %rdi
callq 0x4700
nop