// File: /workspace/github_cpp_makefile_star2_O1/tonymuu[P]distributed-kv-store/MP2Node.cpp
// Function: MP2Node::checkMessages()
void MP2Node::checkMessages() {
	char * data;
	int size;

	// dequeue all messages and handle them
	while ( !memberNode->mp2q.empty() ) {
	    // Pop a message from the queue
		data = (char *)memberNode->mp2q.front().elt;
		size = memberNode->mp2q.front().size;
		memberNode->mp2q.pop();

		string strMsg(data, data + size);
		Message msg(strMsg);

		// Handle the message types here
        switch (msg.type) {
            case CREATE:
                handleCreateMessage(msg);
                break;
            case UPDATE:
                handleUpdateMessage(msg);
                break;
            case READ:
                handleReadMessage(msg);
                break;
            case DELETE:
                handleDeleteMessage(msg);
                break;
            case REPLY:
            case READREPLY:
                handleReplyMessage(msg);
                break;
            default:
                break;
        }
	}

	/*
	* This function should also ensure all READ and UPDATE operation
	* get QUORUM replies
	*/
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movq %rdi, %rbx
movq 0x50(%rdi), %rdi
movq 0xa8(%rdi), %rax
cmpq %rax, 0xc8(%rdi)
je 0x1146c
leaq 0x38(%rsp), %r14
leaq 0x28(%rsp), %r15
leaq 0x48(%rsp), %r12
addq $0x98, %rdi
movq (%rax), %rbp
movslq 0x8(%rax), %r13
callq 0x5e2c
addq %rbp, %r13
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x5a48
movq %r14, 0x28(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x5a48
movq %r12, %rdi
movq %r15, %rsi
callq 0x159a4
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x11131
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32c0
movl 0x48(%rsp), %eax
cmpq $0x5, %rax
ja 0x113d5
leaq 0x7b5a(%rip), %rcx      # 0x18ca0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x16056
movq %rbx, %rdi
leaq 0xc0(%rsp), %rsi
callq 0x126a6
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x11194
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x111b9
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rcx
jmp 0x113c2
leaq 0x228(%rsp), %rdi
movq %r12, %rsi
callq 0x16056
movq %rbx, %rdi
leaq 0x228(%rsp), %rsi
callq 0x119fc
movq 0x280(%rsp), %rdi
leaq 0x290(%rsp), %rax
cmpq %rax, %rdi
je 0x11213
movq 0x290(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x250(%rsp), %rdi
leaq 0x260(%rsp), %rax
cmpq %rax, %rdi
je 0x11238
movq 0x260(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x230(%rsp), %rdi
leaq 0x240(%rsp), %rcx
jmp 0x113c2
leaq 0x138(%rsp), %rdi
movq %r12, %rsi
callq 0x16056
movq %rbx, %rdi
leaq 0x138(%rsp), %rsi
callq 0x1231c
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x11292
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x112b7
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rcx
jmp 0x113c2
leaq 0x2a0(%rsp), %rdi
movq %r12, %rsi
callq 0x16056
movq %rbx, %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x11516
movq 0x2f8(%rsp), %rdi
leaq 0x308(%rsp), %rax
cmpq %rax, %rdi
je 0x11311
movq 0x308(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x2c8(%rsp), %rdi
leaq 0x2d8(%rsp), %rax
cmpq %rax, %rdi
je 0x11336
movq 0x2d8(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x2a8(%rsp), %rdi
leaq 0x2b8(%rsp), %rcx
jmp 0x113c2
leaq 0x1b0(%rsp), %rdi
movq %r12, %rsi
callq 0x16056
movq %rbx, %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x11ee2
movq 0x208(%rsp), %rdi
leaq 0x218(%rsp), %rax
cmpq %rax, %rdi
je 0x1138d
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x1d8(%rsp), %rdi
leaq 0x1e8(%rsp), %rax
cmpq %rax, %rdi
je 0x113b2
movq 0x1e8(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x1b8(%rsp), %rdi
leaq 0x1c8(%rsp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
je 0x113d5
movq (%rax), %rsi
incq %rsi
callq 0x32c0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x113fa
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x1141c
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x11438
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x11454
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x50(%rbx), %rdi
movq 0xa8(%rdi), %rax
cmpq %rax, 0xc8(%rdi)
jne 0x110c5
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
jmp 0x114bd
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
jmp 0x114bd
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
jmp 0x114bd
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
jmp 0x114bd
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x1293c
jmp 0x114c7
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x1293c
jmp 0x114f2
movq %rax, %rbx
jmp 0x114f2
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x114f2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1150e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x34b0