// File: devanshdalal[P]cloud-computing-concepts-part-2/MP2Node.cpp
// Function: MP2Node::updateKeyValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, ReplicaType)
bool MP2Node::updateKeyValue(string key, string value, ReplicaType replica)
{
	/*
	 * Implement this
	 */
	// Update key in local hash table and return true or false
	switch (replica)
	{
	case ReplicaType::PRIMARY:
	{
		return ht->update(key, value);
	}
	case ReplicaType::SECONDARY:
	{
		return secondary->update(key, value);
	}
	case ReplicaType::TERTIARY:
	{
		return tertiary->update(key, value);
	}
	default:
		break;
	}
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rsi, -0x118(%rbp)
movq %rdx, -0x110(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xfc(%rbp)
testl %eax, %eax
je 0x1ec77
jmp 0x1ec52
movl -0xfc(%rbp), %eax
subl $0x1, %eax
je 0x1ed1a
jmp 0x1ec63
movl -0xfc(%rbp), %eax
subl $0x2, %eax
je 0x1edd5
jmp 0x1ee8a
movq -0x118(%rbp), %rsi
movq -0x108(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x120(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x4150
movq -0x110(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x4150
jmp 0x1ecab
movq -0x120(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x25cc0
movb %al, -0x121(%rbp)
jmp 0x1ecc7
movb -0x121(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x41e0
leaq -0x48(%rbp), %rdi
callq 0x41e0
jmp 0x1ee90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x1ed0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x41e0
leaq -0x48(%rbp), %rdi
callq 0x41e0
jmp 0x1ee9e
movq -0x118(%rbp), %rsi
movq -0x108(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x130(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x4150
movq -0x110(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x4150
jmp 0x1ed54
movq -0x130(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0xb8(%rbp), %rdx
callq 0x25cc0
movb %al, -0x131(%rbp)
jmp 0x1ed76
movb -0x131(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x41e0
leaq -0x98(%rbp), %rdi
callq 0x41e0
jmp 0x1ee90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x1edc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x41e0
leaq -0x98(%rbp), %rdi
callq 0x41e0
jmp 0x1ee9e
movq -0x118(%rbp), %rsi
movq -0x108(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x140(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4150
movq -0x110(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x4150
jmp 0x1ee0f
movq -0x140(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0xf8(%rbp), %rdx
callq 0x25cc0
movb %al, -0x141(%rbp)
jmp 0x1ee31
movb -0x141(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x41e0
leaq -0xd8(%rbp), %rdi
callq 0x41e0
jmp 0x1ee90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x1ee7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x41e0
leaq -0xd8(%rbp), %rdi
callq 0x41e0
jmp 0x1ee9e
jmp 0x1ee8c
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x4570
nopw (%rax,%rax)