// File: /workspace/github_cpp_makefile_star2_O1/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 $0x88, %rsp
movq %rdi, %rbx
leaq 0x1e185(%rip), %rax     # 0x3c4a4
movl (%rax), %ecx
leaq 0x1e190(%rip), %rax     # 0x3c4b8
movl (%rax), %r8d
callq 0x21d26
leaq 0x1d7f9(%rip), %rax     # 0x3bb30
movq %rax, (%rbx)
leaq 0x208(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x220(%rbx), %r15
leaq 0x288(%rbx), %rax
movq %rax, 0x58(%rsp)
leaq 0x2a0(%rbx), %rax
movq %rax, 0x50(%rsp)
leaq 0x2b8(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x2d0(%rbx), %rax
movq %rax, 0x60(%rsp)
xorl %eax, %eax
movq %rax, 0x2e0(%rbx)
movl %eax, 0x2e8(%rbx)
leaq 0x2f8(%rbx), %rcx
movq %rcx, 0x78(%rsp)
movq %rax, 0x308(%rbx)
movl %eax, 0x310(%rbx)
leaq 0x320(%rbx), %rcx
movq %rcx, 0x70(%rsp)
leaq 0x338(%rbx), %rcx
movq %rcx, 0x68(%rsp)
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 0x1347f(%rip), %rcx     # 0x318ca
movl $0x5, %r8d
xorl %esi, %esi
callq 0x4440
movl $0xffffffff, 0x238(%rbx) # imm = 0xFFFFFFFF
leaq 0x1e043(%rip), %rax     # 0x3c4ac
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
leaq 0x1e039(%rip), %rax     # 0x3c4b0
mulsd (%rax), %xmm0
mulsd 0x14d55(%rip), %xmm0    # 0x331d8
cvttsd2si %xmm0, %rax
movl %eax, 0x23c(%rbx)
leaq 0x1e05b(%rip), %rax     # 0x3c4f0
movsd (%rax), %xmm0
mulsd 0x14d3f(%rip), %xmm0    # 0x331e0
leaq 0x1dff0(%rip), %rax     # 0x3c498
movsd (%rax), %xmm1
movsd %xmm1, 0x80(%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 0x1e062(%rip), %rax     # 0x3c550
movsd (%rax), %xmm0
divsd 0x80(%rsp), %xmm0
callq 0x4090
cvttsd2si %xmm0, %rax
movl %eax, 0x26c(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x270(%rbx)
movq $0x0, 0x280(%rbx)
leaq 0x1df7f(%rip), %r14     # 0x3c4a8
movslq (%r14), %r12
leaq 0x1e015(%rip), %rax     # 0x3c548
movsd (%rax), %xmm0
divsd 0x80(%rsp), %xmm0
callq 0x4090
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x14c8f(%rip), %xmm0    # 0x331e8
cvttsd2si %xmm0, %rsi
andq %rcx, %rsi
orq %rax, %rsi
leaq 0x10(%rsp), %rdx
movq %rsi, (%rdx)
leaq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movq %r12, %rsi
callq 0x138c2
leaq 0x20(%rsp), %r12
movq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x1439e
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1e5a6
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movslq (%r14), %rsi
movl 0x26c(%rbx), %eax
leaq 0x10(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x138c2
leaq 0x20(%rsp), %r12
movq 0x50(%rsp), %rdi
movq %r12, %rsi
callq 0x1439e
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1e5ee
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movslq (%r14), %rsi
leaq 0x10(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x179da
movq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0x17d96
leaq 0x20(%rsp), %rdi
movq 0x20(%rdi), %rax
movq %rax, 0x20(%r12)
movupd (%rdi), %xmm0
movupd 0x10(%rdi), %xmm1
movupd %xmm1, 0x10(%r12)
movupd %xmm0, (%r12)
xorl %eax, %eax
movl %eax, 0x8(%rdi)
movq $0x0, 0x10(%rdi)
movl %eax, 0x18(%rdi)
movslq (%r14), %rsi
leaq 0x10(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0xf(%rsp), %rcx
callq 0x179da
movq 0x78(%rsp), %r12
movq %r12, %rdi
callq 0x17d96
leaq 0x20(%rsp), %rdi
movq 0x20(%rdi), %rax
movq %rax, 0x20(%r12)
movupd (%rdi), %xmm0
movupd 0x10(%rdi), %xmm1
movupd %xmm1, 0x10(%r12)
movupd %xmm0, (%r12)
xorl %eax, %eax
movl %eax, 0x8(%rdi)
movq %rax, 0x10(%rdi)
movl %eax, 0x18(%rdi)
movslq (%r14), %rsi
leaq 0x10(%rsp), %rdx
movq %rax, (%rdx)
leaq 0xf(%rsp), %rcx
callq 0x138c2
leaq 0x20(%rsp), %r12
movq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x1439e
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1e6d8
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movslq (%r14), %rsi
leaq 0x10(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x138c2
leaq 0x20(%rsp), %r12
movq 0x70(%rsp), %rdi
movq %r12, %rsi
callq 0x1439e
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1e71e
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movslq (%r14), %rsi
leaq 0x10(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0x20(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x138c2
leaq 0x20(%rsp), %r12
movq 0x68(%rsp), %rdi
movq %r12, %rsi
callq 0x1439e
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1e764
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
movslq (%r14), %rsi
movq 0x18(%rsp), %rdi
callq 0x1dbac
movslq (%r14), %rsi
movq %r15, %rdi
callq 0x1db16
cmpl $0x0, (%r14)
jle 0x1e7f9
xorl %ebp, %ebp
leaq 0x20(%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 0x22bd8
movq %r13, 0x20(%rsp)
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x1deda
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 0x2663c
movq %r13, 0x20(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x1dd8a
incl %ebp
cmpl (%r14), %ebp
jl 0x1e789
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1e843
jmp 0x1e843
jmp 0x1e843
jmp 0x1e92e
jmp 0x1e843
jmp 0x1e92e
jmp 0x1e843
jmp 0x1e843
jmp 0x1e843
jmp 0x1e843
movq %rax, %r12
movl $0x288, %esi            # imm = 0x288
jmp 0x1e837
movq %rax, %r12
movl $0x230, %esi            # imm = 0x230
movq %r13, %rdi
callq 0x4300
jmp 0x1e846
jmp 0x1e843
movq %rax, %r12
movq 0x68(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
movq 0x78(%rsp), %r14
je 0x1e867
movq 0x348(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x70(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1e883
movq 0x330(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq %r14, %rdi
callq 0x17d96
movq 0x60(%rsp), %rdi
callq 0x17d96
movq 0x48(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1e8b1
movq 0x2c8(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x50(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1e8cd
movq 0x2b0(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x58(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1e8e9
movq 0x298(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq (%r15), %rdi
testq %rdi, %rdi
je 0x1e900
movq 0x230(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq 0x18(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1e91c
movq 0x218(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x21e72
movq %r12, %rdi
callq 0x4540
jmp 0x1e92e
movq %rax, %rdi
callq 0x13940