// File: 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
movq %rsp, %rbp
subq $0xad0, %rsp            # imm = 0xAD0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x828(%rbp)
movq -0x828(%rbp), %rax
movq 0x60(%rax), %rdi
addq $0x98, %rdi
callq 0x6a70
xorb $-0x1, %al
testb $0x1, %al
jne 0x1f0cc
jmp 0x2089a
movq -0x828(%rbp), %rax
movq 0x60(%rax), %rdi
addq $0x98, %rdi
callq 0x6a90
movq %rax, %rcx
movq -0x828(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x10(%rbp)
movq 0x60(%rax), %rdi
addq $0x98, %rdi
callq 0x6a90
movq %rax, %rcx
movq -0x828(%rbp), %rax
movl 0x8(%rcx), %ecx
movl %ecx, -0x14(%rbp)
movq 0x60(%rax), %rdi
addq $0x98, %rdi
callq 0x6ab0
movq -0x10(%rbp), %rax
movq %rax, -0x840(%rbp)
movslq -0x14(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x838(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x830(%rbp)
callq 0x4580
movq -0x840(%rbp), %rsi
movq -0x838(%rbp), %rdx
movq -0x830(%rbp), %rcx
leaq -0x38(%rbp), %rdi
callq 0x21530
jmp 0x1f16d
leaq -0x39(%rbp), %rdi
callq 0x4370
leaq -0xe8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4150
jmp 0x1f188
leaq -0xc8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x280c0
jmp 0x1f19d
leaq -0xe8(%rbp), %rdi
callq 0x41e0
movl -0xc8(%rbp), %eax
movq %rax, -0x848(%rbp)
subq $0x5, %rax
ja 0x20867
movq -0x848(%rbp), %rax
leaq 0xbac6(%rip), %rcx      # 0x2ac94
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x4370
jmp 0x208a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2088f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x41e0
jmp 0x2088f
leaq -0xc0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0x4150
jmp 0x1f242
movq -0x828(%rbp), %rsi
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rdx
callq 0x1e970
jmp 0x1f25e
leaq -0x130(%rbp), %rdi
callq 0x41e0
movq 0x1ad57(%rip), %rdi     # 0x39fc8
leaq 0xba8d(%rip), %rsi      # 0x2ad05
callq 0x42f0
movq %rax, -0x850(%rbp)
jmp 0x1f286
movq -0x828(%rbp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq -0x150(%rbp), %rdi
callq 0x12740
jmp 0x1f2a3
movq -0x850(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x42a0
movq %rax, -0x858(%rbp)
jmp 0x1f2bf
movq -0x858(%rbp), %rdi
leaq 0xba4e(%rip), %rsi      # 0x2ad1b
callq 0x42f0
movq %rax, -0x860(%rbp)
jmp 0x1f2db
leaq -0x80(%rbp), %rsi
leaq -0x170(%rbp), %rdi
callq 0x12740
jmp 0x1f2ed
movq -0x860(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x42a0
movq %rax, -0x868(%rbp)
jmp 0x1f309
movq -0x868(%rbp), %rdi
leaq 0xafef(%rip), %rsi      # 0x2a306
callq 0x42f0
movq %rax, -0x870(%rbp)
jmp 0x1f325
movq -0x870(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0x42a0
movq %rax, -0x878(%rbp)
jmp 0x1f341
movq -0x878(%rbp), %rdi
leaq 0xb9d3(%rip), %rsi      # 0x2ad22
callq 0x42f0
movq %rax, -0x880(%rbp)
jmp 0x1f35d
movq -0x880(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x42a0
movq %rax, -0x888(%rbp)
jmp 0x1f379
movq -0x888(%rbp), %rdi
leaq 0xafbe(%rip), %rsi      # 0x2a345
callq 0x42f0
jmp 0x1f38e
leaq -0x170(%rbp), %rdi
callq 0x41e0
leaq -0x150(%rbp), %rdi
callq 0x41e0
leaq -0x110(%rbp), %rdi
callq 0x4550
testb $0x1, %al
jne 0x1f63c
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0x8a0(%rbp)
addq $0x8, %rax
movq %rax, -0x898(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x88c(%rbp)
movq -0xf0(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0x4150
jmp 0x1f3f9
leaq -0x1b0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x4150
jmp 0x1f40e
movl -0x88c(%rbp), %ecx
movq -0x898(%rbp), %rsi
movq -0x8a0(%rbp), %rdi
xorl %edx, %edx
leaq -0x190(%rbp), %r8
leaq -0x1b0(%rbp), %r9
callq 0x16640
jmp 0x1f439
leaq -0x1b0(%rbp), %rdi
callq 0x41e0
leaq -0x190(%rbp), %rdi
callq 0x41e0
movq -0x828(%rbp), %rax
movl -0x78(%rbp), %ecx
movl %ecx, -0x8a4(%rbp)
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq -0x22e(%rbp), %rdi
callq 0x170d0
jmp 0x1f477
leaq -0x250(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x4150
jmp 0x1f48c
movl -0x8a4(%rbp), %esi
leaq -0x228(%rbp), %rdi
leaq -0x22e(%rbp), %rdx
leaq -0x250(%rbp), %rcx
callq 0x28ac0
jmp 0x1f4ae
leaq -0x250(%rbp), %rdi
callq 0x41e0
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x70(%rcx), %rcx
movq %rcx, -0x8c0(%rbp)
addq $0x8, %rax
movq %rax, -0x8b8(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x8b0(%rbp)
leaq -0x270(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x28bb0
jmp 0x1f4fb
movq -0x8b0(%rbp), %rdx
movq -0x8b8(%rbp), %rsi
movq -0x8c0(%rbp), %rdi
leaq -0x270(%rbp), %rcx
callq 0xcce0
jmp 0x1f51e
leaq -0x270(%rbp), %rdi
callq 0x41e0
leaq -0x228(%rbp), %rdi
callq 0x21280
jmp 0x1f6c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x20883
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f6d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f5a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x41e0
leaq -0x150(%rbp), %rdi
callq 0x41e0
jmp 0x1f6d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f5d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x41e0
leaq -0x190(%rbp), %rdi
callq 0x41e0
jmp 0x1f6d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x41e0
jmp 0x1f6d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f62b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x41e0
leaq -0x228(%rbp), %rdi
callq 0x21280
jmp 0x1f6d8
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0x8d8(%rbp)
addq $0x8, %rax
movq %rax, -0x8d0(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x8c4(%rbp)
movq -0xf0(%rbp), %rsi
leaq -0x290(%rbp), %rdi
callq 0x4150
jmp 0x1f67b
movl -0x8c4(%rbp), %ecx
movq -0x8d0(%rbp), %rsi
movq -0x8d8(%rbp), %rdi
xorl %edx, %edx
leaq -0x290(%rbp), %r8
callq 0x16b40
jmp 0x1f69f
leaq -0x290(%rbp), %rdi
callq 0x41e0
jmp 0x1f6c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x41e0
jmp 0x1f6d8
leaq -0x110(%rbp), %rdi
callq 0x41e0
jmp 0x20869
leaq -0x110(%rbp), %rdi
callq 0x41e0
jmp 0x20883
leaq -0xc0(%rbp), %rax
movq %rax, -0x298(%rbp)
leaq -0xa0(%rbp), %rax
movq %rax, -0x2a0(%rbp)
leaq -0xc4(%rbp), %rax
movq %rax, -0x2a8(%rbp)
movq -0x298(%rbp), %rsi
leaq -0x2c8(%rbp), %rdi
callq 0x4150
jmp 0x1f728
movq -0x2a0(%rbp), %rsi
leaq -0x2e8(%rbp), %rdi
callq 0x4150
jmp 0x1f73d
movq -0x828(%rbp), %rdi
movq -0x2a8(%rbp), %rax
movl (%rax), %ecx
leaq -0x2c8(%rbp), %rsi
leaq -0x2e8(%rbp), %rdx
callq 0x1ec10
movb %al, -0x8d9(%rbp)
jmp 0x1f768
leaq -0x2e8(%rbp), %rdi
callq 0x41e0
leaq -0x2c8(%rbp), %rdi
callq 0x41e0
movb -0x8d9(%rbp), %al
testb $0x1, %al
jne 0x1f78f
jmp 0x1f9a7
cmpl $0x0, -0x78(%rbp)
jl 0x1f9a2
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0x8f0(%rbp)
addq $0x8, %rax
movq %rax, -0x8e8(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x8e0(%rbp)
movq -0x298(%rbp), %rsi
leaq -0x308(%rbp), %rdi
callq 0x4150
jmp 0x1f7d8
movq -0x2a0(%rbp), %rsi
leaq -0x328(%rbp), %rdi
callq 0x4150
jmp 0x1f7ed
movl -0x8e0(%rbp), %ecx
movq -0x8e8(%rbp), %rsi
movq -0x8f0(%rbp), %rdi
xorl %edx, %edx
leaq -0x308(%rbp), %r8
leaq -0x328(%rbp), %r9
callq 0x16790
jmp 0x1f818
leaq -0x328(%rbp), %rdi
callq 0x41e0
leaq -0x308(%rbp), %rdi
callq 0x41e0
movq -0x828(%rbp), %rax
movl -0x78(%rbp), %ecx
movl %ecx, -0x8f4(%rbp)
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq -0x3a6(%rbp), %rdi
callq 0x170d0
jmp 0x1f856
movl -0x8f4(%rbp), %esi
leaq -0x3a0(%rbp), %rdi
leaq -0x3a6(%rbp), %rdx
movl $0x4, %ecx
movl $0x1, %r8d
callq 0x289d0
jmp 0x1f87c
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x70(%rcx), %rcx
movq %rcx, -0x910(%rbp)
addq $0x8, %rax
movq %rax, -0x908(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x900(%rbp)
leaq -0x3c8(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0x28bb0
jmp 0x1f8bd
movq -0x900(%rbp), %rdx
movq -0x908(%rbp), %rsi
movq -0x910(%rbp), %rdi
leaq -0x3c8(%rbp), %rcx
callq 0xcce0
jmp 0x1f8e0
leaq -0x3c8(%rbp), %rdi
callq 0x41e0
leaq -0x3a0(%rbp), %rdi
callq 0x21280
jmp 0x1f9a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f923
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x41e0
leaq -0x2c8(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f95a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x328(%rbp), %rdi
callq 0x41e0
leaq -0x308(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1f991
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x3c8(%rbp), %rdi
callq 0x41e0
leaq -0x3a0(%rbp), %rdi
callq 0x21280
jmp 0x20883
jmp 0x1fa77
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0x928(%rbp)
addq $0x8, %rax
movq %rax, -0x920(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x914(%rbp)
movq -0x298(%rbp), %rsi
leaq -0x3e8(%rbp), %rdi
callq 0x4150
jmp 0x1f9e6
movq -0x2a0(%rbp), %rsi
leaq -0x408(%rbp), %rdi
callq 0x4150
jmp 0x1f9fb
movl -0x914(%rbp), %ecx
movq -0x920(%rbp), %rsi
movq -0x928(%rbp), %rdi
xorl %edx, %edx
leaq -0x3e8(%rbp), %r8
leaq -0x408(%rbp), %r9
callq 0x16c50
jmp 0x1fa26
leaq -0x408(%rbp), %rdi
callq 0x41e0
leaq -0x3e8(%rbp), %rdi
callq 0x41e0
jmp 0x1fa77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1fa66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x408(%rbp), %rdi
callq 0x41e0
leaq -0x3e8(%rbp), %rdi
callq 0x41e0
jmp 0x20883
jmp 0x20869
leaq -0xc0(%rbp), %rax
movq %rax, -0x410(%rbp)
leaq -0xa0(%rbp), %rax
movq %rax, -0x418(%rbp)
leaq -0xc4(%rbp), %rax
movq %rax, -0x420(%rbp)
movq -0x410(%rbp), %rsi
leaq -0x440(%rbp), %rdi
callq 0x4150
jmp 0x1fabb
movq -0x418(%rbp), %rsi
leaq -0x460(%rbp), %rdi
callq 0x4150
jmp 0x1fad0
movq -0x828(%rbp), %rdi
movq -0x420(%rbp), %rax
movl (%rax), %ecx
leaq -0x440(%rbp), %rsi
leaq -0x460(%rbp), %rdx
callq 0x1e710
jmp 0x1faf5
leaq -0x460(%rbp), %rdi
callq 0x41e0
leaq -0x440(%rbp), %rdi
callq 0x41e0
cmpl $0x0, -0x78(%rbp)
jl 0x1fd20
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0x940(%rbp)
addq $0x8, %rax
movq %rax, -0x938(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x92c(%rbp)
movq -0x410(%rbp), %rsi
leaq -0x480(%rbp), %rdi
callq 0x4150
jmp 0x1fb56
movq -0x418(%rbp), %rsi
leaq -0x4a0(%rbp), %rdi
callq 0x4150
jmp 0x1fb6b
movl -0x92c(%rbp), %ecx
movq -0x938(%rbp), %rsi
movq -0x940(%rbp), %rdi
xorl %edx, %edx
leaq -0x480(%rbp), %r8
leaq -0x4a0(%rbp), %r9
callq 0x164f0
jmp 0x1fb96
leaq -0x4a0(%rbp), %rdi
callq 0x41e0
leaq -0x480(%rbp), %rdi
callq 0x41e0
movq -0x828(%rbp), %rax
movl -0x78(%rbp), %ecx
movl %ecx, -0x944(%rbp)
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq -0x51e(%rbp), %rdi
callq 0x170d0
jmp 0x1fbd4
movl -0x944(%rbp), %esi
leaq -0x518(%rbp), %rdi
leaq -0x51e(%rbp), %rdx
movl $0x4, %ecx
movl $0x1, %r8d
callq 0x289d0
jmp 0x1fbfa
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x70(%rcx), %rcx
movq %rcx, -0x960(%rbp)
addq $0x8, %rax
movq %rax, -0x958(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x950(%rbp)
leaq -0x540(%rbp), %rdi
leaq -0x518(%rbp), %rsi
callq 0x28bb0
jmp 0x1fc3b
movq -0x950(%rbp), %rdx
movq -0x958(%rbp), %rsi
movq -0x960(%rbp), %rdi
leaq -0x540(%rbp), %rcx
callq 0xcce0
jmp 0x1fc5e
leaq -0x540(%rbp), %rdi
callq 0x41e0
leaq -0x518(%rbp), %rdi
callq 0x21280
jmp 0x1fd20
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1fca1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x460(%rbp), %rdi
callq 0x41e0
leaq -0x440(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1fcd8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x4a0(%rbp), %rdi
callq 0x41e0
leaq -0x480(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1fd0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x540(%rbp), %rdi
callq 0x41e0
leaq -0x518(%rbp), %rdi
callq 0x21280
jmp 0x20883
jmp 0x20869
leaq -0xc0(%rbp), %rax
movq %rax, -0x548(%rbp)
movq -0x548(%rbp), %rsi
leaq -0x568(%rbp), %rdi
callq 0x4150
jmp 0x1fd48
movq -0x828(%rbp), %rdi
leaq -0x568(%rbp), %rsi
callq 0x1eeb0
movb %al, -0x961(%rbp)
jmp 0x1fd63
leaq -0x568(%rbp), %rdi
callq 0x41e0
movb -0x961(%rbp), %al
testb $0x1, %al
jne 0x1fd7e
jmp 0x1ff2b
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0x978(%rbp)
addq $0x8, %rax
movq %rax, -0x970(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x968(%rbp)
movq -0x548(%rbp), %rsi
leaq -0x588(%rbp), %rdi
callq 0x4150
jmp 0x1fdbd
movl -0x968(%rbp), %ecx
movq -0x970(%rbp), %rsi
movq -0x978(%rbp), %rdi
xorl %edx, %edx
leaq -0x588(%rbp), %r8
callq 0x168e0
jmp 0x1fde1
leaq -0x588(%rbp), %rdi
callq 0x41e0
movq -0x828(%rbp), %rax
movl -0x78(%rbp), %ecx
movl %ecx, -0x97c(%rbp)
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq -0x606(%rbp), %rdi
callq 0x170d0
jmp 0x1fe13
movl -0x97c(%rbp), %esi
leaq -0x600(%rbp), %rdi
leaq -0x606(%rbp), %rdx
movl $0x4, %ecx
movl $0x1, %r8d
callq 0x289d0
jmp 0x1fe39
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x70(%rcx), %rcx
movq %rcx, -0x998(%rbp)
addq $0x8, %rax
movq %rax, -0x990(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x988(%rbp)
leaq -0x628(%rbp), %rdi
leaq -0x600(%rbp), %rsi
callq 0x28bb0
jmp 0x1fe7a
movq -0x988(%rbp), %rdx
movq -0x990(%rbp), %rsi
movq -0x998(%rbp), %rdi
leaq -0x628(%rbp), %rcx
callq 0xcce0
jmp 0x1fe9d
leaq -0x628(%rbp), %rdi
callq 0x41e0
leaq -0x600(%rbp), %rdi
callq 0x21280
jmp 0x1ffb9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x568(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x588(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1ff1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x628(%rbp), %rdi
callq 0x41e0
leaq -0x600(%rbp), %rdi
callq 0x21280
jmp 0x20883
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0x9b0(%rbp)
addq $0x8, %rax
movq %rax, -0x9a8(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x99c(%rbp)
movq -0x548(%rbp), %rsi
leaq -0x648(%rbp), %rdi
callq 0x4150
jmp 0x1ff6a
movl -0x99c(%rbp), %ecx
movq -0x9a8(%rbp), %rsi
movq -0x9b0(%rbp), %rdi
xorl %edx, %edx
leaq -0x648(%rbp), %r8
callq 0x16da0
jmp 0x1ff8e
leaq -0x648(%rbp), %rdi
callq 0x41e0
jmp 0x1ffb9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x648(%rbp), %rdi
callq 0x41e0
jmp 0x20883
jmp 0x20869
movq -0x828(%rbp), %rdi
subq $-0x80, %rdi
leaq -0x78(%rbp), %rsi
callq 0x215a0
movq %rax, -0x9b8(%rbp)
jmp 0x1ffdb
movq -0x828(%rbp), %rdi
movq -0x9b8(%rbp), %rax
movq %rax, -0x650(%rbp)
addq $0x80, %rdi
callq 0x21600
movq %rax, -0x658(%rbp)
leaq -0x650(%rbp), %rdi
leaq -0x658(%rbp), %rsi
callq 0x215d0
testb $0x1, %al
jne 0x2001f
jmp 0x2033a
leaq -0x650(%rbp), %rdi
movq %rdi, -0x9c8(%rbp)
callq 0x21630
movq -0x9c8(%rbp), %rdi
addq $0x10, %rax
movq %rax, -0x660(%rbp)
callq 0x21630
movq -0x9c8(%rbp), %rdi
addq $0x30, %rax
movq %rax, -0x668(%rbp)
callq 0x21630
addq $0x58, %rax
movq %rax, -0x670(%rbp)
movq 0x19f56(%rip), %rdi     # 0x39fc8
leaq 0xacac(%rip), %rsi      # 0x2ad25
callq 0x42f0
movq %rax, -0x9c0(%rbp)
jmp 0x20087
movq -0x828(%rbp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq -0x690(%rbp), %rdi
callq 0x12740
jmp 0x200a4
movq -0x9c0(%rbp), %rdi
leaq -0x690(%rbp), %rsi
callq 0x42a0
movq %rax, -0x9d0(%rbp)
jmp 0x200c0
movq -0x9d0(%rbp), %rdi
leaq 0xac4d(%rip), %rsi      # 0x2ad1b
callq 0x42f0
movq %rax, -0x9d8(%rbp)
jmp 0x200dc
leaq -0x80(%rbp), %rsi
leaq -0x6b0(%rbp), %rdi
callq 0x12740
jmp 0x200ee
movq -0x9d8(%rbp), %rdi
leaq -0x6b0(%rbp), %rsi
callq 0x42a0
movq %rax, -0x9e0(%rbp)
jmp 0x2010a
movq -0x9e0(%rbp), %rdi
leaq 0xa5ae(%rip), %rsi      # 0x2a6c6
callq 0x42f0
movq %rax, -0x9e8(%rbp)
jmp 0x20126
movq -0x9e8(%rbp), %rdi
movq -0x660(%rbp), %rsi
callq 0x42a0
movq %rax, -0x9f0(%rbp)
jmp 0x20142
movq -0x9f0(%rbp), %rdi
leaq 0xabf0(%rip), %rsi      # 0x2ad40
callq 0x42f0
movq %rax, -0x9f8(%rbp)
jmp 0x2015e
movq -0x9f8(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x42a0
movq %rax, -0xa00(%rbp)
jmp 0x2017a
movq -0xa00(%rbp), %rdi
leaq 0xa1bd(%rip), %rsi      # 0x2a345
callq 0x42f0
jmp 0x2018f
leaq -0x6b0(%rbp), %rdi
callq 0x41e0
leaq -0x690(%rbp), %rdi
callq 0x41e0
movq -0x668(%rbp), %rdi
callq 0x4550
testb $0x1, %al
jne 0x201b9
jmp 0x20207
leaq -0xa0(%rbp), %rsi
movq -0x668(%rbp), %rdi
callq 0x4050
jmp 0x201ce
jmp 0x20207
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x201f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x6b0(%rbp), %rdi
callq 0x41e0
leaq -0x690(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq -0x670(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x670(%rbp), %rax
cmpq $0x2, (%rax)
jb 0x20338
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0xa18(%rbp)
addq $0x8, %rax
movq %rax, -0xa10(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0xa04(%rbp)
movq -0x660(%rbp), %rsi
leaq -0x6d0(%rbp), %rdi
callq 0x4150
jmp 0x20268
movq -0x668(%rbp), %rsi
leaq -0x6f0(%rbp), %rdi
callq 0x4150
jmp 0x2027d
movl -0xa04(%rbp), %ecx
movq -0xa10(%rbp), %rsi
movq -0xa18(%rbp), %rdi
movl $0x1, %edx
leaq -0x6d0(%rbp), %r8
leaq -0x6f0(%rbp), %r9
callq 0x16640
jmp 0x202ab
leaq -0x6f0(%rbp), %rdi
callq 0x41e0
leaq -0x6d0(%rbp), %rdi
callq 0x41e0
movq -0x828(%rbp), %rdi
subq $-0x80, %rdi
movq -0x650(%rbp), %rax
movq %rax, -0x6f8(%rbp)
movq -0x6f8(%rbp), %rsi
callq 0x21650
movq %rax, -0xa20(%rbp)
jmp 0x202f1
movq -0xa20(%rbp), %rax
movq %rax, -0x700(%rbp)
jmp 0x20338
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x20327
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x6f0(%rbp), %rdi
callq 0x41e0
leaq -0x6d0(%rbp), %rdi
callq 0x41e0
jmp 0x20883
jmp 0x2033a
jmp 0x20869
movq -0x828(%rbp), %rdi
subq $-0x80, %rdi
leaq -0x78(%rbp), %rsi
callq 0x215a0
movq %rax, -0xa28(%rbp)
jmp 0x2035c
movq -0x828(%rbp), %rdi
movq -0xa28(%rbp), %rax
movq %rax, -0x708(%rbp)
addq $0x80, %rdi
callq 0x21600
movq %rax, -0x710(%rbp)
leaq -0x708(%rbp), %rdi
leaq -0x710(%rbp), %rsi
callq 0x215d0
testb $0x1, %al
jne 0x203a0
jmp 0x20865
leaq -0x708(%rbp), %rdi
callq 0x21630
addq $0x8, %rax
movq %rax, -0x718(%rbp)
movq -0x718(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x720(%rbp)
movq -0x718(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x728(%rbp)
movq -0x718(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x730(%rbp)
movq 0x19bd4(%rip), %rdi     # 0x39fc8
leaq 0xa947(%rip), %rsi      # 0x2ad42
callq 0x42f0
movq %rax, -0xa30(%rbp)
jmp 0x20409
movq -0x828(%rbp), %rax
movq 0x60(%rax), %rsi
addq $0x8, %rsi
leaq -0x750(%rbp), %rdi
callq 0x12740
jmp 0x20426
movq -0xa30(%rbp), %rdi
leaq -0x750(%rbp), %rsi
callq 0x42a0
movq %rax, -0xa38(%rbp)
jmp 0x20442
movq -0xa38(%rbp), %rdi
leaq 0xa8cb(%rip), %rsi      # 0x2ad1b
callq 0x42f0
movq %rax, -0xa40(%rbp)
jmp 0x2045e
leaq -0x80(%rbp), %rsi
leaq -0x770(%rbp), %rdi
callq 0x12740
jmp 0x20470
movq -0xa40(%rbp), %rdi
leaq -0x770(%rbp), %rsi
callq 0x42a0
movq %rax, -0xa48(%rbp)
jmp 0x2048c
movq -0xa48(%rbp), %rdi
leaq 0xa22c(%rip), %rsi      # 0x2a6c6
callq 0x42f0
movq %rax, -0xa50(%rbp)
jmp 0x204a8
movq -0xa50(%rbp), %rdi
movq -0x720(%rbp), %rsi
callq 0x42a0
movq %rax, -0xa58(%rbp)
jmp 0x204c4
movq -0xa58(%rbp), %rdi
leaq 0xa86e(%rip), %rsi      # 0x2ad40
callq 0x42f0
movq %rax, -0xa60(%rbp)
jmp 0x204e0
movq -0xa60(%rbp), %rdi
movq -0x728(%rbp), %rsi
callq 0x42a0
movq %rax, -0xa68(%rbp)
jmp 0x204fc
movq -0xa68(%rbp), %rdi
leaq 0xa836(%rip), %rsi      # 0x2ad40
callq 0x42f0
movq %rax, -0xa70(%rbp)
jmp 0x20518
movq -0xa70(%rbp), %rdi
movl -0xc8(%rbp), %esi
callq 0x4560
movq %rax, -0xa78(%rbp)
jmp 0x20533
movq -0xa78(%rbp), %rdi
leaq 0x9e04(%rip), %rsi      # 0x2a345
callq 0x42f0
jmp 0x20548
leaq -0x770(%rbp), %rdi
callq 0x41e0
leaq -0x750(%rbp), %rdi
callq 0x41e0
movq -0x730(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x730(%rbp), %rax
cmpq $0x2, (%rax)
jb 0x20863
movq -0x718(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x2069f
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0xa90(%rbp)
addq $0x8, %rax
movq %rax, -0xa88(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0xa7c(%rbp)
movq -0x720(%rbp), %rsi
leaq -0x790(%rbp), %rdi
callq 0x4150
jmp 0x205d1
movq -0x728(%rbp), %rsi
leaq -0x7b0(%rbp), %rdi
callq 0x4150
jmp 0x205e6
movl -0xa7c(%rbp), %ecx
movq -0xa88(%rbp), %rsi
movq -0xa90(%rbp), %rdi
movl $0x1, %edx
leaq -0x790(%rbp), %r8
leaq -0x7b0(%rbp), %r9
callq 0x164f0
jmp 0x20614
leaq -0x7b0(%rbp), %rdi
callq 0x41e0
leaq -0x790(%rbp), %rdi
callq 0x41e0
jmp 0x20827
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x20657
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x770(%rbp), %rdi
callq 0x41e0
leaq -0x750(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2068e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x7b0(%rbp), %rdi
callq 0x41e0
leaq -0x790(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq -0x718(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x20785
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0xaa8(%rbp)
addq $0x8, %rax
movq %rax, -0xaa0(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0xa94(%rbp)
movq -0x720(%rbp), %rsi
leaq -0x7d0(%rbp), %rdi
callq 0x4150
jmp 0x206ee
movq -0x728(%rbp), %rsi
leaq -0x7f0(%rbp), %rdi
callq 0x4150
jmp 0x20703
movl -0xa94(%rbp), %ecx
movq -0xaa0(%rbp), %rsi
movq -0xaa8(%rbp), %rdi
movl $0x1, %edx
leaq -0x7d0(%rbp), %r8
leaq -0x7f0(%rbp), %r9
callq 0x16790
jmp 0x20731
leaq -0x7f0(%rbp), %rdi
callq 0x41e0
leaq -0x7d0(%rbp), %rdi
callq 0x41e0
jmp 0x20825
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x20774
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x7f0(%rbp), %rdi
callq 0x41e0
leaq -0x7d0(%rbp), %rdi
callq 0x41e0
jmp 0x20883
movq -0x718(%rbp), %rax
cmpl $0x3, (%rax)
jne 0x20823
movq -0x828(%rbp), %rcx
movq 0x60(%rcx), %rax
movq 0x78(%rcx), %rcx
movq %rcx, -0xac0(%rbp)
addq $0x8, %rax
movq %rax, -0xab8(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0xaac(%rbp)
movq -0x720(%rbp), %rsi
leaq -0x810(%rbp), %rdi
callq 0x4150
jmp 0x207d4
movl -0xaac(%rbp), %ecx
movq -0xab8(%rbp), %rsi
movq -0xac0(%rbp), %rdi
movl $0x1, %edx
leaq -0x810(%rbp), %r8
callq 0x168e0
jmp 0x207fb
leaq -0x810(%rbp), %rdi
callq 0x41e0
jmp 0x20823
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x810(%rbp), %rdi
callq 0x41e0
jmp 0x20883
jmp 0x20825
jmp 0x20827
movq -0x828(%rbp), %rdi
subq $-0x80, %rdi
movq -0x708(%rbp), %rax
movq %rax, -0x818(%rbp)
movq -0x818(%rbp), %rsi
callq 0x21650
movq %rax, -0xac8(%rbp)
jmp 0x20855
movq -0xac8(%rbp), %rax
movq %rax, -0x820(%rbp)
jmp 0x20865
jmp 0x20869
jmp 0x20869
leaq -0xc8(%rbp), %rdi
callq 0x21280
leaq -0x38(%rbp), %rdi
callq 0x41e0
jmp 0x1f0aa
leaq -0xc8(%rbp), %rdi
callq 0x21280
leaq -0x38(%rbp), %rdi
callq 0x41e0
jmp 0x208a3
addq $0xad0, %rsp            # imm = 0xAD0
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x4570
nopl (%rax)