// File: tonymuu[P]distributed-kv-store/MP2Node.cpp
// Function: MP2Node::clientCreate(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::clientCreate(string key, string value) {
    // start a transaction
    Transaction transaction(CREATE, 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, CREATE, 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
xorl %esi, %esi
callq 0x21950
movq -0x238(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x4050
jmp 0x1ed18
movq -0x248(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x4050
jmp 0x1ed2a
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 0x1ed54
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 0x1ed83
movq -0x240(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rdx
callq 0x1f030
jmp 0x1ed9f
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 0x1eff0
movslq -0xd0(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x16ff0
movq %rax, %rsi
leaq -0xf0(%rbp), %rdi
callq 0x26240
jmp 0x1ee0f
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 0x1ee38
movq -0x238(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0x4160
jmp 0x1ee4d
movq -0x248(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x4160
jmp 0x1ee62
movl -0x264(%rbp), %esi
leaq -0x168(%rbp), %rdi
leaq -0x16e(%rbp), %rdx
xorl %ecx, %ecx
leaq -0x190(%rbp), %r8
leaq -0x1b0(%rbp), %r9
callq 0x2a650
jmp 0x1ee8d
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 0x1eec6
leaq -0x230(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x2a530
jmp 0x1eedb
movq -0x240(%rbp), %rdi
leaq -0x1b6(%rbp), %rsi
leaq -0x230(%rbp), %rdx
callq 0x1f440
jmp 0x1eef7
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 0x1edbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1f01a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x4200
jmp 0x1f01a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1f00e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1efe2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1efa2
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 0x1efe2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x1efd6
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 0x1f00e
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
nopl (%rax)