// File: /workspace/github_cpp_makefile_star2_O1/devanshdalal[P]cloud-computing-concepts-part-2/MP2Node.cpp
// Function: MP2Node::clientCreateOrUpdate(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, MessageType)
void MP2Node::clientCreateOrUpdate(string key, string value, MessageType type)
{
	/*
	 * Implement this
	 */
	int current = g_transID++;
	auto nodes = findNodes(key);
	// std::cout << "Start clientCreate " << key << " " << nodes.size() << "\n";
	for (auto node_id = 0; node_id < nodes.size(); ++node_id)
	{
		auto req = Message(current, memberNode->addr, type, key, value,
						   static_cast<ReplicaType>(node_id));
		emulNet->ENsend(&(memberNode->addr), nodes[node_id].getAddress(), req.toString());
	}
	local_state_[current] = {type, key, value, par->getcurrtime() + WRITE_TIMEOUT, 0};
	// std::cout << "End clientCreate\n";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movl %ecx, 0x10(%rsp)
movq %rdx, 0x20(%rsp)
movq %rsi, %rdx
movq %rdi, %rbx
movl 0x18966(%rip), %eax     # 0x288ac
leal 0x1(%rax), %ecx
movl %ecx, 0x1895d(%rip)     # 0x288ac
movl %eax, 0x14(%rsp)
leaq 0x138(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rsi), %rsi
movq %rdx, 0x28(%rsp)
movq 0x8(%rdx), %rdx
addq %rsi, %rdx
leaq 0x128(%rsp), %r12
movq %r12, %rdi
callq 0xbb34
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x103c0
movq %rbx, 0x18(%rsp)
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0xffb0
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x1018b
xorl %r14d, %r14d
leaq 0x108(%rsp), %rbx
xorl %r15d, %r15d
movl 0x14(%rsp), %ebp
movq 0x18(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq 0x4a(%rsp), %rdi
callq 0xce50
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0xbb34
leaq 0x80(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x20(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %r12
movq %r12, %rdi
callq 0xbb34
movl %r15d, (%rsp)
leaq 0x90(%rsp), %rdi
movl %ebp, %esi
leaq 0x4a(%rsp), %rdx
movl 0x10(%rsp), %ecx
leaq 0x50(%rsp), %r8
movq %r12, %r9
callq 0x16622
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x1007b
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x10097
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x18(%rsp), %rax
movq 0x60(%rax), %rbp
movq 0x70(%rax), %r12
movq 0x30(%rsp), %rdi
addq %r14, %rdi
callq 0x14cc4
movq %rax, %r13
movq %rbx, %rdi
leaq 0x90(%rsp), %rsi
callq 0x16bf4
addq $0x8, %rbp
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x6b8c
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x100fe
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x10123
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x10148
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x1016d
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
incq %r15
sarq $0x5, %rax
addq $0x20, %r14
cmpq %r15, %rax
ja 0xffce
leaq 0x98(%rsp), %r12
movl 0x10(%rsp), %eax
movl %eax, -0x8(%r12)
leaq 0xa8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xbb34
leaq 0xb8(%rsp), %r15
leaq 0xc8(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x20(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0xbb34
movq 0x18(%rsp), %rbx
movq 0x68(%rbx), %rdi
callq 0xce42
addl $0xf, %eax
movl %eax, 0xd8(%rsp)
movq $0x0, 0xe0(%rsp)
subq $-0x80, %rbx
leaq 0x14(%rsp), %rsi
movq %rbx, %rdi
callq 0x13a48
movq %rax, %rbx
leaq 0xd8(%rsp), %rbp
movl -0x48(%rbp), %eax
movl %eax, (%rbx)
leaq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x3340
movq %rbx, %rdi
addq $0x28, %rdi
movq %r15, %rsi
callq 0x3340
movups (%rbp), %xmm0
movups %xmm0, 0x48(%rbx)
movq -0x20(%rbp), %rdi
cmpq %r13, %rdi
je 0x1026b
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x10288
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x30(%rsp), %rdi
callq 0xb860
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x13aac
jmp 0x103ae
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r13, %rdi
je 0x102de
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x102de
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r14, %rdi
je 0x103ae
movq 0xa8(%rsp), %rsi
jmp 0x10365
jmp 0x10399
movq %rax, %rbx
movq 0x128(%rsp), %rdi
cmpq %r14, %rdi
je 0x103b8
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x103b8
movq %rax, %rbx
jmp 0x10351
movq %rax, %rbx
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x10351
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x103ae
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x103ae
movq %rax, %rbx
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x103a1
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x103a1
movq %rax, %rbx
jmp 0x103ae
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x139f8
leaq 0x30(%rsp), %rdi
callq 0xb860
movq %rbx, %rdi
callq 0x3470