// File: adamiaonr[P]rid-analytics/src/path-state.cpp
// Function: Path_State::to_string()
char * Path_State::to_string() {

    // using calloc() since node_str will be returned
    char * node_str = (char *) calloc(MAX_PATH_STATE_STRING_SIZE, sizeof(char));
    char status[MAX_PATH_STATE_STRING_SIZE];

    switch(this->path_status) {

        case OUTCOME_CORRECT_DELIVERY:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "CORRECT_DELIVERY");
            break;
        case OUTCOME_INCORRECT_DELIVERY:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "INCORRECT_DELIVERY");
            break;
        case OUTCOME_HARD_FALLBACK_DELIVERY:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "HARD_FALLBACK_DELIVERY");
        case OUTCOME_SOFT_FALLBACK_FWD:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "SOFT_FALLBACK_FWD");
            break;
        case OUTCOME_FEEDBACK_DELIVERY:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "FEEDBACK_DELIVERY");
            break;
        // case OUTCOME_FALLBACK_RELAY:
        //     snprintf(status, MAX_PATH_STATE_STRING_SIZE, "FALLBACK_RELAY");
        //     break;
        case OUTCOME_PACKET_DROP:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "PACKET_DROP");
            break;
        case OUTCOME_TTL_DROP:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "TTL_DROP");
            break;
        case STATUS_TP:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "STATUS_TP");
            break;
        case STATUS_FP:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "STATUS_FP");
            break;
        case STATUS_TN:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "STATUS_TN");
            break;
        default:
            snprintf(status, MAX_PATH_STATE_STRING_SIZE, "UNKNOWN");
            break;
    }

    snprintf(
        node_str, MAX_PATH_STATE_STRING_SIZE, 
        "ROUTER[%s] : [PROB : %-.5LE][PATH_LENGTH : %-5d][OUTCOME: %s]",
        this->router->get_id().c_str(),
        this->path_prob, this->path_length, status);

    return node_str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl $0x80, %edi
movl $0x1, %esi
callq 0x5320
movq %rax, %rcx
movq -0xc0(%rbp), %rax
movq %rcx, -0x10(%rbp)
movl 0x10(%rax), %eax
movq %rax, -0xb8(%rbp)
subq $0xa, %rax
ja 0x3fa87
movq -0xb8(%rbp), %rax
leaq 0x23f17(%rip), %rcx     # 0x63870
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23f29(%rip), %rdx     # 0x6389e
movb $0x0, %al
callq 0x5830
jmp 0x3faa1
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23f08(%rip), %rdx     # 0x6389c
movb $0x0, %al
callq 0x5830
jmp 0x3faa1
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23efc(%rip), %rdx     # 0x638af
movb $0x0, %al
callq 0x5830
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23ef9(%rip), %rdx     # 0x638c6
movb $0x0, %al
callq 0x5830
jmp 0x3faa1
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23eec(%rip), %rdx     # 0x638d8
movb $0x0, %al
callq 0x5830
jmp 0x3faa1
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23edf(%rip), %rdx     # 0x638ea
movb $0x0, %al
callq 0x5830
jmp 0x3faa1
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23ecc(%rip), %rdx     # 0x638f6
movb $0x0, %al
callq 0x5830
jmp 0x3faa1
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23eb9(%rip), %rdx     # 0x638ff
movb $0x0, %al
callq 0x5830
jmp 0x3faa1
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23ea7(%rip), %rdx     # 0x63909
movb $0x0, %al
callq 0x5830
jmp 0x3faa1
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23e95(%rip), %rdx     # 0x63913
movb $0x0, %al
callq 0x5830
jmp 0x3faa1
leaq -0x90(%rbp), %rdi
movl $0x80, %esi
leaq 0x23e83(%rip), %rdx     # 0x6391d
movb $0x0, %al
callq 0x5830
movq -0xc0(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, -0xc8(%rbp)
movq (%rax), %rsi
leaq -0xb0(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x35650
movq -0xd0(%rbp), %rdi
callq 0x51d0
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movq -0xc0(%rbp), %rax
fldt 0x20(%rax)
movl 0xc(%rax), %r8d
leaq -0x90(%rbp), %r9
movq %rsp, %rax
fstpt (%rax)
leaq 0x23e25(%rip), %rdx     # 0x63925
xorl %eax, %eax
movl $0x80, %esi
callq 0x5830
leaq -0xb0(%rbp), %rdi
callq 0x52f0
movq -0x10(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop