// File: zkl94[P]distributed-key-value-store/MP2Node.cpp
// Function: MP2Node::updateKeyValue(Address, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, ReplicaType, int, MessageType)
bool MP2Node::updateKeyValue(Address fromAddr, string key, string value, ReplicaType replica, int transID, MessageType t) {
    // Update key in local hash table and return true or false
    bool success = this->ht->update(key, value);
    Message *message;
    if (success) {
        log->logUpdateSuccess(&(this->memberNode->addr), false, transID, key, value);
        message = new Message(transID, this->memberNode->addr, REPLY, true);
    } else {
        log->logUpdateFail(&(this->memberNode->addr), false, transID, key, value);
        message = new Message(transID, this->memberNode->addr, REPLY, false);
    }

    string _string = message->toString();
    emulNet->ENsend(&(this->memberNode->addr), &fromAddr, (char *)_string.c_str(), _string.size());

    delete message;

    return success;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rcx, -0x140(%rbp)
movq %rdx, -0x160(%rbp)
movq %rsi, %rax
movq -0x160(%rbp), %rsi
movq %rax, -0x158(%rbp)
movl 0x10(%rbp), %edx
movq %rdi, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x150(%rbp)
movq 0x48(%rax), %rax
movq %rax, -0x148(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4150
movq -0x140(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x4150
jmp 0x1c8e6
movq -0x148(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x23a70
movb %al, -0x161(%rbp)
jmp 0x1c902
leaq -0x70(%rbp), %rdi
callq 0x41e0
leaq -0x50(%rbp), %rdi
callq 0x41e0
movb -0x161(%rbp), %al
andb $0x1, %al
movb %al, -0x29(%rbp)
testb $0x1, -0x29(%rbp)
je 0x1cabb
movq -0x160(%rbp), %rsi
movq -0x150(%rbp), %rcx
movq 0x50(%rcx), %rax
movq 0x68(%rcx), %rcx
movq %rcx, -0x178(%rbp)
addq $0x8, %rax
movq %rax, -0x170(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x168(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x4150
movq -0x140(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x4150
jmp 0x1c97b
movl -0x168(%rbp), %ecx
movq -0x170(%rbp), %rsi
movq -0x178(%rbp), %rdi
xorl %edx, %edx
leaq -0xa8(%rbp), %r8
leaq -0xc8(%rbp), %r9
callq 0x14730
jmp 0x1c9a6
leaq -0xc8(%rbp), %rdi
callq 0x41e0
leaq -0xa8(%rbp), %rdi
callq 0x41e0
movl $0x78, %edi
callq 0x4310
movq %rax, %rcx
movq -0x150(%rbp), %rax
movq %rcx, -0x188(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x17c(%rbp)
movq 0x50(%rax), %rsi
addq $0x8, %rsi
leaq -0xce(%rbp), %rdi
callq 0x15070
jmp 0x1c9f8
movl -0x17c(%rbp), %esi
movq -0x188(%rbp), %rdi
leaq -0xce(%rbp), %rdx
movl $0x4, %ecx
movl $0x1, %r8d
callq 0x267a0
jmp 0x1ca1e
movq -0x188(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x1cc16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1ca54
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x41e0
leaq -0x50(%rbp), %rdi
callq 0x41e0
jmp 0x1cd05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1ca88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x41e0
leaq -0xa8(%rbp), %rdi
callq 0x41e0
jmp 0x1cd05
movq -0x188(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movl $0x78, %esi
callq 0x4320
jmp 0x1cd05
movq -0x160(%rbp), %rsi
movq -0x150(%rbp), %rcx
movq 0x50(%rcx), %rax
movq 0x68(%rcx), %rcx
movq %rcx, -0x1a0(%rbp)
addq $0x8, %rax
movq %rax, -0x198(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x18c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x4150
movq -0x140(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x4150
jmp 0x1cb0d
movl -0x18c(%rbp), %ecx
movq -0x198(%rbp), %rsi
movq -0x1a0(%rbp), %rdi
xorl %edx, %edx
leaq -0xf0(%rbp), %r8
leaq -0x110(%rbp), %r9
callq 0x14bf0
jmp 0x1cb38
leaq -0x110(%rbp), %rdi
callq 0x41e0
leaq -0xf0(%rbp), %rdi
callq 0x41e0
movl $0x78, %edi
callq 0x4310
movq %rax, %rcx
movq -0x150(%rbp), %rax
movq %rcx, -0x1b0(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x1a4(%rbp)
movq 0x50(%rax), %rsi
addq $0x8, %rsi
leaq -0x116(%rbp), %rdi
callq 0x15070
jmp 0x1cb8a
movl -0x1a4(%rbp), %esi
movq -0x1b0(%rbp), %rdi
leaq -0x116(%rbp), %rdx
movl $0x4, %ecx
xorl %r8d, %r8d
callq 0x267a0
jmp 0x1cbad
movq -0x1b0(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x1cc16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1cbe3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x41e0
leaq -0xf0(%rbp), %rdi
callq 0x41e0
jmp 0x1cd05
movq -0x1b0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movl $0x78, %esi
callq 0x4320
jmp 0x1cd05
movq -0x88(%rbp), %rsi
leaq -0x138(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x26980
movq -0x150(%rbp), %rcx
movq -0x1d0(%rbp), %rdi
movq 0x50(%rcx), %rax
movq 0x60(%rcx), %rcx
movq %rcx, -0x1c8(%rbp)
addq $0x8, %rax
movq %rax, -0x1c0(%rbp)
callq 0x4140
movq -0x1d0(%rbp), %rdi
movq %rax, -0x1b8(%rbp)
callq 0x4220
movq -0x1c8(%rbp), %rdi
movq -0x1c0(%rbp), %rsi
movq -0x158(%rbp), %rdx
movq -0x1b8(%rbp), %rcx
movl %eax, %r8d
callq 0xac80
jmp 0x1cc96
movq -0x88(%rbp), %rax
movq %rax, -0x1d8(%rbp)
cmpq $0x0, %rax
je 0x1ccc7
movq -0x1d8(%rbp), %rdi
callq 0x1ea70
movq -0x1d8(%rbp), %rdi
movl $0x78, %esi
callq 0x4320
movb -0x29(%rbp), %al
movb %al, -0x1d9(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x41e0
movb -0x1d9(%rbp), %al
andb $0x1, %al
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x41e0
movq -0x78(%rbp), %rdi
callq 0x4550
nop