// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, -0x30(%rbp)
movl %r8d, -0x2c(%rbp)
movq %rcx, %r12
movl %edx, %r13d
movl %esi, %r14d
movq %rdi, %rbx
movq 0x20(%rbp), %r15
leaq 0x132a(%rip), %rsi      # 0x5247
callq 0x21d0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21c0
leaq 0x12bc(%rip), %r15      # 0x51f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
movl 0x220(%rbx), %esi
movq %rbx, %rdi
callq 0x22f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
leaq 0x12ea(%rip), %rsi      # 0x5249
movq %rbx, %rdi
callq 0x21d0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rbx, %rdi
movl %r14d, %esi
callq 0x22f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rbx, %rdi
movl %r13d, %esi
callq 0x22f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
callq 0x22f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rbx, %rdi
movl -0x30(%rbp), %esi
callq 0x22f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rbx, %rdi
movq 0x10(%rbp), %rsi
callq 0x2180
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
movq %rbx, %rdi
movl 0x18(%rbp), %esi
callq 0x22f0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21d0
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop