// File: /workspace/github_cpp_makefile_star2_O3/estwings57[P]CasHMC/sources/HMCController.cpp
// Function: CasHMC::HMCController::HMCController(std::basic_ofstream<char, std::char_traits<char>>&, std::basic_ofstream<char, std::char_traits<char>>&)
HMCController::HMCController(ofstream &debugOut_, ofstream &stateOut_):
	DualVectorObject<Transaction, Packet>(debugOut_, stateOut_, MAX_REQ_BUF, MAX_LINK_BUF),
	readDone(NULL),
	writeDone(NULL)
{
	header = " (HC)";
	
	inServiceLink = -1;
	maxLinkBand = LINK_WIDTH * LINK_SPEED / 8;
	linkEpochCycle = ceil((double)LINK_EPOCH*1000000/CPU_CLK_PERIOD);
	requestAccLNG = 0;
	responseAccLNG = 0;
	sleepLink = 0;
	alloMSHR = 0;
	accuMSHR = 0;
	returnTransCnt = 0;
	quiesceClk = ceil((double)tQUIESCE/CPU_CLK_PERIOD);
	staggerSleep = 0;
	staggerActive = 0;
	staySREF = 0;
	stayActive = vector<uint64_t>(NUM_LINKS, ceil((double)tOP/CPU_CLK_PERIOD));
	quiesceLink = vector<uint64_t>(NUM_LINKS, quiesceClk);
	staggeringSleep = vector<bool>(NUM_LINKS, false);
	staggeringActive = vector<bool>(NUM_LINKS, false);
	modeTransition = vector<uint64_t>(NUM_LINKS, 0);
	
	linkSleepTime = vector<uint64_t>(NUM_LINKS, 0);
	linkDownTime = vector<uint64_t>(NUM_LINKS, 0);
	
	//Make class objects
	downLinkMasters.reserve(NUM_LINKS);
	upLinkSlaves.reserve(NUM_LINKS);
	for(int l=0; l<NUM_LINKS; l++) {
		downLinkMasters.push_back(new LinkMaster(debugOut, stateOut, l, true));
		upLinkSlaves.push_back(new LinkSlave(debugOut, stateOut, l, false));
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
leaq 0x1d8e0(%rip), %rax     # 0x3b4a4
movl (%rax), %ecx
leaq 0x1d8eb(%rip), %rax     # 0x3b4b8
movl (%rax), %r8d
callq 0x21636
leaq 0x1cf54(%rip), %rax     # 0x3ab30
movq %rax, (%rbx)
leaq 0x208(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x220(%rbx), %r15
leaq 0x2d0(%rbx), %rax
movq %rax, 0x50(%rsp)
xorl %eax, %eax
movq %rax, 0x2e0(%rbx)
movl %eax, 0x2e8(%rbx)
leaq 0x2f8(%rbx), %rcx
movq %rcx, 0x58(%rsp)
movq %rax, 0x308(%rbx)
movl %eax, 0x310(%rbx)
leaq 0x20(%rbx), %rdi
xorpd %xmm0, %xmm0
movupd %xmm0, 0x208(%rbx)
movupd %xmm0, 0x218(%rbx)
movupd %xmm0, 0x228(%rbx)
movupd %xmm0, 0x288(%rbx)
movupd %xmm0, 0x298(%rbx)
movupd %xmm0, 0x2a8(%rbx)
movupd %xmm0, 0x2b8(%rbx)
movupd %xmm0, 0x2c8(%rbx)
movl %eax, 0x2d8(%rbx)
movupd %xmm0, 0x2f0(%rbx)
movl %eax, 0x300(%rbx)
movupd %xmm0, 0x318(%rbx)
movupd %xmm0, 0x328(%rbx)
movupd %xmm0, 0x338(%rbx)
movupd %xmm0, 0x348(%rbx)
movq %rax, 0x358(%rbx)
movq 0x28(%rbx), %rdx
leaq 0x12c76(%rip), %rcx     # 0x3092a
movl $0x5, %r8d
xorl %esi, %esi
callq 0x4440
movl $0xffffffff, 0x238(%rbx) # imm = 0xFFFFFFFF
leaq 0x1d7da(%rip), %rax     # 0x3b4ac
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
leaq 0x1d7d0(%rip), %rax     # 0x3b4b0
mulsd (%rax), %xmm0
mulsd 0x1455c(%rip), %xmm0    # 0x32248
cvttsd2si %xmm0, %rax
movl %eax, 0x23c(%rbx)
leaq 0x1d7f2(%rip), %rax     # 0x3b4f0
movsd (%rax), %xmm0
mulsd 0x14546(%rip), %xmm0    # 0x32250
leaq 0x1d787(%rip), %rax     # 0x3b498
movsd (%rax), %xmm1
movsd %xmm1, 0x60(%rsp)
divsd %xmm1, %xmm0
callq 0x4090
cvttsd2si %xmm0, %rax
movl %eax, 0x240(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x248(%rbx)
movupd %xmm0, 0x258(%rbx)
movl $0x0, 0x268(%rbx)
leaq 0x1d7fc(%rip), %rax     # 0x3b550
movsd (%rax), %xmm0
divsd 0x60(%rsp), %xmm0
callq 0x4090
cvttsd2si %xmm0, %rax
movl %eax, 0x26c(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x270(%rbx)
movq $0x0, 0x280(%rbx)
leaq 0x1d71c(%rip), %r14     # 0x3b4a8
movslq (%r14), %r12
leaq 0x1d7b2(%rip), %rax     # 0x3b548
movsd (%rax), %xmm0
divsd 0x60(%rsp), %xmm0
callq 0x4090
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x1449f(%rip), %xmm0    # 0x32258
cvttsd2si %xmm0, %rsi
andq %rcx, %rsi
orq %rax, %rsi
leaq 0x40(%rsp), %rdx
movq %rsi, (%rdx)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movq %r12, %rsi
callq 0x1336a
movq 0x288(%rbx), %rdi
movq 0x298(%rbx), %rsi
movapd 0x10(%rsp), %xmm0
movupd %xmm0, 0x288(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x298(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x1de3d
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1de3d
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movslq (%r14), %rsi
movl 0x26c(%rbx), %eax
leaq 0x40(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x1336a
movq 0x2a0(%rbx), %rdi
movq 0x2b0(%rbx), %rsi
movapd 0x10(%rsp), %xmm0
movupd %xmm0, 0x2a0(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x2b0(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x1debc
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1debc
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movslq (%r14), %rsi
leaq 0x40(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x1702a
movq 0x50(%rsp), %r12
movq %r12, %rdi
callq 0x175f4
leaq 0x10(%rsp), %rdi
movq 0x20(%rdi), %rax
movq %rax, 0x20(%r12)
movupd (%rdi), %xmm0
movupd 0x10(%rdi), %xmm1
movupd %xmm1, 0x10(%r12)
movupd %xmm0, (%r12)
movslq (%r14), %rsi
leaq 0x40(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0xf(%rsp), %rcx
callq 0x1702a
movq 0x58(%rsp), %r12
movq %r12, %rdi
callq 0x175f4
leaq 0x10(%rsp), %rdi
movq 0x20(%rdi), %rax
movq %rax, 0x20(%r12)
movupd (%rdi), %xmm0
movupd 0x10(%rdi), %xmm1
movupd %xmm1, 0x10(%r12)
movupd %xmm0, (%r12)
movslq (%r14), %rsi
leaq 0x40(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0xf(%rsp), %rcx
callq 0x1336a
movq 0x2b8(%rbx), %rdi
movq 0x2c8(%rbx), %rsi
movapd 0x10(%rsp), %xmm0
movupd %xmm0, 0x2b8(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x2c8(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x1dfc5
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1dfc5
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movslq (%r14), %rsi
leaq 0x40(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x1336a
movq 0x320(%rbx), %rdi
movq 0x330(%rbx), %rsi
movapd 0x10(%rsp), %xmm0
movupd %xmm0, 0x320(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x330(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x1e042
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1e042
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movslq (%r14), %rsi
leaq 0x40(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x1336a
movq 0x338(%rbx), %rdi
movq 0x348(%rbx), %rsi
movapd 0x10(%rsp), %xmm0
movupd %xmm0, 0x338(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x348(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x1e0bf
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1e0bf
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movslq (%r14), %rsi
movq 0x48(%rsp), %rdi
callq 0x1d422
movslq (%r14), %rsi
movq %r15, %rdi
callq 0x1d386
cmpl $0x0, (%r14)
jle 0x1e154
xorl %ebp, %ebp
leaq 0x10(%rsp), %r12
movl $0x288, %edi            # imm = 0x288
callq 0x42f0
movq %rax, %r13
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
movq %rax, %rdi
movl %ebp, %ecx
movl $0x1, %r8d
callq 0x22498
movq %r13, 0x10(%rsp)
movq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x1d76a
movl $0x230, %edi            # imm = 0x230
callq 0x42f0
movq %rax, %r13
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
movq %rax, %rdi
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x25ebc
movq %r13, 0x10(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1d612
incl %ebp
cmpl (%r14), %ebp
jl 0x1e0e4
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1e19b
jmp 0x1e19b
jmp 0x1e19b
jmp 0x1e284
jmp 0x1e19b
jmp 0x1e284
jmp 0x1e19b
jmp 0x1e19b
jmp 0x1e19b
jmp 0x1e19b
movq %rax, %rbp
movl $0x288, %esi            # imm = 0x288
jmp 0x1e18f
movq %rax, %rbp
movl $0x230, %esi            # imm = 0x230
movq %r13, %rdi
callq 0x4300
jmp 0x1e19e
jmp 0x1e19b
movq %rax, %rbp
movq 0x338(%rbx), %rdi
testq %rdi, %rdi
movq 0x58(%rsp), %r14
je 0x1e1be
movq 0x348(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x320(%rbx), %rdi
testq %rdi, %rdi
je 0x1e1d9
movq 0x330(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq %r14, %rdi
callq 0x175f4
movq 0x50(%rsp), %rdi
callq 0x175f4
movq 0x2b8(%rbx), %rdi
testq %rdi, %rdi
je 0x1e206
movq 0x2c8(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
leaq 0x288(%rbx), %r14
movq 0x2a0(%rbx), %rdi
testq %rdi, %rdi
je 0x1e228
movq 0x2b0(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1e23f
movq 0x298(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq (%r15), %rdi
testq %rdi, %rdi
je 0x1e256
movq 0x230(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x48(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1e272
movq 0x218(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x21788
movq %rbp, %rdi
callq 0x4540
jmp 0x1e284
movq %rax, %rdi
callq 0x13489