// File: /workspace/github_cpp_makefile_star2_O2/richardposner[P]BioNetFit2/src/code/Pheromones.cpp
// Function: Pheromones::recvMessage(int, int, int, bool, std::unordered_multimap<int, Pheromones::swarmMessage, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, Pheromones::swarmMessage>>>&, bool, int)
int Pheromones::recvMessage(signed int senderID, const int receiverID, int tag, bool block, swarmMsgHolder &messageHolder, bool eraseMessage, int messageID) {
	int numMessages = 0;
	std::string serializedMessage; //Raquel: moved this from inside the loop to here so it's not redeclared
	swarmMessage smessage;

	if (swarm_->options.useCluster) {
		//swarmMessage smessage;
		//std::string serializedMessage;
		//cout << "RRR recvMessage senderID: " << senderID << " receiverID: " << receiverID << " tag: " << tag <<endl;
		std::string msg;
		MPI_Status status;
		int flag = 0;

		while (1) {
			//std::cout << "rcv loop" << std::endl;
			//usleep(10000);

			MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &flag, &status);
			//MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
			//if(status == MPI_SUCCESS)
			if (flag==1) {
				//cout << "status tag: " << recvStatus->tag() << std::endl;
				//cout << "status source: " << recvStatus->source() << std::endl;
				//boost::optional<int> msgLength = recvStatus->count<char>();
				//char smChar[*msgLength];
				//char smChar[MAX_SWARM_MESSAGE_SIZE];
				//cout << "recvStatus->tag() " << recvStatus->tag() << " DONE_BREEDING " << DONE_BREEDING << endl;
				int count;

				MPI_Get_count(&status, MPI_CHAR, &count);


				if (swarm_->options.verbosity>=3) {
					cout << "message size " << count << endl;
				}
				//if (block) 
				if (swarm_->options.verbosity>=3) {
					cout << "trying a blocking receive to receiverID " << receiverID << " from senderID " << senderID  << endl;
				}
				//cout << "Tag: " << tag << "; smChar length: " << sizeof(smChar) << "; *msgLength: " << *msgLength << endl;
				//world_->recv(senderID, tag, smChar, *msgLength);
				//world_->recv(senderID, recvStatus->tag(), smChar, *msgLength);
					//world_->recv(senderID, recvStatus->tag(), msg);
				char *buffer = new char[count + 1];
				MPI_Recv(buffer, count, MPI_CHAR, status.MPI_SOURCE, status.MPI_TAG, MPI_COMM_WORLD, &status);
				buffer[count] = '\0';
				msg = std::string(buffer);
				delete [] buffer;
				//cout <<"RRR received message is smChar = " << smChar << endl;
				if (swarm_->options.verbosity>=3) {
					cout <<"RRR received message is = " << msg << endl;
					cout << "Message size is " << msg.length() << endl;
				}
				//world_->recv(boost::mpi::any_source, tag, *msgLength);
				block = false;
			    if (swarm_->options.verbosity>=3) {

			    	cout << "RRR passed receive step." << endl;
			    }

				//smessage = deserializeSwarmMessage(std::string(smChar));
				if(msg.length()>0){
					smessage = deserializeSwarmMessage(msg);


				}else{
				    if (swarm_->options.verbosity>=3) {

				    	cout << "MESSAGE EMPTY!!!" << endl;
				    }
					//smessage.tag = std::to_string(recvStatus->tag());
					//smessage.sender = senderID;
					//smessage.id = messageID;
				}
			    if (swarm_->options.verbosity>=3) {

			    	cout << "RRR deserialized message" << endl;
			    }
				msg.clear();
			    if (swarm_->options.verbosity>=3) {

			    	cout << "Cleaned serialized message" << endl;
			    }
				// If we have any messages in our messageHolder, let's process them
				//std::cout << "messageholder not empty: " << smessage.tag << ":" << smessage.sender << std::endl;

				// Make sure our message matches the sender, tag, and id we requested
				if ( (tag == -1 || tag == stoi(smessage.tag)) && (senderID == -1 || senderID == smessage.sender) && (messageID == -1 || messageID == smessage.id)) {
					// Insert the message into our message holder and increment numMessages
				    if (swarm_->options.verbosity>=3) {

				    	std::cout << "inserting message in the holder" << std::endl;
				    }
					messageHolder.insert(std::pair<int, swarmMessage>(stoi(smessage.tag), smessage));

					++numMessages;

					// If user doesn't want to erase the message, put it back in the queue
					if (!eraseMessage) {
					    if (swarm_->options.verbosity>=3) {

					    	std::cout << "Not erasing message" << std::endl;
					    }
						sendToSwarm(senderID, receiverID, stoi(smessage.tag), false, smessage.message);
					}

					// Clear out the smessage for next use
					clearSwarmMessage(smessage);
				}
				else {
				    if (swarm_->options.verbosity>=3) {

				    	std::cout << "putting it back in the queue..." << std::endl;
				    	std::cout << "@@@@@@@@@@@@@@@@@@@@@@@ Expected: " << tag << "; Received: " << smessage.tag << "@@@@@@@@@@@@@@@@@@@@@@@@@@" << std::endl;
				    }
					sendToSwarm(smessage.sender, receiverID, stoi(smessage.tag), false, smessage.message);

					if(tag == DONE_BREEDING && stoi(smessage.tag) == SIMULATION_END ){

						if(swarm_->options.verbosity >= 3){
							std::cout << "SENDER REINSERTED = " << smessage.sender << endl;
						}
						swarm_->fixRunningParticle(smessage.sender);

						std::vector<unsigned int> NewlyFinishedParticles = swarm_->checkMasterMessages();

						for(auto i = NewlyFinishedParticles.begin(); i!=NewlyFinishedParticles.end(); ++i){
							if (swarm_->options.verbosity>=3) {
						    	std::cout << "@@@@@@@@@@@@@@@@@@@@@@@ PROCESSING LATE PAR: " << *i << std::endl;
						    	std::cout << "from pheromones: " << swarm_->subparticleCurrParamSets_.size() << std::endl;
						    }
							std::map<std::string,double> mysimParams;
							int mid = fcalcMID(*i, swarm_->options.models.size());
							int pID = fcalcParID(*i, swarm_->options.models.size());

							auto fp = swarm_->options.models.at(mid)->freeParams_.begin();

							for (unsigned int j = 0; j < swarm_->subparticleCurrParamSets_[pID][mid].size(); j++) {
//								std::map<unsigned int, std::map<unsigned int, std::vector<double> > > subparticleCurrParamSets_;   //razi: PID, MID, PARAMA VALUESS

								//paramSet.insert(pair<string, double> (fp->first, subparticleCurrParamSets_[bestP][mid][i])); //make this work later, to clone the best particle
								mysimParams.insert(pair<std::string, double> (fp->first, swarm_->subparticleCurrParamSets_[pID][mid][j]));

								++fp;
							}
							swarm_->processLateParticles(mysimParams, *i, true, 0);

						}



					}
				}

				break;
			}
			else if (!block) {
				break;
			}
		}
	}
	else {
		//cout << "RAQUEL entering recvMessage entering while loop" << endl;
		//cout << "RAQUEL receiver ID: " << receiverID << " senderID: " << senderID << endl;
		unsigned int priority = 0;

		while(1) {
			//cout << "RAQUEL inside recvMessage entered while loop" << endl;

			message_queue::size_type recvd_size;

			char buffer[MAX_SWARM_MESSAGE_SIZE];
			//std::cout << "rcv loop" << std::endl;
			if (block) {
//std::cout << "trying a blocking receive to " << receiverID << " from " << senderID << std::endl;

				smq_[receiverID]->receive(buffer, sizeof(buffer), recvd_size, priority);
				buffer[recvd_size] = '\0';


				block = false;
//std::cout << "blocking receive to " << receiverID << " from " << senderID << " succeeded with recv_size of " << recvd_size << " and message of " << buffer << std::endl;
			}
			else {

//std::cout << "trying a non-blocking receive to " << receiverID << " from " << senderID << std::endl;
				bool hasMessage = smq_[receiverID]->try_receive(buffer, sizeof(buffer), recvd_size, priority);
				buffer[recvd_size] = '\0';

//std::cout << "non-blocking receive to " << receiverID << " from " << senderID << " succeeded with recv_size of " << recvd_size << " and bool of " << hasMessage << std::endl;
				if (!hasMessage) {
//std::cout << "breaking" << std::endl;
					break;
				}
			}
			// If we have any messages in our messageHolder, let's process them

			// De-serialize the smessage
			swarmMessage smessage = deserializeSwarmMessage(buffer);


sleep(1);

			//razi: uncomment later
			//std::cout << "smessage not empty: " << smessage.tag << std::endl;
			//std::cout << "tag: " << tag << ":" << smessage.tag << std::endl;
			//std::cout << "sender: " << tag << ":" << smessage.sender << std::endl;
			//std::cout << "id: " << tag << ":" << smessage.id << std::endl;

			// Make sure our message matches the sender, tag, and id we requested
			if ( (tag == -1 || stoi(smessage.tag) == tag) && (senderID == -1 || senderID == smessage.sender) && (messageID == -1 || messageID == smessage.id)) {
				// Insert the message into our message holder and increment numMessages
				messageHolder.insert(std::pair<int, swarmMessage>(stoi(smessage.tag), smessage));
//std::cout << "storing pair with tag of " << stoi(smessage.tag) << std::endl;
				++numMessages;

				// If user doesn't want to erase the message, put it back in the queue
				if (!eraseMessage) {
					//std::cout << "noerase" << std::endl;
					sendToSwarm(senderID, receiverID, tag, false, smessage.message);
				}
			}
			else {
				// If this isn't our message, put it back in the queue. This will go SLOW
				// unless we use a different queue for every particle

//std::cout << "putting it back in the queue..." << std::endl;
				sendToSwarm(smessage.sender, receiverID, stoi(smessage.tag), false, smessage.message, smessage.id);

				if (!block) {
					break;
				}
			}
		}
	}
	//cout << "RAQUEL inside recvMessage exiting with num messages: " << numMessages << endl;

	return numMessages;





}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5b8, %rsp            # imm = 0x5B8
movq %r9, 0x40(%rsp)
movl %r8d, %r13d
movl %ecx, 0x18(%rsp)
movl %esi, 0x10(%rsp)
leaq 0x170(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0xc8(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
xorps %xmm0, %xmm0
andq $0x0, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movq 0x50(%rdi), %rax
cmpb $0x1, 0x1631(%rax)
movq %rdi, 0x28(%rsp)
movl %edx, 0x14(%rsp)
jne 0x610a1
movq %rdi, %rbx
pushq $0x1
popq %rax
movq %rax, 0x20(%rsp)
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0x3c(%rsp), %r14
andl $0x0, (%r14)
movb $0x0, (%rax)
movq 0x104ef0(%rip), %r15    # 0x165f60
pushq $-0x1
popq %rbp
leaq 0x60(%rsp), %r12
movl %ebp, %edi
movl %ebp, %esi
movq %r15, %rdx
movq %r14, %rcx
movq %r12, %r8
callq 0x28520
cmpl $0x1, 0x3c(%rsp)
je 0x612a3
testb %r13b, %r13b
jne 0x61078
xorl %ebx, %ebx
jmp 0x619ef
movq $0x0, 0x20(%rsp)
leaq 0x48(%rsp), %rax
andl $0x0, (%rax)
movslq %edx, %rbx
leaq 0x1d0(%rsp), %rbp
leaq 0x180(%rsp), %r12
leaq 0x78(%rsp), %r15
movq 0x28(%rsp), %rax
movq 0x68(%rax), %rax
movq (%rax,%rbx,8), %rdi
testb $0x1, %r13b
je 0x61106
movl $0x3e8, %edx            # imm = 0x3E8
movq %rbp, %rsi
leaq 0x60(%rsp), %rcx
leaq 0x48(%rsp), %r8
callq 0x61ce6
movq 0x60(%rsp), %rax
movb $0x0, 0x1d0(%rsp,%rax)
xorl %r13d, %r13d
jmp 0x61132
movl $0x3e8, %edx            # imm = 0x3E8
movq %rbp, %rsi
leaq 0x60(%rsp), %rcx
leaq 0x48(%rsp), %r8
callq 0x61e74
movq 0x60(%rsp), %rcx
movb $0x0, 0x1d0(%rsp,%rcx)
testb %al, %al
je 0x61299
movq %r12, %rdi
movq %rbp, %rsi
leaq 0xf8(%rsp), %rdx
callq 0x33402
movq %r15, %rdi
movq 0x28(%rsp), %rsi
movq %r12, %rdx
callq 0x60e6e
movq %r12, %rdi
callq 0x295a0
pushq $0x1
popq %rdi
callq 0x287a0
cmpl $-0x1, 0x18(%rsp)
je 0x61183
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3343d
cmpl 0x18(%rsp), %eax
jne 0x61247
movl 0x10(%rsp), %ecx
cmpl $-0x1, %ecx
sete %al
movl 0x9c(%rsp), %r14d
cmpl %ecx, %r14d
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x6124f
cmpl $-0x1, 0x5f8(%rsp)
je 0x611c4
movl 0x5f8(%rsp), %eax
cmpl %eax, 0x98(%rsp)
jne 0x6124f
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3343d
movl %eax, 0xf8(%rsp)
leaq 0x100(%rsp), %rdi
movq %r15, %rsi
callq 0x61c3c
movq 0x40(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x65bcc
leaq 0x100(%rsp), %rdi
callq 0x5d216
movq 0x20(%rsp), %rax
incl %eax
movq %rax, 0x20(%rsp)
movb $0x1, %r14b
cmpb $0x0, 0x5f0(%rsp)
jne 0x61287
orl $-0x1, (%rsp)
movq 0x28(%rsp), %rdi
movl 0x10(%rsp), %esi
movl 0x14(%rsp), %edx
movl 0x18(%rsp), %ecx
xorl %r8d, %r8d
leaq 0xa0(%rsp), %r9
callq 0x600c8
jmp 0x61287
movl 0x9c(%rsp), %r14d
movq %r15, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3343d
movl 0x98(%rsp), %ecx
movl %ecx, (%rsp)
movq 0x28(%rsp), %rdi
movl %r14d, %esi
movl 0x14(%rsp), %edx
movl %eax, %ecx
xorl %r8d, %r8d
leaq 0xa0(%rsp), %r9
callq 0x600c8
movl %r13d, %r14d
movq %r15, %rdi
callq 0x5d216
testb $0x1, %r14b
jne 0x610ca
movq 0x20(%rsp), %rbx
jmp 0x619f9
movq 0x104c9e(%rip), %rsi    # 0x165f48
leaq 0x60(%rsp), %r14
leaq 0x30(%rsp), %rdx
movq %r14, %rdi
callq 0x28e80
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x6133f
movq 0x104cc8(%rip), %rdi    # 0x165f98
leaq 0x787b2(%rip), %rsi     # 0xd9a89
callq 0x289f0
movl 0x30(%rsp), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
callq 0x284a0
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x6133f
movq 0x104c94(%rip), %rdi    # 0x165f98
leaq 0x7878c(%rip), %rsi     # 0xd9a97
callq 0x289f0
movq %rax, %rdi
movl 0x14(%rsp), %esi
callq 0x29290
leaq 0x7879d(%rip), %rsi     # 0xd9ac0
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
movl 0x10(%rsp), %esi
callq 0x29290
movq %rax, %rdi
callq 0x284a0
movslq 0x30(%rsp), %r12
leaq 0x1(%r12), %rdi
callq 0x28040
movq %rax, %r15
movl 0x60(%rsp), %ecx
movl 0x64(%rsp), %r8d
movq %r14, (%rsp)
movq 0x104be3(%rip), %rdx    # 0x165f48
movq 0x104bf4(%rip), %r9     # 0x165f60
movq %rax, %rdi
movl %r12d, %esi
callq 0x28840
movslq 0x30(%rsp), %rax
movb $0x0, (%r15,%rax)
leaq 0x1d0(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
movq %r15, %rsi
callq 0x33402
leaq 0x78(%rsp), %rdi
leaq 0x1d0(%rsp), %r14
movq %r14, %rsi
callq 0x28c40
movq %r14, %rdi
callq 0x295a0
movq %r15, %rdi
callq 0x28cf0
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x61446
movq 0x104bc6(%rip), %rdi    # 0x165f98
leaq 0x786f7(%rip), %rsi     # 0xd9ad0
callq 0x289f0
leaq 0x78(%rsp), %rsi
movq %rax, %rdi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movq 0x104b9e(%rip), %rdi    # 0x165f98
leaq 0x786ea(%rip), %rsi     # 0xd9aeb
callq 0x289f0
movq 0x80(%rsp), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x61446
movq 0x104b66(%rip), %rdi    # 0x165f98
leaq 0x786c3(%rip), %rsi     # 0xd9afc
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
cmpq $0x0, 0x80(%rsp)
je 0x614aa
leaq 0x140(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x28dd0
leaq 0x1d0(%rsp), %rdi
leaq 0x140(%rsp), %rdx
movq %rbx, %rsi
callq 0x60e6e
leaq 0xb8(%rsp), %rdi
leaq 0x1d0(%rsp), %r14
movq %r14, %rsi
callq 0x61d84
movq %r14, %rdi
callq 0x5d216
leaq 0x140(%rsp), %rdi
callq 0x295a0
jmp 0x614d2
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x614d2
movq 0x104ada(%rip), %rdi    # 0x165f98
leaq 0x78650(%rip), %rsi     # 0xd9b15
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x614fa
movq 0x104ab2(%rip), %rdi    # 0x165f98
leaq 0x78639(%rip), %rsi     # 0xd9b26
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
andq $0x0, 0x80(%rsp)
movq 0x78(%rsp), %rax
movb $0x0, (%rax)
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x61533
movq 0x104a79(%rip), %rdi    # 0x165f98
leaq 0x78619(%rip), %rsi     # 0xd9b3f
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
cmpl $-0x1, 0x18(%rsp)
je 0x61552
leaq 0xb8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x3343d
cmpl 0x18(%rsp), %eax
jne 0x61588
cmpl $-0x1, 0x10(%rsp)
je 0x61566
movl 0x10(%rsp), %eax
cmpl %eax, 0xdc(%rsp)
jne 0x61588
cmpl $-0x1, 0x5f8(%rsp)
je 0x61908
movl 0x5f8(%rsp), %eax
cmpl %eax, 0xd8(%rsp)
je 0x61908
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x61605
movq 0x1049fc(%rip), %rdi    # 0x165f98
leaq 0x785eb(%rip), %rsi     # 0xd9b8e
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x1049e1(%rip), %rdi    # 0x165f98
leaq 0x785f0(%rip), %rsi     # 0xd9bae
callq 0x289f0
movq %rax, %rdi
movl 0x18(%rsp), %esi
callq 0x29290
leaq 0x785fb(%rip), %rsi     # 0xd9bd1
movq %rax, %rdi
callq 0x289f0
leaq 0xb8(%rsp), %rsi
movq %rax, %rdi
callq 0x28910
leaq 0x7c2d5(%rip), %rsi     # 0xdd8ca
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0xb8(%rsp), %rdi
movl 0x24(%rdi), %ebp
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x3343d
orl $-0x1, (%rsp)
movq $0x0, 0x20(%rsp)
movq %rbx, %rdi
movl %ebp, %esi
movl 0x14(%rsp), %edx
movl %eax, %ecx
xorl %r8d, %r8d
leaq 0xe0(%rsp), %r9
callq 0x600c8
cmpl $0x11, 0x18(%rsp)
jne 0x619ea
movq $0x0, 0x20(%rsp)
leaq 0xb8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x3343d
cmpl $0xd, %eax
jne 0x619ea
movq 0x50(%rbx), %rdi
cmpl $0x3, 0x1614(%rdi)
jb 0x616ac
movq 0x104913(%rip), %rdi    # 0x165f98
leaq 0x78552(%rip), %rsi     # 0xd9bde
callq 0x289f0
movl 0xdc(%rsp), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
callq 0x284a0
movq 0x50(%rbx), %rdi
movl 0xdc(%rsp), %esi
callq 0x7bbe4
movq 0x50(%rbx), %rsi
leaq 0x48(%rsp), %rdi
callq 0x770c4
movq 0x48(%rsp), %r12
leaq 0xf8(%rsp), %r13
leaq 0x34(%rsp), %rbp
cmpq 0x50(%rsp), %r12
je 0x618f0
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x61749
movq 0x1048a1(%rip), %rdi    # 0x165f98
leaq 0x784f5(%rip), %rsi     # 0xd9bf3
callq 0x289f0
movl (%r12), %esi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0x10487a(%rip), %rdi    # 0x165f98
leaq 0x784fc(%rip), %rsi     # 0xd9c21
callq 0x289f0
movq 0x50(%rbx), %rcx
movq 0x1488(%rcx), %rsi
movq %rax, %rdi
callq 0x286e0
movq %rax, %rdi
callq 0x284a0
movq 0x50(%rbx), %rax
andl $0x0, 0x1d8(%rsp)
andq $0x0, 0x1e0(%rsp)
leaq 0x1d8(%rsp), %rcx
movq %rcx, 0x1e8(%rsp)
movq %rcx, 0x1f0(%rsp)
andq $0x0, 0x1f8(%rsp)
movl (%r12), %edi
movq 0x15c8(%rax), %rsi
subq 0x15c0(%rax), %rsi
shrq $0x3, %rsi
callq 0x9ec14
movl %eax, %r14d
movl (%r12), %edi
movq 0x50(%rbx), %rax
movq 0x15c8(%rax), %rsi
subq 0x15c0(%rax), %rsi
shrq $0x3, %rsi
callq 0x9ec1e
movl %eax, %r15d
movq %r12, 0x18(%rsp)
movq 0x50(%rbx), %rdi
movl $0x15c0, %eax           # imm = 0x15C0
addq %rax, %rdi
movslq %r14d, %rsi
callq 0x3374c
movq (%rax), %rax
movq 0x48(%rax), %r12
xorl %ebx, %ebx
movq 0x28(%rsp), %rax
movq 0x50(%rax), %rdi
movl $0x1460, %eax           # imm = 0x1460
addq %rax, %rdi
movl %r15d, 0xf8(%rsp)
movq %r13, %rsi
callq 0x61db6
movl %r14d, 0x34(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x61e04
movl %ebx, %ebx
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0x61892
movq 0x28(%rsp), %rax
movq 0x50(%rax), %rdi
movl $0x1460, %eax           # imm = 0x1460
addq %rax, %rdi
movl %r15d, 0x34(%rsp)
movq %rbp, %rsi
callq 0x61db6
movl %r14d, 0x38(%rsp)
movq %rax, %rdi
leaq 0x38(%rsp), %rsi
callq 0x61e04
leaq 0x20(%r12), %rsi
leaq (,%rbx,8), %rdx
addq (%rax), %rdx
movq %r13, %rdi
callq 0x61e52
leaq 0x1d0(%rsp), %rdi
movq %r13, %rsi
callq 0x4bce2
movq %r13, %rdi
callq 0x295a0
movq %r12, %rdi
callq 0x28700
movq %rax, %r12
incl %ebx
jmp 0x617dd
movq 0x28(%rsp), %rbx
movq 0x50(%rbx), %r14
leaq 0x1a0(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x4e96a
movq 0x18(%rsp), %r12
movl (%r12), %edx
movq %r14, %rdi
leaq 0x1a0(%rsp), %r14
movq %r14, %rsi
pushq $0x1
popq %rcx
xorl %r8d, %r8d
callq 0x787c4
movq %r14, %rdi
callq 0x495ac
leaq 0x1d0(%rsp), %rdi
callq 0x495ac
addq $0x4, %r12
jmp 0x616d8
leaq 0x48(%rsp), %rdi
callq 0x5b268
movq $0x0, 0x20(%rsp)
jmp 0x619ea
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x61930
movq 0x10467c(%rip), %rdi    # 0x165f98
leaq 0x78237(%rip), %rsi     # 0xd9b5a
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0xb8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x3343d
leaq 0x1d8(%rsp), %r14
movl %eax, -0x8(%r14)
leaq 0xb8(%rsp), %rsi
movq %r14, %rdi
callq 0x61c3c
leaq 0x1d0(%rsp), %rsi
movq 0x40(%rsp), %rdi
callq 0x65bcc
movq %r14, %rdi
callq 0x5d216
cmpb $0x0, 0x5f0(%rsp)
jne 0x619dd
movq 0x50(%rbx), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x619aa
movq 0x104602(%rip), %rdi    # 0x165f98
leaq 0x781dd(%rip), %rsi     # 0xd9b7a
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0xb8(%rsp), %rdi
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x3343d
orl $-0x1, (%rsp)
movq %rbx, %rdi
movl 0x10(%rsp), %esi
movl 0x14(%rsp), %edx
movl %eax, %ecx
xorl %r8d, %r8d
leaq 0xe0(%rsp), %r9
callq 0x600c8
leaq 0xb8(%rsp), %rsi
callq 0x61b12
movq 0x20(%rsp), %rbx
leaq 0x78(%rsp), %rdi
callq 0x295a0
leaq 0xb8(%rsp), %rdi
callq 0x5d216
leaq 0x160(%rsp), %rdi
callq 0x295a0
movl %ebx, %eax
addq $0x5b8, %rsp            # imm = 0x5B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
callq 0x5d216
jmp 0x61ae5
jmp 0x61a8d
jmp 0x61a8d
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x295a0
jmp 0x61ae5
jmp 0x61a8d
jmp 0x61a8d
jmp 0x61a8d
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
callq 0x495ac
jmp 0x61ace
jmp 0x61acb
jmp 0x61acb
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x5d216
jmp 0x61aa7
jmp 0x61acb
jmp 0x61aa4
jmp 0x61a8d
movq %rax, %rbx
jmp 0x61adb
jmp 0x61a92
jmp 0x61a92
movq %rax, %rbx
jmp 0x61ae5
movq %rax, %rbx
jmp 0x61aef
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
jmp 0x61aea
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x5d216
jmp 0x61aef
jmp 0x61acb
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x295a0
jmp 0x61ace
jmp 0x61acb
jmp 0x61acb
movq %rax, %rbx
leaq 0x1d0(%rsp), %rdi
callq 0x495ac
leaq 0x48(%rsp), %rdi
callq 0x5b268
leaq 0x78(%rsp), %rdi
callq 0x295a0
leaq 0xb8(%rsp), %rdi
callq 0x5d216
leaq 0x160(%rsp), %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x292f0
nop