// File: /workspace/github_cpp_makefile_star2_O2/zkl94[P]distributed-key-value-store/MP2Node.cpp
// Function: MP2Node::clientReadDelete(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, MessageType)
void MP2Node::clientReadDelete(string key, MessageType t) {
    // construct message
    int transID = this->lowestTransID++;
    this->transID2Bundle.emplace(transID, new Bundle(t, key, ""));

    Message *primary_message = new Message(transID, this->memberNode->addr, t, key);
    Message *secondary_message = new Message(transID, this->memberNode->addr, t, key);
    Message *tertiary_message = new Message(transID, this->memberNode->addr, t, key);

    // find primary replica position
    // size_t position = this->hashFunction(key);

    vector<Node> v = findNodes(key);
    // cout << "there are " << v.size() << " nodes for this key" << endl;

    // Address _toAddr = this->ring[position].nodeAddress;
    string primary_string = primary_message->toString();
    emulNet->ENsend(&(this->memberNode->addr), &(v[0].nodeAddress), (char *)primary_string.c_str(), primary_string.size());

    // _toAddr = this->ring[position+1].nodeAddress;
    string secondary_string = secondary_message->toString();
    emulNet->ENsend(&(this->memberNode->addr), &(v[1].nodeAddress), (char *)secondary_string.c_str(), secondary_string.size());

    // _toAddr = this->ring[position+2].nodeAddress;
    string tertiary_string = tertiary_message->toString();
    emulNet->ENsend(&(this->memberNode->addr), &(v[2].nodeAddress), (char *)tertiary_string.c_str(), tertiary_string.size());

    delete primary_message;
    delete secondary_message;
    delete tertiary_message;

    // these messages go to the three replicas and the coordinator waits for responses
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
movl 0x88(%rdi), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x88(%rdi)
movl %eax, (%rsp)
pushq $0x58
popq %rdi
callq 0x3260
movq %rax, %r14
leaq 0x118(%rsp), %rdi
movq %r12, %rsi
callq 0x3340
leaq 0x5cc7(%rip), %rsi      # 0x12338
leaq 0xf8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x8908
movb $0x1, %r15b
leaq 0x118(%rsp), %rdx
leaq 0xf8(%rsp), %rcx
movq %r14, %rdi
movl %ebp, %esi
callq 0xe682
leaq 0x90(%rbx), %rdi
leaq 0x58(%rsp), %rdx
movq %r14, (%rdx)
xorl %r15d, %r15d
movq %rsp, %rsi
callq 0xf4ba
leaq 0xf8(%rsp), %rdi
callq 0x3110
leaq 0x118(%rsp), %rdi
callq 0x3110
pushq $0x78
popq %rdi
callq 0x3260
movq %rax, %r14
movl (%rsp), %r15d
movq 0x50(%rbx), %rsi
addq $0x8, %rsi
leaq 0x12(%rsp), %rdi
callq 0x9f14
leaq 0xd8(%rsp), %rdi
movq %r12, %rsi
callq 0x3340
leaq 0x12(%rsp), %rdx
leaq 0xd8(%rsp), %r8
movq %r14, %rdi
movl %r15d, %esi
movl %ebp, %ecx
callq 0x10d70
leaq 0xd8(%rsp), %rdi
callq 0x3110
pushq $0x78
popq %rdi
callq 0x3260
movq %rax, %r15
movl (%rsp), %r13d
movq 0x50(%rbx), %rsi
addq $0x8, %rsi
leaq 0xc(%rsp), %rdi
callq 0x9f14
leaq 0xb8(%rsp), %rdi
movq %r12, %rsi
callq 0x3340
movq %r14, 0x18(%rsp)
leaq 0xc(%rsp), %rdx
leaq 0xb8(%rsp), %r8
movq %r15, %rdi
movl %r13d, %esi
movl %ebp, %ecx
callq 0x10d70
leaq 0xb8(%rsp), %rdi
callq 0x3110
pushq $0x78
popq %rdi
callq 0x3260
movq %rax, %r13
movl (%rsp), %r14d
movq 0x50(%rbx), %rsi
addq $0x8, %rsi
leaq 0x6(%rsp), %rdi
callq 0x9f14
leaq 0x98(%rsp), %rdi
movq %r12, %rsi
callq 0x3340
leaq 0x6(%rsp), %rdx
leaq 0x98(%rsp), %r8
movq %r13, %rdi
movl %r14d, %esi
movl %ebp, %ecx
callq 0x10d70
leaq 0x98(%rsp), %rdi
callq 0x3110
leaq 0x138(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x3340
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xca10
leaq 0x138(%rsp), %rdi
callq 0x3110
leaq 0x58(%rsp), %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
callq 0x10fb8
movq 0x50(%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
movq 0x20(%rsp), %rdx
addq $0x8, %rdx
movq 0x58(%rsp), %rcx
movl 0x60(%rsp), %r8d
callq 0x56ee
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x10fb8
movq 0x50(%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
movq 0x20(%rsp), %rdx
addq $0x28, %rdx
movq 0x38(%rsp), %rcx
movl 0x40(%rsp), %r8d
callq 0x56ee
leaq 0x78(%rsp), %rdi
movq %r13, %rsi
callq 0x10fb8
movq 0x50(%rbx), %rsi
movq 0x60(%rbx), %rdi
addq $0x8, %rsi
movq 0x20(%rsp), %rdx
addq $0x48, %rdx
movq 0x78(%rsp), %rcx
movl 0x80(%rsp), %r8d
callq 0x56ee
movq %r14, %rdi
callq 0xe704
pushq $0x78
popq %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3270
movq %r15, %rdi
callq 0xe704
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3270
movq %r13, %rdi
callq 0xe704
movq %r13, %rdi
movq %rbx, %rsi
callq 0x3270
leaq 0x78(%rsp), %rdi
callq 0x3110
leaq 0x38(%rsp), %rdi
callq 0x3110
leaq 0x58(%rsp), %rdi
callq 0x3110
leaq 0x20(%rsp), %rdi
callq 0x894c
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x3110
jmp 0xc936
jmp 0xc933
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3110
jmp 0xc947
jmp 0xc944
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x3110
leaq 0x20(%rsp), %rdi
callq 0x894c
jmp 0xca07
movq %rax, %rbx
jmp 0xc951
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x3110
jmp 0xca07
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3110
jmp 0xc9c0
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x3110
jmp 0xc9cb
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x3110
jmp 0xc9d6
movq %rax, %rbx
movb $0x1, %r15b
jmp 0xc9ea
movq %rax, %rbx
jmp 0xc9fc
movq %rax, %rbx
pushq $0x78
popq %rsi
movq %r13, %rdi
jmp 0xca02
movq %rax, %rbx
pushq $0x78
popq %rsi
movq %r15, %rdi
jmp 0xca02
movq %rax, %rbx
pushq $0x78
jmp 0xc9fe
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x3110
leaq 0x118(%rsp), %rdi
callq 0x3110
testb %r15b, %r15b
je 0xca07
pushq $0x58
popq %rsi
movq %r14, %rdi
callq 0x3270
movq %rbx, %rdi
callq 0x3420
nop