// File: /workspace/github_cpp_makefile_star2_O2/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 0x1aea9(%rip), %rax     # 0x314a4
movl (%rax), %ecx
leaq 0x1aeb4(%rip), %rax     # 0x314b8
movl (%rax), %r8d
callq 0x193a4
leaq 0x1a535(%rip), %rax     # 0x30b48
movq %rax, (%rbx)
leaq 0x208(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x220(%rbx), %rax
movq %rax, 0x30(%rsp)
andq $0x0, 0x2e0(%rbx)
leaq 0x288(%rbx), %r12
andl $0x0, 0x2e8(%rbx)
leaq 0x2a0(%rbx), %r13
andq $0x0, 0x308(%rbx)
leaq 0x2b8(%rbx), %rbp
andl $0x0, 0x310(%rbx)
leaq 0x2d0(%rbx), %rax
movq %rax, 0x80(%rsp)
leaq 0x2f8(%rbx), %rax
movq %rax, 0x78(%rsp)
leaq 0x320(%rbx), %rax
movq %rax, 0x70(%rsp)
leaq 0x338(%rbx), %rax
movq %rax, 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)
andl $0x0, 0x2d8(%rbx)
movupd %xmm0, 0x2c8(%rbx)
andl $0x0, 0x300(%rbx)
movupd %xmm0, 0x2f0(%rbx)
movupd %xmm0, 0x318(%rbx)
movupd %xmm0, 0x328(%rbx)
movupd %xmm0, 0x338(%rbx)
movupd %xmm0, 0x348(%rbx)
andq $0x0, 0x358(%rbx)
leaq 0xe1e9(%rip), %rsi      # 0x2490a
callq 0x4560
orl $-0x1, 0x238(%rbx)
leaq 0x1ad78(%rip), %rax     # 0x314ac
cvtsi2sdl (%rax), %xmm0
leaq 0x1ad71(%rip), %rax     # 0x314b0
mulsd (%rax), %xmm0
mulsd 0xfadd(%rip), %xmm0     # 0x26228
cvttsd2si %xmm0, %rax
movl %eax, 0x23c(%rbx)
leaq 0x1ad93(%rip), %rax     # 0x314f0
movsd (%rax), %xmm0
mulsd 0xfac7(%rip), %xmm0     # 0x26230
leaq 0x1ad28(%rip), %rax     # 0x31498
movsd (%rax), %xmm1
movsd %xmm1, 0x10(%rsp)
divsd %xmm1, %xmm0
callq 0x4080
cvttsd2si %xmm0, %rax
movl %eax, 0x240(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x248(%rbx)
andl $0x0, 0x268(%rbx)
movupd %xmm0, 0x258(%rbx)
leaq 0x1ada0(%rip), %rax     # 0x31550
movsd (%rax), %xmm0
divsd 0x10(%rsp), %xmm0
callq 0x4080
cvttsd2si %xmm0, %rax
movl %eax, 0x26c(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x270(%rbx)
andq $0x0, 0x280(%rbx)
leaq 0x1acc3(%rip), %r15     # 0x314a8
movslq (%r15), %r14
leaq 0x1ad59(%rip), %rax     # 0x31548
movsd (%rax), %xmm0
divsd 0x10(%rsp), %xmm0
callq 0x4080
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xfa26(%rip), %xmm0     # 0x26238
cvttsd2si %xmm0, %rsi
andq %rcx, %rsi
orq %rax, %rsi
leaq 0x18(%rsp), %rdx
movq %rsi, (%rdx)
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movq %r14, %rsi
callq 0xdc32
leaq 0x40(%rsp), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0xe706
movq %r14, %rdi
callq 0xe66e
movslq (%r15), %rsi
movl 0x26c(%rbx), %eax
leaq 0x18(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0xdc32
leaq 0x40(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0xe706
movq %r14, %rdi
callq 0xe66e
movslq (%r15), %rsi
leaq 0x18(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x10e3e
leaq 0x40(%rsp), %r14
movq 0x80(%rsp), %rdi
movq %r14, %rsi
callq 0x10ea2
movq %r14, %rdi
callq 0x10ef4
movslq (%r15), %rsi
leaq 0x18(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x10e3e
leaq 0x40(%rsp), %r14
movq 0x78(%rsp), %rdi
movq %r14, %rsi
callq 0x10ea2
movq %r14, %rdi
callq 0x10ef4
movslq (%r15), %rsi
leaq 0x18(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0xdc32
leaq 0x40(%rsp), %r14
movq %rbp, %rdi
movq %r14, %rsi
callq 0xe706
movq %r14, %rdi
callq 0xe66e
movslq (%r15), %rsi
leaq 0x18(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0xdc32
leaq 0x40(%rsp), %r14
movq 0x70(%rsp), %rdi
movq %r14, %rsi
callq 0xe706
movq %r14, %rdi
callq 0xe66e
movslq (%r15), %rsi
leaq 0x18(%rsp), %rdx
andq $0x0, (%rdx)
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0xdc32
leaq 0x40(%rsp), %r14
movq 0x68(%rsp), %rdi
movq %r14, %rsi
callq 0xe706
movq %r14, %rdi
callq 0xe66e
movslq (%r15), %rsi
movq 0x38(%rsp), %rdi
callq 0x15dce
movslq (%r15), %rsi
movq 0x30(%rsp), %rdi
callq 0x15d38
movq %rbp, 0x20(%rsp)
movq %r13, 0x28(%rsp)
movq %r12, 0x10(%rsp)
xorl %r13d, %r13d
pushq $0x1
popq %rbp
leaq 0x40(%rsp), %r12
cmpl (%r15), %r13d
jge 0x16a37
movl $0x288, %edi            # imm = 0x288
callq 0x4310
movq %rax, %r14
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
movq %rax, %rdi
movl %r13d, %ecx
movl %ebp, %r8d
callq 0x19ef4
movq %r14, 0x40(%rsp)
movq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x161a8
movl $0x230, %edi            # imm = 0x230
callq 0x4310
movq %rax, %r14
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
movq %rax, %rdi
movl %r13d, %ecx
xorl %r8d, %r8d
callq 0x1c81c
movq %r14, 0x40(%rsp)
movq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x16068
incl %r13d
jmp 0x169c3
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x16a57
jmp 0x16a57
jmp 0x16a57
jmp 0x16a57
jmp 0x16a57
jmp 0x16a57
jmp 0x16a57
movq %rax, %r15
jmp 0x16a8c
movq %rax, %r15
movl $0x288, %esi            # imm = 0x288
jmp 0x16a6e
movq %rax, %r15
movl $0x230, %esi            # imm = 0x230
movq %r14, %rdi
callq 0x4320
jmp 0x16a7d
jmp 0x16a7a
movq %rax, %r15
movq 0x10(%rsp), %r12
movq 0x28(%rsp), %r13
movq 0x20(%rsp), %rbp
movq 0x68(%rsp), %rdi
callq 0xe66e
movq 0x70(%rsp), %rdi
callq 0xe66e
movq 0x78(%rsp), %rdi
callq 0x10ef4
movq 0x80(%rsp), %rdi
callq 0x10ef4
movq %rbp, %rdi
callq 0xe66e
movq %r13, %rdi
callq 0xe66e
movq %r12, %rdi
callq 0xe66e
movq 0x30(%rsp), %rdi
callq 0x15f90
movq 0x38(%rsp), %rdi
callq 0x136ac
movq %rbx, %rdi
callq 0x19530
movq %r15, %rdi
callq 0x4520
nop