// File: /workspace/github_cpp_makefile_star2_O1/estwings57[P]CasHMC/sources/HMCController.cpp
// Function: CasHMC::HMCController::LinkPowerEntryManager()
void HMCController::LinkPowerEntryManager()
{
	switch(LINK_POWER) {
		case NO_MANAGEMENT:{
			break;
		}
		case QUIESCE_SLEEP:{
			//Check for last active link
			bool lastActive = false;
			for(int l=0; l<NUM_LINKS; l++) {
				if(downLinkMasters[l]->currentState == ACTIVE) {
					if(!lastActive) {
						lastActive = true;
					}
					else {
						lastActive = false;
						break;
					}
				}
			}
				
			for(int l=0; l<NUM_LINKS; l++) {
				if(downLinkMasters[l]->currentState == ACTIVE) {
					//Setting the quiesce link traffic cycle to enter low power mode
					if(downLinkMasters[l]->Buffers.size() > 0
					|| downLinkMasters[l]->retBufReadP != downLinkMasters[l]->retBufWriteP
					|| downLinkMasters[l]->tokenCount < MAX_LINK_BUF) {
						quiesceLink[l] = currentClockCycle + quiesceClk;
					}
					else if(currentClockCycle >= quiesceLink[l] && currentClockCycle >= stayActive[l]) {
						//In order to prevent from blocking response packet to HMC controller 
						if(!lastActive || returnTransCnt == 0) {
							//Check the opposite link state for entering low power mode
							downLinkMasters[l]->currentState = WAIT;
							downLinkMasters[l]->QuitePacket();
							staySREF = currentClockCycle + ceil((double)(tSREF)/CPU_CLK_PERIOD);
						}
					}
				}
				else if(downLinkMasters[l]->currentState == CONFIRM) {
					//Stagger transition between active mode and sleep modes in order to avoid supply voltage shifts
					if(currentClockCycle >= staggerSleep) {
						//When the last link exits active mode, links are transitioned to down mode to further reduce power consumption
						bool lastExit = true;
						for(int k=0; k<NUM_LINKS; k++) {
							if(l != k && !(downLinkMasters[k]->currentState == SLEEP || downLinkMasters[k]->currentState == TRANSITION_TO_SLEEP)) {
								lastExit = false;
								break;
							}
						}
						
						if(lastExit) {
							uint64_t tran = 0;
							if(staggeringSleep[l]) {
								staggeringSleep[l] = false;
								tran = ceil((double)(tSS+tSD)/CPU_CLK_PERIOD);
							}
							else {
								tran = ceil((double)(tPST+tSD)/CPU_CLK_PERIOD);
							}
							modeTransition[l] = currentClockCycle + tran;
							downLinkMasters[l]->currentState = TRANSITION_TO_DOWN;
							DEBUG(ALI(33)<<header<<"Down) link DOWN MODE transition after "<<modeTransition[l]<<" cycle");
						}
						//Link sleep mode entry
						else {
							uint64_t stag = 0;
							uint64_t tran = 0;
							if(staggeringSleep[l]) {
								staggeringSleep[l] = false;
								stag = ceil((double)tSS/CPU_CLK_PERIOD);
								tran = ceil((double)(tSS+tSME)/CPU_CLK_PERIOD);
							}
							else {
								stag = ceil((double)(tPST+tSS)/CPU_CLK_PERIOD);
								tran = ceil((double)(tPST+tSME)/CPU_CLK_PERIOD);
							}
							staggerSleep = currentClockCycle + stag;
							modeTransition[l] = currentClockCycle + tran;
							downLinkMasters[l]->currentState = TRANSITION_TO_SLEEP;
							DEBUG(ALI(33)<<header<<"Down) link SLEEP MODE transition after "<<modeTransition[l]<<" cycle (stagger : "<<staggerSleep<<") (LM_D"<<l<<")");
						}
					}
					else {
						staggeringSleep[l] = true;
					}
				}
				//Sleep mode entry
				else if(downLinkMasters[l]->currentState == TRANSITION_TO_SLEEP) {
					if(currentClockCycle >= modeTransition[l]) {
						downLinkMasters[l]->currentState = SLEEP;
						DE_CR(ALI(33)<<header<<"Down) entering link SLEEP MODE (LM_D"<<l<<")");
					}
				}
				//Down mode entry
				else if(downLinkMasters[l]->currentState == TRANSITION_TO_DOWN) {
					if(currentClockCycle >= modeTransition[l]) {
						for(int k=0; k<NUM_LINKS; k++) {
							downLinkMasters[k]->currentState = DOWN;
						}
						DE_CR(ALI(33)<<header<<"Down) entering link DOWN MODE");
					}
				}
			}
			break;
		}
		case MSHR:
		case LINK_MONITOR:
		case AUTONOMOUS:{
			//Transition links to sleep mode as many as sleepLink
			for(int l=NUM_LINKS - 1; l>=NUM_LINKS-sleepLink; l--) {
				if(downLinkMasters[l]->currentState == ACTIVE) {
					//The condition to enter sleep mode
					if(downLinkMasters[l]->Buffers.size() == 0
					&& downLinkMasters[l]->retBufReadP == downLinkMasters[l]->retBufWriteP
					&& downLinkMasters[l]->tokenCount == MAX_LINK_BUF
					&& currentClockCycle >= stayActive[l]) {
						//Check the opposite link state for entering low power mode
						downLinkMasters[l]->currentState = WAIT;
						downLinkMasters[l]->QuitePacket();
						staySREF = currentClockCycle + ceil((double)(tSREF)/CPU_CLK_PERIOD);
					}
				}
				else if(downLinkMasters[l]->currentState == CONFIRM) {
					//Stagger transition between active mode and sleep modes in order to avoid supply voltage shifts
					if(currentClockCycle >= staggerSleep) {
						uint64_t stag = 0;
						uint64_t tran = 0;
						if(staggeringSleep[l]) {
							staggeringSleep[l] = false;
							stag = ceil((double)tSS/CPU_CLK_PERIOD);
							tran = ceil((double)tSME/CPU_CLK_PERIOD);
						}
						else {
							stag = ceil((double)(tPST+tSS)/CPU_CLK_PERIOD);
							tran = ceil((double)(tPST+tSME)/CPU_CLK_PERIOD);
						}
						staggerSleep = currentClockCycle + stag;
						modeTransition[l] = currentClockCycle + tran;
						downLinkMasters[l]->currentState = TRANSITION_TO_SLEEP;
						DEBUG(ALI(33)<<header<<"Down) link SLEEP MODE transition after "<<modeTransition[l]<<" cycle (stagger : "<<staggerSleep<<") (LM_D"<<l<<")");
					}
					else {
						staggeringSleep[l] = true;
					}
				}
				//Sleep mode entry
				else if(downLinkMasters[l]->currentState == TRANSITION_TO_SLEEP) {
					if(currentClockCycle >= modeTransition[l]) {
						downLinkMasters[l]->currentState = SLEEP;
						DE_CR(ALI(33)<<header<<"Down) entering link SLEEP MODE (LM_D"<<l<<")");
					}
				}
			}
			break;
		}
		default:{
			ERROR(header<<"   == Error - WRONG LINK_POWER parameter  (LINK_POWER : "<<LINK_POWER<<")");
			exit(0);
			break;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x1b868(%rip), %r14     # 0x3c4e8
movl (%r14), %eax
leal -0x2(%rax), %ecx
cmpl $0x3, %ecx
jae 0x2115d
leaq 0x1b812(%rip), %r13     # 0x3c4a8
movslq (%r13), %rdx
leal -0x1(%rdx), %eax
movl 0x258(%rbx), %ecx
movq %rdx, %rsi
subl %ecx, %edx
cmpl %edx, %eax
jb 0x21855
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
leaq -0x8(,%rsi,8), %r12
decq %rsi
movq %rsi, 0x20(%rsp)
movl %eax, %r14d
xorl %r15d, %r15d
leaq 0x3f(%rcx), %rax
movq %rax, 0x30(%rsp)
movq 0x208(%rbx), %rax
addq %r12, %rax
movq (%rax,%r15,8), %rbp
movl 0x200(%rbp), %eax
cmpl $0x8, %eax
je 0x20e46
cmpl $0x6, %eax
je 0x20dde
testl %eax, %eax
jne 0x2113f
movq 0x1d8(%rbp), %rax
cmpq 0x1d0(%rbp), %rax
jne 0x2113f
movl 0x25c(%rbp), %eax
cmpl 0x260(%rbp), %eax
jne 0x2113f
movl 0x208(%rbp), %eax
leaq 0x1b77e(%rip), %rcx     # 0x3c4b8
cmpl (%rcx), %eax
jne 0x2113f
movq 0x8(%rbx), %rax
movq 0x288(%rbx), %rcx
addq %r12, %rcx
cmpq (%rcx,%r15,8), %rax
jb 0x2113f
movl $0x5, 0x200(%rbp)
movq %rbp, %rdi
callq 0x25774
movsd 0x8(%rbx), %xmm0
unpcklps 0x10388(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x10370(%rip), %xmm0    # 0x310f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
leaq 0x1b7a7(%rip), %rax     # 0x3c540
movsd (%rax), %xmm0
leaq 0x1b6f4(%rip), %rax     # 0x3c498
divsd (%rax), %xmm0
callq 0x4090
addsd 0x10(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x12425(%rip), %xmm0    # 0x331e8
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x280(%rbx)
jmp 0x2113f
movq 0x20(%rsp), %rax
leaq (%rax,%r15), %rcx
leaq 0x3f(%rcx), %rax
testq %rcx, %rcx
cmovnsq %rcx, %rax
sarq $0x6, %rax
movq %rcx, %rdx
andq 0x30(%rsp), %rdx
xorl %esi, %esi
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
cmpq %rdi, %rdx
setbe %sil
movl $0x1, %edx
shlq %cl, %rdx
movq 0x8(%rbx), %rdi
leaq -0x8(,%rsi,8), %rcx
cmpq 0x270(%rbx), %rdi
jae 0x20eed
shlq $0x3, %rax
addq 0x2d0(%rbx), %rax
orq %rdx, (%rcx,%rax)
jmp 0x2113f
movq 0x8(%rbx), %rax
movq 0x2b8(%rbx), %rcx
addq %r12, %rcx
cmpq (%rcx,%r15,8), %rax
jb 0x2113f
movl $0x1, 0x200(%rbp)
leaq 0x1b619(%rip), %rax     # 0x3c488
cmpb $0x1, (%rax)
jne 0x2113f
movq 0x1b151(%rip), %rdx     # 0x3bfd0
movq (%rdx), %rax
movq -0x18(%rax), %rcx
movq $0x21, 0x10(%rdx,%rcx)
movq -0x18(%rax), %rax
leaq (%rdx,%rax), %rbp
cmpb $0x0, 0xe1(%rdx,%rax)
jne 0x20ebb
movq %rbp, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%rbp)
movb $0x1, 0xe1(%rbp)
movb $0x20, 0xe0(%rbp)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x1b0ff(%rip), %rdi     # 0x3bfd0
callq 0x4340
movq %rax, %rbp
movl $0x24, %edx
movq %rax, %rdi
leaq 0x12661(%rip), %rsi     # 0x33549
jmp 0x210ef
shlq $0x3, %rax
addq 0x2d0(%rbx), %rax
movq (%rcx,%rax), %rsi
testq %rdx, %rsi
je 0x20f43
notq %rdx
andq %rdx, %rsi
movq %rsi, (%rax,%rcx)
leaq 0x1b61e(%rip), %rax     # 0x3c530
movsd (%rax), %xmm0
leaq 0x1b57b(%rip), %rax     # 0x3c498
movsd (%rax), %xmm1
movsd %xmm1, 0x8(%rsp)
divsd %xmm1, %xmm0
callq 0x4090
movapd %xmm0, 0x10(%rsp)
leaq 0x1b5eb(%rip), %rax     # 0x3c528
movsd (%rax), %xmm0
jmp 0x20f94
leaq 0x1b5d6(%rip), %rax     # 0x3c520
movsd (%rax), %xmm1
movsd %xmm1, 0x40(%rsp)
leaq 0x1b5d5(%rip), %rax     # 0x3c530
movsd (%rax), %xmm0
addsd %xmm1, %xmm0
leaq 0x1b52e(%rip), %rax     # 0x3c498
movsd (%rax), %xmm1
movsd %xmm1, 0x8(%rsp)
divsd %xmm1, %xmm0
callq 0x4090
movapd %xmm0, 0x10(%rsp)
movsd 0x40(%rsp), %xmm0
leaq 0x1b598(%rip), %rax     # 0x3c528
addsd (%rax), %xmm0
divsd 0x8(%rsp), %xmm0
callq 0x4090
cvttsd2si %xmm0, %rax
movsd 0x1223c(%rip), %xmm1    # 0x331e8
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movapd 0x10(%rsp), %xmm0
cvttsd2si %xmm0, %rax
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
movq %rax, %rsi
sarq $0x3f, %rsi
andq %rcx, %rsi
orq %rax, %rsi
movq 0x8(%rbx), %rax
addq %rax, %rsi
movq %rsi, 0x270(%rbx)
addq %rax, %rdx
movq 0x2b8(%rbx), %rax
addq %r12, %rax
movq %rdx, (%rax,%r15,8)
movl $0x8, 0x200(%rbp)
leaq 0x1b475(%rip), %rax     # 0x3c488
cmpb $0x1, (%rax)
jne 0x2113f
leaq 0x1b466(%rip), %rax     # 0x3c489
cmpb $0x0, (%rax)
jne 0x2113f
movq 0x1af9d(%rip), %rdx     # 0x3bfd0
movq (%rdx), %rax
movq -0x18(%rax), %rcx
movq $0x21, 0x10(%rdx,%rcx)
movq -0x18(%rax), %rax
leaq (%rdx,%rax), %rbp
cmpb $0x0, 0xe1(%rdx,%rax)
jne 0x2106f
movq %rbp, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%rbp)
movb $0x1, 0xe1(%rbp)
movb $0x20, 0xe0(%rbp)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x1af4b(%rip), %rdi     # 0x3bfd0
callq 0x4340
movq %rax, %rbp
movl $0x27, %edx
movq %rax, %rdi
leaq 0x1246a(%rip), %rsi     # 0x33506
callq 0x4340
movq 0x2b8(%rbx), %rax
addq %r12, %rax
movq (%rax,%r15,8), %rsi
movq %rbp, %rdi
callq 0x41e0
movq %rax, %rbp
movl $0x12, %edx
movq %rax, %rdi
leaq 0x12465(%rip), %rsi     # 0x3352e
callq 0x4340
movq 0x270(%rbx), %rsi
movq %rbp, %rdi
callq 0x41e0
movq %rax, %rbp
movl $0x7, %edx
movq %rax, %rdi
leaq 0x12452(%rip), %rsi     # 0x33541
callq 0x4340
leal (%r14,%r15), %esi
movq %rbp, %rdi
callq 0x4500
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1334f(%rip), %rsi     # 0x34461
callq 0x4340
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41f0
movl (%r13), %eax
subl 0x258(%rbx), %eax
decq %r15
leal (%r14,%r15), %ecx
cmpl %ecx, %eax
jbe 0x20cd9
jmp 0x21855
testl %eax, %eax
je 0x21855
cmpl $0x1, %eax
jne 0x21864
leaq 0x1b333(%rip), %rbp     # 0x3c4a8
movslq (%rbp), %rax
testq %rax, %rax
jle 0x211ae
movq 0x208(%rbx), %rcx
xorl %edx, %edx
xorl %r12d, %r12d
movq (%rcx,%rdx,8), %rsi
cmpl $0x0, 0x200(%rsi)
jne 0x211a0
testb $0x1, %r12b
jne 0x211ae
movb $0x1, %r12b
incq %rdx
cmpq %rdx, %rax
jne 0x2118a
xorb $0x1, %r12b
jmp 0x211b1
movb $0x1, %r12b
movl (%rbp), %eax
testl %eax, %eax
jle 0x21855
xorl %r14d, %r14d
leaq 0x12146(%rip), %r15     # 0x3330c
movq 0x208(%rbx), %rcx
movq (%rcx,%r14,8), %r13
movl 0x200(%r13), %edx
cmpq $0x9, %rdx
ja 0x2159d
movslq (%r15,%rdx,4), %rdx
addq %r15, %rdx
jmpq *%rdx
movq 0x1d8(%r13), %rax
cmpq 0x1d0(%r13), %rax
jne 0x21221
movl 0x25c(%r13), %eax
cmpl 0x260(%r13), %eax
jne 0x21221
movl 0x208(%r13), %eax
leaq 0x1b29f(%rip), %rcx     # 0x3c4b8
cmpl (%rcx), %eax
jae 0x215b2
movl 0x26c(%rbx), %eax
addq 0x8(%rbx), %rax
movq 0x2a0(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
jmp 0x2159d
movq 0x8(%rbx), %rax
movq 0x2b8(%rbx), %rcx
cmpq (%rcx,%r14,8), %rax
jb 0x2159d
movl $0x1, 0x200(%r13)
leaq 0x1b226(%rip), %rax     # 0x3c488
cmpb $0x1, (%rax)
jne 0x2159d
movq 0x1ad5e(%rip), %rdx     # 0x3bfd0
movq (%rdx), %rax
movq -0x18(%rax), %rcx
movq $0x21, 0x10(%rdx,%rcx)
movq -0x18(%rax), %rax
leaq (%rdx,%rax), %r13
cmpb $0x0, 0xe1(%rdx,%rax)
jne 0x212b0
movq %r13, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r13)
movb $0x1, 0xe1(%r13)
movb $0x20, 0xe0(%r13)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x1ad09(%rip), %rdi     # 0x3bfd0
callq 0x4340
movq %rax, %r13
movl $0x24, %edx
movq %rax, %rdi
leaq 0x1226b(%rip), %rsi     # 0x33549
callq 0x4340
movq %r13, %rdi
movl %r14d, %esi
callq 0x4500
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x13161(%rip), %rsi     # 0x34461
jmp 0x21570
movq 0x8(%rbx), %rdx
cmpq 0x270(%rbx), %rdx
jae 0x213f3
movq 0x2d0(%rbx), %rax
movq %r14, %rdx
movl $0x1, %esi
movl %r14d, %ecx
shlq %cl, %rsi
shrq $0x6, %rdx
orq %rsi, (%rax,%rdx,8)
jmp 0x2159d
movq 0x8(%rbx), %rdx
movq 0x2b8(%rbx), %rsi
cmpq (%rsi,%r14,8), %rdx
jb 0x2159d
testl %eax, %eax
jle 0x2136b
movl %eax, %eax
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
movl $0x2, 0x200(%rsi)
incq %rdx
cmpq %rdx, %rax
jne 0x21355
leaq 0x1b116(%rip), %rax     # 0x3c488
cmpb $0x0, (%rax)
je 0x2159d
movq 0x1ac4e(%rip), %rdx     # 0x3bfd0
movq (%rdx), %rax
movq -0x18(%rax), %rcx
movq $0x21, 0x10(%rdx,%rcx)
movq -0x18(%rax), %rax
leaq (%rdx,%rax), %r13
cmpb $0x0, 0xe1(%rdx,%rax)
jne 0x213c0
movq %r13, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r13)
movb $0x1, 0xe1(%r13)
movb $0x20, 0xe0(%r13)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x1abf9(%rip), %rdi     # 0x3bfd0
callq 0x4340
movq %rax, %r13
movl $0x1d, %edx
movq %rax, %rdi
leaq 0x12180(%rip), %rsi     # 0x3356e
jmp 0x21570
testl %eax, %eax
jle 0x21420
movl %eax, %eax
xorl %edx, %edx
cmpq %rdx, %r14
je 0x21418
movq (%rcx,%rdx,8), %rsi
movl 0x200(%rsi), %esi
cmpl $0x8, %esi
je 0x21418
cmpl $0x1, %esi
jne 0x21666
incq %rdx
cmpq %rdx, %rax
jne 0x213fb
movq 0x2d0(%rbx), %rax
movq %r14, %rdx
movl $0x1, %esi
movl %r14d, %ecx
shlq %cl, %rsi
shrq $0x6, %rdx
movq (%rax,%rdx,8), %rcx
btq %r14, %rcx
leaq 0x1b0d8(%rip), %rdi     # 0x3c520
jae 0x2145b
notq %rsi
andq %rsi, %rcx
movq %rcx, (%rax,%rdx,8)
leaq 0x1b0d5(%rip), %rdi     # 0x3c530
movsd (%rdi), %xmm0
leaq 0x1b0d2(%rip), %rax     # 0x3c538
addsd (%rax), %xmm0
leaq 0x1b027(%rip), %rax     # 0x3c498
divsd (%rax), %xmm0
callq 0x4090
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x11d5a(%rip), %xmm0    # 0x331e8
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
addq 0x8(%rbx), %rdx
movq 0x2b8(%rbx), %rax
movq %rdx, (%rax,%r14,8)
movl $0x9, 0x200(%r13)
leaq 0x1afce(%rip), %rax     # 0x3c488
cmpb $0x1, (%rax)
jne 0x2159d
leaq 0x1afbf(%rip), %rax     # 0x3c489
cmpb $0x0, (%rax)
jne 0x2159d
movq 0x1aaf6(%rip), %rdx     # 0x3bfd0
movq (%rdx), %rax
movq -0x18(%rax), %rcx
movq $0x21, 0x10(%rdx,%rcx)
movq -0x18(%rax), %rax
leaq (%rdx,%rax), %r13
cmpb $0x0, 0xe1(%rdx,%rax)
jne 0x21518
movq %r13, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r13)
movb $0x1, 0xe1(%r13)
movb $0x20, 0xe0(%r13)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x1aaa1(%rip), %rdi     # 0x3bfd0
callq 0x4340
movq %rax, %r13
movl $0x26, %edx
movq %rax, %rdi
leaq 0x11f92(%rip), %rsi     # 0x334d8
callq 0x4340
movq 0x2b8(%rbx), %rax
movq (%rax,%r14,8), %rsi
movq %r13, %rdi
callq 0x41e0
movq %rax, %r13
movl $0x6, %edx
movq %rax, %rdi
leaq 0x11f8f(%rip), %rsi     # 0x334ff
callq 0x4340
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x42d0
movsbl %al, %esi
movq %r13, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x41f0
incq %r14
movslq (%rbp), %rax
cmpq %rax, %r14
jl 0x211c6
jmp 0x21855
movq 0x8(%rbx), %rax
movq 0x2a0(%rbx), %rcx
cmpq (%rcx,%r14,8), %rax
jb 0x2159d
movq 0x288(%rbx), %rcx
cmpq (%rcx,%r14,8), %rax
jb 0x2159d
cmpl $0x0, 0x268(%rbx)
sete %al
orb %r12b, %al
testb $0x1, %al
je 0x2159d
movl $0x5, 0x200(%r13)
movq %r13, %rdi
callq 0x25774
movsd 0x8(%rbx), %xmm0
unpcklps 0xfb00(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xfae8(%rip), %xmm0     # 0x310f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
leaq 0x1af1f(%rip), %rax     # 0x3c540
movsd (%rax), %xmm0
leaq 0x1ae6c(%rip), %rax     # 0x3c498
divsd (%rax), %xmm0
callq 0x4090
addsd 0x20(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0x11b9d(%rip), %xmm0    # 0x331e8
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x280(%rbx)
jmp 0x2159d
movq 0x2d0(%rbx), %rax
movl $0x1, %edx
movl %r14d, %ecx
shlq %cl, %rdx
movq %r14, %rcx
shrq $0x6, %rcx
movq (%rax,%rcx,8), %rsi
btq %r14, %rsi
jae 0x216a6
notq %rdx
andq %rdx, %rsi
movq %rsi, (%rax,%rcx,8)
leaq 0x1ae96(%rip), %rax     # 0x3c530
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0x216c6
leaq 0x1ae73(%rip), %rax     # 0x3c520
movsd (%rax), %xmm1
leaq 0x1ae78(%rip), %rax     # 0x3c530
movsd (%rax), %xmm0
movsd %xmm1, 0x20(%rsp)
addsd %xmm1, %xmm0
leaq 0x1adcb(%rip), %rax     # 0x3c498
movsd (%rax), %xmm1
movsd %xmm1, 0x10(%rsp)
divsd %xmm1, %xmm0
callq 0x4090
movapd %xmm0, 0x30(%rsp)
leaq 0x1ae3b(%rip), %rax     # 0x3c528
movsd 0x20(%rsp), %xmm0
addsd (%rax), %xmm0
divsd 0x10(%rsp), %xmm0
callq 0x4090
movapd 0x30(%rsp), %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
movsd 0x11acc(%rip), %xmm1    # 0x331e8
subsd %xmm1, %xmm2
cvttsd2si %xmm2, %rdx
andq %rcx, %rdx
orq %rax, %rdx
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rsi
sarq $0x3f, %rcx
andq %rcx, %rsi
orq %rax, %rsi
movq 0x8(%rbx), %rax
addq %rax, %rdx
movq %rdx, 0x270(%rbx)
addq %rax, %rsi
movq 0x2b8(%rbx), %rax
movq %rsi, (%rax,%r14,8)
movl $0x8, 0x200(%r13)
leaq 0x1ad14(%rip), %rax     # 0x3c488
cmpb $0x1, (%rax)
jne 0x2159d
leaq 0x1ad05(%rip), %rax     # 0x3c489
cmpb $0x0, (%rax)
jne 0x2159d
movq 0x1a83c(%rip), %rdx     # 0x3bfd0
movq (%rdx), %rax
movq -0x18(%rax), %rcx
movq $0x21, 0x10(%rdx,%rcx)
movq -0x18(%rax), %rax
leaq (%rdx,%rax), %r13
cmpb $0x0, 0xe1(%rdx,%rax)
jne 0x217d2
movq %r13, %rdi
movl $0x20, %esi
callq 0x42d0
movb %al, 0xe0(%r13)
movb $0x1, 0xe1(%r13)
movb $0x20, 0xe0(%r13)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq 0x1a7e7(%rip), %rdi     # 0x3bfd0
callq 0x4340
movq %rax, %r13
movl $0x27, %edx
movq %rax, %rdi
leaq 0x11d06(%rip), %rsi     # 0x33506
callq 0x4340
movq 0x2b8(%rbx), %rax
movq (%rax,%r14,8), %rsi
movq %r13, %rdi
callq 0x41e0
movq %rax, %r13
movl $0x12, %edx
movq %rax, %rdi
leaq 0x11d04(%rip), %rsi     # 0x3352e
callq 0x4340
movq 0x270(%rbx), %rsi
movq %r13, %rdi
callq 0x41e0
movq %rax, %r13
movl $0x7, %edx
movq %rax, %rdi
leaq 0x11cf1(%rip), %rsi     # 0x33541
jmp 0x212de
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a785(%rip), %rdi     # 0x3bff0
leaq 0xf7b0(%rip), %rsi      # 0x31022
callq 0x42e0
leaq 0x11b21(%rip), %rsi     # 0x3339f
movq %rax, %rdi
callq 0x42e0
leaq 0xffaa(%rip), %rsi      # 0x31837
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
movl $0x1e7, %esi            # imm = 0x1E7
callq 0x4500
leaq 0xf798(%rip), %rsi      # 0x31041
movq %rax, %rdi
callq 0x42e0
addq $0x20, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4290
leaq 0x11cc5(%rip), %rsi     # 0x3358c
movq %rax, %rdi
callq 0x42e0
movl (%r14), %esi
movq %rax, %rdi
callq 0x4500
leaq 0x12b80(%rip), %rsi     # 0x34461
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
callq 0x4170
xorl %edi, %edi
callq 0x4360