// File: 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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rsi, -0xd0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
addq $0x8, %rdi
movq %rdi, -0xc8(%rbp)
callq 0x44b0
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
movq %rdi, -0xc0(%rbp)
callq 0x44b0
movq -0xb8(%rbp), %rdi
addq $0x48, %rdi
callq 0x71f0
jmp 0x29f9e
movq -0xb8(%rbp), %rdi
addq $0x58, %rdi
movq %rdi, -0xd8(%rbp)
callq 0x44b0
movq -0xd8(%rbp), %rdi
leaq 0x2cfd(%rip), %rsi      # 0x2ccc0
callq 0x44a0
jmp 0x29fca
leaq -0x38(%rbp), %rdi
callq 0x28ce0
movq -0xb8(%rbp), %rsi
movq -0xd0(%rbp), %rdi
addq $0x58, %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x4660
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
cmpq $-0x1, -0x40(%rbp)
je 0x2a0b4
movq -0xd0(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rcx
subq %rdx, %rcx
leaq -0x68(%rbp), %rdi
callq 0x4370
jmp 0x2a022
leaq -0x38(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x28d00
jmp 0x2a031
movq -0xd0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movq -0x40(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x48(%rbp)
addq $0x58, %rsi
movq -0x48(%rbp), %rdx
callq 0x4660
movq %rax, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x4200
jmp 0x29ffa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x2a3e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x2a3d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x2a3cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x4200
jmp 0x2a3cb
movq -0xd0(%rbp), %rsi
movq -0x48(%rbp), %rdx
leaq -0x88(%rbp), %rdi
movq $-0x1, %rcx
callq 0x4370
jmp 0x2a0d4
leaq -0x38(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x28d70
jmp 0x2a0e6
leaq -0x88(%rbp), %rdi
callq 0x4200
xorl %eax, %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
callq 0x28da0
movq %rax, -0xe0(%rbp)
jmp 0x2a108
movq -0xe0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x28de0
movl %eax, -0xe4(%rbp)
jmp 0x2a125
movq -0xb8(%rbp), %rax
movl -0xe4(%rbp), %ecx
movl %ecx, 0x50(%rax)
leaq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x28da0
movq %rax, -0xf0(%rbp)
jmp 0x2a14c
movq -0xf0(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x4160
jmp 0x2a161
leaq -0x8e(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x2af80
jmp 0x2a176
leaq -0xb0(%rbp), %rdi
callq 0x4200
movq -0xb8(%rbp), %rdi
addq $0x48, %rdi
leaq -0x8e(%rbp), %rsi
callq 0x18e70
jmp 0x2a19b
leaq -0x38(%rbp), %rdi
movl $0x2, %esi
callq 0x28da0
movq %rax, -0xf8(%rbp)
jmp 0x2a1b2
movq -0xf8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x28de0
movl %eax, -0xfc(%rbp)
jmp 0x2a1cf
movq -0xb8(%rbp), %rax
movl -0xfc(%rbp), %ecx
movl %ecx, (%rax)
movl (%rax), %eax
movq %rax, -0x108(%rbp)
subq $0x5, %rax
ja 0x2a3b9
movq -0x108(%rbp), %rax
leaq 0x2ae5(%rip), %rcx      # 0x2cce4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x4200
jmp 0x2a3cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x4200
jmp 0x2a3cb
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x28da0
movq %rax, -0x110(%rbp)
jmp 0x2a259
movq -0x110(%rbp), %rsi
movq -0xb8(%rbp), %rdi
addq $0x8, %rdi
callq 0x4050
jmp 0x2a272
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
callq 0x28da0
movq %rax, -0x118(%rbp)
jmp 0x2a289
movq -0x118(%rbp), %rsi
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
callq 0x4050
jmp 0x2a2a2
leaq -0x38(%rbp), %rdi
callq 0x298c0
cmpq $0x5, %rax
jbe 0x2a2f5
leaq -0x38(%rbp), %rdi
movl $0x5, %esi
callq 0x28da0
movq %rax, -0x120(%rbp)
jmp 0x2a2c8
movq -0x120(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x28de0
movl %eax, -0x124(%rbp)
jmp 0x2a2e5
movq -0xb8(%rbp), %rax
movl -0x124(%rbp), %ecx
movl %ecx, 0x4(%rax)
jmp 0x2a3b9
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x28da0
movq %rax, -0x130(%rbp)
jmp 0x2a311
movq -0x130(%rbp), %rsi
movq -0xb8(%rbp), %rdi
addq $0x8, %rdi
callq 0x4050
jmp 0x2a32a
jmp 0x2a3b9
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x28da0
movq %rax, -0x138(%rbp)
jmp 0x2a346
movq -0x138(%rbp), %rdi
leaq 0x29c0(%rip), %rsi      # 0x2cd14
callq 0x2b0f0
movb %al, -0x139(%rbp)
jmp 0x2a361
movb -0x139(%rbp), %al
testb $0x1, %al
jne 0x2a36d
jmp 0x2a37a
movq -0xb8(%rbp), %rax
movb $0x1, 0x54(%rax)
jmp 0x2a385
movq -0xb8(%rbp), %rax
movb $0x0, 0x54(%rax)
jmp 0x2a3b9
leaq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x28da0
movq %rax, -0x148(%rbp)
jmp 0x2a39e
movq -0x148(%rbp), %rsi
movq -0xb8(%rbp), %rdi
addq $0x28, %rdi
callq 0x4050
jmp 0x2a3b7
jmp 0x2a3b9
leaq -0x38(%rbp), %rdi
callq 0x28e20
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x28e20
movq -0xd8(%rbp), %rdi
callq 0x4200
movq -0xc0(%rbp), %rdi
callq 0x4200
movq -0xc8(%rbp), %rdi
callq 0x4200
movq -0x18(%rbp), %rdi
callq 0x45b0
nopw %cs:(%rax,%rax)