// File: /workspace/github_cpp_makefile_star2_O3/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 0x1115a
leaq 0x38(%rsp), %r14
leaq 0x28(%rsp), %r15
leaq 0x48(%rsp), %r12
addq $0x98, %rdi
movq (%rax), %rbp
movslq 0x8(%rax), %r13
callq 0x5e3c
addq %rbp, %r13
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x5a4e
movq %r14, 0x28(%rsp)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x5a4e
movq %r12, %rdi
movq %r15, %rsi
callq 0x156a8
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x10e1f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32c0
movl 0x48(%rsp), %eax
cmpq $0x5, %rax
ja 0x110c3
leaq 0x6e10(%rip), %rcx      # 0x17c44
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0x15d5a
movq %rbx, %rdi
leaq 0xc0(%rsp), %rsi
callq 0x12394
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x10e82
movq 0x128(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x10ea7
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0xc8(%rsp), %rdi
leaq 0xd8(%rsp), %rcx
jmp 0x110b0
leaq 0x228(%rsp), %rdi
movq %r12, %rsi
callq 0x15d5a
movq %rbx, %rdi
leaq 0x228(%rsp), %rsi
callq 0x116ea
movq 0x280(%rsp), %rdi
leaq 0x290(%rsp), %rax
cmpq %rax, %rdi
je 0x10f01
movq 0x290(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x250(%rsp), %rdi
leaq 0x260(%rsp), %rax
cmpq %rax, %rdi
je 0x10f26
movq 0x260(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x230(%rsp), %rdi
leaq 0x240(%rsp), %rcx
jmp 0x110b0
leaq 0x138(%rsp), %rdi
movq %r12, %rsi
callq 0x15d5a
movq %rbx, %rdi
leaq 0x138(%rsp), %rsi
callq 0x1200a
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x10f80
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x10fa5
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x140(%rsp), %rdi
leaq 0x150(%rsp), %rcx
jmp 0x110b0
leaq 0x2a0(%rsp), %rdi
movq %r12, %rsi
callq 0x15d5a
movq %rbx, %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x11204
movq 0x2f8(%rsp), %rdi
leaq 0x308(%rsp), %rax
cmpq %rax, %rdi
je 0x10fff
movq 0x308(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x2c8(%rsp), %rdi
leaq 0x2d8(%rsp), %rax
cmpq %rax, %rdi
je 0x11024
movq 0x2d8(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x2a8(%rsp), %rdi
leaq 0x2b8(%rsp), %rcx
jmp 0x110b0
leaq 0x1b0(%rsp), %rdi
movq %r12, %rsi
callq 0x15d5a
movq %rbx, %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x11bd0
movq 0x208(%rsp), %rdi
leaq 0x218(%rsp), %rax
cmpq %rax, %rdi
je 0x1107b
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x1d8(%rsp), %rdi
leaq 0x1e8(%rsp), %rax
cmpq %rax, %rdi
je 0x110a0
movq 0x1e8(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x1b8(%rsp), %rdi
leaq 0x1c8(%rsp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
je 0x110c3
movq (%rax), %rsi
incq %rsi
callq 0x32c0
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x110e8
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x1110a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x11126
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x11142
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x50(%rbx), %rdi
movq 0xa8(%rdi), %rax
cmpq %rax, 0xc8(%rdi)
jne 0x10db3
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 0x111ab
movq %rax, %rbx
leaq 0x1b0(%rsp), %rdi
jmp 0x111ab
movq %rax, %rbx
leaq 0x228(%rsp), %rdi
jmp 0x111ab
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
jmp 0x111ab
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x1263c
jmp 0x111b5
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x1263c
jmp 0x111e0
movq %rax, %rbx
jmp 0x111e0
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x111e0
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32c0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x111fc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x34b0