// File: /workspace/github_cpp_makefile_star2_O3/devanshdalal[P]cloud-computing-concepts-part-2/MP2Node.cpp
// Function: MP2Node::checkMessages()
void MP2Node::checkMessages()
{
	/*
	 * Implement this. Parts of it are already implemented
	 */
	char *data;
	int size;

	/*
	 * Declare your local variables here
	 */

	// 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 message(data, data + size);

		/*
		 * Handle the message types here
		 */
		// std::cout << "message:" << message << "\n";
		Message msg(message);
		// {CREATE, READ, UPDATE, DELETE, REPLY, READREPLY};
		switch (msg.type)
		{
		case MessageType::READ:
		{
			const auto &key = msg.key;
			const auto value = readKey(key);
			std::cout << "MessageType::READ on " << memberNode->addr.getAddress()
					  << " from " << msg.fromAddr.getAddress()
					  << " " << key << ", " << value << "\n";
			if (not value.empty())
			{
				log->logReadSuccess(&(memberNode->addr), false /*is_coordinator*/, msg.transID, key, value);
				auto reply = Message(msg.transID, memberNode->addr, value);
				// std::cout << "reply.toString(): " << reply.toString() << "\n";
				emulNet->ENsend(&(memberNode->addr), &(msg.fromAddr), reply.toString());
			}
			else
			{
				log->logReadFail(&(memberNode->addr), false /*is_coordinator*/, msg.transID, key);
			}
			break;
		}
		case MessageType::UPDATE:
		{
			const auto &key = msg.key;
			const auto &value = msg.value;
			const auto &replica = msg.replica;
			if (updateKeyValue(key, value, replica))
			{
				if (msg.transID >= 0)
				{
					log->logUpdateSuccess(&(memberNode->addr), false /*is_coordinator*/, msg.transID, key, value);
					auto reply = Message(msg.transID, memberNode->addr, MessageType::REPLY, true);
					emulNet->ENsend(&(memberNode->addr), &(msg.fromAddr), reply.toString());
				}
			}
			else
			{
				log->logUpdateFail(&(memberNode->addr), false /*is_coordinator*/, msg.transID, key, value);
			}
			break;
		}
		case MessageType::CREATE:
		{
			const auto &key = msg.key;
			const auto &value = msg.value;
			const auto &replica = msg.replica;
			// std::cout << "MessageType::CREATE/UPDATE on " << memberNode->addr.getAddress()
			// 		  << " from " << msg.fromAddr.getAddress() << " key: "
			// 		  << key << "," << msg.replica << "\n";
			createKeyValue(key, value, replica);
			if (msg.transID >= 0)
			{
				log->logCreateSuccess(&(memberNode->addr), false /*is_coordinator*/, msg.transID, key, value);
				auto reply = Message(msg.transID, memberNode->addr, MessageType::REPLY, true);
				emulNet->ENsend(&(memberNode->addr), &(msg.fromAddr), reply.toString());
			}
			break;
		}
		case MessageType::DELETE:
		{
			const auto &key = msg.key;
			if (deletekey(key))
			{
				log->logDeleteSuccess(&(memberNode->addr), false /*is_coordinator*/, msg.transID, key);
				auto reply = Message(msg.transID, memberNode->addr, MessageType::REPLY, true);
				emulNet->ENsend(&(memberNode->addr), &(msg.fromAddr), reply.toString());
			}
			else
			{
				log->logDeleteFail(&(memberNode->addr), false /*is_coordinator*/, msg.transID, key);
			}
			break;
		}
		case MessageType::READREPLY:
		{
			auto it = local_state_.find(msg.transID);
			// for (auto &v : local_state_)
			// {
			// 	std::cout << "v: " << v.first << "???" << v.second.key << "\n";
			// }
			if (it != local_state_.end())
			{
				const auto &key = it->second.key;
				auto &value = it->second.value;
				auto &replies = it->second.replies;
				std::cout << "MessageType::READREPLY on " << memberNode->addr.getAddress()
						  << " from " << msg.fromAddr.getAddress() << " key: "
						  << key << "," << msg.value << "\n";
				if (value.empty())
				{
					value = msg.value;
				}
				++replies;
				if (replies >= READ_QUORUM)
				{
					// READ success
					log->logReadSuccess(&(memberNode->addr), true /*is_coordinator*/, msg.transID, key, value);
					local_state_.erase(it);
				}
			}
			break;
		}
		case MessageType::REPLY:
		{
			auto it = local_state_.find(msg.transID);
			if (it != local_state_.end())
			{
				auto &state = it->second;
				const auto &key = state.key;
				const auto &value = state.value;
				auto &replies = state.replies;
				std::cout << "MessageType::REPLY for " << memberNode->addr.getAddress()
						  << " from " << msg.fromAddr.getAddress() << " key: "
						  << key << "," << value << "," << msg.type << "\n";
				++replies;
				if (replies >= WRITE_QUORUM)
				{
					// READ success
					// std::cout << "log->logCreateSuccess\n";
					if (state.type == MessageType::CREATE)
					{
						log->logCreateSuccess(&(memberNode->addr), true /*is_coordinator*/, msg.transID, key, value);
					}
					else if (state.type == MessageType::UPDATE)
					{
						log->logUpdateSuccess(&(memberNode->addr), true /*is_coordinator*/, msg.transID, key, value);
					}
					else if (state.type == MessageType::DELETE)
					{
						log->logDeleteSuccess(&(memberNode->addr), true /*is_coordinator*/, msg.transID, key);
					}
					local_state_.erase(it);
				}
			}

			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 $0x558, %rsp            # imm = 0x558
movq %rdi, 0x8(%rsp)
movq 0x60(%rdi), %rdi
movq 0xa8(%rdi), %rax
cmpq %rax, 0xc8(%rdi)
je 0x12ac5
movq 0x8(%rsp), %rdx
leaq 0x80(%rdx), %rcx
movq %rcx, 0x130(%rsp)
leaq 0x88(%rdx), %rcx
movq %rcx, 0x30(%rsp)
leaq 0x3a0(%rsp), %rbp
leaq 0x380(%rsp), %rbx
addq $0x98, %rdi
movq (%rax), %r14
movslq 0x8(%rax), %r15
callq 0x61dc
addq %r14, %r15
leaq 0x148(%rsp), %rax
movq %rax, 0x138(%rsp)
leaq 0x138(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xba52
leaq 0x530(%rsp), %r14
movq %r14, 0x520(%rsp)
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdx
addq %rsi, %rdx
leaq 0x520(%rsp), %r15
movq %r15, %rdi
callq 0xba52
leaq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x15dc0
movq 0x520(%rsp), %rdi
cmpq %r14, %rdi
je 0x1175a
movq 0x530(%rsp), %rsi
incq %rsi
callq 0x3280
movl 0x38(%rsp), %eax
cmpq $0x5, %rax
ja 0x128ca
leaq 0x74e1(%rip), %rcx      # 0x18c50
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x250(%rsp), %rax
movq %rax, 0x240(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x240(%rsp), %rdi
callq 0xba52
leaq 0x3b0(%rsp), %rax
movq %rax, 0x3a0(%rsp)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
movq %rbp, %r14
movq %rbp, %rdi
callq 0xba52
movl 0x3c(%rsp), %ecx
movq 0x8(%rsp), %rdi
leaq 0x240(%rsp), %rsi
movq %r14, %rdx
callq 0x10e86
movq 0x3a0(%rsp), %rdi
leaq 0x3b0(%rsp), %rax
cmpq %rax, %rdi
je 0x11808
movq 0x3b0(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x240(%rsp), %rdi
leaq 0x250(%rsp), %rax
cmpq %rax, %rdi
je 0x1182d
movq 0x250(%rsp), %rsi
incq %rsi
callq 0x3280
movl 0x88(%rsp), %r14d
testl %r14d, %r14d
js 0x128ca
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r15
movq 0x78(%rax), %r12
leaq 0x230(%rsp), %rax
movq %rax, 0x220(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x220(%rsp), %rdi
callq 0xba52
leaq 0x390(%rsp), %rax
movq %rax, 0x380(%rsp)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %r13
movq %rbx, %rdi
callq 0xba52
addq $0x8, %r15
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
movl %r14d, %ecx
leaq 0x220(%rsp), %r8
movq %r13, %r9
callq 0xc464
movq 0x380(%rsp), %rdi
leaq 0x390(%rsp), %rax
cmpq %rax, %rdi
je 0x118e1
movq 0x390(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x220(%rsp), %rdi
leaq 0x230(%rsp), %rax
cmpq %rax, %rdi
je 0x11906
movq 0x230(%rsp), %rsi
incq %rsi
callq 0x3280
movl 0x88(%rsp), %r14d
movq 0x8(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq 0x54c(%rsp), %r15
movq %r15, %rdi
callq 0xcd2c
leaq 0xb0(%rsp), %r12
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl $0x4, %ecx
movl $0x1, %r8d
callq 0x16740
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r14
movq 0x70(%rax), %r15
leaq 0x4c0(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x16918
addq $0x8, %r14
movq %r15, %rdi
movq %r14, %rsi
leaq 0x80(%rsp), %rdx
movq %r13, %rcx
callq 0x6b44
movq 0x4c0(%rsp), %rdi
leaq 0x4d0(%rsp), %rax
cmpq %rax, %rdi
je 0x1201c
movq 0x4d0(%rsp), %rsi
jmp 0x12014
movq 0x8(%rsp), %rax
movq 0x90(%rax), %rcx
testq %rcx, %rcx
je 0x128ca
movl 0x88(%rsp), %eax
movq 0x30(%rsp), %r15
xorl %edx, %edx
cmpl %eax, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %r15
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x119cd
cmpq 0x30(%rsp), %r15
je 0x128ca
cmpl 0x20(%r15), %eax
jl 0x128ca
movl $0x17, %edx
movq 0xe5cc(%rip), %rdi      # 0x1ffd0
leaq 0x72f3(%rip), %rsi      # 0x18cfe
callq 0x32d0
movq 0x8(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq 0xb0(%rsp), %rdi
callq 0xb42e
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0xe58f(%rip), %rdi      # 0x1ffd0
callq 0x32d0
movq %rax, %r14
movl $0x6, %edx
movq %rax, %rdi
leaq 0x727f(%rip), %rsi      # 0x18cd7
callq 0x32d0
leaq 0x10(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xb42e
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rax, %r14
movl $0x6, %edx
movq %rax, %rdi
leaq 0x6be3(%rip), %rsi      # 0x18676
callq 0x32d0
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x7242(%rip), %rsi      # 0x18cfc
callq 0x32d0
movq 0x50(%r15), %rsi
movq 0x58(%r15), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x721b(%rip), %rsi      # 0x18cfc
callq 0x32d0
movl 0x38(%rsp), %esi
movq %r14, %rdi
callq 0x3450
movl $0x1, %edx
movq %rax, %rdi
leaq 0x67f4(%rip), %rsi      # 0x182f5
callq 0x32d0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x11b22
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x11b47
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x78(%r15), %rax
incq %rax
movq %rax, 0x78(%r15)
cmpq $0x2, %rax
jb 0x128ca
movl 0x28(%r15), %eax
cmpl $0x3, %eax
je 0x12a31
cmpl $0x2, %eax
je 0x1296e
testl %eax, %eax
jne 0x12ab0
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r14
movq 0x78(%rax), %r12
movl 0x88(%rsp), %r13d
leaq 0x350(%rsp), %rax
movq %rax, 0x340(%rsp)
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
addq %rsi, %rdx
leaq 0x340(%rsp), %rdi
callq 0xba52
leaq 0x190(%rsp), %rax
movq %rax, 0x180(%rsp)
movq 0x50(%r15), %rsi
movq 0x58(%r15), %rdx
addq %rsi, %rdx
leaq 0x180(%rsp), %rdi
callq 0xba52
addq $0x8, %r14
movq %r12, %rdi
movq %r14, %rsi
movl $0x1, %edx
movl %r13d, %ecx
leaq 0x340(%rsp), %r8
leaq 0x180(%rsp), %r9
callq 0xc464
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x11c2b
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x340(%rsp), %rdi
leaq 0x350(%rsp), %rcx
jmp 0x12a9d
leaq 0x2b0(%rsp), %rax
movq %rax, 0x2a0(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x2a0(%rsp), %rdi
callq 0xba52
leaq 0x410(%rsp), %rax
movq %rax, 0x400(%rsp)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
leaq 0x400(%rsp), %r14
movq %r14, %rdi
callq 0xba52
movl 0x3c(%rsp), %ecx
movq 0x8(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
movq %r14, %rdx
callq 0x112ae
movl %eax, %r14d
movq 0x400(%rsp), %rdi
leaq 0x410(%rsp), %rax
cmpq %rax, %rdi
je 0x11cd8
movq 0x410(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x2a0(%rsp), %rdi
leaq 0x2b0(%rsp), %rax
cmpq %rax, %rdi
je 0x11cfd
movq 0x2b0(%rsp), %rsi
incq %rsi
callq 0x3280
testb %r14b, %r14b
je 0x12765
movl 0x88(%rsp), %r14d
testl %r14d, %r14d
js 0x128ca
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r15
movq 0x78(%rax), %r12
leaq 0x290(%rsp), %rax
movq %rax, 0x280(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x280(%rsp), %rdi
callq 0xba52
leaq 0x3f0(%rsp), %rax
movq %rax, 0x3e0(%rsp)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
leaq 0x3e0(%rsp), %r13
movq %r13, %rdi
callq 0xba52
addq $0x8, %r15
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
movl %r14d, %ecx
leaq 0x280(%rsp), %r8
movq %r13, %r9
callq 0xc648
movq 0x3e0(%rsp), %rdi
leaq 0x3f0(%rsp), %rax
cmpq %rax, %rdi
je 0x11dbf
movq 0x3f0(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x280(%rsp), %rdi
leaq 0x290(%rsp), %rax
cmpq %rax, %rdi
je 0x11de4
movq 0x290(%rsp), %rsi
incq %rsi
callq 0x3280
movl 0x88(%rsp), %r14d
movq 0x8(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq 0x552(%rsp), %r15
movq %r15, %rdi
callq 0xcd2c
leaq 0xb0(%rsp), %r12
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl $0x4, %ecx
movl $0x1, %r8d
callq 0x16740
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r14
movq 0x70(%rax), %r15
leaq 0x4e0(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x16918
addq $0x8, %r14
movq %r15, %rdi
movq %r14, %rsi
leaq 0x80(%rsp), %rdx
movq %r13, %rcx
callq 0x6b44
movq 0x4e0(%rsp), %rdi
leaq 0x4f0(%rsp), %rax
cmpq %rax, %rdi
je 0x1201c
movq 0x4f0(%rsp), %rsi
jmp 0x12014
leaq 0x210(%rsp), %rax
movq %rax, 0x200(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x200(%rsp), %rdi
callq 0xba52
movq 0x8(%rsp), %rdi
leaq 0x200(%rsp), %rsi
callq 0x11502
movl %eax, %r12d
movq 0x200(%rsp), %rdi
leaq 0x210(%rsp), %rax
cmpq %rax, %rdi
je 0x11eee
movq 0x210(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r15
movq 0x78(%rax), %r13
movl 0x88(%rsp), %r14d
testb %r12b, %r12b
je 0x126f9
leaq 0x1f0(%rsp), %rax
movq %rax, 0x1e0(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1e0(%rsp), %rdi
callq 0xba52
addq $0x8, %r15
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
movl %r14d, %ecx
leaq 0x1e0(%rsp), %r8
callq 0xc73a
movq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %rax
cmpq %rax, %rdi
je 0x11f77
movq 0x1f0(%rsp), %rsi
incq %rsi
callq 0x3280
movl 0x88(%rsp), %r14d
movq 0x8(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq 0x546(%rsp), %r15
movq %r15, %rdi
callq 0xcd2c
leaq 0xb0(%rsp), %r12
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl $0x4, %ecx
movl $0x1, %r8d
callq 0x16740
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r14
movq 0x70(%rax), %r15
leaq 0x4a0(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x16918
addq $0x8, %r14
movq %r15, %rdi
movq %r14, %rsi
leaq 0x80(%rsp), %rdx
movq %r13, %rcx
callq 0x6b44
movq 0x4a0(%rsp), %rdi
leaq 0x4b0(%rsp), %rax
cmpq %rax, %rdi
je 0x1201c
movq 0x4b0(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x12041
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x12066
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x128ca
movq 0xc8(%rsp), %rsi
jmp 0x128c2
leaq 0x490(%rsp), %rax
movq %rax, 0x480(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x480(%rsp), %r14
movq %r14, %rdi
callq 0xba52
leaq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x110d0
movq 0x480(%rsp), %rdi
leaq 0x490(%rsp), %rax
cmpq %rax, %rdi
je 0x120f0
movq 0x490(%rsp), %rsi
incq %rsi
callq 0x3280
movl $0x15, %edx
movq 0xded4(%rip), %rdi      # 0x1ffd0
leaq 0x6bbe(%rip), %rsi      # 0x18cc1
callq 0x32d0
movq 0x8(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq 0xb0(%rsp), %rdi
callq 0xb42e
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0xde97(%rip), %rdi      # 0x1ffd0
callq 0x32d0
movq %rax, %r14
movl $0x6, %edx
movq %rax, %rdi
leaq 0x6b87(%rip), %rsi      # 0x18cd7
callq 0x32d0
leaq 0x460(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xb42e
movq 0x460(%rsp), %rsi
movq 0x468(%rsp), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6122(%rip), %rsi      # 0x182b6
callq 0x32d0
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
leaq 0x6b21(%rip), %rsi      # 0x18cde
callq 0x32d0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r14, %rdi
callq 0x32d0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6112(%rip), %rsi      # 0x182f5
callq 0x32d0
movq 0x460(%rsp), %rdi
leaq 0x470(%rsp), %rax
cmpq %rax, %rdi
je 0x1220d
movq 0x470(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x12232
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x3280
cmpq $0x0, 0x18(%rsp)
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r15
movq 0x78(%rax), %r14
je 0x1283b
movl 0x88(%rsp), %r13d
leaq 0x2f0(%rsp), %rax
movq %rax, 0x2e0(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x2e0(%rsp), %rdi
callq 0xba52
leaq 0x450(%rsp), %rax
movq %rax, 0x440(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x440(%rsp), %r12
movq %r12, %rdi
callq 0xba52
addq $0x8, %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
movl %r13d, %ecx
leaq 0x2e0(%rsp), %r8
movq %r12, %r9
callq 0xc556
movq 0x440(%rsp), %rdi
leaq 0x450(%rsp), %rax
cmpq %rax, %rdi
je 0x122ee
movq 0x450(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x2e0(%rsp), %rdi
leaq 0x2f0(%rsp), %rax
cmpq %rax, %rdi
je 0x12313
movq 0x2f0(%rsp), %rsi
incq %rsi
callq 0x3280
movl 0x88(%rsp), %r14d
movq 0x8(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq 0x15a(%rsp), %rdi
callq 0xcd2c
leaq 0x420(%rsp), %r15
leaq 0x430(%rsp), %rax
movq %rax, 0x420(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0xba52
leaq 0xb0(%rsp), %rdi
movl %r14d, %esi
leaq 0x15a(%rsp), %rdx
movq %r15, %rcx
callq 0x1682a
movq 0x420(%rsp), %rdi
leaq 0x430(%rsp), %rax
cmpq %rax, %rdi
je 0x123a2
movq 0x430(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r14
movq 0x70(%rax), %r15
leaq 0x500(%rsp), %r12
movq %r12, %rdi
leaq 0xb0(%rsp), %rsi
callq 0x16918
addq $0x8, %r14
movq %r15, %rdi
movq %r14, %rsi
leaq 0x80(%rsp), %rdx
movq %r12, %rcx
callq 0x6b44
movq 0x500(%rsp), %rdi
leaq 0x510(%rsp), %rax
cmpq %rax, %rdi
je 0x12406
movq 0x510(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x108(%rsp), %rdi
leaq 0x118(%rsp), %rax
cmpq %rax, %rdi
je 0x1242b
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x12450
movq 0xe8(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x128ae
movq 0xc8(%rsp), %rsi
jmp 0x128a6
movq 0x8(%rsp), %rax
movq 0x90(%rax), %rcx
testq %rcx, %rcx
je 0x128ca
movl 0x88(%rsp), %eax
movq 0x30(%rsp), %r15
xorl %edx, %edx
cmpl %eax, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %r15
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0x12497
cmpq 0x30(%rsp), %r15
je 0x128ca
cmpl 0x20(%r15), %eax
jl 0x128ca
movl $0x1a, %edx
movq 0xdb02(%rip), %rdi      # 0x1ffd0
leaq 0x680c(%rip), %rsi      # 0x18ce1
callq 0x32d0
movq 0x8(%rsp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq 0xb0(%rsp), %rdi
callq 0xb42e
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq 0xdac5(%rip), %rdi      # 0x1ffd0
callq 0x32d0
movq %rax, %r14
movl $0x6, %edx
movq %rax, %rdi
leaq 0x67b5(%rip), %rsi      # 0x18cd7
callq 0x32d0
leaq 0x10(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0xb42e
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rax, %r14
movl $0x6, %edx
movq %rax, %rdi
leaq 0x6119(%rip), %rsi      # 0x18676
callq 0x32d0
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
movq %r14, %rdi
callq 0x32d0
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x6778(%rip), %rsi      # 0x18cfc
callq 0x32d0
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq %r14, %rdi
callq 0x32d0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5d4b(%rip), %rsi      # 0x182f5
callq 0x32d0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x125cb
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x125f0
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x3280
cmpq $0x0, 0x58(%r15)
jne 0x12605
leaq 0x50(%r15), %rdi
leaq 0x60(%rsp), %rsi
callq 0x3140
movq 0x78(%r15), %rax
incq %rax
movq %rax, 0x78(%r15)
cmpq $0x2, %rax
jb 0x128ca
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r14
movq 0x78(%rax), %r12
movl 0x88(%rsp), %eax
movl %eax, 0x12c(%rsp)
leaq 0x1b0(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
addq %rsi, %rdx
leaq 0x1a0(%rsp), %rdi
callq 0xba52
leaq 0x370(%rsp), %rax
movq %rax, 0x360(%rsp)
movq 0x50(%r15), %rsi
movq 0x58(%r15), %rdx
addq %rsi, %rdx
leaq 0x360(%rsp), %r13
movq %r13, %rdi
callq 0xba52
addq $0x8, %r14
movq %r12, %rdi
movq %r14, %rsi
movl $0x1, %edx
movl 0x12c(%rsp), %ecx
leaq 0x1a0(%rsp), %r8
movq %r13, %r9
callq 0xc556
movq 0x360(%rsp), %rdi
leaq 0x370(%rsp), %rax
cmpq %rax, %rdi
je 0x126d3
movq 0x370(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x1a0(%rsp), %rdi
leaq 0x1b0(%rsp), %rax
cmpq %rax, %rdi
je 0x12ab0
movq 0x1b0(%rsp), %rsi
jmp 0x12aa8
leaq 0x1d0(%rsp), %rax
movq %rax, 0x1c0(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1c0(%rsp), %rdi
callq 0xba52
addq $0x8, %r15
movq %r13, %rdi
movq %r15, %rsi
xorl %edx, %edx
movl %r14d, %ecx
leaq 0x1c0(%rsp), %r8
callq 0xcae6
movq 0x1c0(%rsp), %rdi
leaq 0x1d0(%rsp), %rax
cmpq %rax, %rdi
je 0x128ca
movq 0x1d0(%rsp), %rsi
jmp 0x128c2
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r14
movq 0x78(%rax), %r13
movl 0x88(%rsp), %r15d
leaq 0x270(%rsp), %rax
movq %rax, 0x260(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x260(%rsp), %rdi
callq 0xba52
leaq 0x3d0(%rsp), %rax
movq %rax, 0x3c0(%rsp)
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
addq %rsi, %rdx
leaq 0x3c0(%rsp), %r12
movq %r12, %rdi
callq 0xba52
addq $0x8, %r14
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
movl %r15d, %ecx
leaq 0x260(%rsp), %r8
movq %r12, %r9
callq 0xc9f4
movq 0x3c0(%rsp), %rdi
leaq 0x3d0(%rsp), %rax
cmpq %rax, %rdi
je 0x12815
movq 0x3d0(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x260(%rsp), %rdi
leaq 0x270(%rsp), %rax
cmpq %rax, %rdi
je 0x128ca
movq 0x270(%rsp), %rsi
jmp 0x128c2
movl 0x88(%rsp), %r12d
leaq 0x2d0(%rsp), %rax
movq %rax, 0x2c0(%rsp)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
leaq 0x2c0(%rsp), %rdi
callq 0xba52
addq $0x8, %r15
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
movl %r12d, %ecx
leaq 0x2c0(%rsp), %r8
callq 0xc910
movq 0x2c0(%rsp), %rdi
leaq 0x2d0(%rsp), %rax
cmpq %rax, %rdi
je 0x128ae
movq 0x2d0(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x128ca
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x128ef
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1290b
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x12927
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x1294c
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x8(%rsp), %rax
movq 0x60(%rax), %rdi
movq 0xa8(%rdi), %rax
cmpq %rax, 0xc8(%rdi)
jne 0x116c4
jmp 0x12ac5
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r14
movq 0x78(%rax), %r12
movl 0x88(%rsp), %r13d
leaq 0x330(%rsp), %rax
movq %rax, 0x320(%rsp)
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
addq %rsi, %rdx
leaq 0x320(%rsp), %rdi
callq 0xba52
leaq 0x170(%rsp), %rax
movq %rax, 0x160(%rsp)
movq 0x50(%r15), %rsi
movq 0x58(%r15), %rdx
addq %rsi, %rdx
leaq 0x160(%rsp), %rdi
callq 0xba52
addq $0x8, %r14
movq %r12, %rdi
movq %r14, %rsi
movl $0x1, %edx
movl %r13d, %ecx
leaq 0x320(%rsp), %r8
leaq 0x160(%rsp), %r9
callq 0xc648
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x12a1f
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x320(%rsp), %rdi
leaq 0x330(%rsp), %rcx
jmp 0x12a9d
movq 0x8(%rsp), %rax
movq 0x60(%rax), %r12
movq 0x78(%rax), %r13
movl 0x88(%rsp), %r14d
leaq 0x310(%rsp), %rax
movq %rax, 0x300(%rsp)
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
addq %rsi, %rdx
leaq 0x300(%rsp), %rdi
callq 0xba52
addq $0x8, %r12
movq %r13, %rdi
movq %r12, %rsi
movl $0x1, %edx
movl %r14d, %ecx
leaq 0x300(%rsp), %r8
callq 0xc73a
movq 0x300(%rsp), %rdi
leaq 0x310(%rsp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
je 0x12ab0
movq (%rax), %rsi
incq %rsi
callq 0x3280
movq 0x130(%rsp), %rdi
movq %r15, %rsi
callq 0x146f2
jmp 0x128ca
addq $0x558, %rsp            # imm = 0x558
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x300(%rsp), %rdi
leaq 0x310(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x310(%rsp), %rsi
jmp 0x130b2
movq %rax, %rbx
movq 0x160(%rsp), %rdi
leaq 0x170(%rsp), %rax
cmpq %rax, %rdi
je 0x12b2d
movq 0x170(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12b2d
movq %rax, %rbx
movq 0x320(%rsp), %rdi
leaq 0x330(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x330(%rsp), %rsi
jmp 0x130b2
movq %rax, %rbx
movq 0x180(%rsp), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x12b80
movq 0x190(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12b80
movq %rax, %rbx
movq 0x340(%rsp), %rdi
leaq 0x350(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x350(%rsp), %rsi
jmp 0x130b2
movq %rax, %rbx
movq 0x360(%rsp), %rdi
leaq 0x370(%rsp), %rax
cmpq %rax, %rdi
je 0x12bd3
movq 0x370(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12bd3
movq %rax, %rbx
movq 0x1a0(%rsp), %rdi
leaq 0x1b0(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x1b0(%rsp), %rsi
jmp 0x130b2
jmp 0x12cc3
jmp 0x1304c
jmp 0x12cc3
jmp 0x1304c
jmp 0x1304c
movq %rax, %rbx
movq 0x4e0(%rsp), %rdi
leaq 0x4f0(%rsp), %rax
cmpq %rax, %rdi
je 0x12dcd
movq 0x4f0(%rsp), %rsi
jmp 0x12dc0
jmp 0x12dca
movq %rax, %rbx
movq 0x3e0(%rsp), %rdi
leaq 0x3f0(%rsp), %rax
cmpq %rax, %rdi
je 0x12c6d
movq 0x3f0(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12c6d
movq %rax, %rbx
movq 0x280(%rsp), %rdi
leaq 0x290(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x290(%rsp), %rsi
jmp 0x130b2
jmp 0x1304c
movq %rax, %rbx
movq 0x2c0(%rsp), %rdi
leaq 0x2d0(%rsp), %rax
cmpq %rax, %rdi
je 0x1309e
movq 0x2d0(%rsp), %rsi
jmp 0x13096
jmp 0x12cc3
movq %rax, %rbx
jmp 0x1301b
movq %rax, %rbx
movq 0x3c0(%rsp), %rdi
leaq 0x3d0(%rsp), %rax
cmpq %rax, %rdi
je 0x12cf8
movq 0x3d0(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12cf8
movq %rax, %rbx
movq 0x260(%rsp), %rdi
leaq 0x270(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x270(%rsp), %rsi
jmp 0x130b2
movq %rax, %rbx
movq 0x4a0(%rsp), %rdi
leaq 0x4b0(%rsp), %rax
cmpq %rax, %rdi
je 0x12dcd
movq 0x4b0(%rsp), %rsi
jmp 0x12dc0
jmp 0x12dca
movq %rax, %rbx
movq 0x1e0(%rsp), %rdi
leaq 0x1f0(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x1f0(%rsp), %rsi
jmp 0x130b2
movq %rax, %rbx
movq 0x1c0(%rsp), %rdi
leaq 0x1d0(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x1d0(%rsp), %rsi
jmp 0x130b2
jmp 0x1304c
movq %rax, %rbx
movq 0x4c0(%rsp), %rdi
leaq 0x4d0(%rsp), %rax
cmpq %rax, %rdi
je 0x12dcd
movq 0x4d0(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12dcd
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x13728
jmp 0x130ba
movq %rax, %rbx
movq 0x380(%rsp), %rdi
leaq 0x390(%rsp), %rax
cmpq %rax, %rdi
je 0x12e0c
movq 0x390(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12e0c
movq %rax, %rbx
movq 0x220(%rsp), %rdi
leaq 0x230(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x230(%rsp), %rsi
jmp 0x130b2
movq %rax, %rbx
movq 0x500(%rsp), %rdi
leaq 0x510(%rsp), %rax
cmpq %rax, %rdi
je 0x12e5f
movq 0x510(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12e5f
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x13728
jmp 0x1309e
movq %rax, %rbx
movq 0x420(%rsp), %rdi
leaq 0x430(%rsp), %rax
cmpq %rax, %rdi
je 0x1309e
movq 0x430(%rsp), %rsi
jmp 0x13096
movq %rax, %rbx
movq 0x440(%rsp), %rdi
leaq 0x450(%rsp), %rax
cmpq %rax, %rdi
je 0x12ec7
movq 0x450(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12ec7
movq %rax, %rbx
movq 0x2e0(%rsp), %rdi
leaq 0x2f0(%rsp), %rax
cmpq %rax, %rdi
je 0x1309e
movq 0x2f0(%rsp), %rsi
jmp 0x13096
movq %rax, %rbx
movq 0x200(%rsp), %rdi
leaq 0x210(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x210(%rsp), %rsi
jmp 0x130b2
jmp 0x13047
jmp 0x13042
movq %rax, %rbx
movq 0x480(%rsp), %rdi
leaq 0x490(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x490(%rsp), %rsi
jmp 0x130b2
jmp 0x1304c
movq %rax, %rbx
movq 0x3a0(%rsp), %rdi
leaq 0x3b0(%rsp), %rax
cmpq %rax, %rdi
je 0x12fa5
movq 0x3b0(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12fa5
movq %rax, %rbx
movq 0x400(%rsp), %rdi
leaq 0x410(%rsp), %rax
cmpq %rax, %rdi
je 0x12fce
movq 0x410(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x12fce
movq %rax, %rbx
movq 0x240(%rsp), %rdi
leaq 0x250(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x250(%rsp), %rsi
jmp 0x130b2
movq %rax, %rbx
movq 0x2a0(%rsp), %rdi
leaq 0x2b0(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x2b0(%rsp), %rsi
jmp 0x130b2
jmp 0x1304c
jmp 0x12ffc
jmp 0x13042
jmp 0x1304c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1301b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0xc0(%rsp), %rsi
jmp 0x130b2
jmp 0x1304c
jmp 0x1304c
movq %rax, %rbx
jmp 0x1309e
movq %rax, %rbx
jmp 0x13079
movq %rax, %rbx
jmp 0x130ba
movq %rax, %rbx
movq 0x460(%rsp), %rdi
leaq 0x470(%rsp), %rax
cmpq %rax, %rdi
je 0x13079
movq 0x470(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x1309e
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x130ba
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x38(%rsp), %rdi
callq 0x13728
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x130e9
movq 0x148(%rsp), %rsi
incq %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x3470
movq %rax, %rbx
jmp 0x130c4
movq %rax, %rbx
movq 0x520(%rsp), %rdi
cmpq %r14, %rdi
je 0x130c4
movq 0x530(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x130c4