// File: /workspace/github_cpp_makefile_star2_O2/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
leaq 0x8(%rsp), %r14
leaq 0x28(%rsp), %r15
leaq 0x2a0(%rsp), %r12
movq 0x50(%rbx), %rdi
movq 0xa8(%rdi), %rax
cmpq %rax, 0xc8(%rdi)
je 0xe7a6
addq $0x98, %rdi
movq (%rax), %rbp
movslq 0x8(%rax), %r13
callq 0x5ac2
addq %rbp, %r13
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0xf55a
movq %r15, %rdi
movq %r14, %rsi
callq 0x33a0
movq %r12, %rdi
movq %r15, %rsi
callq 0x11a68
movq %r15, %rdi
callq 0x3120
movl 0x2a0(%rsp), %eax
cmpq $0x5, %rax
ja 0xe791
leaq 0x5578(%rip), %rcx      # 0x13c44
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x11e20
movq %rbx, %rdi
leaq 0x48(%rsp), %r13
movq %r13, %rsi
callq 0xf1b4
jmp 0xe789
leaq 0x1b0(%rsp), %rdi
movq %r12, %rsi
callq 0x11e20
movq %rbx, %rdi
leaq 0x1b0(%rsp), %r13
movq %r13, %rsi
callq 0xeac6
jmp 0xe789
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x11e20
movq %rbx, %rdi
leaq 0xc0(%rsp), %r13
movq %r13, %rsi
callq 0xefc2
jmp 0xe789
leaq 0x228(%rsp), %rdi
movq %r12, %rsi
callq 0x11e20
movq %rbx, %rdi
leaq 0x228(%rsp), %r13
movq %r13, %rsi
callq 0xe832
jmp 0xe789
leaq 0x138(%rsp), %rdi
movq %r12, %rsi
callq 0x11e20
movq %rbx, %rdi
leaq 0x138(%rsp), %r13
movq %r13, %rsi
callq 0xed5a
movq %r13, %rdi
callq 0xf3c4
movq %r12, %rdi
callq 0xf3c4
movq %r14, %rdi
callq 0x3120
jmp 0xe650
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
jmp 0xe7f4
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
jmp 0xe7f4
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
jmp 0xe7f4
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0xe7f4
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xf3c4
jmp 0xe7fe
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
callq 0xf3c4
jmp 0xe81f
movq %rax, %rbx
jmp 0xe81f
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3120
leaq 0x8(%rsp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x3490
nop