// File: /workspace/github_cpp_makefile_star2_O3/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 $0x158, %rsp            # imm = 0x158
movl %ecx, 0x14(%rsp)
movq %rdx, 0x28(%rsp)
movq %rsi, %rcx
movq %rdi, %rbx
movl 0x18c36(%rip), %edx     # 0x288ac
leal 0x1(%rdx), %eax
movl %eax, 0x18c2d(%rip)     # 0x288ac
movq %rdx, 0x98(%rsp)
movl %edx, 0x24(%rsp)
leaq 0x148(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rsi), %rsi
movq %rcx, 0x30(%rsp)
movq 0x8(%rcx), %rdx
addq %rsi, %rdx
leaq 0x138(%rsp), %r12
movq %r12, %rdi
callq 0xba52
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x100fa
movq %rbx, 0x18(%rsp)
movq 0x138(%rsp), %rdi
cmpq %r14, %rdi
je 0xfce8
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x40(%rsp), %rax
cmpq 0x38(%rsp), %rax
je 0xfec5
xorl %r14d, %r14d
leaq 0x118(%rsp), %rbx
xorl %r15d, %r15d
movq 0x18(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq 0x52(%rsp), %rdi
callq 0xcd2c
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x30(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0xba52
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %r12
movq %r12, %rdi
callq 0xba52
movl %r15d, (%rsp)
leaq 0xa0(%rsp), %rdi
movq 0x98(%rsp), %rsi
leaq 0x52(%rsp), %rdx
movl 0x14(%rsp), %ecx
leaq 0x58(%rsp), %r8
movq %r12, %r9
callq 0x16346
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0xfdb5
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0xfdd1
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x18(%rsp), %rax
movq 0x60(%rax), %r12
movq 0x70(%rax), %r13
movq 0x38(%rsp), %rdi
addq %r14, %rdi
callq 0x14a0c
movq %rax, %rbp
movq %rbx, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x16918
addq $0x8, %r12
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x6b44
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0xfe38
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0xfe5d
movq 0x108(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rax
cmpq %rax, %rdi
je 0xfe82
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0xfea7
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x40(%rsp), %rax
subq 0x38(%rsp), %rax
incq %r15
sarq $0x5, %rax
addq $0x20, %r14
cmpq %r15, %rax
ja 0xfd06
leaq 0xa8(%rsp), %r12
movl 0x14(%rsp), %eax
movl %eax, -0x8(%r12)
leaq 0xb8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x30(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0xba52
leaq 0xc8(%rsp), %r15
leaq 0xd8(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0xba52
movq 0x18(%rsp), %rbx
movq 0x68(%rbx), %rdi
callq 0xcd1e
addl $0xf, %eax
movl %eax, 0xe8(%rsp)
movq $0x0, 0xf0(%rsp)
subq $-0x80, %rbx
leaq 0x24(%rsp), %rsi
movq %rbx, %rdi
callq 0x13778
movq %rax, %rbx
leaq 0xe8(%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 0xffa5
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xa8(%rsp), %rdi
cmpq %r14, %rdi
je 0xffc2
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x38(%rsp), %rdi
callq 0xb770
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x137de
jmp 0x100e8
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r13, %rdi
je 0x10018
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x10018
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r14, %rdi
je 0x100e8
movq 0xb8(%rsp), %rsi
jmp 0x1009f
jmp 0x100d3
movq %rax, %rbx
movq 0x138(%rsp), %rdi
cmpq %r14, %rdi
je 0x100f2
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x100f2
movq %rax, %rbx
jmp 0x1008b
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x1008b
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x100e8
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x100e8
movq %rax, %rbx
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x100db
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x100db
movq %rax, %rbx
jmp 0x100e8
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0x13728
leaq 0x38(%rsp), %rdi
callq 0xb770
movq %rbx, %rdi
callq 0x3470