// File: /workspace/github_cpp_makefile_star2_O1/zkl94[P]distributed-key-value-store/MP1Node.cpp
// Function: MP1Node::updateEntry(Member*, int, short, long)
void MP1Node::updateEntry(Member *memberNode, int id, short port, long heartbeat) {
    // if this node (with id) is already in to be deleted map, just ignore it
    auto alreadyintobedeletedlist = this->tobedeleted->count(id);
    if (alreadyintobedeletedlist != 0) {
        // already in to be deleted map
        // cout << "already in tobedeleted map, ignore the update" <<endl;
        return;
    }

    // if it is not to be deleted, then update/insert normally
    bool found = false;
    for (MemberListEntry memberListEntry: memberNode->memberList) {
        if (memberListEntry.getid() == id && memberListEntry.getport() == port) {
            found = true;
            // the incoming heartbeat is more latest
            if (memberListEntry.getheartbeat() < heartbeat) {
                // cout << "doing heartbeat update for " << id <<endl;
                memberListEntry.setheartbeat(heartbeat);
                memberListEntry.settimestamp(par->getcurrtime());
            }
            break;
        }
    }

    if (!found) {
        MemberListEntry *newEntry = new MemberListEntry(id, port, heartbeat, par->getcurrtime());
        memberNode->memberList.push_back(*newEntry);

        logNodeAddWrapper(memberNode, id, port);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, 0x10(%rsp)
movl %ecx, %ebp
movl %edx, %ebx
movq %rsi, %r12
movq %rdi, 0x8(%rsp)
movq 0x38(%rdi), %rax
movq 0x10(%rax), %rdx
addq $0x8, %rax
movq %rax, %rcx
testq %rdx, %rdx
je 0x5d0f
movq %rax, %rcx
xorl %esi, %esi
cmpl %ebx, 0x20(%rdx)
setl %sil
cmovgeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x5cf8
movq %rax, %rdx
cmpq %rax, %rcx
je 0x5d21
cmpl %ebx, 0x20(%rcx)
cmovgq %rax, %rcx
movq %rcx, %rdx
cmpq %rax, %rdx
jne 0x5e19
movq 0x28(%r12), %r13
movq 0x30(%r12), %r15
cmpq %r15, %r13
je 0x5dc9
movq %r12, 0x18(%rsp)
xorl %r12d, %r12d
leaq 0x20(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0xd1bc
movq %r14, %rdi
callq 0xd1f2
cmpl %ebx, %eax
jne 0x5daf
movq %r14, %rdi
callq 0xd1f6
cmpw %bp, %ax
jne 0x5daf
movq %r14, %rdi
callq 0xd1fc
movb $0x1, %r12b
movb $0x1, %cl
cmpq 0x10(%rsp), %rax
jge 0x5db1
movq %r14, %rdi
movq 0x10(%rsp), %rsi
callq 0xd212
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xd162
movslq %eax, %rsi
movq %r14, %rdi
callq 0xd218
movb $0x1, %r12b
movb $0x1, %cl
jmp 0x5db1
xorl %ecx, %ecx
testb %cl, %cl
jne 0x5dbe
addq $0x18, %r13
cmpq %r15, %r13
jne 0x5d4a
testb $0x1, %r12b
movq 0x18(%rsp), %r12
jne 0x5e19
movl $0x18, %edi
callq 0x3270
movq %rax, %r14
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xd162
movslq %eax, %r8
movswl %bp, %ebp
movq %r14, %rdi
movl %ebx, %esi
movl %ebp, %edx
movq 0x10(%rsp), %rcx
callq 0xd1a4
leaq 0x28(%r12), %rdi
movq %r14, %rsi
callq 0x6320
movq 0x8(%rsp), %rdi
movq %r12, %rsi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x4f3e
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x18, %esi
movq %r14, %rdi
callq 0x3280
movq %rbx, %rdi
callq 0x3450