// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movl %edx, %r12d
movl %esi, %r13d
movq %rdi, %rbx
movq 0x20(%rbp), %r15
leaq 0xd00(%rip), %rsi       # 0x5277
movl $0x1, %edx
callq 0x2220
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21e0
leaq 0xc8d(%rip), %r15       # 0x5220
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
movl 0x220(%rbx), %esi
movq %rbx, %rdi
callq 0x2310
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
leaq 0xcb1(%rip), %rsi       # 0x5279
movl $0x2, %edx
movq %rbx, %rdi
callq 0x2220
movl $0x1, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2220
movq %rbx, %rdi
movl %r13d, %esi
callq 0x2310
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2310
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x2220
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
callq 0x2310
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
movq %rbx, %rdi
movl -0x30(%rbp), %esi
callq 0x2310
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
movq 0x10(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0x2220
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
movq %rbx, %rdi
movl 0x18(%rbp), %esi
callq 0x2310
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2220
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq