// File: /workspace/github_cpp_makefile_star2_O2/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, 0xc(%rsp)
movq %rdx, 0x20(%rsp)
movq %rdi, %rbx
movl 0x165ed(%rip), %ecx     # 0x238bc
leal 0x1(%rcx), %eax
movl %eax, 0x165e4(%rip)     # 0x238bc
movq %rcx, 0x40(%rsp)
movl %ecx, 0x1c(%rsp)
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movq %rsi, 0x28(%rsp)
callq 0x3370
leaq 0x48(%rsp), %rdi
movq %rbx, 0x10(%rsp)
movq %rbx, %rsi
movq %r14, %rdx
callq 0xd54e
leaq 0x80(%rsp), %rdi
callq 0x3110
movq $0x0, 0x30(%rsp)
leaq 0x118(%rsp), %r12
xorl %ebx, %ebx
movq 0x50(%rsp), %rax
subq 0x48(%rsp), %rax
sarq $0x5, %rax
cmpq %rbx, %rax
jbe 0xd41d
movq 0x10(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq 0x3a(%rsp), %rdi
callq 0xa4e4
leaq 0x60(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x3370
leaq 0x138(%rsp), %r13
movq %r13, %rdi
movq 0x20(%rsp), %rsi
callq 0x3370
movl %ebx, (%rsp)
leaq 0xa0(%rsp), %rdi
movq 0x40(%rsp), %rsi
leaq 0x3a(%rsp), %rdx
movl 0xc(%rsp), %ecx
leaq 0x60(%rsp), %r14
movq %r14, %r8
movq %r13, %r9
callq 0x1176e
movq %r13, %rdi
callq 0x3110
movq %r14, %rdi
callq 0x3110
movq 0x10(%rsp), %rax
movq 0x60(%rax), %r13
movq 0x70(%rax), %r15
movq 0x48(%rsp), %rdi
addq 0x30(%rsp), %rdi
callq 0x107d2
movq %rax, %rbp
movq %r12, %rdi
leaq 0xa0(%rsp), %rsi
callq 0x11c40
addq $0x8, %r13
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x5d28
movq %r12, %rdi
callq 0x3110
leaq 0xa0(%rsp), %rdi
callq 0xf466
incq %rbx
addq $0x20, 0x30(%rsp)
jmp 0xd32b
leaq 0xa8(%rsp), %r14
movl 0xc(%rsp), %eax
movl %eax, -0x8(%r14)
movq %r14, %rdi
movq 0x28(%rsp), %rsi
callq 0x3370
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
movq 0x20(%rsp), %rsi
callq 0x3370
movq 0x10(%rsp), %rbx
movq 0x68(%rbx), %rdi
callq 0xa4d8
addl $0xf, %eax
movl %eax, 0xe8(%rsp)
andq $0x0, 0xf0(%rsp)
subq $-0x80, %rbx
leaq 0x1c(%rsp), %rsi
movq %rbx, %rdi
callq 0xf48a
leaq 0xa0(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0xf4d8
movq %rbx, %rdi
callq 0xf514
leaq 0x48(%rsp), %rdi
callq 0x8f1a
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 0xf514
jmp 0xd53b
movq %rax, %rbx
movq %r15, %rdi
callq 0x3110
jmp 0xd4da
movq %rax, %rbx
movq %r14, %rdi
jmp 0xd51f
jmp 0xd538
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x3110
jmp 0xd545
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x3110
jmp 0xd51a
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x3110
jmp 0xd529
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3110
jmp 0xd53b
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0xf466
jmp 0xd53b
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x8f1a
movq %rbx, %rdi
callq 0x3450
nop