// File: devanshdalal[P]cloud-computing-concepts-part-2/MP2Node.cpp
// Function: MP2Node::createKeyValue(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::createKeyValue(string key, string value, ReplicaType replica)
{
	/*
	 * Implement this
	 */
	// Insert key, value, replicaType into the hash table

	switch (replica)
	{
	case ReplicaType::PRIMARY:
	{
		ht->create(key, value);
		break;
	}
	case ReplicaType::SECONDARY:
	{
		secondary->create(key, value);
		break;
	}
	case ReplicaType::TERTIARY:
	{
		tertiary->create(key, value);
		break;
	}
	default:
		break;
	}
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rsi, -0x110(%rbp)
movq %rdx, -0x108(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0xf4(%rbp)
testl %eax, %eax
je 0x1e777
jmp 0x1e752
movl -0xf4(%rbp), %eax
subl $0x1, %eax
je 0x1e809
jmp 0x1e763
movl -0xf4(%rbp), %eax
subl $0x2, %eax
je 0x1e8b3
jmp 0x1e957
movq -0x110(%rbp), %rsi
movq -0x100(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x118(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x4150
movq -0x108(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x4150
jmp 0x1e7ab
movq -0x118(%rbp), %rdi
leaq -0x40(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x25b90
jmp 0x1e7c1
leaq -0x60(%rbp), %rdi
callq 0x41e0
leaq -0x40(%rbp), %rdi
callq 0x41e0
jmp 0x1e959
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1e7fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x41e0
leaq -0x40(%rbp), %rdi
callq 0x41e0
jmp 0x1e966
movq -0x110(%rbp), %rsi
movq -0x100(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x120(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x4150
movq -0x108(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x4150
jmp 0x1e843
movq -0x120(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x25b90
jmp 0x1e85f
leaq -0xb0(%rbp), %rdi
callq 0x41e0
leaq -0x90(%rbp), %rdi
callq 0x41e0
jmp 0x1e959
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1e8a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x41e0
leaq -0x90(%rbp), %rdi
callq 0x41e0
jmp 0x1e966
movq -0x110(%rbp), %rsi
movq -0x100(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x128(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x4150
movq -0x108(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x4150
jmp 0x1e8ed
movq -0x128(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
leaq -0xf0(%rbp), %rdx
callq 0x25b90
jmp 0x1e909
leaq -0xf0(%rbp), %rdi
callq 0x41e0
leaq -0xd0(%rbp), %rdi
callq 0x41e0
jmp 0x1e959
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1e949
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x41e0
leaq -0xd0(%rbp), %rdi
callq 0x41e0
jmp 0x1e966
jmp 0x1e959
movb $0x1, %al
andb $0x1, %al
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x4570
nop