// File: /workspace/github_cpp_makefile_star2_O1/estwings57[P]CasHMC/sources/LinkSlave.cpp
// Function: CasHMC::LinkSlave::Update()
void LinkSlave::Update()
{
	//Extracting flow control and checking CRC, SEQ from linkRxTx packet 
	if(linkRxTx.size() > 0) {
		//Make sure that linkRxTx[0] is not virtual tail packet.
		if(linkRxTx[0] == NULL) {
			ERROR(header<<"  == Error - linkRxTx[0] is NULL (It could be one of virtual tail packet  (CurrentClock : "<<currentClockCycle<<")");
			exit(0);
		}
		else {
			for(int i=0; i<linkRxTx.size(); i++) {
				if(linkRxTx[i]->bufPopDelay == 0) {
					//Link retraining sequence
					if(linkRxTx[i]->CMD == NULL_) {
						//[Responder descrambler initializing]
						//The responder descrambler sync should occur within tRESP1 of the PLL locking
						if(downstream && localLinkMaster->currentState == SLEEP) {
							localLinkMaster->firstNull = true;
							localLinkMaster->currentState = RETRAIN1;
							uint64_t tran = ceil((double)(tRESP1)/tCK);
							localLinkMaster->retrainTransit = currentClockCycle + tran;
						}
						//[Requester descrambler synchronization]
						else if(!downstream && localLinkMaster->currentState == RETRAIN1) {
							localLinkMaster->firstNull = true;
							localLinkMaster->currentState = RETRAIN2;
						}
						//[Responder FLIT synchrony]
						//Responder link lock should occur within tRESP2
						else if(downstream && localLinkMaster->currentState == RETRAIN1) {
							localLinkMaster->firstNull = true;
							localLinkMaster->currentState = RETRAIN2;
							uint64_t tran = ceil((double)(tRESP2)/tCK);
							localLinkMaster->retrainTransit = currentClockCycle + tran;
						}
						//[Requester FLIT synchrony and sending a minimum of 32 NULL FLITs before entering ACTIVE]
						else if(!downstream && localLinkMaster->currentState == RETRAIN2) {
							currentState = ACTIVE;
							localLinkMaster->FinishRetrain();
						}
						//[sending a minimum of 32 NULL FLITs before entering ACTIVE]
						else if(downstream && localLinkMaster->currentState == RETRAIN2) {
							currentState = ACTIVE;
							localLinkMaster->FinishRetrain();
						}
						delete linkRxTx[i];
						linkRxTx.erase(linkRxTx.begin()+i);
						continue;
					}
					
					//Retry control
					if(linkRxTx[i]->CMD == IRTRY) {
						if(linkRxTx[i]->bufPopDelay == 0) {
							linkRxTx[i]->chkRRP = true;
							localLinkMaster->UpdateRetryPointer(linkRxTx[i]);
							if(linkRxTx[i]->FRP == 1) {
								if(localLinkMaster->currentState != LINK_RETRY) {
									localLinkMaster->LinkRetry(linkRxTx[i]);
								}
							}
							else if(linkRxTx[i]->FRP == 2) {
								if(localLinkMaster->currentState == START_RETRY
								|| localLinkMaster->currentState == LINK_RETRY) {
									localLinkMaster->FinishRetry();
									currentState = ACTIVE;
									slaveSEQ = 0;
								}
							}
							delete linkRxTx[i];
							linkRxTx.erase(linkRxTx.begin()+i);
							break;
						}
					}
					else if(currentState == START_RETRY) {
						delete linkRxTx[i];
						linkRxTx.erase(linkRxTx.begin()+i);
						break;
					}
				
					//Flow control
					if(linkRxTx[i]->chkRRP == false) {
						linkRxTx[i]->chkRRP = true;
						localLinkMaster->UpdateRetryPointer(linkRxTx[i]);

						//PRET packet is not saved in the retry buffer (No need to check CRC)
						if(linkRxTx[i]->CMD == PRET) {
							delete linkRxTx[i];
							linkRxTx.erase(linkRxTx.begin()+i);
							break;
						}
					}
					
					//Link low power mode control
					if(linkRxTx[i]->CMD == QUIET) {
						//(upstream) all-way links are checked to enter sleep mode
						if(localLinkMaster->currentState == WAIT) {
							localLinkMaster->currentState = CONFIRM;
							DEBUG(ALI(18)<<header<<ALI(15)<<*linkRxTx[i]<<(downstream ? "Down) " : "Up)   ")
								<<"link is ready to enter LOW POWER mode");
						}
						//(downstream) link is checking the link state to enter sleep mode
						else {
							currentState = WAIT;
							DEBUG(ALI(18)<<header<<ALI(15)<<*linkRxTx[i]<<(downstream ? "Down) " : "Up)   ")
								<<"link is checking the link state to enter sleep mode");
						}
						delete linkRxTx[i];
						linkRxTx.erase(linkRxTx.begin()+i);
						break;
					}
					
					//Count CRC calculation time
					if(linkRxTx[i]->chkRRP == true && linkRxTx[i]->chkCRC == false) {
						if(CRC_CHECK && !startCRC) {
							startCRC = true;
							countdownCRC = ceil((double)CRC_CAL_CYCLE * linkRxTx[i]->LNG);
						}
							
						if(CRC_CHECK && countdownCRC > 0) {
							DEBUG(ALI(18)<<header<<ALI(15)<<*linkRxTx[i]<<(downstream ? "Down) " : "Up)   ")
									<<"WAITING CRC calculation ("<<countdownCRC<<"/"<<ceil((double)CRC_CAL_CYCLE*linkRxTx[i]->LNG)<<")");
						}
						else {
							//Error check
							linkRxTx[i]->chkCRC = true;
							if(CheckNoError(linkRxTx[i])) {
								localLinkMaster->ReturnRetryPointer(linkRxTx[i]);
								localLinkMaster->UpdateToken(linkRxTx[i]);
								if(linkRxTx[i]->CMD != TRET) {
									Receive(linkRxTx[i]);
								}
								else {
									delete linkRxTx[i];
								}
								linkRxTx.erase(linkRxTx.begin()+i);
								break;
							}
							//Error abort mode
							else {
								if(localLinkMaster->retryStartPacket == NULL) {
									localLinkMaster->retryStartPacket = new Packet(*linkRxTx[i]);
								}
								else {
									ERROR(header<<"  == Error - localLinkMaster->retryStartPacket is NOT NULL  (CurrentClock : "<<currentClockCycle<<")");
									exit(0);
								}
								localLinkMaster->StartRetry(linkRxTx[i]);
								localLinkMaster->linkP->statis->errorPerLink[linkSlaveID]++;
								for(int j=0; j<linkRxTx.size(); j++) {
									if(linkRxTx[j] != NULL) {
										delete linkRxTx[j];
									}
									linkRxTx.erase(linkRxTx.begin()+j);
									j--;
								}
								linkRxTx.clear();
								currentState = START_RETRY;
							}
							startCRC = false;
						}
						countdownCRC = (countdownCRC>0) ? countdownCRC-1 : 0;
					}
				}
			}
		}
	}
	
	//Checking the link state to enter sleep mode
	if(currentState == WAIT) {
		//Link is ready for low power mode
		if(localLinkMaster->Buffers.size() == 0
		&& localLinkMaster->retBufReadP == localLinkMaster->retBufWriteP
		&& localLinkMaster->tokenCount == MAX_LINK_BUF) {
			currentState = SLEEP;
			localLinkMaster->currentState = SLEEP;
			localLinkMaster->QuitePacket();
		}
	}

	//Sending packet
	if(Buffers.size() > 0) {
		bool chkRcv = (downstream ? downBufferDest->ReceiveDown(Buffers[0]) : upBufferDest->ReceiveUp(Buffers[0]));
		if(chkRcv) {
			localLinkMaster->ReturnTocken(Buffers[0]);
			DEBUG(ALI(18)<<header<<ALI(15)<<*Buffers[0]<<(downstream ? "Down) " : "Up)   ")
						<<"SENDING packet to "<<(downstream ? "crossbar switch (CS)" : "HMC controller (HC)"));
			Buffers.erase(Buffers.begin(), Buffers.begin()+Buffers[0]->LNG);
		}
		else {
			//DEBUG(ALI(18)<<header<<ALI(15)<<*Buffers[0]<<"(downstream ? "Down) Crossbar switch" : "Up)   HMC controller")<<" buffer FULL");	
		}
	}

	Step();
	for(int i=0; i<linkRxTx.size(); i++) {
		if(linkRxTx[i] != NULL) {
			linkRxTx[i]->bufPopDelay = (linkRxTx[i]->bufPopDelay>0) ? linkRxTx[i]->bufPopDelay-1 : 0;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x1e8(%rdi), %rax
cmpq %rax, 0x1f0(%rdi)
je 0x272b2
cmpq $0x0, (%rax)
je 0x2757f
movq 0x1e8(%rbx), %rax
cmpq %rax, 0x1f0(%rbx)
je 0x272b2
leaq 0x15b93(%rip), %r14     # 0x3c560
leaq 0x15bcc(%rip), %r13     # 0x3c5a0
leaq 0x15b8d(%rip), %r15     # 0x3c568
xorl %ebp, %ebp
movq (%rax,%rbp,8), %rsi
cmpl $0x0, 0x14(%rsi)
jne 0x26de3
movl 0x434(%rsi), %eax
testl %eax, %eax
je 0x26ca0
cmpl $0x3, %eax
je 0x26f2d
cmpl $0xa, 0x200(%rbx)
je 0x27275
cmpb $0x0, 0x421(%rsi)
jne 0x26a43
movb $0x1, 0x421(%rsi)
movq 0x218(%rbx), %rdi
callq 0x22eea
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rdi
cmpl $0x1, 0x434(%rdi)
je 0x27225
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %r12
cmpl $0x4, 0x434(%r12)
je 0x26f81
cmpb $0x1, 0x421(%r12)
jne 0x26de3
cmpb $0x0, 0x420(%r12)
jne 0x26de3
leaq 0x15a4a(%rip), %rax     # 0x3c4cc
movb (%rax), %r13b
cmpb $0x1, %r13b
jne 0x26e09
cmpb $0x0, 0x228(%rbx)
jne 0x26ac9
movb $0x1, 0x228(%rbx)
movl 0x430(%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
leaq 0x15a1a(%rip), %rax     # 0x3c4d0
mulsd (%rax), %xmm0
callq 0x4090
cvttsd2si %xmm0, %eax
movl %eax, 0x224(%rbx)
testb %r13b, %r13b
je 0x26e09
cmpl $0x0, 0x224(%rbx)
jle 0x26e09
leaq 0x159a2(%rip), %rax     # 0x3c488
cmpb $0x1, (%rax)
movl $0x0, %r13d
jne 0x26f0c
leaq 0x1598d(%rip), %rax     # 0x3c489
cmpb $0x0, (%rax)
jne 0x26f0c
movq 0x154c4(%rip), %rdx     # 0x3bfd0
movq (%rdx), %rax
movq -0x18(%rax), %rcx
movq $0x12, 0x10(%rdx,%rcx)
movq -0x18(%rax), %rax
leaq (%rdx,%rax), %r12
cmpb $0x0, 0xe1(%rdx,%rax)
jne 0x26b4c
movq %r12, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r12)
movb $0x1, 0xe1(%r12)
movb $0x20, 0xe0(%r12)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x1546c(%rip), %rdi     # 0x3bfd0
callq 0x4340
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rcx
movq $0xf, 0x10(%r12,%rcx)
movq -0x18(%rax), %rax
leaq (%r12,%rax), %r13
cmpb $0x0, 0xe1(%r12,%rax)
jne 0x26bab
movq %r13, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r13)
movb $0x1, 0xe1(%r13)
movb $0x20, 0xe0(%r13)
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rsi
movq %r12, %rdi
callq 0x28bbe
cmpb $0x0, 0x1cc(%rbx)
movq %rax, %r12
leaq 0xcb20(%rip), %rsi      # 0x336f7
leaq 0xcb12(%rip), %rax      # 0x336f0
cmovneq %rax, %rsi
movl $0x6, %edx
movq %r12, %rdi
callq 0x4340
movl $0x19, %edx
movq %r12, %rdi
leaq 0xcf6c(%rip), %rsi      # 0x33b6a
callq 0x4340
movl 0x224(%rbx), %esi
movq %r12, %rdi
callq 0x4500
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0xa677(%rip), %rsi      # 0x3129a
callq 0x4340
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rax
movl 0x430(%rax), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
leaq 0x15888(%rip), %rax     # 0x3c4d0
mulsd (%rax), %xmm0
callq 0x4090
movq %r12, %rdi
callq 0x4460
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0xd7f6(%rip), %rsi      # 0x34461
callq 0x4340
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41f0
xorl %r13d, %r13d
jmp 0x26f0c
movb 0x1cc(%rbx), %al
cmpb $0x1, %al
jne 0x26cdc
movq 0x218(%rbx), %r12
cmpl $0x1, 0x200(%r12)
jne 0x26cd8
movb $0x1, 0x268(%r12)
movl $0x3, 0x200(%r12)
movsd (%r14), %xmm0
jmp 0x26d32
testb %al, %al
jne 0x26d06
movq 0x218(%rbx), %rcx
cmpl $0x3, 0x200(%rcx)
jne 0x26d02
movb $0x1, 0x268(%rcx)
movl $0x4, 0x200(%rcx)
jmp 0x26d9e
testb %al, %al
je 0x26d6b
movq 0x218(%rbx), %r12
cmpl $0x3, 0x200(%r12)
jne 0x26d67
movb $0x1, 0x268(%r12)
movl $0x4, 0x200(%r12)
movsd (%r15), %xmm0
divsd (%r13), %xmm0
callq 0x4090
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xc497(%rip), %xmm0     # 0x331e8
cvttsd2si %xmm0, %rdx
andl %ecx, %edx
orl %edx, %eax
addl 0x8(%rbx), %eax
movl %eax, 0x264(%r12)
jmp 0x26d9e
testb %al, %al
jne 0x26d7f
movq 0x218(%rbx), %rdi
cmpl $0x4, 0x200(%rdi)
je 0x26d8f
testb %al, %al
je 0x26d9e
movq 0x218(%rbx), %rdi
cmpl $0x4, 0x200(%rdi)
jne 0x26d9e
movl $0x0, 0x200(%rbx)
callq 0x25958
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rdi
testq %rdi, %rdi
je 0x26db4
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x1e8(%rbx), %rax
movq 0x1f0(%rbx), %rdx
leaq (%rax,%rbp,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x26ddb
leaq (%rax,%rbp,8), %rdi
subq %rsi, %rdx
callq 0x4480
addq $-0x8, 0x1f0(%rbx)
incq %rbp
movq 0x1e8(%rbx), %rax
movq 0x1f0(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rbp, %rcx
ja 0x269dd
jmp 0x272b2
movb $0x1, 0x420(%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2768c
testb %al, %al
jne 0x2722f
movq 0x218(%rbx), %rax
cmpq $0x0, 0x248(%rax)
jne 0x275e1
movl $0x468, %edi            # imm = 0x468
callq 0x42f0
movq %rax, %r12
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rsi
movq %r12, %rdi
callq 0x2879e
xorl %r13d, %r13d
movq 0x218(%rbx), %rdi
movq %r12, 0x248(%rdi)
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rsi
callq 0x23c76
movq 0x218(%rbx), %rax
movq 0x210(%rax), %rax
movq 0x1e0(%rax), %rax
movl 0x204(%rbx), %ecx
movq 0xf8(%rax), %rax
incl (%rax,%rcx,4)
movq 0x1e8(%rbx), %rax
cmpq %rax, 0x1f0(%rbx)
je 0x26efb
movq (%rax), %rdi
testq %rdi, %rdi
je 0x26ebe
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x1e8(%rbx), %rdi
movq 0x1f0(%rbx), %rdx
leaq 0x8(%rdi), %rsi
cmpq %rdx, %rsi
je 0x26edd
subq %rsi, %rdx
callq 0x4480
movq 0x1e8(%rbx), %rax
movq 0x1f0(%rbx), %rcx
addq $-0x8, %rcx
movq %rcx, 0x1f0(%rbx)
cmpq %rax, %rcx
jne 0x26eb0
movl $0xa, 0x200(%rbx)
movb $0x0, 0x228(%rbx)
movl 0x224(%rbx), %eax
leal -0x1(%rax), %ecx
testl %eax, %eax
cmovlel %r13d, %ecx
movl %ecx, 0x224(%rbx)
leaq 0x15678(%rip), %r13     # 0x3c5a0
jmp 0x26de3
movb $0x1, 0x421(%rsi)
movq 0x218(%rbx), %rdi
callq 0x22eea
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rsi
movl 0x448(%rsi), %eax
cmpl $0x2, %eax
je 0x271f2
cmpl $0x1, %eax
jne 0x2721a
movq 0x218(%rbx), %rdi
cmpl $0xb, 0x200(%rdi)
je 0x2721a
callq 0x24040
jmp 0x2721a
movq 0x218(%rbx), %rax
cmpl $0x5, 0x200(%rax)
jne 0x270bd
movl $0x6, 0x200(%rax)
leaq 0x154e2(%rip), %rax     # 0x3c488
cmpb $0x1, (%rax)
jne 0x2721a
leaq 0x154d3(%rip), %rax     # 0x3c489
cmpb $0x0, (%rax)
jne 0x2721a
movq 0x1500a(%rip), %rdx     # 0x3bfd0
movq (%rdx), %rax
movq -0x18(%rax), %rcx
movq $0x12, 0x10(%rdx,%rcx)
movq -0x18(%rax), %rax
leaq (%rdx,%rax), %r12
cmpb $0x0, 0xe1(%rdx,%rax)
jne 0x27006
movq %r12, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r12)
movb $0x1, 0xe1(%r12)
movb $0x20, 0xe0(%r12)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x14fb2(%rip), %rdi     # 0x3bfd0
callq 0x4340
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rcx
movq $0xf, 0x10(%r15,%rcx)
movq -0x18(%rax), %rax
leaq (%r15,%rax), %r12
cmpb $0x0, 0xe1(%r15,%rax)
jne 0x27067
movq %r12, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r12)
movb $0x1, 0xe1(%r12)
movb $0x20, 0xe0(%r12)
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rsi
movq %r15, %rdi
callq 0x28bbe
movq %rax, %r15
cmpb $0x0, 0x1cc(%rbx)
leaq 0xc663(%rip), %rsi      # 0x336f7
leaq 0xc655(%rip), %rax      # 0x336f0
cmovneq %rax, %rsi
movl $0x6, %edx
movq %r15, %rdi
callq 0x4340
leaq 0xcce9(%rip), %rsi      # 0x33d9c
movl $0x25, %edx
jmp 0x271e0
movl $0x5, 0x200(%rbx)
leaq 0x153ba(%rip), %rax     # 0x3c488
cmpb $0x1, (%rax)
jne 0x2721a
leaq 0x153ab(%rip), %rax     # 0x3c489
cmpb $0x0, (%rax)
jne 0x2721a
movq 0x14ee2(%rip), %rdx     # 0x3bfd0
movq (%rdx), %rax
movq -0x18(%rax), %rcx
movq $0x12, 0x10(%rdx,%rcx)
movq -0x18(%rax), %rax
leaq (%rdx,%rax), %r12
cmpb $0x0, 0xe1(%rdx,%rax)
jne 0x2712e
movq %r12, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r12)
movb $0x1, 0xe1(%r12)
movb $0x20, 0xe0(%r12)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x14e8a(%rip), %rdi     # 0x3bfd0
callq 0x4340
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rcx
movq $0xf, 0x10(%r15,%rcx)
movq -0x18(%rax), %rax
leaq (%r15,%rax), %r12
cmpb $0x0, 0xe1(%r15,%rax)
jne 0x2718f
movq %r12, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r12)
movb $0x1, 0xe1(%r12)
movb $0x20, 0xe0(%r12)
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rsi
movq %r15, %rdi
callq 0x28bbe
movq %rax, %r15
cmpb $0x0, 0x1cc(%rbx)
leaq 0xc53b(%rip), %rsi      # 0x336f7
leaq 0xc52d(%rip), %rax      # 0x336f0
cmovneq %rax, %rsi
movl $0x6, %edx
movq %r15, %rdi
callq 0x4340
leaq 0xcbe7(%rip), %rsi      # 0x33dc2
movl $0x33, %edx
movq %r15, %rdi
callq 0x4340
movq %r15, %rdi
callq 0x4170
jmp 0x2721a
movq 0x218(%rbx), %rdi
movl 0x200(%rdi), %eax
andl $-0x2, %eax
cmpl $0xa, %eax
jne 0x2721a
callq 0x24584
xorl %eax, %eax
movl %eax, 0x200(%rbx)
movl %eax, 0x220(%rbx)
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rdi
testq %rdi, %rdi
je 0x27283
movq (%rdi), %rax
jmp 0x27280
movq 0x1e8(%rbx), %rax
movq 0x218(%rbx), %rdi
movq (%rax,%rbp,8), %rsi
callq 0x230cc
movq 0x1e8(%rbx), %rax
movq 0x218(%rbx), %rdi
movq (%rax,%rbp,8), %rsi
callq 0x23488
movq 0x1e8(%rbx), %rax
movq (%rax,%rbp,8), %rsi
cmpl $0x2, 0x434(%rsi)
jne 0x27572
testq %rsi, %rsi
je 0x27283
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x8(%rax)
movq 0x1e8(%rbx), %rax
movq 0x1f0(%rbx), %rdx
leaq (%rax,%rbp,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x272aa
leaq (%rax,%rbp,8), %rdi
subq %rsi, %rdx
callq 0x4480
addq $-0x8, 0x1f0(%rbx)
cmpl $0x5, 0x200(%rbx)
jne 0x27307
movq 0x218(%rbx), %rdi
movq 0x1d8(%rdi), %rax
cmpq 0x1d0(%rdi), %rax
jne 0x27307
movl 0x25c(%rdi), %eax
cmpl 0x260(%rdi), %eax
jne 0x27307
movl 0x208(%rdi), %eax
leaq 0x151cb(%rip), %rcx     # 0x3c4b8
cmpl (%rcx), %eax
jne 0x27307
movl $0x1, %eax
movl %eax, 0x200(%rbx)
movl %eax, 0x200(%rdi)
callq 0x25774
movq 0x1d0(%rbx), %rax
cmpq %rax, 0x1d8(%rbx)
je 0x27514
movq (%rax), %rsi
cmpb $0x1, 0x1cc(%rbx)
jne 0x27335
movq 0x208(%rbx), %rdi
callq 0x1a8b0
jmp 0x27341
movq 0x210(%rbx), %rdi
callq 0x283e6
testb %al, %al
je 0x27514
movq 0x1d0(%rbx), %rax
movq 0x218(%rbx), %rdi
movq (%rax), %rsi
callq 0x236ce
leaq 0x15122(%rip), %rax     # 0x3c488
cmpb $0x1, (%rax)
jne 0x274c8
leaq 0x15113(%rip), %rax     # 0x3c489
cmpb $0x0, (%rax)
jne 0x274c8
movq 0x14c4a(%rip), %rax     # 0x3bfd0
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movq $0x12, 0x10(%rax,%rdx)
movq -0x18(%rcx), %rcx
leaq (%rax,%rcx), %r14
cmpb $0x0, 0xe1(%rax,%rcx)
jne 0x273c4
movq %r14, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r14)
movb $0x1, 0xe1(%r14)
movb $0x20, 0xe0(%r14)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x14bf5(%rip), %rdi     # 0x3bfd0
callq 0x4340
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rcx
movq $0xf, 0x10(%r14,%rcx)
movq -0x18(%rax), %rax
leaq (%r14,%rax), %r15
cmpb $0x0, 0xe1(%r14,%rax)
jne 0x27422
movq %r15, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r15)
movb $0x1, 0xe1(%r15)
movb $0x20, 0xe0(%r15)
movq 0x1d0(%rbx), %rax
movq (%rax), %rsi
movq %r14, %rdi
callq 0x28bbe
movq %rax, %r14
leaq 0xc2aa(%rip), %rax      # 0x336f0
leaq 0xc2aa(%rip), %rsi      # 0x336f7
cmpb $0x0, 0x1cc(%rbx)
cmovneq %rax, %rsi
movl $0x6, %edx
movq %r14, %rdi
callq 0x4340
leaq 0xc9d7(%rip), %rsi      # 0x33e43
movl $0x12, %edx
movq %r14, %rdi
callq 0x4340
movzbl 0x1cc(%rbx), %edx
leaq 0xd93b(%rip), %rax      # 0x34dc2
leaq 0xa42e(%rip), %rsi      # 0x318bc
testq %rdx, %rdx
cmovneq %rax, %rsi
addq $0x13, %rdx
movq %r14, %rdi
callq 0x4340
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41f0
movq 0x1d0(%rbx), %r14
movq (%r14), %rax
movl 0x430(%rax), %eax
testq %rax, %rax
je 0x27514
leaq (%r14,%rax,8), %r15
movq 0x1d8(%rbx), %rdx
subq %r15, %rdx
je 0x274f8
movq %r14, %rdi
movq %r15, %rsi
callq 0x4480
movq 0x1d8(%rbx), %rax
movq %rax, %rcx
subq %r15, %rcx
addq %rcx, %r14
cmpq %r14, %rax
je 0x27514
movq %r14, 0x1d8(%rbx)
movq %rbx, %rdi
callq 0x2653a
movq 0x1e8(%rbx), %rax
movq 0x1f0(%rbx), %rcx
subq %rax, %rcx
je 0x27563
sarq $0x3, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
xorl %esi, %esi
movq (%rax,%rsi,8), %rdi
testq %rdi, %rdi
je 0x2755b
movl 0x14(%rdi), %r8d
leal -0x1(%r8), %r9d
testl %r8d, %r8d
cmovlel %edx, %r9d
movl %r9d, 0x14(%rdi)
incq %rsi
cmpq %rsi, %rcx
jne 0x2753f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x1a9a6
jmp 0x27283
movq 0x14a6a(%rip), %rdi     # 0x3bff0
leaq 0x9a95(%rip), %rsi      # 0x31022
callq 0x42e0
leaq 0xc70b(%rip), %rsi      # 0x33ca4
movq %rax, %rdi
callq 0x42e0
leaq 0xa28f(%rip), %rsi      # 0x31837
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movl $0x49, %esi
callq 0x4500
leaq 0x9a7d(%rip), %rsi      # 0x31041
movq %rax, %rdi
callq 0x42e0
leaq 0x20(%rbx), %rsi
movq %rax, %rdi
callq 0x4290
leaq 0xc762(%rip), %rsi      # 0x33d41
jmp 0x27641
movq 0x14a08(%rip), %rdi     # 0x3bff0
leaq 0x9a33(%rip), %rsi      # 0x31022
callq 0x42e0
leaq 0xc6a9(%rip), %rsi      # 0x33ca4
movq %rax, %rdi
callq 0x42e0
leaq 0xa22d(%rip), %rsi      # 0x31837
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movl $0xd2, %esi
callq 0x4500
leaq 0x9a1b(%rip), %rsi      # 0x31041
movq %rax, %rdi
callq 0x42e0
leaq 0x20(%rbx), %rsi
movq %rax, %rdi
callq 0x4290
leaq 0xc7b5(%rip), %rsi      # 0x33df6
movq %rax, %rdi
callq 0x42e0
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x40c0
leaq 0xce05(%rip), %rsi      # 0x34461
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x4170
xorl %edi, %edi
callq 0x4360
movq %rax, %rbx
movl $0x468, %esi            # imm = 0x468
movq %r12, %rdi
callq 0x4300
movq %rbx, %rdi
callq 0x4540
nop