// File: /workspace/github_cpp_makefile_star2_O2/tonymuu[P]distributed-kv-store/Message.cpp
// Function: Message::Message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Message::Message(string message){
	this->delimiter = "::";
	vector<string> tuple;
	size_t pos = message.find(delimiter);
	size_t start = 0;
	while (pos != string::npos) {
		string field = message.substr(start, pos-start);
		tuple.push_back(field);
		start = pos + 2;
		pos = message.find(delimiter, start);
	}
	tuple.push_back(message.substr(start));

	transID = stoi(tuple.at(0));
	Address addr(tuple.at(1));
	fromAddr = addr;
	type = static_cast<MessageType>(stoi(tuple.at(2)));
	switch(type){
		case CREATE:
		case UPDATE:
			key = tuple.at(3);
			value = tuple.at(4);
			if (tuple.size() > 5)
				replica = static_cast<ReplicaType>(stoi(tuple.at(5)));
			break;
		case READ:
		case DELETE:
			key = tuple.at(3);
			break;
		case REPLY:
			if (tuple.at(3) == "1")
				success = true;
			else
				success = false;
			break;
		case READREPLY:
			value = tuple.at(3);
			break;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0x18(%rdi), %rax
movq %rax, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
movq %rsi, %rbp
xorl %eax, %eax
movb %al, 0x18(%rdi)
leaq 0x38(%rdi), %rcx
movq %rcx, 0x28(%rdi)
andq $0x0, 0x30(%rdi)
movb %al, 0x38(%rdi)
andl $0x0, 0x48(%rdi)
leaq 0x8(%rdi), %rcx
movq %rcx, 0x20(%rsp)
andw $0x0, 0x4c(%rdi)
leaq 0x28(%rdi), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x58(%rdi), %r15
leaq 0x68(%rdi), %rcx
movq %rcx, 0x58(%rdi)
andq $0x0, 0x60(%rdi)
movb %al, 0x68(%rdi)
leaq 0x2188(%rip), %rsi      # 0x13c5c
movq %r15, %rdi
callq 0x34d0
movq %rbx, 0x30(%rsp)
leaq 0x48(%rbx), %rax
movq %rax, 0x28(%rsp)
xorps %xmm0, %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
xorl %ebx, %ebx
movq %rbp, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x3520
movq %rax, %r12
leaq 0x38(%rsp), %r13
cmpq $-0x1, %r12
je 0x11b57
movq %r12, %rcx
subq %rbx, %rcx
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x32e0
movq %r14, %rdi
movq %r13, %rsi
callq 0x1157a
movq %r12, %rbx
addq $0x2, %rbx
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3520
movq %rax, %r12
movq %r13, %rdi
callq 0x3120
jmp 0x11b10
leaq 0x38(%rsp), %rdi
pushq $-0x1
popq %rcx
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x32e0
movq %rsp, %rdi
leaq 0x38(%rsp), %rsi
callq 0x11952
movq 0x30(%rsp), %rbx
leaq 0x38(%rsp), %rdi
callq 0x3120
movq %rsp, %rdi
xorl %esi, %esi
callq 0x115a6
pushq $0xa
popq %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x115c7
movl %eax, 0x50(%rbx)
movq %rsp, %rdi
pushq $0x1
popq %rsi
callq 0x115a6
leaq 0x58(%rsp), %rdi
movq %rax, %rsi
callq 0x33a0
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x12574
leaq 0x58(%rsp), %rdi
callq 0x3120
leaq 0x38(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0xac2e
movq %rsp, %rdi
pushq $0x2
popq %rsi
callq 0x115a6
pushq $0xa
popq %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x115c7
movl %eax, (%rbx)
cmpl $0x5, %eax
ja 0x11c9d
movl %eax, %eax
leaq 0x2074(%rip), %rcx      # 0x13c80
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rsp, %rdi
pushq $0x3
popq %rsi
callq 0x115a6
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x3170
movq %rsp, %rdi
pushq $0x4
popq %rsi
callq 0x115a6
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x3170
movq 0x8(%rsp), %rax
subq (%rsp), %rax
cmpq $0xa1, %rax
jb 0x11c9d
movq %rsp, %rdi
pushq $0x5
popq %rsi
callq 0x115a6
pushq $0xa
popq %rdx
movq %rax, %rdi
xorl %esi, %esi
callq 0x115c7
movl %eax, 0x4(%rbx)
jmp 0x11c9d
movq %rsp, %rdi
pushq $0x3
popq %rsi
callq 0x115a6
movq 0x20(%rsp), %rdi
jmp 0x11c95
movq %rsp, %rdi
pushq $0x3
popq %rsi
callq 0x115a6
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x3170
movq %rsp, %rdi
callq 0x115e4
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rdi
pushq $0x3
popq %rsi
callq 0x115a6
leaq 0x1fea(%rip), %rsi      # 0x13cb0
movq %rax, %rdi
callq 0x12621
testb %al, %al
je 0x11cd8
movb $0x1, 0x54(%rbx)
jmp 0x11c9d
movb $0x0, 0x54(%rbx)
jmp 0x11c9d
movq %rax, %r12
leaq 0x58(%rsp), %rdi
jmp 0x11d02
jmp 0x11cfa
jmp 0x11cf5
movq %rax, %r12
jmp 0x11d0f
jmp 0x11cf5
jmp 0x11cf5
movq %rax, %r12
jmp 0x11d07
movq %rax, %r12
leaq 0x38(%rsp), %rdi
callq 0x3120
movq %rsp, %rdi
callq 0x115e4
movq %r15, %rdi
callq 0x3120
movq 0x18(%rsp), %rdi
callq 0x3120
movq 0x20(%rsp), %rdi
callq 0x3120
movq %r12, %rdi
callq 0x3490
nop