// File: zkl94[P]distributed-key-value-store/MP2Node.cpp
// Function: MP2Node::createKeyValue(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::createKeyValue(Address fromAddr, string key, string value, ReplicaType replica, int transID, MessageType t) {
    // Insert key, value, replicaType into the hash table
    // the transID is used for logging and response
    this->ht->create(key, value);
    // create must will succeed
    log->logCreateSuccess(&(this->memberNode->addr), false, transID, key, value);

    // reply
    Message *message = new Message(transID, this->memberNode->addr, REPLY, true);
    string _string = message->toString();
    emulNet->ENsend(&(this->memberNode->addr), &fromAddr, (char *)_string.c_str(), _string.size());

    delete message;

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rcx, -0xf0(%rbp)
movq %rdx, -0x110(%rbp)
movq %rsi, %rax
movq -0x110(%rbp), %rsi
movq %rax, -0x108(%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, -0x100(%rbp)
movq 0x48(%rax), %rax
movq %rax, -0xf8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4150
movq -0xf0(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x4150
jmp 0x1c0c6
movq -0xf8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x23940
jmp 0x1c0dc
leaq -0x68(%rbp), %rdi
callq 0x41e0
leaq -0x48(%rbp), %rdi
callq 0x41e0
movq -0x100(%rbp), %rcx
movq -0x110(%rbp), %rsi
movq 0x50(%rcx), %rax
movq 0x68(%rcx), %rcx
movq %rcx, -0x128(%rbp)
addq $0x8, %rax
movq %rax, -0x120(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x114(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x4150
movq -0xf0(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x4150
jmp 0x1c140
movl -0x114(%rbp), %ecx
movq -0x120(%rbp), %rsi
movq -0x128(%rbp), %rdi
xorl %edx, %edx
leaq -0x98(%rbp), %r8
leaq -0xb8(%rbp), %r9
callq 0x14490
jmp 0x1c16b
leaq -0xb8(%rbp), %rdi
callq 0x41e0
leaq -0x98(%rbp), %rdi
callq 0x41e0
movl $0x78, %edi
callq 0x4310
movq %rax, %rcx
movq -0x100(%rbp), %rax
movq %rcx, -0x138(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, -0x12c(%rbp)
movq 0x50(%rax), %rsi
addq $0x8, %rsi
leaq -0xc6(%rbp), %rdi
callq 0x15070
jmp 0x1c1bd
movl -0x12c(%rbp), %esi
movq -0x138(%rbp), %rdi
leaq -0xc6(%rbp), %rdx
movl $0x4, %ecx
movl $0x1, %r8d
callq 0x267a0
jmp 0x1c1e3
movq -0x138(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x26980
movq -0x100(%rbp), %rcx
movq -0x158(%rbp), %rdi
movq 0x50(%rcx), %rax
movq 0x60(%rcx), %rcx
movq %rcx, -0x150(%rbp)
addq $0x8, %rax
movq %rax, -0x148(%rbp)
callq 0x4140
movq -0x158(%rbp), %rdi
movq %rax, -0x140(%rbp)
callq 0x4220
movq -0x150(%rbp), %rdi
movq -0x148(%rbp), %rsi
movq -0x108(%rbp), %rdx
movq -0x140(%rbp), %rcx
movl %eax, %r8d
callq 0xac80
jmp 0x1c271
movq -0xc0(%rbp), %rax
movq %rax, -0x160(%rbp)
cmpq $0x0, %rax
je 0x1c2a2
movq -0x160(%rbp), %rdi
callq 0x1ea70
movq -0x160(%rbp), %rdi
movl $0x78, %esi
callq 0x4320
leaq -0xe8(%rbp), %rdi
callq 0x41e0
movb $0x1, %al
andb $0x1, %al
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x1c2de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x41e0
leaq -0x48(%rbp), %rdi
callq 0x41e0
jmp 0x1c354
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x1c30f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x41e0
leaq -0x98(%rbp), %rdi
callq 0x41e0
jmp 0x1c354
movq -0x138(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
movl $0x78, %esi
callq 0x4320
jmp 0x1c354
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x41e0
movq -0x70(%rbp), %rdi
callq 0x4550
nopl (%rax)