// File: estwings57[P]CasHMC/sources/HMCController.cpp
// Function: CasHMC::HMCController::Update()
void HMCController::Update()
{
	//Link wakes up from low power mode
	LinkPowerExitManager();
	
	//accumulate the allocated MSHR size
	accuMSHR += alloMSHR;
	
	//Downstream buffer state
	if(bufPopDelay==0 && downBuffers.size() > 0) {
		//Check packet dependency
		int link = -1;
		for(int l=0; l<NUM_LINKS; l++) {
			for(int i=0; i<downLinkMasters[l]->Buffers.size(); i++) {
				if(downLinkMasters[l]->Buffers[i] != NULL) {
					unsigned maxBlockBit = _log2(ADDRESS_MAPPING);
					if((downLinkMasters[l]->Buffers[i]->ADRS >> maxBlockBit) == (downBuffers[0]->address >> maxBlockBit)) {
						link = l;
						DEBUG(ALI(18)<<header<<ALI(15)<<*downBuffers[0]<<"Down) This transaction has a DEPENDENCY with "<<*downLinkMasters[l]->Buffers[i]);
						break;
					}
				}
			}
		}
		
		if(link == -1) {
			for(int l=0; l<NUM_LINKS; l++) {
				link = FindAvailableLink(inServiceLink, downLinkMasters);
				if(link == -1) {
					//DEBUG(ALI(18)<<header<<ALI(15)<<*downBuffers[0]<<"Down) all link buffer FULL");
				}
				else if(downLinkMasters[link]->currentState != ACTIVE
				&& downLinkMasters[link]->currentState != LINK_RETRY) {
					continue;
					//DEBUG(ALI(18)<<header<<ALI(15)<<*downBuffers[0]<<"Down) link "<<l<<" is not ACTIVE mode ["<<downLinkMasters[link]->powerMode<<"]");
				}
				else {
					Packet *packet = ConvTranIntoPacket(downBuffers[0]);
					if(downLinkMasters[link]->Receive(packet)) {
						DE_CR(ALI(18)<<header<<ALI(15)<<*packet<<"Down) SENDING packet to link mater "<<link<<" (LM_D"<<link<<")");
						if(!((packet->CMD >= P_WR16 && packet->CMD <= P_WR128)
						|| packet->CMD == P_WR256 || packet->CMD == P_2ADD8
						|| packet->CMD == P_ADD16 || packet->CMD == P_INC8
						|| packet->CMD == P_BWR)) {
							returnTransCnt++;
						}
						//Call callback function if posted write packet is tranmitted
						if((packet->CMD >= P_WR16 && packet->CMD <= P_WR128) || packet->CMD == P_WR256) {
							if(writeDone != NULL) {
								(*writeDone)(packet->ADRS, currentClockCycle);
							}
						}
						requestAccLNG += packet->LNG;
						delete downBuffers[0];
						downBuffers.erase(downBuffers.begin());
						break;
					}
					else {
						packet->ReductGlobalTAG();
						delete packet;
						//DEBUG(ALI(18)<<header<<ALI(15)<<*packet<<"Down) Link "<<link<<" buffer FULL");	
					}
				}
			}
		}
		else {
			Packet *packet = ConvTranIntoPacket(downBuffers[0]);
			if(downLinkMasters[link]->Receive(packet)) {
				DE_CR(ALI(18)<<header<<ALI(15)<<*packet<<"Down) SENDING packet to link mater "<<link<<" (LM_D"<<link<<")");
				delete downBuffers[0];
				downBuffers.erase(downBuffers.begin());
			}
			else {
				packet->ReductGlobalTAG();
				delete packet;
				//DEBUG(ALI(18)<<header<<ALI(15)<<*packet<<"Down) Link "<<link<<" buffer FULL");	
			}
		}
	}
	
	//Upstream buffer state
	if(upBuffers.size() > 0) {
		//Make sure that buffer[0] is not virtual tail packet.
		if(upBuffers[0] == NULL) {
			ERROR(header<<"  == Error - HMC controller up buffer[0] is NULL (It could be one of virtual tail packet occupying packet length  (CurrentClock : "<<currentClockCycle<<")");
			exit(0);
		}
		else {
			DE_CR(ALI(18)<<header<<ALI(15)<<*upBuffers[0]<<"Up)   RETURNING transaction to system bus");
			upBuffers[0]->trace->tranFullLat = currentClockCycle - upBuffers[0]->trace->tranTransmitTime;
			if(upBuffers[0]->CMD == RD_RS) {
				upBuffers[0]->trace->statis->hmcTransmitSize += (upBuffers[0]->LNG - 1)*16;
			}
			returnTransCnt--;
			//Call callback function if it is registered
			if(upBuffers[0]->CMD == WR_RS) {
				if(writeDone != NULL) {
					(*writeDone)(upBuffers[0]->ADRS, currentClockCycle);
				}
			}
			else if(upBuffers[0]->CMD == RD_RS) {
				if(readDone != NULL) {
					(*readDone)(upBuffers[0]->ADRS, currentClockCycle);
				}
			}
			int packetLNG = upBuffers[0]->LNG;
			responseAccLNG += packetLNG;
			delete upBuffers[0]->trace;
			delete upBuffers[0];
			upBuffers.erase(upBuffers.begin(), upBuffers.begin()+packetLNG);
		}
	}
	
	//Link state manager
	LinkPowerStateManager();
	//Link goes to low power mode
	LinkPowerEntryManager();
	
	LinkStatistic();
	Step();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x36ce0
movq -0xe0(%rbp), %rax
movl 0x25c(%rax), %ecx
addq 0x260(%rax), %rcx
movq %rcx, 0x260(%rax)
cmpl $0x0, 0x200(%rax)
jne 0x3674d
movq -0xe0(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x1b4f0
cmpq $0x0, %rax
jbe 0x3674d
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
leaq 0x3062c(%rip), %rcx     # 0x66548
cmpl (%rcx), %eax
jge 0x3619e
movl $0x0, -0x14(%rbp)
movq -0xe0(%rbp), %rdi
movslq -0x14(%rbp), %rax
movq %rax, -0xe8(%rbp)
addq $0x208, %rdi            # imm = 0x208
movslq -0x10(%rbp), %rsi
callq 0x17770
movq (%rax), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x22d60
movq %rax, %rcx
movq -0xe8(%rbp), %rax
cmpq %rcx, %rax
jae 0x3618e
movq -0xe0(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x10(%rbp), %rsi
callq 0x17770
movq (%rax), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x29940
cmpq $0x0, (%rax)
je 0x3617e
leaq 0x30682(%rip), %rax     # 0x6662c
movl (%rax), %edi
callq 0x29ce0
movq -0xe0(%rbp), %rdi
movl %eax, -0x18(%rbp)
addq $0x208, %rdi            # imm = 0x208
movslq -0x10(%rbp), %rsi
callq 0x17770
movq (%rax), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x29940
movq -0xe0(%rbp), %rdi
movq (%rax), %rax
movq 0x450(%rax), %rax
movl -0x18(%rbp), %ecx
shrq %cl, %rax
movq %rax, -0xf0(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
xorl %eax, %eax
movl %eax, %esi
callq 0x3a790
movq %rax, %rcx
movq -0xf0(%rbp), %rax
movq (%rcx), %rcx
movq 0x18(%rcx), %rdx
movl -0x18(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
cmpq %rcx, %rax
jne 0x3617c
movl -0x10(%rbp), %eax
movl %eax, -0xc(%rbp)
leaq 0x304ec(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x3617a
leaq 0x304dd(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x3617a
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %esi
movq 0x2ff64(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x118(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x118(%rbp), %rdi
movb %al, -0x1d(%rbp)
movzbl -0x1d(%rbp), %esi
callq 0x4550
movq -0xe0(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x110(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x110(%rbp), %rdi
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %esi
callq 0x4440
movq %rax, -0x108(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x108(%rbp), %rdi
movb %al, -0x25(%rbp)
movzbl -0x25(%rbp), %esi
callq 0x4550
movq -0xe0(%rbp), %rdi
movq %rax, -0x100(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
xorl %eax, %eax
movl %eax, %esi
callq 0x3a790
movq -0x100(%rbp), %rdi
movq (%rax), %rsi
callq 0x4a3b0
movq %rax, %rdi
leaq 0x1d18f(%rip), %rsi     # 0x532b5
callq 0x4380
movq -0xe0(%rbp), %rdi
movq %rax, -0xf8(%rbp)
addq $0x208, %rdi            # imm = 0x208
movslq -0x10(%rbp), %rsi
callq 0x17770
movq (%rax), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x29940
movq -0xf8(%rbp), %rdi
movq (%rax), %rsi
callq 0x44960
movq %rax, %rdi
movq 0x2fe3b(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x3618e
jmp 0x3617e
jmp 0x36180
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x35f2b
jmp 0x36190
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x35f12
cmpl $-0x1, -0xc(%rbp)
jne 0x3653b
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
leaq 0x3038f(%rip), %rcx     # 0x66548
cmpl (%rcx), %eax
jge 0x36536
movq -0xe0(%rbp), %rsi
movq %rsi, %rdi
addq $0x238, %rdi            # imm = 0x238
addq $0x208, %rsi            # imm = 0x208
callq 0x40270
movl %eax, -0xc(%rbp)
cmpl $-0x1, -0xc(%rbp)
jne 0x361ec
jmp 0x36526
movq -0xe0(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0xc(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x0, 0x200(%rax)
je 0x36237
movq -0xe0(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0xc(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0xb, 0x200(%rax)
je 0x36237
jmp 0x36528
movq -0xe0(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
xorl %eax, %eax
movl %eax, %esi
callq 0x3a790
movq -0xe0(%rbp), %rdi
movq (%rax), %rsi
callq 0x37c70
movq -0xe0(%rbp), %rdi
movq %rax, -0x38(%rbp)
addq $0x208, %rdi            # imm = 0x208
movslq -0xc(%rbp), %rsi
callq 0x17770
movq (%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x29f60
testb $0x1, %al
jne 0x3628d
jmp 0x364f9
leaq 0x30294(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x36395
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %esi
movq 0x2fd1c(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x130(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x130(%rbp), %rdi
movb %al, -0x3d(%rbp)
movzbl -0x3d(%rbp), %esi
callq 0x4550
movq -0xe0(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x128(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x128(%rbp), %rdi
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %esi
callq 0x4440
movq %rax, -0x120(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x120(%rbp), %rdi
movb %al, -0x45(%rbp)
movzbl -0x45(%rbp), %esi
callq 0x4550
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x44960
movq %rax, %rdi
leaq 0x1cf96(%rip), %rsi     # 0x532e3
callq 0x4380
movq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x1d143(%rip), %rsi     # 0x534aa
callq 0x4380
movq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x1dff8(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x2fc20(%rip), %rsi     # 0x65fb0
callq 0x43c0
movq -0x38(%rbp), %rax
cmpl $0x18, 0x434(%rax)
jl 0x363af
movq -0x38(%rbp), %rax
cmpl $0x1f, 0x434(%rax)
jle 0x36406
movq -0x38(%rbp), %rax
cmpl $0x5f, 0x434(%rax)
je 0x36406
movq -0x38(%rbp), %rax
cmpl $0x22, 0x434(%rax)
je 0x36406
movq -0x38(%rbp), %rax
cmpl $0x23, 0x434(%rax)
je 0x36406
movq -0x38(%rbp), %rax
cmpl $0x54, 0x434(%rax)
je 0x36406
movq -0x38(%rbp), %rax
cmpl $0x21, 0x434(%rax)
je 0x36406
movq -0xe0(%rbp), %rax
movl 0x268(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x268(%rax)
movq -0x38(%rbp), %rax
cmpl $0x18, 0x434(%rax)
jl 0x36420
movq -0x38(%rbp), %rax
cmpl $0x1f, 0x434(%rax)
jle 0x3642d
movq -0x38(%rbp), %rax
cmpl $0x5f, 0x434(%rax)
jne 0x36463
movq -0xe0(%rbp), %rax
cmpq $0x0, 0x358(%rax)
je 0x36461
movq -0xe0(%rbp), %rax
movq 0x358(%rax), %rdi
movq -0x38(%rbp), %rcx
movq 0x450(%rcx), %rsi
movq 0x8(%rax), %rdx
movq (%rdi), %rax
callq *0x10(%rax)
jmp 0x36463
movq -0xe0(%rbp), %rdi
movq -0x38(%rbp), %rax
movl 0x430(%rax), %eax
addq 0x248(%rdi), %rax
movq %rax, 0x248(%rdi)
addq $0x1d0, %rdi            # imm = 0x1D0
xorl %eax, %eax
movl %eax, %esi
callq 0x3a790
movq (%rax), %rax
movq %rax, -0x138(%rbp)
cmpq $0x0, %rax
je 0x364af
movq -0x138(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0xe0(%rbp), %rdi
movq %rdi, %rax
addq $0x1d0, %rax            # imm = 0x1D0
movq %rax, -0x140(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x1b8a0
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3a820
movq -0x140(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x3a7b0
movq %rax, -0x60(%rbp)
jmp 0x36536
movq -0x38(%rbp), %rdi
callq 0x44940
movq -0x38(%rbp), %rax
movq %rax, -0x148(%rbp)
cmpq $0x0, %rax
je 0x36520
movq -0x148(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x36522
jmp 0x36524
jmp 0x36526
jmp 0x36528
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x361af
jmp 0x3674b
movq -0xe0(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
xorl %eax, %eax
movl %eax, %esi
callq 0x3a790
movq -0xe0(%rbp), %rdi
movq (%rax), %rsi
callq 0x37c70
movq -0xe0(%rbp), %rdi
movq %rax, -0x68(%rbp)
addq $0x208, %rdi            # imm = 0x208
movslq -0xc(%rbp), %rsi
callq 0x17770
movq (%rax), %rdi
movq -0x68(%rbp), %rsi
callq 0x29f60
testb $0x1, %al
jne 0x36591
jmp 0x36720
leaq 0x2ff90(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x36699
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %esi
movq 0x2fa18(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x160(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x160(%rbp), %rdi
movb %al, -0x6d(%rbp)
movzbl -0x6d(%rbp), %esi
callq 0x4550
movq -0xe0(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x158(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x158(%rbp), %rdi
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %esi
callq 0x4440
movq %rax, -0x150(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x150(%rbp), %rdi
movb %al, -0x75(%rbp)
movzbl -0x75(%rbp), %esi
callq 0x4550
movq %rax, %rdi
movq -0x68(%rbp), %rsi
callq 0x44960
movq %rax, %rdi
leaq 0x1cc92(%rip), %rsi     # 0x532e3
callq 0x4380
movq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x1ce3f(%rip), %rsi     # 0x534aa
callq 0x4380
movq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x1dcf4(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x2f91c(%rip), %rsi     # 0x65fb0
callq 0x43c0
movq -0xe0(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
xorl %eax, %eax
movl %eax, %esi
callq 0x3a790
movq (%rax), %rax
movq %rax, -0x168(%rbp)
cmpq $0x0, %rax
je 0x366cd
movq -0x168(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0xe0(%rbp), %rdi
movq %rdi, %rax
addq $0x1d0, %rax            # imm = 0x1D0
movq %rax, -0x170(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x1b8a0
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3a820
movq -0x170(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x3a7b0
movq %rax, -0x90(%rbp)
jmp 0x36749
movq -0x68(%rbp), %rdi
callq 0x44940
movq -0x68(%rbp), %rax
movq %rax, -0x178(%rbp)
cmpq $0x0, %rax
je 0x36747
movq -0x178(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x36749
jmp 0x3674b
jmp 0x3674d
movq -0xe0(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x22d60
cmpq $0x0, %rax
jbe 0x36c9f
movq -0xe0(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
cmpq $0x0, (%rax)
jne 0x36832
movq 0x2f85e(%rip), %rdi     # 0x65ff0
leaq 0x1a8a1(%rip), %rsi     # 0x5103a
callq 0x4380
movq %rax, %rdi
leaq 0x1cb5f(%rip), %rsi     # 0x53307
callq 0x4380
movq %rax, %rdi
leaq 0x1b07e(%rip), %rsi     # 0x51835
callq 0x4380
movq %rax, %rdi
movl $0xc9, %esi
callq 0x4610
movq %rax, %rdi
leaq 0x1a886(%rip), %rsi     # 0x51059
callq 0x4380
movq -0xe0(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x1cb2c(%rip), %rsi     # 0x53321
callq 0x4380
movq %rax, %rdi
movq -0xe0(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x40f0
movq %rax, %rdi
leaq 0x1db62(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x2f78a(%rip), %rsi     # 0x65fb0
callq 0x43c0
xorl %edi, %edi
callq 0x4460
leaq 0x2fcef(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x3693f
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %esi
movq 0x2f771(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x198(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x198(%rbp), %rdi
movb %al, -0x95(%rbp)
movzbl -0x95(%rbp), %esi
callq 0x4550
movq -0xe0(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0x190(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0x190(%rbp), %rdi
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %esi
callq 0x4440
movq %rax, -0x188(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x188(%rbp), %rdi
movb %al, -0x9d(%rbp)
movzbl -0x9d(%rbp), %esi
callq 0x4550
movq -0xe0(%rbp), %rdi
movq %rax, -0x180(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq -0x180(%rbp), %rdi
movq (%rax), %rsi
callq 0x44960
movq %rax, %rdi
leaq 0x1ca79(%rip), %rsi     # 0x533a4
callq 0x4380
movq %rax, %rdi
movq 0x2f676(%rip), %rsi     # 0x65fb0
callq 0x43c0
movq -0xe0(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x1a8(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq -0xe0(%rbp), %rdi
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
movl 0x8(%rcx), %ecx
subq %rcx, %rax
movl %eax, -0x19c(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movl -0x19c(%rbp), %ecx
movq -0xe0(%rbp), %rdi
movq (%rax), %rax
movq 0x8(%rax), %rax
movl %ecx, 0xc(%rax)
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq (%rax), %rax
cmpl $0x38, 0x434(%rax)
jne 0x36a2d
movq -0xe0(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq -0xe0(%rbp), %rdi
movq (%rax), %rax
movl 0x430(%rax), %eax
subl $0x1, %eax
shll $0x4, %eax
movl %eax, %eax
movq %rax, -0x1b0(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq -0x1b0(%rbp), %rcx
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
addq 0x128(%rax), %rcx
movq %rcx, 0x128(%rax)
movq -0xe0(%rbp), %rdi
movl 0x268(%rdi), %eax
addl $-0x1, %eax
movl %eax, 0x268(%rdi)
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq (%rax), %rax
cmpl $0x39, 0x434(%rax)
jne 0x36abf
movq -0xe0(%rbp), %rax
cmpq $0x0, 0x358(%rax)
je 0x36aba
movq -0xe0(%rbp), %rdi
movq 0x358(%rdi), %rax
movq %rax, -0x1b8(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq -0x1b8(%rbp), %rdi
movq %rax, %rcx
movq -0xe0(%rbp), %rax
movq (%rcx), %rcx
movq 0x450(%rcx), %rsi
movq 0x8(%rax), %rdx
movq (%rdi), %rax
callq *0x10(%rax)
jmp 0x36b41
movq -0xe0(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq (%rax), %rax
cmpl $0x38, 0x434(%rax)
jne 0x36b3f
movq -0xe0(%rbp), %rax
cmpq $0x0, 0x350(%rax)
je 0x36b3d
movq -0xe0(%rbp), %rdi
movq 0x350(%rdi), %rax
movq %rax, -0x1c0(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq -0x1c0(%rbp), %rdi
movq %rax, %rcx
movq -0xe0(%rbp), %rax
movq (%rcx), %rcx
movq 0x450(%rcx), %rsi
movq 0x8(%rax), %rdx
movq (%rdi), %rax
callq *0x10(%rax)
jmp 0x36b3f
jmp 0x36b41
movq -0xe0(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq -0xe0(%rbp), %rdi
movq (%rax), %rax
movl 0x430(%rax), %eax
movl %eax, -0xa4(%rbp)
movslq -0xa4(%rbp), %rax
addq 0x250(%rdi), %rax
movq %rax, 0x250(%rdi)
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x1c8(%rbp)
cmpq $0x0, %rax
je 0x36bc4
movq -0x1c8(%rbp), %rdi
callq 0x17b80
movq -0x1c8(%rbp), %rdi
movl $0x20, %esi
callq 0x43a0
movq -0xe0(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
xorl %eax, %eax
movl %eax, %esi
callq 0x29940
movq (%rax), %rax
movq %rax, -0x1d0(%rbp)
cmpq $0x0, %rax
je 0x36bf8
movq -0x1d0(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0xe0(%rbp), %rdi
movq %rdi, %rax
addq $0x1e8, %rax            # imm = 0x1E8
movq %rax, -0x1d8(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x29a60
movq -0xe0(%rbp), %rdi
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0xd0(%rbp)
movslq -0xa4(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x29a20
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x29a60
movq -0x1d8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movq -0xc0(%rbp), %rdx
callq 0x29960
movq %rax, -0xd8(%rbp)
jmp 0x36c9f
movq -0xe0(%rbp), %rdi
callq 0x38330
movq -0xe0(%rbp), %rdi
callq 0x38d10
movq -0xe0(%rbp), %rdi
callq 0x3a1d0
movq -0xe0(%rbp), %rdi
callq 0x3a860
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
nopl (%rax,%rax)