// File: /workspace/github_cpp_makefile_star2_O3/estwings57[P]CasHMC/sources/LinkMaster.cpp
// Function: CasHMC::LinkMaster::LinkMaster(std::basic_ofstream<char, std::char_traits<char>>&, std::basic_ofstream<char, std::char_traits<char>>&, unsigned int, bool)
LinkMaster::LinkMaster(ofstream &debugOut_, ofstream &stateOut_, unsigned id, bool down):
	SingleVectorObject<Packet>(debugOut_, stateOut_, MAX_LINK_BUF, down),
	linkMasterID(id)
{
	classID << linkMasterID;
	header = "   (LM_";
	header += downstream ? "D" : "U";
	header += classID.str() + ")";
	
	tokenCount = MAX_LINK_BUF;
	lastestRRP = 0;
	linkP = NULL;
	localLinkSlave = NULL;
	masterSEQ = 0;
	countdownCRC = 0;
	startCRC = false;
	retryStartPacket = NULL;
	readyStartRetry = false;
	startRetryTimer = false;
	retryTimer = 0;
	retryAttempts = 1;
	retBufReadP = 0;
	retBufWriteP = 0;
	retrainTransit = 0;
	firstNull = true;
	
	retryBuffers = vector<Packet *>(MAX_RETRY_BUF, NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movl %ecx, %ebp
movq %rdi, %rbx
leaq 0x19008(%rip), %r15     # 0x3b4b8
movl (%r15), %ecx
callq 0x25c22
leaq 0x18751(%rip), %rax     # 0x3ac10
movq %rax, (%rbx)
movl %ebp, 0x204(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x220(%rbx)
xorl %eax, %eax
movq %rax, 0x230(%rbx)
movups %xmm0, 0x270(%rbx)
movq %rax, 0x280(%rbx)
leaq 0x50(%rbx), %rdi
movl %ebp, %esi
callq 0x41e0
leaq 0x20(%rbx), %r14
movq 0x28(%rbx), %rdx
leaq 0x1034d(%rip), %rcx     # 0x32850
movl $0x7, %r8d
movq %r14, %rdi
xorl %esi, %esi
callq 0x4440
leaq 0x110fb(%rip), %rax     # 0x33615
leaq 0xfa59(%rip), %rsi      # 0x31f7a
cmpb $0x0, 0x1cc(%rbx)
cmovneq %rax, %rsi
movq %r14, %rdi
callq 0x4580
leaq 0x58(%rbx), %rsi
leaq 0x30(%rsp), %rdi
callq 0x4450
leaq 0x10f98(%rip), %rsi     # 0x334e1
leaq 0x30(%rsp), %rdi
callq 0x4580
leaq 0x20(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x2257b
movq %rsi, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x22586
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq %r12, %rsi
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r14, %rdi
callq 0x4110
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x225bd
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4300
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x225d8
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4300
movl (%r15), %eax
movl %eax, 0x208(%rbx)
xorl %eax, %eax
movq %rax, 0x248(%rbx)
movw $0x0, 0x250(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x20c(%rbx)
movl %eax, 0x21c(%rbx)
movq %rax, 0x238(%rbx)
movb $0x0, 0x240(%rbx)
movsd 0x10227(%rip), %xmm0    # 0x32840
movups %xmm0, 0x254(%rbx)
movl %eax, 0x264(%rbx)
movb $0x1, 0x268(%rbx)
leaq 0x18e88(%rip), %rcx     # 0x3b4bc
movslq (%rcx), %rsi
leaq 0x30(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x25cc8
movq 0x270(%rbx), %rdi
movq 0x280(%rbx), %rsi
movaps 0x10(%rsp), %xmm0
movups %xmm0, 0x270(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x280(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x226a9
subq %rdi, %rsi
callq 0x4300
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x226a9
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x226f6
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x226d7
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x4300
jmp 0x226d7
movq %rax, %r14
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x226f9
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x4300
jmp 0x226f9
jmp 0x226f6
movq %rax, %r14
leaq 0x220(%rbx), %r15
leaq 0x270(%rbx), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x2271e
movq 0x280(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq (%r15), %rdi
testq %rdi, %rdi
je 0x22735
movq 0x230(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x25e42
movq %r14, %rdi
callq 0x4540
nop