// File: sidscrazy[P]Paxos/./plan/PaxosNodeLogger.cpp
// Function: PaxosNodeLogger::AddRowToLogFile(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, long)
int PaxosNodeLogger::AddRowToLogFile(int nodeAlive, int N, string value, int nodeRole, int maxPromisedN, string consensusValue, int currentAction, int64_t ts)
{
//    time_t timeStamp = time(0); // will this work on linux?
   
    myfile << "\n"; // get to the new line for next entry.
    myfile << ts        << ",";         // get to the new line for next entry.
    myfile << nodeuniqueid      << ",";         // string: unique guid for the node which owns this log file, same as file name.
    myfile << "NA" << ",";
    myfile << nodeAlive         << ",";         // int: denotes if the node is alive is crashed state.
    myfile << N                 << ",";         // int: The value of N proposed or accepted by a node. In say Broadcast action, its value is redundant.
    myfile << value             << ",";         // string: Pick value v of highest proposal number -> this is the v we are talking about
    myfile << nodeRole          << ",";         // int: Proposer, Acceptor, Learner.
    myfile << maxPromisedN      << ",";         // int: Maximum Promised value of N so far for the node. Even leader can have a promised N
    myfile << consensusValue    << ",";         // string: Final agreed upon consensus value
    myfile << currentAction     << ",";         // int Current action on the node as the logging is happening 
                                                // proposeStart, proposeEnd,
                                                // promiseStart, promiseEnd,
                                                // acceptReqStart, acceptReqEnd,
                                                // broadcastStart, broadcastEnd,
                                                // nodecrashStart, nodecrashEnd

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rcx, -0x38(%rbp)
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x28(%rbp)
leaq 0xc07(%rip), %rsi       # 0x8247
callq 0x21e0
movq -0x28(%rbp), %rdi
movq 0x20(%rbp), %rsi
callq 0x2340
movq %rax, %rdi
leaq 0xb94(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x28(%rbp), %rdi
movl 0x220(%rdi), %esi
callq 0x2310
movq %rax, %rdi
leaq 0xb76(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x28(%rbp), %rdi
leaq 0xbbf(%rip), %rsi       # 0x8249
callq 0x21e0
movq %rax, %rdi
leaq 0xb57(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x28(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x2310
movq %rax, %rdi
leaq 0xb3c(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x28(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x2310
movq %rax, %rdi
leaq 0xb21(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x38(%rbp), %rsi
movq -0x28(%rbp), %rdi
callq 0x21a0
movq %rax, %rdi
leaq 0xb05(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x2310
movq %rax, %rdi
leaq 0xaea(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x28(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x2310
movq %rax, %rdi
leaq 0xacf(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdi
callq 0x21a0
movq %rax, %rdi
leaq 0xab3(%rip), %rsi       # 0x81f0
callq 0x21e0
movq -0x28(%rbp), %rdi
movl 0x18(%rbp), %esi
callq 0x2310
movq %rax, %rdi
leaq 0xa98(%rip), %rsi       # 0x81f0
callq 0x21e0
movl $0x1, %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)