// File: sidscrazy[P]Paxos/./plan/PaxosNodeLogger.cpp
// Function: PaxosNodeLogger::AddMsg(message*, int)
void PaxosNodeLogger::AddMsg (message *m, int role) {
    myfile << "\n"; // get to the new line for next entry.
    myfile << m->timestamp        << ",";         // get to the new line for next entry.
    myfile << m->sender     << ",";         // string: unique guid for the node which owns this log file, same as file name.
    myfile << m->receiver     << ",";         
    myfile << MSG_ENTRY         << ",";         // int: denotes if the node is alive is crashed state.
    myfile << m->round                 << ",";         // int: The value of N proposed or accepted by a node. In say Broadcast action, its value is redundant.
    myfile << m->value             << ",";         // string: Pick value v of highest proposal number -> this is the v we are talking about
    myfile << role          << ",";         // int: Proposer, Acceptor, Learner.
    myfile << m->round     << ",";         // int: Maximum Promised value of N so far for the node. Even leader can have a promised N
    if (m->type == MSG_CONSENSUS){
        myfile << m->value    << ","; 
    } else {
        myfile << ""    << ","; 
    }
    myfile << m->type     << ",";         // int Current action on the node as the logging is happening                              
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
leaq 0xab5(%rip), %rsi       # 0x8247
callq 0x21e0
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x2340
movq %rax, %rdi
leaq 0xa3e(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %esi
callq 0x2310
movq %rax, %rdi
leaq 0xa20(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x2310
movq %rax, %rdi
leaq 0xa01(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x20(%rbp), %rdi
movl $0x1, %esi
callq 0x2310
movq %rax, %rdi
leaq 0x9e4(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x2310
movq %rax, %rdi
leaq 0x9c5(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x2310
movq %rax, %rdi
leaq 0x9a6(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x20(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2310
movq %rax, %rdi
leaq 0x98b(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x2310
movq %rax, %rdi
leaq 0x96c(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x10(%rbp), %rax
cmpl $0x6, 0x10(%rax)
jne 0x78b4
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x2310
movq %rax, %rdi
leaq 0x943(%rip), %rsi       # 0x81f0
callq 0x21e0
jmp 0x78d3
movq -0x20(%rbp), %rdi
leaq 0x989(%rip), %rsi       # 0x8248
callq 0x21e0
movq %rax, %rdi
leaq 0x922(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x2310
movq %rax, %rdi
leaq 0x903(%rip), %rsi       # 0x81f0
callq 0x21e0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)