// File: dramninjasUMD[P]BOBSim/LogicLayerInterface.cpp
// Function: BOBSim::LogicLayerInterface::Update()
void LogicLayerInterface::Update()
{
	//send back to channel if there is something in the outgoing queue
	if(outgoingQueue.size()>0 && (*ReturnToSimpleController)(outgoingQueue[0],0))
	{
		//if we just send the response, we are done and can clear the current stuff
		if(outgoingQueue[0]->transactionType==LOGIC_RESPONSE)
		{
			currentTransaction = NULL;
			currentLogicOperation = NULL;
		}

		outgoingQueue.erase(outgoingQueue.begin());
	}

	// if we aren't working on anything and there are logic ops waiting
	if (currentTransaction == NULL && !pendingLogicOpsQueue.empty())
	{
		//cast logic operation arguments from transaction
		if(pendingLogicOpsQueue[0]->logicOpContents != NULL)
		{

			//extract logic operation from transaction and grab handle to current operations
			currentLogicOperation = (LogicOperation *)pendingLogicOpsQueue[0]->logicOpContents;
			currentTransaction = pendingLogicOpsQueue[0];

			if(DEBUG_LOGIC) DEBUG(" == In logic layer "<<simpleControllerID<<" : interpreting transaction "<<*currentTransaction);

			// grabbed the pointers, now we can remove from queue
			pendingLogicOpsQueue.pop_front();


			//figure out what to do for each type
			switch(currentLogicOperation->logicType)
			{
			case LogicOperation::PAGE_FILL:
				//
				//Arguments:  1) Number of continuous pages
				//            2) Pattern to copy
				//
				uint64_t pageStart;
				uint64_t numPages;
				uint pattern;
				if(currentLogicOperation->arguments.size()!=2)
				{
					ERROR("== ERROR - Incorrect number of arguments for logic operation "<<currentLogicOperation->logicType);
					exit(-1);
				}

				//get arguments
				pageStart = currentTransaction->address;
				numPages = currentLogicOperation->arguments[0];
				pattern = (uint)currentLogicOperation->arguments[1];

				if(DEBUG_LOGIC)
				{
					DEBUG("       PAGE FILL");
					DEBUG("        Start     : "<<pageStart);
					DEBUG("        Num Pages : "<<numPages);
					DEBUG("        Fill with : "<<pattern);
				}

				//generate the writes required to write a pattern to each page
				for(int i=0; i<numPages; i++)
				{
					Transaction *trans = new Transaction(DATA_WRITE, 64, pageStart + i*(1<<(log2(BUS_ALIGNMENT_SIZE)+log2(NUM_CHANNELS))));
					trans->originatedFromLogicOp = true;

					if(DEBUG_LOGIC) DEBUG("      == Logic Op created : "<<*trans);

					outgoingQueue.push_back(trans);

					//pattern not used lol :(
				}

				//put the response at the back of the queue so when all the writes empty out, the response is ready to go
				currentTransaction->transactionType = LOGIC_RESPONSE;
				outgoingQueue.push_back(currentTransaction);

				break;
			case LogicOperation::MEM_COPY:
				//
				//Arguments : 1) Destination Address
				//            2) Size
				//

				uint64_t sourceAddress;
				uint64_t destinationAddress; //start of destination copy
				uint64_t sizeToCopy; //number of 64-byte words to copy
				if(currentLogicOperation->arguments.size()!=2)
				{
					ERROR("== ERROR - Incorrect number of arguments for logic operation "<<currentLogicOperation->logicType);
					exit(-1);
				}

				sourceAddress = currentTransaction->address;
				destinationAddress = currentLogicOperation->arguments[0];
				sizeToCopy = currentLogicOperation->arguments[1];

				if(DEBUG_LOGIC)
				{
					DEBUG("       MEM COPY");
					DEBUG("        Source Address      : 0x"<<hex<<setw(8)<<setfill('0')<<sourceAddress);
					DEBUG("        Dest Address        : 0x"<<hex<<setw(8)<<setfill('0')<<destinationAddress);
					DEBUG("        Size to copy (x64B) : "<<dec<<sizeToCopy);
				}

				for(int i=0; i<sizeToCopy; i++)
				{
					Transaction *trans = new Transaction(DATA_READ, 64, sourceAddress + i*(1<<(log2(BUS_ALIGNMENT_SIZE)+log2(NUM_CHANNELS))));
					trans->originatedFromLogicOp = true;

					if(DEBUG_LOGIC) DEBUG("      == Logic Op created : "<<*trans);

					outgoingQueue.push_back(trans);
				}

				break;
			case LogicOperation::PAGE_TABLE_WALK:
				uint64_t src_address;
				src_address = currentTransaction->address;
				for (size_t i=0; i<currentLogicOperation->arguments.size(); i++)
				{
					Transaction *trans = new Transaction(DATA_READ, 64, currentLogicOperation->arguments[i]);
					trans->originatedFromLogicOp = true;
					outgoingQueue.push_back(trans);
				}

				break;
			default:
				ERROR("== ERROR - Unknown logic type in logic layer : "<<currentLogicOperation->logicType);
				exit(-1);
			}

		}
		else
		{
			ERROR(" == Error - Logic operation has no contents : "<<*newOperationQueue[0]);
			exit(-1);
		}
	}


	//if we're getting data, it is probably from a logic op that generated requests
	if(!newOperationQueue.empty() && newOperationQueue[0]->transactionType == RETURN_DATA)
	{
		//
		//do some checks to ensure the data makes sense
		//
		if(currentTransaction==NULL)
		{
			ERROR("== ERROR - Getting data without a corresponding transaction");
			exit(-1);
		}

		if (DEBUG_LOGIC) DEBUG("   ==[L:"<<simpleControllerID<<"] oh hai, return data"<<*newOperationQueue[0]);
		//handle the return data based on the logic op that is being executed
		Transaction *t;
		switch(currentLogicOperation->logicType)
		{
		case LogicOperation::MEM_COPY:
			if (DEBUG_LOGIC) DEBUG(newOperationQueue[0]->address - currentTransaction->address);
			t = new Transaction(DATA_WRITE, 64, newOperationQueue[0]->address - currentTransaction->address + currentLogicOperation->arguments[0]);
			t->originatedFromLogicOp = true;

			if(DEBUG_LOGIC) DEBUG("      == Logic Op Copy moved data from 0x"<<hex<<setw(8)<<setfill('0')<<newOperationQueue[0]->address<<dec<<" to : "<<*t);

			outgoingQueue.push_back(t);

			issuedRequests++;

			newOperationQueue.erase(newOperationQueue.begin());

			//check to see if we are done with the requests
			if(issuedRequests==currentLogicOperation->arguments[1])
			{
				if(DEBUG_LOGIC) DEBUG("      == All WRITE commands issued for copy - creating response");

				//send back response
				currentTransaction->transactionType = LOGIC_RESPONSE;
				outgoingQueue.push_back(currentTransaction);
				issuedRequests = 0;
			}
			break;
		case LogicOperation::PAGE_TABLE_WALK:
			issuedRequests++;

			if (DEBUG_LOGIC) DEBUG("   ==[L:"<<simpleControllerID<<"] Getting back PT read for 0x"<<std::hex<<(newOperationQueue[0]->address)<<std::dec<<"("<<issuedRequests<<"/3)");

			//check to see if we are done with the requests
			if(issuedRequests == currentLogicOperation->arguments.size())
			{
				if(DEBUG_LOGIC) DEBUG("      ==[L:"<<simpleControllerID<<"] All walked all page table levels, - creating response");

				//send back response
				currentTransaction->transactionType = LOGIC_RESPONSE;
				outgoingQueue.push_back(currentTransaction);
				issuedRequests = 0;
			}
			newOperationQueue.erase(newOperationQueue.begin());

			break;

		default:
			ERROR("== ERROR - Getting data back for a logic op that doesnt create requests : "<<*currentTransaction);
			exit(-1);
			break;
		};
	}
	currentClockCycle++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
addq $0x90, %rdi
callq 0xbe00
cmpq $0x0, %rax
jbe 0x1ce47
movq -0xe8(%rbp), %rdi
movq (%rdi), %rax
movq %rax, -0xf0(%rbp)
addq $0x90, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe40
movq -0xf0(%rbp), %rdi
movq (%rax), %rsi
movq (%rdi), %rax
xorl %edx, %edx
callq *0x10(%rax)
testb $0x1, %al
jne 0x1cdc9
jmp 0x1ce47
movq -0xe8(%rbp), %rdi
addq $0x90, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe40
movq (%rax), %rax
cmpl $0x4, (%rax)
jne 0x1cdff
movq -0xe8(%rbp), %rax
movq $0x0, 0x18(%rax)
movq $0x0, 0x20(%rax)
movq -0xe8(%rbp), %rdi
movq %rdi, %rax
addq $0x90, %rax
movq %rax, -0xf8(%rbp)
addq $0x90, %rdi
callq 0xc0b0
movq %rax, -0x18(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xc120
movq -0xf8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xc040
movq %rax, -0x20(%rbp)
movq -0xe8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x1d914
movq -0xe8(%rbp), %rdi
addq $0x28, %rdi
callq 0x1e110
testb $0x1, %al
jne 0x1d914
movq -0xe8(%rbp), %rdi
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1e140
movq (%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x1d873
movq -0xe8(%rbp), %rdi
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1e140
movq -0xe8(%rbp), %rdi
movq (%rax), %rax
movq 0x28(%rax), %rax
movq %rax, 0x20(%rdi)
addq $0x28, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1e140
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, 0x18(%rax)
testb $0x1, 0x1b668(%rip)     # 0x38546
je 0x1cf44
leaq 0x1b48d(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1cf42
movq 0x1b0d5(%rip), %rdi     # 0x37fc8
leaq 0xeb37(%rip), %rsi      # 0x2ba31
callq 0x31c0
movq %rax, %rdi
movq -0xe8(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x32d0
movq %rax, %rdi
leaq 0xeb2a(%rip), %rsi      # 0x2ba45
callq 0x31c0
movq %rax, %rdi
movq -0xe8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x294b0
movq %rax, %rdi
movq 0x1b06b(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1cf44
movq -0xe8(%rbp), %rdi
addq $0x28, %rdi
callq 0x1e170
movq -0xe8(%rbp), %rax
movq 0x20(%rax), %rax
movl (%rax), %eax
movl %eax, -0xfc(%rbp)
testl %eax, %eax
je 0x1cf92
jmp 0x1cf6d
movl -0xfc(%rbp), %eax
subl $0x1, %eax
je 0x1d2da
jmp 0x1cf7e
movl -0xfc(%rbp), %eax
subl $0x2, %eax
je 0x1d6cf
jmp 0x1d7e4
movq -0xe8(%rbp), %rax
movq 0x20(%rax), %rdi
addq $0x8, %rdi
callq 0x1e1e0
cmpq $0x2, %rax
je 0x1d03a
movq 0x1b039(%rip), %rdi     # 0x37ff0
leaq 0xd152(%rip), %rsi      # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0xea95(%rip), %rsi      # 0x2ba62
callq 0x31c0
movq %rax, %rdi
leaq 0xd0dd(%rip), %rsi      # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0x6d, %esi
callq 0x3380
movq %rax, %rdi
leaq 0xd129(%rip), %rsi      # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0xea73(%rip), %rsi      # 0x2ba7a
callq 0x31c0
movq %rax, %rdi
movq -0xe8(%rbp), %rax
movq 0x20(%rax), %rax
movl (%rax), %esi
callq 0x3380
movq %rax, %rdi
movq 0x1af7d(%rip), %rsi     # 0x37fa8
callq 0x3200
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3270
movq -0xe8(%rbp), %rax
movq 0x18(%rax), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, -0x28(%rbp)
movq 0x20(%rax), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xc160
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x30(%rbp)
movq 0x20(%rax), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0xc160
movq (%rax), %rax
movl %eax, -0x34(%rbp)
testb $0x1, 0x1b4b8(%rip)     # 0x38546
je 0x1d171
leaq 0x1b2d9(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1d0c2
movq 0x1af21(%rip), %rdi     # 0x37fc8
leaq 0xea0a(%rip), %rsi      # 0x2bab8
callq 0x31c0
movq %rax, %rdi
movq 0x1aeeb(%rip), %rsi     # 0x37fa8
callq 0x3200
leaq 0x1b2ab(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1d0fc
movq 0x1aef3(%rip), %rdi     # 0x37fc8
leaq 0xe9ed(%rip), %rsi      # 0x2bac9
callq 0x31c0
movq %rax, %rdi
movq -0x28(%rbp), %rsi
callq 0x3070
movq %rax, %rdi
movq 0x1aeb1(%rip), %rsi     # 0x37fa8
callq 0x3200
leaq 0x1b271(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1d136
movq 0x1aeb9(%rip), %rdi     # 0x37fc8
leaq 0xe9c8(%rip), %rsi      # 0x2bade
callq 0x31c0
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x3070
movq %rax, %rdi
movq 0x1ae77(%rip), %rsi     # 0x37fa8
callq 0x3200
leaq 0x1b237(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1d16f
movq 0x1ae7f(%rip), %rdi     # 0x37fc8
leaq 0xe9a3(%rip), %rsi      # 0x2baf3
callq 0x31c0
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x32d0
movq %rax, %rdi
movq 0x1ae3e(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1d171
movl $0x0, -0x38(%rbp)
movslq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x1d2b1
movl $0x90, %edi
callq 0x31d0
movq %rax, -0x118(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x110(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x104(%rbp)
movl 0x1b1b7(%rip), %edi     # 0x38368
callq 0xb660
movl %eax, -0x100(%rbp)
jmp 0x1d1be
movl 0x1b1a8(%rip), %edi     # 0x3836c
callq 0xb660
movl %eax, -0x11c(%rbp)
jmp 0x1d1d1
movq -0x118(%rbp), %rdi
movl -0x104(%rbp), %eax
movl -0x11c(%rbp), %edx
movl -0x100(%rbp), %ecx
addl %edx, %ecx
movl $0x1, %esi
movl %esi, %edx
shll %cl, %edx
movq -0x110(%rbp), %rcx
imull %edx, %eax
cltq
addq %rax, %rcx
movl $0x40, %edx
callq 0x293f0
jmp 0x1d210
movq -0x118(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movb $0x1, 0x30(%rax)
testb $0x1, 0x1b31c(%rip)     # 0x38546
je 0x1d28c
leaq 0x1b141(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1d28a
movq 0x1ad89(%rip), %rdi     # 0x37fc8
leaq 0xe8c2(%rip), %rsi      # 0x2bb08
callq 0x31c0
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x294b0
movq %rax, %rdi
movq 0x1ad47(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1d28a
movq -0x118(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x90, %esi
callq 0x31f0
jmp 0x1e084
jmp 0x1d28c
movq -0xe8(%rbp), %rdi
addq $0x90, %rdi
leaq -0x40(%rbp), %rsi
callq 0xbfd0
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1d178
movq -0xe8(%rbp), %rsi
movq 0x18(%rsi), %rax
movl $0x4, (%rax)
movq %rsi, %rdi
addq $0x90, %rdi
addq $0x18, %rsi
callq 0xbfd0
jmp 0x1d86e
movq -0xe8(%rbp), %rax
movq 0x20(%rax), %rdi
addq $0x8, %rdi
callq 0x1e1e0
cmpq $0x2, %rax
je 0x1d382
movq 0x1acf1(%rip), %rdi     # 0x37ff0
leaq 0xce0a(%rip), %rsi      # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0xe74d(%rip), %rsi      # 0x2ba62
callq 0x31c0
movq %rax, %rdi
leaq 0xcd95(%rip), %rsi      # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0x9b, %esi
callq 0x3380
movq %rax, %rdi
leaq 0xcde1(%rip), %rsi      # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0xe72b(%rip), %rsi      # 0x2ba7a
callq 0x31c0
movq %rax, %rdi
movq -0xe8(%rbp), %rax
movq 0x20(%rax), %rax
movl (%rax), %esi
callq 0x3380
movq %rax, %rdi
movq 0x1ac35(%rip), %rsi     # 0x37fa8
callq 0x3200
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3270
movq -0xe8(%rbp), %rax
movq 0x18(%rax), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, -0x58(%rbp)
movq 0x20(%rax), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xc160
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x60(%rbp)
movq 0x20(%rax), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0xc160
movq (%rax), %rax
movq %rax, -0x68(%rbp)
testb $0x1, 0x1b16f(%rip)     # 0x38546
je 0x1d57e
leaq 0x1af90(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1d40b
movq 0x1abd8(%rip), %rdi     # 0x37fc8
leaq 0xe72e(%rip), %rsi      # 0x2bb25
callq 0x31c0
movq %rax, %rdi
movq 0x1aba2(%rip), %rsi     # 0x37fa8
callq 0x3200
leaq 0x1af62(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1d49f
movq 0x1aba6(%rip), %rdi     # 0x37fc8
leaq 0xe70c(%rip), %rsi      # 0x2bb35
callq 0x31c0
movq %rax, %rdi
leaq -0x41a8(%rip), %rsi     # 0x19290
callq 0x30a0
movq %rax, -0x130(%rbp)
movl $0x8, %edi
callq 0x1e200
movq -0x130(%rbp), %rdi
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %esi
callq 0x3250
movq %rax, -0x128(%rbp)
movl $0x30, %edi
callq 0x1e220
movq -0x128(%rbp), %rdi
movb %al, -0x6d(%rbp)
movzbl -0x6d(%rbp), %esi
callq 0x3310
movq %rax, %rdi
movq -0x58(%rbp), %rsi
callq 0x3070
movq %rax, %rdi
movq 0x1ab0e(%rip), %rsi     # 0x37fa8
callq 0x3200
leaq 0x1aece(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1d533
movq 0x1ab12(%rip), %rdi     # 0x37fc8
leaq 0xe699(%rip), %rsi      # 0x2bb56
callq 0x31c0
movq %rax, %rdi
leaq -0x423c(%rip), %rsi     # 0x19290
callq 0x30a0
movq %rax, -0x140(%rbp)
movl $0x8, %edi
callq 0x1e200
movq -0x140(%rbp), %rdi
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %esi
callq 0x3250
movq %rax, -0x138(%rbp)
movl $0x30, %edi
callq 0x1e220
movq -0x138(%rbp), %rdi
movb %al, -0x75(%rbp)
movzbl -0x75(%rbp), %esi
callq 0x3310
movq %rax, %rdi
movq -0x60(%rbp), %rsi
callq 0x3070
movq %rax, %rdi
movq 0x1aa7a(%rip), %rsi     # 0x37fa8
callq 0x3200
leaq 0x1ae3a(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1d57c
movq 0x1aa82(%rip), %rdi     # 0x37fc8
leaq 0xe62a(%rip), %rsi      # 0x2bb77
callq 0x31c0
movq %rax, %rdi
leaq -0x429c(%rip), %rsi     # 0x192c0
callq 0x30a0
movq %rax, %rdi
movq -0x68(%rbp), %rsi
callq 0x3070
movq %rax, %rdi
movq 0x1aa31(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1d57e
movl $0x0, -0x7c(%rbp)
movslq -0x7c(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x1d6ca
movl $0x90, %edi
callq 0x31d0
movq %rax, -0x158(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x150(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x148(%rbp)
movl 0x1adaa(%rip), %edi     # 0x38368
callq 0xb660
movl %eax, -0x144(%rbp)
jmp 0x1d5cb
movl 0x1ad9b(%rip), %edi     # 0x3836c
callq 0xb660
movl %eax, -0x15c(%rbp)
jmp 0x1d5de
movq -0x158(%rbp), %rdi
movl -0x148(%rbp), %eax
movl -0x15c(%rbp), %edx
movl -0x144(%rbp), %ecx
addl %edx, %ecx
movl $0x1, %edx
shll %cl, %edx
movq -0x150(%rbp), %rcx
imull %edx, %eax
cltq
addq %rax, %rcx
xorl %esi, %esi
movl $0x40, %edx
callq 0x293f0
jmp 0x1d61d
movq -0x158(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movb $0x1, 0x30(%rax)
testb $0x1, 0x1af09(%rip)     # 0x38546
je 0x1d6a2
leaq 0x1ad2e(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1d6a0
movq 0x1a976(%rip), %rdi     # 0x37fc8
leaq 0xe4af(%rip), %rsi      # 0x2bb08
callq 0x31c0
movq %rax, %rdi
movq -0x88(%rbp), %rsi
callq 0x294b0
movq %rax, %rdi
movq 0x1a931(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1d6a0
movq -0x158(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x90, %esi
callq 0x31f0
jmp 0x1e084
jmp 0x1d6a2
movq -0xe8(%rbp), %rdi
addq $0x90, %rdi
leaq -0x88(%rbp), %rsi
callq 0xbfd0
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x1d585
jmp 0x1d86e
movq -0xe8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
movq $0x0, -0x98(%rbp)
movq -0xe8(%rbp), %rax
movq -0x98(%rbp), %rcx
movq %rcx, -0x168(%rbp)
movq 0x20(%rax), %rdi
addq $0x8, %rdi
callq 0x1e1e0
movq %rax, %rcx
movq -0x168(%rbp), %rax
cmpq %rcx, %rax
jae 0x1d7df
movl $0x90, %edi
callq 0x31d0
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movq %rcx, -0x170(%rbp)
movq %rcx, -0x178(%rbp)
movq 0x20(%rax), %rdi
addq $0x8, %rdi
movq -0x98(%rbp), %rsi
callq 0xc160
movq -0x170(%rbp), %rdi
movq (%rax), %rcx
xorl %esi, %esi
movl $0x40, %edx
callq 0x293f0
jmp 0x1d773
movq -0xe8(%rbp), %rdi
movq -0x178(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movb $0x1, 0x30(%rax)
addq $0x90, %rdi
leaq -0xa0(%rbp), %rsi
callq 0xbfd0
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x1d6f0
movq -0x178(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x90, %esi
callq 0x31f0
jmp 0x1e084
jmp 0x1d86e
movq 0x1a805(%rip), %rdi     # 0x37ff0
leaq 0xc91e(%rip), %rsi      # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0xe261(%rip), %rsi      # 0x2ba62
callq 0x31c0
movq %rax, %rdi
leaq 0xc8a9(%rip), %rsi      # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0xc2, %esi
callq 0x3380
movq %rax, %rdi
leaq 0xc8f5(%rip), %rsi      # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0xe35b(%rip), %rsi      # 0x2bb96
callq 0x31c0
movq %rax, %rdi
movq -0xe8(%rbp), %rax
movq 0x20(%rax), %rax
movl (%rax), %esi
callq 0x3380
movq %rax, %rdi
movq 0x1a749(%rip), %rsi     # 0x37fa8
callq 0x3200
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3270
jmp 0x1d912
movq 0x1a776(%rip), %rdi     # 0x37ff0
leaq 0xc88f(%rip), %rsi      # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0xe1d2(%rip), %rsi      # 0x2ba62
callq 0x31c0
movq %rax, %rdi
leaq 0xc81a(%rip), %rsi      # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0xc9, %esi
callq 0x3380
movq %rax, %rdi
leaq 0xc866(%rip), %rsi      # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0xe2fc(%rip), %rsi      # 0x2bbc6
callq 0x31c0
movq -0xe8(%rbp), %rdi
movq %rax, -0x180(%rbp)
addq $0x78, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe40
movq -0x180(%rbp), %rdi
movq (%rax), %rsi
callq 0x294b0
movq %rax, %rdi
movq 0x1a6a5(%rip), %rsi     # 0x37fa8
callq 0x3200
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3270
jmp 0x1d914
movq -0xe8(%rbp), %rdi
addq $0x78, %rdi
callq 0x1e240
testb $0x1, %al
jne 0x1e068
movq -0xe8(%rbp), %rdi
addq $0x78, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe40
movq (%rax), %rax
cmpl $0x2, (%rax)
jne 0x1e068
movq -0xe8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x1d9cf
movq 0x1a68f(%rip), %rdi     # 0x37ff0
leaq 0xc7a8(%rip), %rsi      # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0xe0eb(%rip), %rsi      # 0x2ba62
callq 0x31c0
movq %rax, %rdi
leaq 0xc733(%rip), %rsi      # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0xd7, %esi
callq 0x3380
movq %rax, %rdi
leaq 0xc77f(%rip), %rsi      # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0xe244(%rip), %rsi      # 0x2bbf5
callq 0x31c0
movq %rax, %rdi
movq 0x1a5e8(%rip), %rsi     # 0x37fa8
callq 0x3200
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3270
testb $0x1, 0x1ab70(%rip)     # 0x38546
je 0x1da53
leaq 0x1a995(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1da51
movq 0x1a5dd(%rip), %rdi     # 0x37fc8
leaq 0xe2eb(%rip), %rsi      # 0x2bcdd
callq 0x31c0
movq %rax, %rdi
movq -0xe8(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x32d0
movq %rax, %rdi
leaq 0xe21e(%rip), %rsi      # 0x2bc31
callq 0x31c0
movq -0xe8(%rbp), %rdi
movq %rax, -0x188(%rbp)
addq $0x78, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe40
movq -0x188(%rbp), %rdi
movq (%rax), %rsi
callq 0x294b0
movq %rax, %rdi
movq 0x1a55c(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1da53
movq -0xe8(%rbp), %rax
movq 0x20(%rax), %rax
movl (%rax), %eax
movl %eax, -0x18c(%rbp)
subl $0x1, %eax
je 0x1da81
jmp 0x1da6d
movl -0x18c(%rbp), %eax
subl $0x2, %eax
je 0x1ddcd
jmp 0x1dfde
testb $0x1, 0x1aabe(%rip)     # 0x38546
je 0x1dae0
leaq 0x1a8e3(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1dade
movq -0xe8(%rbp), %rdi
addq $0x78, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe40
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movq (%rcx), %rcx
movq 0x8(%rcx), %rsi
movq 0x18(%rax), %rax
subq 0x8(%rax), %rsi
movq 0x1a4fe(%rip), %rdi     # 0x37fc8
callq 0x3070
movq %rax, %rdi
movq 0x1a4cf(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1dae0
movl $0x90, %edi
callq 0x31d0
movq -0xe8(%rbp), %rdi
movq %rax, -0x198(%rbp)
movq %rax, -0x1b0(%rbp)
addq $0x78, %rdi
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x1a8(%rbp)
callq 0xbe40
movq -0xe8(%rbp), %rdx
movq -0x1a8(%rbp), %rsi
movq (%rax), %rax
movq 0x8(%rax), %rax
movq 0x18(%rdx), %rcx
movq 0x20(%rdx), %rdi
movq 0x8(%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x1a0(%rbp)
addq $0x8, %rdi
callq 0xc160
movq -0x1a0(%rbp), %rcx
movq -0x198(%rbp), %rdi
movq (%rax), %rax
addq %rax, %rcx
movl $0x1, %esi
movl $0x40, %edx
callq 0x293f0
jmp 0x1db6c
movq -0x1b0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rax
movb $0x1, 0x30(%rax)
testb $0x1, 0x1a9ba(%rip)     # 0x38546
je 0x1dca7
leaq 0x1a7db(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1dca5
movq 0x1a41f(%rip), %rdi     # 0x37fc8
leaq 0xe097(%rip), %rsi      # 0x2bc47
callq 0x31c0
movq %rax, %rdi
leaq -0x492f(%rip), %rsi     # 0x19290
callq 0x30a0
movq %rax, -0x1c8(%rbp)
movl $0x8, %edi
callq 0x1e200
movq -0x1c8(%rbp), %rdi
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %esi
callq 0x3250
movq %rax, -0x1c0(%rbp)
movl $0x30, %edi
callq 0x1e220
movq -0x1c0(%rbp), %rdi
movb %al, -0xad(%rbp)
movzbl -0xad(%rbp), %esi
callq 0x3310
movq -0xe8(%rbp), %rdi
movq %rax, -0x1b8(%rbp)
addq $0x78, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe40
movq -0x1b8(%rbp), %rdi
movq (%rax), %rax
movq 0x8(%rax), %rsi
callq 0x3070
movq %rax, %rdi
leaq -0x498f(%rip), %rsi     # 0x192c0
callq 0x30a0
movq %rax, %rdi
leaq 0xe013(%rip), %rsi      # 0x2bc71
callq 0x31c0
movq %rax, %rdi
movq -0xa8(%rbp), %rsi
callq 0x294b0
movq %rax, %rdi
movq 0x1a32c(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1dca5
movq -0x1b0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x90, %esi
callq 0x31f0
jmp 0x1e084
jmp 0x1dca7
movq -0xe8(%rbp), %rdi
addq $0x90, %rdi
leaq -0xa8(%rbp), %rsi
callq 0xbfd0
movq -0xe8(%rbp), %rdi
movl 0xa8(%rdi), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rdi)
movq %rdi, %rax
addq $0x78, %rax
movq %rax, -0x1d8(%rbp)
addq $0x78, %rdi
callq 0xc0b0
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xc120
movq -0x1d8(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0xc040
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movq %rcx, -0xc8(%rbp)
movl 0xa8(%rax), %ecx
movq %rcx, -0x1d0(%rbp)
movq 0x20(%rax), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0xc160
movq %rax, %rcx
movq -0x1d0(%rbp), %rax
cmpq (%rcx), %rax
jne 0x1ddc8
testb $0x1, 0x1a7e5(%rip)     # 0x38546
je 0x1dd93
leaq 0x1a60a(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1dd91
movq 0x1a252(%rip), %rdi     # 0x37fc8
leaq 0xdefb(%rip), %rsi      # 0x2bc78
callq 0x31c0
movq %rax, %rdi
movq 0x1a21c(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1dd93
movq -0xe8(%rbp), %rsi
movq 0x18(%rsi), %rax
movl $0x4, (%rax)
movq %rsi, %rdi
addq $0x90, %rdi
addq $0x18, %rsi
callq 0xbfd0
movq -0xe8(%rbp), %rax
movl $0x0, 0xa8(%rax)
jmp 0x1e066
movq -0xe8(%rbp), %rax
movl 0xa8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xa8(%rax)
testb $0x1, 0x1a75c(%rip)     # 0x38546
je 0x1dec4
leaq 0x1a57d(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1dec2
movq 0x1a1c1(%rip), %rdi     # 0x37fc8
leaq 0xdecf(%rip), %rsi      # 0x2bcdd
callq 0x31c0
movq %rax, %rdi
movq -0xe8(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x32d0
movq %rax, %rdi
leaq 0xde89(%rip), %rsi      # 0x2bcb8
callq 0x31c0
movq %rax, %rdi
leaq -0x4bae(%rip), %rsi     # 0x19290
callq 0x30a0
movq -0xe8(%rbp), %rdi
movq %rax, -0x1e0(%rbp)
addq $0x78, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xbe40
movq -0x1e0(%rbp), %rdi
movq (%rax), %rax
movq 0x8(%rax), %rsi
callq 0x3070
movq %rax, %rdi
leaq -0x4bbb(%rip), %rsi     # 0x192c0
callq 0x30a0
movq %rax, %rdi
leaq 0xc28d(%rip), %rsi      # 0x2a117
callq 0x31c0
movq %rax, %rdi
movq -0xe8(%rbp), %rax
movl 0xa8(%rax), %esi
callq 0x32d0
movq %rax, %rdi
leaq 0xde28(%rip), %rsi      # 0x2bcd6
callq 0x31c0
movq %rax, %rdi
movq 0x1a0eb(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1dec4
movq -0xe8(%rbp), %rax
movl 0xa8(%rax), %ecx
movq %rcx, -0x1e8(%rbp)
movq 0x20(%rax), %rdi
addq $0x8, %rdi
callq 0x1e1e0
movq %rax, %rcx
movq -0x1e8(%rbp), %rax
cmpq %rcx, %rax
jne 0x1df87
testb $0x1, 0x1a647(%rip)     # 0x38546
je 0x1df52
leaq 0x1a46c(%rip), %rax     # 0x38374
cmpl $0x0, (%rax)
je 0x1df50
movq 0x1a0b4(%rip), %rdi     # 0x37fc8
leaq 0xddbf(%rip), %rsi      # 0x2bcda
callq 0x31c0
movq %rax, %rdi
movq -0xe8(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x32d0
movq %rax, %rdi
leaq 0xddaa(%rip), %rsi      # 0x2bce6
callq 0x31c0
movq %rax, %rdi
movq 0x1a05d(%rip), %rsi     # 0x37fa8
callq 0x3200
jmp 0x1df52
movq -0xe8(%rbp), %rsi
movq 0x18(%rsi), %rax
movl $0x4, (%rax)
movq %rsi, %rdi
addq $0x90, %rdi
addq $0x18, %rsi
callq 0xbfd0
movq -0xe8(%rbp), %rax
movl $0x0, 0xa8(%rax)
movq -0xe8(%rbp), %rdi
movq %rdi, %rax
addq $0x78, %rax
movq %rax, -0x1f0(%rbp)
addq $0x78, %rdi
callq 0xc0b0
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xc120
movq -0x1f0(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0xc040
movq %rax, -0xe0(%rbp)
jmp 0x1e066
movq 0x1a00b(%rip), %rdi     # 0x37ff0
leaq 0xc124(%rip), %rsi      # 0x2a110
callq 0x31c0
movq %rax, %rdi
leaq 0xda67(%rip), %rsi      # 0x2ba62
callq 0x31c0
movq %rax, %rdi
leaq 0xc0af(%rip), %rsi      # 0x2a0b9
callq 0x31c0
movq %rax, %rdi
movl $0x10c, %esi            # imm = 0x10C
callq 0x3380
movq %rax, %rdi
leaq 0xc0fb(%rip), %rsi      # 0x2a121
callq 0x31c0
movq %rax, %rdi
leaq 0xdce9(%rip), %rsi      # 0x2bd1e
callq 0x31c0
movq %rax, %rdi
movq -0xe8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x294b0
movq %rax, %rdi
movq 0x19f51(%rip), %rsi     # 0x37fa8
callq 0x3200
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3270
jmp 0x1e068
movq -0xe8(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x33a0
nopl (%rax)