// File: /workspace/github_cpp_makefile_star2_O2/richardposner[P]BioNetFit2/src/code/Pheromones.cpp
// Function: Pheromones::sendToSwarm(int, int, int, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, int)
void Pheromones::sendToSwarm(int senderID, signed int receiverID, int tag, bool block, std::vector<std::string> &message, int messageID) {
	// Using MPI
	if (swarm_->options.useCluster) {
		std::vector<int> receivers;

		// Find out rank, size
		int world_rank;
		MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
		int world_size;
		MPI_Comm_size(MPI_COMM_WORLD, &world_size);


		// Construct the swarmMessage
		swarmMessage smessage;
		smessage.sender = senderID;


		// Sending to the entire swarm
		if (receiverID == -1) {
			//std::cout << "sending to entire swarm because receiver is -1" << std::endl;

			// TODO: Replace this exchange with a world_->sendrecv()
			smessage.tag = toString(GET_RUNNING_PARTICLES);
			if (swarm_->options.verbosity>=3) {
				std::cout << "trying to get list of running particles.." << std::endl;
			// First we need to get a list of all running particles from the master
			}

			std::string serializedMessage = serializeSwarmMessage(smessage);
			if (swarm_->options.verbosity>=3) {
				cout << "RRR sending serializedMessage GET RUNNING PARTICLES 11 = " << serializedMessage << endl;
			}
			//world_->send(0, GET_RUNNING_PARTICLES, serializedMessage);
			MPI_Send(serializedMessage.c_str(), serializedMessage.length(), MPI_CHAR, 0, GET_RUNNING_PARTICLES, MPI_COMM_WORLD);

			//std::cout << "trying to receive list of running particles.." << std::endl;
			//usleep(10000);

			// This swarmMessage will hold the list of running particles received from master
			MPI_Status status;

			int count;
			MPI_Probe(0, 0, MPI_COMM_WORLD, &status);
			MPI_Get_count(&status, MPI_INT, &count);
			char *buffer = new char[count + 1];
			MPI_Recv(buffer, count, MPI_CHAR, 0, SEND_RUNNING_PARTICLES, MPI_COMM_WORLD, &status);
			buffer[count] = '\0';
			if (swarm_->options.verbosity>=3) {
				std::cout << "received list of running particles = " << buffer << std::endl;
			}
			swarmMessage rsmessage = deserializeSwarmMessage(std::string(buffer));
			delete [] buffer;

			//for (auto p: runningParticles) 
			for (auto p = rsmessage.message.begin(); p != rsmessage.message.end(); ++p) {
			    if (swarm_->options.verbosity>=3) {

			    	std::cout << "adding receiver: " << *p << std::endl;
			    }
				receivers.push_back(stoi(*p));
			}

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

		    	cout << "RRR sendToSwarm senderID: " << senderID << " receiverID: " << receiverID << " tag: " << tag << endl;

				std::cout << "Sending tag " << tag << " to: " << receiverID << std::endl;
		    }
			// If we're not sending to the entire swarm, put only the target pID into the receivers list
			receivers.push_back(receiverID);
		}

		smessage.tag = toString(tag);

		//for (auto m: mpiMessage) 
		for (auto m = message.begin(); m != message.end(); ++m) {
			//std::cout << "adding: " << *m << std::endl;
			smessage.message.push_back(*m);
		}

		std::string smString(serializeSwarmMessage(smessage));
		if (swarm_->options.verbosity>=3) {
			cout << "send message is smString = '" << smString << "'" << endl;
		}
		// Loop through receivers and perform the send operation
		for (std::vector<int>::iterator i = receivers.begin(); i != receivers.end(); ++i) {
			// Blocking send
		    int world_size;
		    MPI_Comm_size(MPI_COMM_WORLD, &world_size);

			if(receiverID < world_size){

				//usleep(10000);


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

				    	std::cout << "attempting a block send from " << senderID << " to " << receiverID << std::endl;
				    }
					try{
						MPI_Send(smString.c_str(), smString.length(), MPI_CHAR, receiverID, tag, MPI_COMM_WORLD);




					} catch (interprocess_exception& e) {
						cout << e.what( ) << std::endl;
			    	}
				    if (swarm_->options.verbosity>=3) {

				    	std::cout << "block send from " << senderID << " to " << receiverID << " succeeded" << std::endl;
				    }
				}
				// Non-blocking send
				else {
					if (swarm_->options.verbosity>=3) {
						std::cout << "attempting a non-block send from " << senderID << " to " << receiverID << std::endl;
					}

					int result = MPI_Send(smString.c_str(), smString.length(), MPI_CHAR, receiverID, tag, MPI_COMM_WORLD);
					if (swarm_->options.verbosity>=3) {
						if (result == MPI_SUCCESS){
							std::cout << "Rank " <<  world_rank << " sent message to " << receiverID << " tag: " << tag << " message: " << smString.c_str() << std::endl;
						}else{
							cout << "ERROR MESSAGE NOT SENT!!!" << endl;
						}
						std::cout << "non-block send from " << senderID << " to " << receiverID << " succeeded" << std::endl;
					}
					//recvStatus_ = recvRequest_.wait();
					//std::cout << "tag: " << recvStatus_.tag() << std::endl;
					//std::cout << "error: " << recvStatus_.error() << std::endl;
				}
			}
		}
	}else {
		// Using IPC
		std::vector<int> receivers;

		// Construct the swarmMessage
		swarmMessage smessage;
		smessage.sender = senderID;

		int nPar = 0; //Raquel: added a counter for debugging

		// Sending to the entire swarm
		if (receiverID == -1) {
			//std::cout << "sending to entire swarm because receiver is -1" << std::endl;
			// First we need to get a list of all running particles from the master

			// Set tag to tell master we need a list of running particles
			smessage.tag = toString(GET_RUNNING_PARTICLES);
			//std::cout << "trying to get list of running particles.." << std::endl;

			// Serialize the message
			std::string serializedMessage = serializeSwarmMessage(smessage);
			if (serializedMessage.length() > MAX_SWARM_MESSAGE_SIZE) {
				std::cout << "ERROR: Serialized Message length: " << serializedMessage.length() << " greater than MAX_SWARM_MESSAGE_SIZE" << std::endl;
				std::abort();
			}

			smq_[0]->send(serializedMessage.c_str(), serializedMessage.length(), 0);

			//std::cout << "trying to receive list of running particles.." << std::endl;

			// This swarmMessage will hold the list of running particles received from master

			message_queue::size_type recvd_size;

			// Receive and de-serialize the message
			char buffer[MAX_SWARM_MESSAGE_SIZE + 1];
			unsigned int priority;

			smq_[0]->receive(buffer, sizeof(buffer), recvd_size, priority);

			buffer[recvd_size] = '\0';
			swarmMessage rsmessage = deserializeSwarmMessage(buffer);

			//std::cout << "received list of running particles.." << std::endl;

			//for (auto p: runningParticles) 
			for (auto p = rsmessage.message.begin(); p != rsmessage.message.end(); ++p) {
				//std::cout << "adding receiver: " << *p << std::endl;
				receivers.push_back(stoi(*p));
				nPar++; //Raquel: added a counter for debugging

			}

			cout << "RAQUEL: Found " << nPar << " particles running." << endl; //Raquel: added for debugging

		}
		else {
			//std::cout << "Sending to: " << receiverID << std::endl;
			// If we're not sending to the entire swarm, put only the target pID into the receivers list
			receivers.push_back(receiverID);
		}

		// Set the message tag as specified by the sender
		smessage.tag = toString(tag);

		// Add the message array to the swarmMessage
		//for (auto m: mpiMessage) 
		for (auto m = message.begin(); m != message.end(); ++m) {
			//std::cout << senderID << " adding: " << *m << std::endl;
			smessage.message.push_back(*m);
		}

		// Set a random messageID
		if (messageID == -1) {
			messageID = rand();
		}

		smessage.id = messageID;

		// Serialize the swarmMessage
		std::string serializedMessage = serializeSwarmMessage(smessage);
		if (serializedMessage.length() > MAX_SWARM_MESSAGE_SIZE) {
			std::cout << "ERROR: Serialized Message length: " << serializedMessage.length() << " greater than MAX_SWARM_MESSAGE_SIZE" << std::endl;
			abort();
		}

		// Loop through receivers and perform the send operation
		for (std::vector<int>::iterator i = receivers.begin(); i != receivers.end(); ++i) {
			std::cout << "### " << senderID << " sending " << smessage.tag << " to " << *i	<< ". ser: " << serializedMessage << std::endl;
			//smq_[*i]->send(serializedMessage.data(), serializedMessage.size(), 0);
			//Raquel: added for debbuging
			bool sendAttempt2 = smq_[*i]->try_send(serializedMessage.data(), serializedMessage.size(), 0);


			if (sendAttempt2 == false){
				cout << "RAQUEL: queue was full when message was sent" << endl;

			}else{ cout << "RAQUEL: sending success" << endl; }
			
			//std::cout << "sent" << std::endl;
			if (block) {
				bool foundMessage = true;
				while (foundMessage) {
					//usleep(150000);
					//std::cout << senderID << "loop" << std::endl;

					// TODO: This non-erasing recvMessage might slow down the receiver finding the message since it
					// requires a re-send every time we check

					// If we're blocking, we need to repeatedly check to see if the message still exists in the queue
					if (recvMessage(senderID, receiverID, tag, false, univMessageReceiver, false, messageID)) {
						foundMessage = true;
					}
					else {
						foundMessage = false;
					}
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x628, %rsp            # imm = 0x628
movq %r9, 0x8(%rsp)
movl %r8d, 0x18(%rsp)
movl %ecx, %ebp
movl %esi, %r14d
movq %rdi, %r15
movl %edx, 0x10(%rsp)
movq 0x50(%rdi), %rax
cmpb $0x1, 0x1631(%rax)
jne 0x6021e
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movq 0x105e4b(%rip), %rdi    # 0x165f60
leaq 0x20(%rsp), %rsi
callq 0x28e40
movq 0x105e3a(%rip), %rdi    # 0x165f60
leaq 0x2c(%rsp), %rsi
callq 0x28b90
leaq 0x240(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
andq $0x0, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movl %r14d, 0x14(%rax)
cmpl $-0x1, 0x10(%rsp)
je 0x6039c
movq 0x50(%r15), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x6020a
movq 0x105e21(%rip), %rdi    # 0x165f98
leaq 0x7975c(%rip), %rsi     # 0xd98da
callq 0x289f0
movq %rax, %rdi
movl %r14d, %esi
callq 0x29290
leaq 0x79760(%rip), %rsi     # 0xd98f5
movq %rax, %rdi
callq 0x289f0
movl 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x29290
leaq 0x79753(%rip), %rsi     # 0xd9903
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
movl %ebp, %esi
callq 0x29290
movq %rax, %rdi
callq 0x284a0
movq 0x105dc7(%rip), %rdi    # 0x165f98
leaq 0x79732(%rip), %rsi     # 0xd990a
callq 0x289f0
movq %rax, %rdi
movl %ebp, %esi
callq 0x29290
leaq 0x79729(%rip), %rsi     # 0xd9917
movq %rax, %rdi
callq 0x289f0
movl 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
callq 0x284a0
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x61c7e
jmp 0x6081f
xorps %xmm0, %xmm0
andq $0x0, 0x60(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
andq $0x0, 0x28(%rax)
movaps %xmm0, 0x50(%rsp)
movups %xmm0, 0x18(%rax)
movl %r14d, 0x14(%rax)
cmpl $-0x1, %edx
je 0x60266
leaq 0x50(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x61c7e
jmp 0x60626
leaq 0x230(%rsp), %rdi
pushq $0xb
popq %rsi
callq 0x9e9c3
leaq 0x70(%rsp), %rbx
leaq 0x230(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0x28c40
movq %r12, %rdi
callq 0x295a0
leaq 0x170(%rsp), %rdi
movq %rbx, %rsi
callq 0x61c3c
leaq 0x30(%rsp), %rdi
leaq 0x170(%rsp), %rdx
callq 0x60dd2
leaq 0x170(%rsp), %rdi
callq 0x5d216
movq 0x38(%rsp), %rdx
cmpq $0x3e9, %rdx            # imm = 0x3E9
jae 0x60c1a
movq 0x68(%r15), %rax
movq (%rax), %rdi
movq 0x30(%rsp), %rsi
xorl %ecx, %ecx
callq 0x61c9c
movq 0x68(%r15), %rax
movq (%rax), %rdi
leaq 0x230(%rsp), %rsi
leaq 0x20(%rsp), %rcx
leaq 0x2c(%rsp), %r8
movl $0x3e9, %edx            # imm = 0x3E9
callq 0x61ce6
movq 0x20(%rsp), %rax
movb $0x0, 0x230(%rsp,%rax)
leaq 0xf0(%rsp), %rdi
leaq 0x230(%rsp), %rsi
leaq 0x14(%rsp), %rdx
callq 0x33402
leaq 0xb0(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
movq %r15, %rsi
callq 0x60e6e
leaq 0xf0(%rsp), %rdi
callq 0x295a0
xorl %ebx, %ebx
movq 0xd8(%rsp), %r13
leaq 0x14(%rsp), %r12
cmpq 0xe0(%rsp), %r13
je 0x605db
movq %r13, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3343d
movl %eax, 0x14(%rsp)
leaq 0x50(%rsp), %rdi
movq %r12, %rsi
callq 0x64006
incl %ebx
addq $0x20, %r13
jmp 0x60368
leaq 0x70(%rsp), %rdi
pushq $0xb
popq %rsi
callq 0x9e9c3
leaq 0x230(%rsp), %rdi
leaq 0x70(%rsp), %rbx
movq %rbx, %rsi
callq 0x28c40
movq %rbx, %rdi
callq 0x295a0
movq 0x50(%r15), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x603ee
movq 0x105bbe(%rip), %rdi    # 0x165f98
leaq 0x7945d(%rip), %rsi     # 0xd983e
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x1f0(%rsp), %rdi
leaq 0x230(%rsp), %rsi
callq 0x61c3c
leaq 0xb0(%rsp), %rdi
leaq 0x1f0(%rsp), %rdx
callq 0x60dd2
leaq 0x1f0(%rsp), %rdi
callq 0x5d216
movq 0x50(%r15), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x6045d
movq 0x105b5f(%rip), %rdi    # 0x165f98
leaq 0x79428(%rip), %rsi     # 0xd9868
callq 0x289f0
leaq 0xb0(%rsp), %rsi
movq %rax, %rdi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movq 0xb0(%rsp), %rdi
movl 0xb8(%rsp), %esi
movq 0x105ad5(%rip), %rdx    # 0x165f48
movq 0x105ae6(%rip), %r9     # 0x165f60
pushq $0xb
popq %r8
xorl %ecx, %ecx
callq 0x28350
movq 0x105ad4(%rip), %rdx    # 0x165f60
leaq 0x50(%rsp), %rcx
xorl %edi, %edi
xorl %esi, %esi
callq 0x28310
movq 0x105aff(%rip), %rsi    # 0x165fa0
leaq 0x50(%rsp), %r12
leaq 0x14(%rsp), %rdx
movq %r12, %rdi
callq 0x28e80
movslq 0x14(%rsp), %r13
leaq 0x1(%r13), %rdi
callq 0x28040
movq %rax, %rbx
subq $0x8, %rsp
movq 0x105a79(%rip), %rdx    # 0x165f48
movq 0x105a8a(%rip), %r9     # 0x165f60
pushq $0xc
popq %r8
movq %rax, %rdi
movl %r13d, %esi
xorl %ecx, %ecx
pushq %r12
callq 0x28840
popq %rcx
popq %rdx
movslq 0x14(%rsp), %rax
movb $0x0, (%rbx,%rax)
movq 0x50(%r15), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x60527
movq 0x105a90(%rip), %rdi    # 0x165f98
leaq 0x79393(%rip), %rsi     # 0xd98a2
callq 0x289f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0x110(%rsp), %rdi
leaq 0x1c(%rsp), %rdx
movq %rbx, %rsi
callq 0x33402
leaq 0x70(%rsp), %rdi
leaq 0x110(%rsp), %rdx
movq %r15, %rsi
callq 0x60e6e
leaq 0x110(%rsp), %rdi
callq 0x295a0
movq %rbx, %rdi
callq 0x28cf0
movq 0x98(%rsp), %rbx
movq 0x105a23(%rip), %r12    # 0x165f98
leaq 0x1c(%rsp), %r13
cmpq 0xa0(%rsp), %rbx
je 0x60808
movq 0x50(%r15), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x605b7
movq %r12, %rdi
leaq 0x79329(%rip), %rsi     # 0xd98c8
callq 0x289f0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movq %rbx, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3343d
movl %eax, 0x1c(%rsp)
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x64006
addq $0x20, %rbx
jmp 0x6057a
movq 0x1059b6(%rip), %rdi    # 0x165f98
leaq 0x79421(%rip), %rsi     # 0xd9a0a
callq 0x289f0
movq %rax, %rdi
movl %ebx, %esi
callq 0x29290
leaq 0x7941a(%rip), %rsi     # 0xd9a19
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
leaq 0xb0(%rsp), %rdi
callq 0x5d216
leaq 0x30(%rsp), %rdi
callq 0x295a0
leaq 0x230(%rsp), %rdi
movl %ebp, %esi
callq 0x9e9c3
movl 0x660(%rsp), %r13d
leaq 0x98(%rsp), %rbx
leaq 0x70(%rsp), %rdi
leaq 0x230(%rsp), %r12
movq %r12, %rsi
callq 0x28c40
movq %r12, %rdi
callq 0x295a0
movq 0x8(%rsp), %rax
movq (%rax), %r12
movq 0x8(%rsp), %rax
cmpq 0x8(%rax), %r12
je 0x60686
movq %rbx, %rdi
movq %r12, %rsi
callq 0x33776
addq $0x20, %r12
jmp 0x6066a
cmpl $-0x1, %r13d
jne 0x60694
callq 0x28280
movl %eax, %r13d
leaq 0x70(%rsp), %rsi
movl %r13d, 0x20(%rsi)
leaq 0x130(%rsp), %rdi
callq 0x61c3c
leaq 0x230(%rsp), %rdi
leaq 0x130(%rsp), %rdx
callq 0x60dd2
leaq 0x130(%rsp), %rdi
callq 0x5d216
cmpq $0x3e9, 0x238(%rsp) # imm = 0x3E9
jae 0x60bdb
movq 0x50(%rsp), %rbx
leaq 0x18(%r15), %r12
cmpq 0x58(%rsp), %rbx
je 0x607e7
movq 0x10589f(%rip), %rdi    # 0x165f98
leaq 0x7932d(%rip), %rsi     # 0xd9a2d
callq 0x289f0
movq %rax, %rdi
movl %r14d, %esi
callq 0x29290
movq %rax, %rdi
leaq 0x79318(%rip), %rsi     # 0xd9a32
callq 0x289f0
movq %rax, %rdi
leaq 0x70(%rsp), %rsi
callq 0x28910
movq %rax, %rdi
leaq 0x7e73f(%rip), %rsi     # 0xdee75
callq 0x289f0
movl (%rbx), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
leaq 0x792ed(%rip), %rsi     # 0xd9a3c
callq 0x289f0
movq %rax, %rdi
leaq 0x230(%rsp), %rsi
callq 0x28910
movq %rax, %rdi
callq 0x284a0
movslq (%rbx), %rax
movq 0x68(%r15), %rcx
movq (%rcx,%rax,8), %rdi
movq 0x230(%rsp), %rsi
movq 0x238(%rsp), %rdx
xorl %ecx, %ecx
callq 0x61d3a
testb %al, %al
leaq 0x792ad(%rip), %rsi     # 0xd9a44
leaq 0x792d3(%rip), %rax     # 0xd9a71
cmovneq %rax, %rsi
movq 0x1057ef(%rip), %rdi    # 0x165f98
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
cmpb $0x0, 0x18(%rsp)
je 0x607de
movl 0x10(%rsp), %edx
movq %r15, %rdi
movl %r14d, %esi
movl %ebp, %ecx
xorl %r8d, %r8d
movq %r12, %r9
pushq %r13
pushq $0x0
callq 0x60fd6
popq %rcx
popq %rdx
testl %eax, %eax
jne 0x607bd
addq $0x4, %rbx
jmp 0x606e7
leaq 0x230(%rsp), %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
callq 0x5d216
leaq 0x50(%rsp), %rdi
jmp 0x60bc4
leaq 0x70(%rsp), %rdi
callq 0x5d216
leaq 0xb0(%rsp), %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
movl %ebp, %esi
callq 0x9e9c3
leaq 0x258(%rsp), %rbx
leaq 0x230(%rsp), %rdi
leaq 0x70(%rsp), %r12
movq %r12, %rsi
callq 0x28c40
movq %r12, %rdi
callq 0x295a0
movq 0x8(%rsp), %rax
movq (%rax), %r12
movq 0x8(%rsp), %rax
cmpq 0x8(%rax), %r12
je 0x60874
movq %rbx, %rdi
movq %r12, %rsi
callq 0x33776
addq $0x20, %r12
jmp 0x60858
leaq 0x1b0(%rsp), %rdi
leaq 0x230(%rsp), %rsi
callq 0x61c3c
leaq 0x70(%rsp), %rdi
leaq 0x1b0(%rsp), %rdx
callq 0x60dd2
leaq 0x1b0(%rsp), %rdi
callq 0x5d216
movq 0x50(%r15), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x608ec
movq 0x1056dc(%rip), %rdi    # 0x165f98
leaq 0x7905a(%rip), %rsi     # 0xd991d
callq 0x289f0
leaq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0x28910
leaq 0x713b0(%rip), %rsi     # 0xd1c8c
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x30(%rsp), %rbx
movq 0x105668(%rip), %r12    # 0x165f60
leaq 0xb0(%rsp), %r13
cmpq 0x38(%rsp), %rbx
je 0x60ba8
movq %r12, %rdi
movq %r13, %rsi
callq 0x28b90
movl 0x10(%rsp), %ecx
cmpl 0xb0(%rsp), %ecx
jge 0x60b5d
movq 0x50(%r15), %rax
movl 0x1614(%rax), %eax
cmpb $0x0, 0x18(%rsp)
je 0x60a07
cmpl $0x3, %eax
jb 0x60986
movq 0x105650(%rip), %rdi    # 0x165f98
leaq 0x78feb(%rip), %rsi     # 0xd993a
callq 0x289f0
movq %rax, %rdi
movl %r14d, %esi
callq 0x29290
movq %rax, %rdi
leaq 0x7e50c(%rip), %rsi     # 0xdee75
callq 0x289f0
movl 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
callq 0x284a0
movl 0x10(%rsp), %ecx
movq 0x70(%rsp), %rdi
movl 0x78(%rsp), %esi
movq 0x1055b2(%rip), %rdx    # 0x165f48
movl %ebp, %r8d
movq %r12, %r9
callq 0x28350
movq 0x50(%r15), %rax
cmpl $0x3, 0x1614(%rax)
jb 0x60b5d
movq 0x1055df(%rip), %rdi    # 0x165f98
leaq 0x78f87(%rip), %rsi     # 0xd9947
callq 0x289f0
movq %rax, %rdi
movl %r14d, %esi
callq 0x29290
movq %rax, %rdi
leaq 0x7e49b(%rip), %rsi     # 0xdee75
callq 0x289f0
movl 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
leaq 0x78f63(%rip), %rsi     # 0xd9958
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
jmp 0x60b5d
cmpl $0x3, %eax
jb 0x60a51
movq 0x105585(%rip), %rdi    # 0x165f98
leaq 0x78f49(%rip), %rsi     # 0xd9963
callq 0x289f0
movq %rax, %rdi
movl %r14d, %esi
callq 0x29290
movq %rax, %rdi
leaq 0x7e441(%rip), %rsi     # 0xdee75
callq 0x289f0
movl 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
callq 0x284a0
movl 0x10(%rsp), %ecx
movq 0x70(%rsp), %rdi
movl 0x78(%rsp), %esi
movq 0x1054e7(%rip), %rdx    # 0x165f48
movl %ebp, %r8d
movq %r12, %r9
callq 0x28350
movq 0x50(%r15), %rcx
cmpl $0x3, 0x1614(%rcx)
jb 0x60b5d
testl %eax, %eax
je 0x60a96
movq 0x105510(%rip), %rdi    # 0x165f98
leaq 0x78f19(%rip), %rsi     # 0xd99a8
callq 0x289f0
jmp 0x60b05
movq 0x1054fb(%rip), %rdi    # 0x165f98
leaq 0x78ee1(%rip), %rsi     # 0xd9985
callq 0x289f0
movl 0x20(%rsp), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
leaq 0x78ecc(%rip), %rsi     # 0xd998b
callq 0x289f0
movl 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
leaq 0x78e29(%rip), %rsi     # 0xd9903
callq 0x289f0
movq %rax, %rdi
movl %ebp, %esi
callq 0x29290
movq %rax, %rdi
leaq 0x78eaa(%rip), %rsi     # 0xd999d
callq 0x289f0
movq 0x70(%rsp), %rsi
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
movq 0x105484(%rip), %rdi    # 0x165f98
leaq 0x78e55(%rip), %rsi     # 0xd9970
callq 0x289f0
movq %rax, %rdi
movl %r14d, %esi
callq 0x29290
movq %rax, %rdi
leaq 0x7e340(%rip), %rsi     # 0xdee75
callq 0x289f0
movl 0x10(%rsp), %esi
movq %rax, %rdi
callq 0x29290
movq %rax, %rdi
leaq 0x78e08(%rip), %rsi     # 0xd9958
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
addq $0x4, %rbx
jmp 0x60900
movq %rax, 0x8(%rsp)
cmpl $0x1, %edx
jne 0x60d7b
movq 0x8(%rsp), %rdi
callq 0x283c0
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
movq 0x10540a(%rip), %rdi    # 0x165f98
movq %rax, %rsi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
callq 0x29150
jmp 0x609a1
leaq 0x70(%rsp), %rdi
callq 0x295a0
leaq 0x230(%rsp), %rdi
callq 0x5d216
leaq 0x30(%rsp), %rdi
callq 0x6283a
addq $0x628, %rsp            # imm = 0x628
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1053b6(%rip), %rdi    # 0x165f98
leaq 0x78dd9(%rip), %rsi     # 0xd99c2
callq 0x289f0
movq 0x238(%rsp), %rsi
movq %rax, %rdi
callq 0x286e0
leaq 0x78de0(%rip), %rsi     # 0xd99e5
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
callq 0x285b0
movq 0x105377(%rip), %rdi    # 0x165f98
leaq 0x78d9a(%rip), %rsi     # 0xd99c2
callq 0x289f0
movq 0x38(%rsp), %rsi
movq %rax, %rdi
callq 0x286e0
leaq 0x78da4(%rip), %rsi     # 0xd99e5
movq %rax, %rdi
callq 0x289f0
movq %rax, %rdi
callq 0x284a0
callq 0x285b0
jmp 0x60d76
movq %rax, 0x8(%rsp)
callq 0x29150
jmp 0x60d7b
movq %rax, %rdi
callq 0x3325c
movq %rax, 0x8(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x295a0
jmp 0x60d45
jmp 0x60d27
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x295a0
jmp 0x60d5f
jmp 0x60cdc
movq %rax, 0x8(%rsp)
leaq 0x1f0(%rsp), %rdi
jmp 0x60cf7
jmp 0x60cdc
jmp 0x60d66
jmp 0x60d66
movq %rax, %rbx
leaq 0x170(%rsp), %rdi
jmp 0x60d0e
jmp 0x60d6d
jmp 0x60d6d
jmp 0x60d6d
movq %rax, %rbx
jmp 0x60d5f
jmp 0x60d27
jmp 0x60da5
jmp 0x60d27
movq %rax, 0x8(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x5d216
jmp 0x60d85
jmp 0x60d66
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x5d216
jmp 0x60db5
jmp 0x60d6d
jmp 0x60d66
jmp 0x60d6d
jmp 0x60d20
movq %rax, 0x8(%rsp)
jmp 0x60d92
movq %rax, 0x8(%rsp)
jmp 0x60d45
jmp 0x60d4f
jmp 0x60d76
jmp 0x60d66
jmp 0x60d36
movq %rax, 0x8(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x5d216
leaq 0xb0(%rsp), %rdi
jmp 0x60d80
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x5d216
leaq 0x30(%rsp), %rdi
jmp 0x60db0
movq %rax, 0x8(%rsp)
jmp 0x60d85
movq %rax, %rbx
jmp 0x60db5
jmp 0x60d76
jmp 0x60da5
movq %rax, 0x8(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x295a0
leaq 0x230(%rsp), %rdi
callq 0x5d216
leaq 0x30(%rsp), %rdi
callq 0x6283a
movq 0x8(%rsp), %rbx
jmp 0x60dc9
jmp 0x60da5
movq %rax, %rbx
leaq 0x230(%rsp), %rdi
callq 0x295a0
leaq 0x70(%rsp), %rdi
callq 0x5d216
leaq 0x50(%rsp), %rdi
callq 0x6283a
movq %rbx, %rdi
callq 0x292f0
nop