// File: tonymuu[P]distributed-kv-store/MP2Node.cpp
// Function: MP2Node::clientUpdate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void MP2Node::clientUpdate(string key, string value){
    // start a transaction
    Transaction transaction(UPDATE, par->getcurrtime());
    transaction.key = key;
    transaction.value = value;
    txMap.emplace(transaction.txId, transaction);

    // send messages to all nodes who should hold the key
    auto nodes = findNodes(key);
    int txId = transaction.txId;
    for (int i = 0; i < nodes.size(); i++) {
        auto node = nodes[i];
        Message msg(txId, memberNode->addr, UPDATE, key, value);
        msg.replica = static_cast<ReplicaType>(i);
        sendMessage(node.nodeAddress, msg);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rsi, -0x238(%rbp)
movq %rdx, -0x248(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x240(%rbp)
movq 0x58(%rax), %rdi
callq 0x18c60
movl %eax, %edx
leaq -0x70(%rbp), %rdi
movl $0x2, %esi
callq 0x21950
movq -0x238(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x4050
jmp 0x1f83b
movq -0x248(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x4050
jmp 0x1f84d
movq -0x240(%rbp), %rdi
addq $0xc0, %rdi
leaq -0x68(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x21f40
movb %dl, -0x251(%rbp)
movq %rax, -0x250(%rbp)
jmp 0x1f877
movq -0x238(%rbp), %rsi
movb -0x251(%rbp), %al
movq -0x250(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movb %al, -0x88(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x4160
jmp 0x1f8a6
movq -0x240(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rdx
callq 0x1f030
jmp 0x1f8c2
leaq -0xc8(%rbp), %rdi
callq 0x4200
movl -0x68(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl $0x0, -0xd0(%rbp)
movslq -0xd0(%rbp), %rax
movq %rax, -0x260(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x150e0
movq %rax, %rcx
movq -0x260(%rbp), %rax
cmpq %rcx, %rax
jae 0x1fb16
movslq -0xd0(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x16ff0
movq %rax, %rsi
leaq -0xf0(%rbp), %rdi
callq 0x26240
jmp 0x1f932
movq -0x240(%rbp), %rax
movl -0xcc(%rbp), %ecx
movl %ecx, -0x264(%rbp)
movq 0x50(%rax), %rsi
addq $0x8, %rsi
leaq -0x16e(%rbp), %rdi
callq 0x18e40
jmp 0x1f95b
movq -0x238(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0x4160
jmp 0x1f970
movq -0x248(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x4160
jmp 0x1f985
movl -0x264(%rbp), %esi
leaq -0x168(%rbp), %rdi
leaq -0x16e(%rbp), %rdx
movl $0x2, %ecx
leaq -0x190(%rbp), %r8
leaq -0x1b0(%rbp), %r9
callq 0x2a650
jmp 0x1f9b3
leaq -0x1b0(%rbp), %rdi
callq 0x4200
leaq -0x190(%rbp), %rdi
callq 0x4200
movl -0xd0(%rbp), %eax
movl %eax, -0x164(%rbp)
leaq -0xe8(%rbp), %rsi
leaq -0x1b6(%rbp), %rdi
callq 0x18e40
jmp 0x1f9ec
leaq -0x230(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x2a530
jmp 0x1fa01
movq -0x240(%rbp), %rdi
leaq -0x1b6(%rbp), %rsi
leaq -0x230(%rbp), %rdx
callq 0x1f440
jmp 0x1fa1d
leaq -0x230(%rbp), %rdi
callq 0x21f90
leaq -0x168(%rbp), %rdi
callq 0x21f90
leaq -0xf0(%rbp), %rdi
callq 0x26200
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x1f8e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1fb40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x4200
jmp 0x1fb40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1fb34
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1fb08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1fac8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x4200
leaq -0x190(%rbp), %rdi
callq 0x4200
jmp 0x1fb08
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1fafc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x21f90
leaq -0x168(%rbp), %rdi
callq 0x21f90
leaq -0xf0(%rbp), %rdi
callq 0x26200
jmp 0x1fb34
leaq -0xa8(%rbp), %rdi
callq 0x15080
leaq -0x70(%rbp), %rdi
callq 0x21fd0
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
leaq -0xa8(%rbp), %rdi
callq 0x15080
leaq -0x70(%rbp), %rdi
callq 0x21fd0
movq -0x78(%rbp), %rdi
callq 0x45b0
nopw %cs:(%rax,%rax)