// File: adamiaonr[P]rid-analytics/src/rid-analytics.cpp
// Function: RID_Analytics::add_outcome(RID_Router*, int, long double, long double)
void RID_Analytics::add_outcome(
    RID_Router * router,
    int outcome, 
    __float080 prob,
    __float080 latency) {

    // header : router\ttype\tprob\tlatency\n
    std::string code = "";
    switch (outcome) {

        case OUTCOME_CORRECT_DELIVERY:
            code = "cd";
            break;

        case OUTCOME_INCORRECT_DELIVERY:
            code = "id";
            break;

        case OUTCOME_SOFT_FALLBACK_FWD:
            code = "sff";
            break;

        case OUTCOME_SOFT_FALLBACK_AID_FWD:
            code = "sffid";
            break;

        case OUTCOME_HARD_FALLBACK_DELIVERY:
            code = "hfd";
            break;

        case OUTCOME_FEEDBACK_DELIVERY:
            code = "fed";
            break;

        case OUTCOME_PACKET_DROP:
            code = "dr";
            break;

        default:
            code = "uk";
            break;
    }

    // add line to outcome file
    this->output_file[1] << router->get_id() << "\t" 
        << code << "\t" << prob << "\t" << latency << "\n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
fldt 0x20(%rbp)
fldt 0x10(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
fstpt -0x30(%rbp)
fstpt -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x61(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x5930
movq -0xa0(%rbp), %rdx
leaq 0x1507d(%rip), %rsi     # 0x63508
leaq -0x60(%rbp), %rdi
callq 0x30320
jmp 0x4e496
leaq -0x61(%rbp), %rdi
callq 0x5510
movl -0x14(%rbp), %eax
movq %rax, -0xb0(%rbp)
subq $0xb, %rax
ja 0x4e584
movq -0xb0(%rbp), %rax
leaq 0x1597f(%rip), %rcx     # 0x63e40
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x5510
jmp 0x4e6e0
leaq 0x15cdc(%rip), %rsi     # 0x641c7
leaq -0x60(%rbp), %rdi
callq 0x5700
jmp 0x4e4f6
jmp 0x4e598
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x4e6d7
leaq 0x15cbe(%rip), %rsi     # 0x641d1
leaq -0x60(%rbp), %rdi
callq 0x5700
jmp 0x4e51e
jmp 0x4e598
leaq 0x15ca3(%rip), %rsi     # 0x641ca
leaq -0x60(%rbp), %rdi
callq 0x5700
jmp 0x4e532
jmp 0x4e598
leaq 0x15c93(%rip), %rsi     # 0x641ce
leaq -0x60(%rbp), %rdi
callq 0x5700
jmp 0x4e546
jmp 0x4e598
leaq 0x15c85(%rip), %rsi     # 0x641d4
leaq -0x60(%rbp), %rdi
callq 0x5700
jmp 0x4e55a
jmp 0x4e598
leaq 0x15c75(%rip), %rsi     # 0x641d8
leaq -0x60(%rbp), %rdi
callq 0x5700
jmp 0x4e56e
jmp 0x4e598
leaq 0x15c65(%rip), %rsi     # 0x641dc
leaq -0x60(%rbp), %rdi
callq 0x5700
jmp 0x4e582
jmp 0x4e598
leaq 0x15c54(%rip), %rsi     # 0x641df
leaq -0x60(%rbp), %rdi
callq 0x5700
jmp 0x4e596
jmp 0x4e598
movq -0xa8(%rbp), %rdi
addq $0x98, %rdi
movl $0x1, %esi
callq 0x51df0
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x35650
jmp 0x4e5c9
movq -0xb8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x5430
movq %rax, -0xc0(%rbp)
jmp 0x4e5e5
movq -0xc0(%rbp), %rdi
leaq 0x14f14(%rip), %rsi     # 0x63507
callq 0x5480
movq %rax, -0xc8(%rbp)
jmp 0x4e601
movq -0xc8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x5430
movq %rax, -0xd0(%rbp)
jmp 0x4e61a
movq -0xd0(%rbp), %rdi
leaq 0x14edf(%rip), %rsi     # 0x63507
callq 0x5480
movq %rax, -0xd8(%rbp)
jmp 0x4e636
movq -0xd8(%rbp), %rdi
fldt -0x30(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0x55b0
movq %rax, -0xe0(%rbp)
jmp 0x4e653
movq -0xe0(%rbp), %rdi
leaq 0x14ea6(%rip), %rsi     # 0x63507
callq 0x5480
movq %rax, -0xe8(%rbp)
jmp 0x4e66f
movq -0xe8(%rbp), %rdi
fldt -0x40(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0x55b0
movq %rax, -0xf0(%rbp)
jmp 0x4e68c
movq -0xf0(%rbp), %rdi
leaq 0x14e29(%rip), %rsi     # 0x634c3
callq 0x5480
jmp 0x4e6a1
leaq -0x98(%rbp), %rdi
callq 0x52f0
leaq -0x60(%rbp), %rdi
callq 0x52f0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x52f0
leaq -0x60(%rbp), %rdi
callq 0x52f0
movq -0x70(%rbp), %rdi
callq 0x5920
nopl (%rax)