// File: /workspace/github_cpp_makefile_star2_O3/zkl94[P]distributed-key-value-store/MP1Node.cpp
// Function: MP1Node::updateToBeDeletedMap()
void MP1Node::updateToBeDeletedMap() {

    std::map<int, int>::iterator it = this->tobedeleted->begin();
    
    while(it != this->tobedeleted->end()) {
        it->second = it->second + 1;
        if (it->second >= TREMOVE) {
            // log the removal
            Address address;
            string _address = to_string(it->first) + ":" + to_string(0);
            address = Address(_address);
            log->logNodeRemove(&memberNode->addr, &address);

            // remove from member list
            bool found = false;
            memberNode->myPos = memberNode->memberList.begin();
            while (memberNode->myPos != memberNode->memberList.end()) {
                if ((*memberNode->myPos).getid() == it->first) {
                    // found it
                    found = true;
                    memberNode->myPos = memberNode->memberList.erase(memberNode->myPos);
                    break;
                }
                ++memberNode->myPos;
            }
            if (!found) {
                cout << "the should-be-deleted entry is not found in member list; sth goes wrong" << endl;
            }

            // remove from to-be-deleted map; can be re-added by membership protocol now
            it = this->tobedeleted->erase(it);
        } else {
            ++it;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq 0x38(%rdi), %r15
movq 0x18(%r15), %r14
leaq 0x8(%r15), %rax
cmpq %rax, %r14
je 0x619a
leaq 0x28(%rsp), %rbp
movq %rdi, 0x88(%rsp)
movl 0x24(%r14), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x24(%r14)
cmpl $0x9, %eax
jl 0x5e87
movl 0x20(%r14), %r15d
movl %r15d, %r12d
negl %r12d
cmovsl %r15d, %r12d
movl $0x1, %r13d
cmpl $0xa, %r12d
jb 0x5ea0
movl $0x4, %r13d
movl %r12d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x5e97
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x5e9d
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x5ea0
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x5e57
addl $-0x3, %r13d
jmp 0x5ea0
movq %r14, %rdi
callq 0x31b0
movq %rax, %r14
jmp 0x618d
addl $-0x2, %r13d
jmp 0x5ea0
decl %r13d
movq %rbp, %rbx
shrl $0x1f, %r15d
movl %r15d, %esi
addl %r13d, %esi
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
movl $0x2d, %edx
callq 0x32f0
movq 0x68(%rsp), %rdi
addq %r15, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x6723
movq %rbp, %rdi
leaq 0x11dcb(%rip), %rsi     # 0x17cb1
callq 0x3480
leaq 0x38(%rsp), %r13
movq %r13, 0x28(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq 0x18(%rsp), %r15
leaq 0x58(%rsp), %r12
je 0x5f1d
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x5f25
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %rbx, %rbp
movq 0x8(%rax), %rdx
movq %rdx, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r12, 0x48(%rsp)
movl $0x1, %esi
leaq 0x48(%rsp), %rdi
movl $0x2d, %edx
callq 0x32f0
movq 0x48(%rsp), %rax
movb $0x30, (%rax)
movq 0x28(%rsp), %rcx
movl $0xf, %edi
cmpq %r13, %rcx
je 0x5f75
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %r8
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x5fa1
movl $0xf, %edi
cmpq %r12, %rsi
je 0x5f9c
movq 0x58(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x5fab
movq %rbp, %rdi
callq 0x30d0
jmp 0x5fb9
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x32c0
movq %r15, 0x8(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x5fd9
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x5fe0
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x6014
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
leaq 0x90(%rsp), %rbx
leaq 0xb2(%rsp), %r12
je 0x603b
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
leaq 0xa0(%rsp), %r13
je 0x605f
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x3280
movq %r13, 0x90(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x6790
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x62c6
movq %r12, %rdi
movq %rbp, %rsi
callq 0xd02a
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
je 0x60af
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x88(%rsp), %rbx
movq 0x10(%rbx), %rdi
movq 0x20(%rbx), %rsi
addq $0x8, %rsi
movq %r12, %rdx
callq 0xc6d6
movq 0x20(%rbx), %rax
movq 0x28(%rax), %rcx
movq %rcx, 0x40(%rax)
movq 0x20(%rbx), %rax
movq 0x40(%rax), %rdi
cmpq 0x30(%rax), %rdi
movq 0x18ee6(%rip), %r12     # 0x1efd0
je 0x610d
callq 0xd09e
movq 0x20(%rbx), %rcx
cmpl 0x20(%r14), %eax
je 0x614b
movq 0x40(%rcx), %rdi
addq $0x18, %rdi
movq %rdi, 0x40(%rcx)
cmpq 0x30(%rcx), %rdi
jne 0x60ec
movl $0x47, %edx
movq %r12, %rdi
leaq 0x10efd(%rip), %rsi     # 0x17019
callq 0x32d0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x3240
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31a0
jmp 0x6163
movq 0x40(%rcx), %rsi
addq $0x28, %rcx
movq %rcx, %rdi
callq 0x6aa0
movq 0x20(%rbx), %rcx
movq %rax, 0x40(%rcx)
movq 0x38(%rbx), %rdi
movq %r14, %rsi
callq 0x6a64
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6189
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x38(%rbx), %r15
leaq 0x8(%r15), %rax
cmpq %rax, %r14
jne 0x5e1f
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6239
movq %rax, %rbx
jmp 0x61dc
movq %rax, %rbx
jmp 0x6230
jmp 0x6239
movq %rax, %rbx
jmp 0x61f8
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r12, %rdi
je 0x61dc
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x61f8
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x6253
movq 0x78(%rsp), %rsi
jmp 0x624b
jmp 0x6239
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r13, %rdi
je 0x6230
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x18(%rsp), %r15
jmp 0x623c
jmp 0x6239
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x6253
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x3450
nop