// File: 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
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq 0x2d857(%rip), %rax     # 0x66588
movl (%rax), %eax
movl %eax, -0x104(%rbp)
testl %eax, %eax
je 0x38d63
jmp 0x38d3f
movl -0x104(%rbp), %eax
subl $0x1, %eax
je 0x38d68
jmp 0x38d4c
movl -0x104(%rbp), %eax
addl $-0x2, %eax
subl $0x3, %eax
jb 0x39979
jmp 0x3a11d
jmp 0x3a1c2
movb $0x0, -0x9(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
leaq 0x2d7cb(%rip), %rcx     # 0x66548
cmpl (%rcx), %eax
jge 0x38dc5
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x10(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x0, 0x200(%rax)
jne 0x38db8
testb $0x1, -0x9(%rbp)
jne 0x38db0
movb $0x1, -0x9(%rbp)
jmp 0x38db6
movb $0x0, -0x9(%rbp)
jmp 0x38dc5
jmp 0x38db8
jmp 0x38dba
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x38d73
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0x2d772(%rip), %rcx     # 0x66548
cmpl (%rcx), %eax
jge 0x39974
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x0, 0x200(%rax)
jne 0x3904f
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq (%rax), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x22d60
cmpq $0x0, %rax
ja 0x38ead
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq -0x110(%rbp), %rdi
movq (%rax), %rax
movl 0x25c(%rax), %eax
movl %eax, -0x114(%rbp)
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq %rax, %rcx
movl -0x114(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x260(%rcx), %eax
jne 0x38ead
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
movl 0x208(%rax), %eax
leaq 0x2d6af(%rip), %rcx     # 0x66558
cmpl (%rcx), %eax
jae 0x38ee7
movq -0x110(%rbp), %rdi
movq 0x8(%rdi), %rax
movl 0x26c(%rdi), %ecx
addq %rcx, %rax
movq %rax, -0x120(%rbp)
addq $0x2a0, %rdi            # imm = 0x2A0
movslq -0x14(%rbp), %rsi
callq 0x17df0
movq -0x120(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x3904a
movq -0x110(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x128(%rbp)
addq $0x2a0, %rdi            # imm = 0x2A0
movslq -0x14(%rbp), %rsi
callq 0x17df0
movq %rax, %rcx
movq -0x128(%rbp), %rax
cmpq (%rcx), %rax
jb 0x39048
movq -0x110(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x130(%rbp)
addq $0x288, %rdi            # imm = 0x288
movslq -0x14(%rbp), %rsi
callq 0x17df0
movq %rax, %rcx
movq -0x130(%rbp), %rax
cmpq (%rcx), %rax
jb 0x39048
testb $0x1, -0x9(%rbp)
je 0x38f6b
movq -0x110(%rbp), %rax
cmpl $0x0, 0x268(%rax)
jne 0x39046
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movq %rdi, -0x140(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x17770
movq -0x140(%rbp), %rdi
movq (%rax), %rax
movl $0x5, 0x200(%rax)
movslq -0x14(%rbp), %rsi
callq 0x17770
movq (%rax), %rdi
callq 0x3f690
movq -0x110(%rbp), %rax
movq 0x8(%rax), %xmm0
movaps 0x1815f(%rip), %xmm1    # 0x51120
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x18163(%rip), %xmm1    # 0x51130
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0x138(%rbp)
leaq 0x2d5f5(%rip), %rax     # 0x665e0
movsd (%rax), %xmm0
leaq 0x2d542(%rip), %rax     # 0x66538
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movq -0x110(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0x138(%rbp), %xmm0
addsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rcx, %rsi
sarq $0x3f, %rsi
movsd 0x1a1c8(%rip), %xmm1    # 0x531f8
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rdx
andq %rsi, %rdx
orq %rdx, %rcx
movq %rcx, 0x280(%rax)
jmp 0x39048
jmp 0x3904a
jmp 0x39964
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x6, 0x200(%rax)
jne 0x396f4
movq -0x110(%rbp), %rcx
movq 0x8(%rcx), %rax
cmpq 0x270(%rcx), %rax
jb 0x396b9
movb $0x1, -0x15(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
leaq 0x2d4a5(%rip), %rcx     # 0x66548
cmpl (%rcx), %eax
jge 0x39108
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
je 0x390fb
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x1c(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x1, 0x200(%rax)
je 0x390fb
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x1c(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x8, 0x200(%rax)
je 0x390fb
movb $0x0, -0x15(%rbp)
jmp 0x39108
jmp 0x390fd
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x39099
testb $0x1, -0x15(%rbp)
je 0x3934d
movq -0x110(%rbp), %rdi
movq $0x0, -0x28(%rbp)
addq $0x2d0, %rdi            # imm = 0x2D0
movslq -0x14(%rbp), %rsi
callq 0x22820
movq %rax, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x22880
testb $0x1, %al
jne 0x3914b
jmp 0x391cf
movq -0x110(%rbp), %rdi
addq $0x2d0, %rdi            # imm = 0x2D0
movslq -0x14(%rbp), %rsi
callq 0x22820
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
leaq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x22b00
leaq 0x2d454(%rip), %rax     # 0x665d0
movsd (%rax), %xmm0
leaq 0x2d451(%rip), %rax     # 0x665d8
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
leaq 0x2d3a2(%rip), %rax     # 0x66538
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x1a03e(%rip), %xmm1    # 0x531f8
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0x39227
leaq 0x2d3ea(%rip), %rax     # 0x665c0
movsd (%rax), %xmm0
leaq 0x2d3f7(%rip), %rax     # 0x665d8
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
leaq 0x2d348(%rip), %rax     # 0x66538
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0x19fe4(%rip), %xmm1    # 0x531f8
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x110(%rbp), %rdi
movq 0x8(%rdi), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x148(%rbp)
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0x14(%rbp), %rsi
callq 0x17df0
movq -0x148(%rbp), %rcx
movq -0x110(%rbp), %rdi
movq %rcx, (%rax)
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
movl $0x9, 0x200(%rax)
leaq 0x2d2a6(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x39348
leaq 0x2d297(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x39348
movl $0x21, %edi
callq 0x177b0
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %esi
movq 0x2cd1e(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x158(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x158(%rbp), %rdi
movb %al, -0x4d(%rbp)
movzbl -0x4d(%rbp), %esi
callq 0x4550
movq -0x110(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x1a148(%rip), %rsi     # 0x53440
callq 0x4380
movq -0x110(%rbp), %rdi
movq %rax, -0x150(%rbp)
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0x14(%rbp), %rsi
callq 0x17df0
movq -0x150(%rbp), %rdi
movq (%rax), %rsi
callq 0x40f0
movq %rax, %rdi
leaq 0x1a133(%rip), %rsi     # 0x53467
callq 0x4380
movq %rax, %rdi
movq 0x2cc6d(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x396b7
movq -0x110(%rbp), %rdi
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
addq $0x2d0, %rdi            # imm = 0x2D0
movslq -0x14(%rbp), %rsi
callq 0x22820
movq %rax, -0x70(%rbp)
movq %rdx, -0x68(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x22880
testb $0x1, %al
jne 0x3938e
jmp 0x39474
movq -0x110(%rbp), %rdi
addq $0x2d0, %rdi            # imm = 0x2D0
movslq -0x14(%rbp), %rsi
callq 0x22820
movq %rax, -0x80(%rbp)
movq %rdx, -0x78(%rbp)
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
callq 0x22b00
leaq 0x2d211(%rip), %rax     # 0x665d0
movq %rax, -0x170(%rbp)
movsd (%rax), %xmm0
leaq 0x2d167(%rip), %rax     # 0x66538
movq %rax, -0x168(%rbp)
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movq -0x170(%rbp), %rcx
movq -0x168(%rbp), %rax
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
movsd 0x19dee(%rip), %xmm1    # 0x531f8
movsd %xmm1, -0x160(%rbp)
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rsi
andq %rdi, %rsi
orq %rsi, %rdx
movq %rdx, -0x58(%rbp)
movsd (%rcx), %xmm0
leaq 0x2d198(%rip), %rcx     # 0x665c8
movsd (%rcx), %xmm1
addsd %xmm1, %xmm0
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movsd -0x160(%rbp), %xmm1
movaps %xmm0, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x60(%rbp)
jmp 0x3953a
leaq 0x2d145(%rip), %rax     # 0x665c0
movq %rax, -0x188(%rbp)
movsd (%rax), %xmm0
leaq 0x2d143(%rip), %rax     # 0x665d0
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
leaq 0x2d09c(%rip), %rax     # 0x66538
movq %rax, -0x180(%rbp)
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movq -0x188(%rbp), %rcx
movq -0x180(%rbp), %rax
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
movsd 0x19d23(%rip), %xmm1    # 0x531f8
movsd %xmm1, -0x178(%rbp)
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rsi
andq %rdi, %rsi
orq %rsi, %rdx
movq %rdx, -0x58(%rbp)
movsd (%rcx), %xmm0
leaq 0x2d0cd(%rip), %rcx     # 0x665c8
movsd (%rcx), %xmm1
addsd %xmm1, %xmm0
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movsd -0x178(%rbp), %xmm1
movaps %xmm0, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x110(%rbp), %rdi
movq 0x8(%rdi), %rax
addq -0x58(%rbp), %rax
movq %rax, 0x270(%rdi)
movq 0x8(%rdi), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x190(%rbp)
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0x14(%rbp), %rsi
callq 0x17df0
movq -0x190(%rbp), %rcx
movq -0x110(%rbp), %rdi
movq %rcx, (%rax)
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
movl $0x8, 0x200(%rax)
leaq 0x2cf84(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x396b5
leaq 0x2cf75(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x396b5
movl $0x21, %edi
callq 0x177b0
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %esi
movq 0x2c9f6(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x1a0(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x1a0(%rbp), %rdi
movb %al, -0x85(%rbp)
movzbl -0x85(%rbp), %esi
callq 0x4550
movq -0x110(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x19e48(%rip), %rsi     # 0x5346e
callq 0x4380
movq -0x110(%rbp), %rdi
movq %rax, -0x198(%rbp)
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0x14(%rbp), %rsi
callq 0x17df0
movq -0x198(%rbp), %rdi
movq (%rax), %rsi
callq 0x40f0
movq %rax, %rdi
leaq 0x19e34(%rip), %rsi     # 0x53496
callq 0x4380
movq %rax, %rdi
movq -0x110(%rbp), %rax
movq 0x270(%rax), %rsi
callq 0x40f0
movq %rax, %rdi
leaq 0x19e22(%rip), %rsi     # 0x534a9
callq 0x4380
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x1acd8(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x2c900(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x396b7
jmp 0x396ef
movq -0x110(%rbp), %rdi
addq $0x2d0, %rdi            # imm = 0x2D0
movslq -0x14(%rbp), %rsi
callq 0x22820
movq %rax, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
leaq -0x98(%rbp), %rdi
movl $0x1, %esi
callq 0x22b00
jmp 0x39962
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x8, 0x200(%rax)
jne 0x39822
movq -0x110(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x1a8(%rbp)
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0x14(%rbp), %rsi
callq 0x17df0
movq %rax, %rcx
movq -0x1a8(%rbp), %rax
cmpq (%rcx), %rax
jb 0x3981d
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
movl $0x1, 0x200(%rax)
leaq 0x2cdad(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x3981b
movl $0x21, %edi
callq 0x177b0
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %esi
movq 0x2c82f(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x1b0(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x1b0(%rbp), %rdi
movb %al, -0x9d(%rbp)
movzbl -0x9d(%rbp), %esi
callq 0x4550
movq -0x110(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x19cc4(%rip), %rsi     # 0x534b1
callq 0x4380
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x1ab72(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x2c79a(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x3981d
jmp 0x39960
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0x14(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x9, 0x200(%rax)
jne 0x3995e
movq -0x110(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x1b8(%rbp)
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0x14(%rbp), %rsi
callq 0x17df0
movq %rax, %rcx
movq -0x1b8(%rbp), %rax
cmpq (%rcx), %rax
jb 0x3995c
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
leaq 0x2ccb3(%rip), %rcx     # 0x66548
cmpl (%rcx), %eax
jge 0x398d1
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0xa4(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
movl $0x2, 0x200(%rax)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x39888
leaq 0x2cc50(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x3995a
movl $0x21, %edi
callq 0x177b0
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %esi
movq 0x2c6d6(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x1c0(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x1c0(%rbp), %rdi
movb %al, -0xa9(%rbp)
movzbl -0xa9(%rbp), %esi
callq 0x4550
movq -0x110(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x19b90(%rip), %rsi     # 0x534d6
callq 0x4380
movq %rax, %rdi
movq 0x2c65b(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x3995c
jmp 0x3995e
jmp 0x39960
jmp 0x39962
jmp 0x39964
jmp 0x39966
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x38dcc
jmp 0x3a1c2
leaq 0x2cbc8(%rip), %rax     # 0x66548
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0xb0(%rbp)
movq -0x110(%rbp), %rdx
movl -0xb0(%rbp), %eax
leaq 0x2cba9(%rip), %rcx     # 0x66548
movl (%rcx), %ecx
subl 0x258(%rdx), %ecx
cmpl %ecx, %eax
jb 0x3a118
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x0, 0x200(%rax)
jne 0x39bb7
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq (%rax), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0x22d60
cmpq $0x0, %rax
jne 0x39bb2
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq -0x110(%rbp), %rdi
movq (%rax), %rax
movl 0x25c(%rax), %eax
movl %eax, -0x1c4(%rbp)
addq $0x208, %rdi            # imm = 0x208
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq %rax, %rcx
movl -0x1c4(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x260(%rcx), %eax
jne 0x39bb2
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
movl 0x208(%rax), %eax
leaq 0x2cac7(%rip), %rcx     # 0x66558
cmpl (%rcx), %eax
jne 0x39bb2
movq -0x110(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x1d0(%rbp)
addq $0x288, %rdi            # imm = 0x288
movslq -0xb0(%rbp), %rsi
callq 0x17df0
movq %rax, %rcx
movq -0x1d0(%rbp), %rax
cmpq (%rcx), %rax
jb 0x39bb2
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movq %rdi, -0x1e0(%rbp)
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq -0x1e0(%rbp), %rdi
movq (%rax), %rax
movl $0x5, 0x200(%rax)
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq (%rax), %rdi
callq 0x3f690
movq -0x110(%rbp), %rax
movq 0x8(%rax), %xmm0
movaps 0x175f3(%rip), %xmm1    # 0x51120
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x175f7(%rip), %xmm1    # 0x51130
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0x1d8(%rbp)
leaq 0x2ca89(%rip), %rax     # 0x665e0
movsd (%rax), %xmm0
leaq 0x2c9d6(%rip), %rax     # 0x66538
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movq -0x110(%rbp), %rax
movaps %xmm0, %xmm1
movsd -0x1d8(%rbp), %xmm0
addsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rcx, %rsi
sarq $0x3f, %rsi
movsd 0x1965c(%rip), %xmm1    # 0x531f8
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rdx
andq %rsi, %rdx
orq %rdx, %rcx
movq %rcx, 0x280(%rax)
jmp 0x3a102
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x6, 0x200(%rax)
jne 0x39fc7
movq -0x110(%rbp), %rcx
movq 0x8(%rcx), %rax
cmpq 0x270(%rcx), %rax
jb 0x39f89
movq -0x110(%rbp), %rdi
movq $0x0, -0xb8(%rbp)
movq $0x0, -0xc0(%rbp)
addq $0x2d0, %rdi            # imm = 0x2D0
movslq -0xb0(%rbp), %rsi
callq 0x22820
movq %rax, -0xd0(%rbp)
movq %rdx, -0xc8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x22880
testb $0x1, %al
jne 0x39c4c
jmp 0x39d2e
movq -0x110(%rbp), %rdi
addq $0x2d0, %rdi            # imm = 0x2D0
movslq -0xb0(%rbp), %rsi
callq 0x22820
movq %rax, -0xe0(%rbp)
movq %rdx, -0xd8(%rbp)
leaq -0xe0(%rbp), %rdi
xorl %esi, %esi
callq 0x22b00
leaq 0x2c947(%rip), %rax     # 0x665d0
movsd (%rax), %xmm0
leaq 0x2c8a4(%rip), %rax     # 0x66538
movq %rax, -0x1f0(%rbp)
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movq -0x1f0(%rbp), %rax
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rcx, %rsi
sarq $0x3f, %rsi
movsd 0x19532(%rip), %xmm1    # 0x531f8
movsd %xmm1, -0x1e8(%rbp)
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rdx
andq %rsi, %rdx
orq %rdx, %rcx
movq %rcx, -0xb8(%rbp)
leaq 0x2c8dd(%rip), %rcx     # 0x665c8
movsd (%rcx), %xmm0
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movsd -0x1e8(%rbp), %xmm1
movaps %xmm0, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0xc0(%rbp)
jmp 0x39dfa
leaq 0x2c88b(%rip), %rax     # 0x665c0
movq %rax, -0x208(%rbp)
movsd (%rax), %xmm0
leaq 0x2c889(%rip), %rax     # 0x665d0
movsd (%rax), %xmm1
addsd %xmm1, %xmm0
leaq 0x2c7e2(%rip), %rax     # 0x66538
movq %rax, -0x200(%rbp)
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movq -0x208(%rbp), %rcx
movq -0x200(%rbp), %rax
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
movsd 0x19469(%rip), %xmm1    # 0x531f8
movsd %xmm1, -0x1f8(%rbp)
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rsi
andq %rdi, %rsi
orq %rsi, %rdx
movq %rdx, -0xb8(%rbp)
movsd (%rcx), %xmm0
leaq 0x2c810(%rip), %rcx     # 0x665c8
movsd (%rcx), %xmm1
addsd %xmm1, %xmm0
movsd (%rax), %xmm1
divsd %xmm1, %xmm0
callq 0x40a0
movsd -0x1f8(%rbp), %xmm1
movaps %xmm0, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0x110(%rbp), %rdi
movq 0x8(%rdi), %rax
addq -0xb8(%rbp), %rax
movq %rax, 0x270(%rdi)
movq 0x8(%rdi), %rax
addq -0xc0(%rbp), %rax
movq %rax, -0x210(%rbp)
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0xb0(%rbp), %rsi
callq 0x17df0
movq -0x210(%rbp), %rcx
movq -0x110(%rbp), %rdi
movq %rcx, (%rax)
addq $0x208, %rdi            # imm = 0x208
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
movl $0x8, 0x200(%rax)
leaq 0x2c6b8(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x39f87
leaq 0x2c6a9(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x39f87
movl $0x21, %edi
callq 0x177b0
movl %eax, -0xe4(%rbp)
movl -0xe4(%rbp), %esi
movq 0x2c12a(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x220(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x220(%rbp), %rdi
movb %al, -0xe5(%rbp)
movzbl -0xe5(%rbp), %esi
callq 0x4550
movq -0x110(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x1957c(%rip), %rsi     # 0x5346e
callq 0x4380
movq -0x110(%rbp), %rdi
movq %rax, -0x218(%rbp)
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0xb0(%rbp), %rsi
callq 0x17df0
movq -0x218(%rbp), %rdi
movq (%rax), %rsi
callq 0x40f0
movq %rax, %rdi
leaq 0x19565(%rip), %rsi     # 0x53496
callq 0x4380
movq %rax, %rdi
movq -0x110(%rbp), %rax
movq 0x270(%rax), %rsi
callq 0x40f0
movq %rax, %rdi
leaq 0x19553(%rip), %rsi     # 0x534a9
callq 0x4380
movq %rax, %rdi
movl -0xb0(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x1a406(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x2c02e(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x39fc2
movq -0x110(%rbp), %rdi
addq $0x2d0, %rdi            # imm = 0x2D0
movslq -0xb0(%rbp), %rsi
callq 0x22820
movq %rax, -0xf8(%rbp)
movq %rdx, -0xf0(%rbp)
leaq -0xf8(%rbp), %rdi
movl $0x1, %esi
callq 0x22b00
jmp 0x3a100
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
cmpl $0x8, 0x200(%rax)
jne 0x3a0fe
movq -0x110(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x228(%rbp)
addq $0x2b8, %rdi            # imm = 0x2B8
movslq -0xb0(%rbp), %rsi
callq 0x17df0
movq %rax, %rcx
movq -0x228(%rbp), %rax
cmpq (%rcx), %rax
jb 0x3a0fc
movq -0x110(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
movslq -0xb0(%rbp), %rsi
callq 0x17770
movq (%rax), %rax
movl $0x1, 0x200(%rax)
leaq 0x2c4d1(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x3a0fa
movl $0x21, %edi
callq 0x177b0
movl %eax, -0xfc(%rbp)
movl -0xfc(%rbp), %esi
movq 0x2bf53(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0x230(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x230(%rbp), %rdi
movb %al, -0xfd(%rbp)
movzbl -0xfd(%rbp), %esi
callq 0x4550
movq -0x110(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x193e8(%rip), %rsi     # 0x534b1
callq 0x4380
movq %rax, %rdi
movl -0xb0(%rbp), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x1a293(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x2bebb(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x3a0fc
jmp 0x3a0fe
jmp 0x3a100
jmp 0x3a102
jmp 0x3a104
movl -0xb0(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xb0(%rbp)
jmp 0x3998b
jmp 0x3a1c2
movq 0x2becc(%rip), %rdi     # 0x65ff0
leaq 0x16f0f(%rip), %rsi     # 0x5103a
callq 0x4380
movq %rax, %rdi
leaq 0x191cd(%rip), %rsi     # 0x53307
callq 0x4380
movq %rax, %rdi
leaq 0x176ec(%rip), %rsi     # 0x51835
callq 0x4380
movq %rax, %rdi
movl $0x1e7, %esi            # imm = 0x1E7
callq 0x4610
movq %rax, %rdi
leaq 0x16ef4(%rip), %rsi     # 0x51059
callq 0x4380
movq -0x110(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, %rdi
leaq 0x1936d(%rip), %rsi     # 0x534f4
callq 0x4380
movq %rax, %rdi
leaq 0x2c3f2(%rip), %rax     # 0x66588
movl (%rax), %esi
callq 0x4610
movq %rax, %rdi
leaq 0x1a1d2(%rip), %rsi     # 0x54379
callq 0x4380
movq %rax, %rdi
movq 0x2bdfa(%rip), %rsi     # 0x65fb0
callq 0x43c0
xorl %edi, %edi
callq 0x4460
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nopl (%rax,%rax)