// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %ecx, %ebp
movq %rdi, %rbx
leaq 0x198c6(%rip), %r12     # 0x3c4b8
movl (%r12), %ecx
callq 0x26416
leaq 0x1900e(%rip), %rax     # 0x3bc10
movq %rax, (%rbx)
movl %ebp, 0x204(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x220(%rbx)
xorl %eax, %eax
movq %rax, 0x230(%rbx)
leaq 0x270(%rbx), %r14
movups %xmm0, 0x270(%rbx)
movq %rax, 0x280(%rbx)
leaq 0x50(%rbx), %rdi
movl %ebp, %esi
callq 0x41e0
leaq 0x20(%rbx), %r15
movq 0x28(%rbx), %rdx
leaq 0x10b87(%rip), %rcx     # 0x337d4
movl $0x7, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x4440
leaq 0x11931(%rip), %rax     # 0x34595
leaq 0x1029f(%rip), %rsi     # 0x32f0a
cmpb $0x0, 0x1cc(%rbx)
cmovneq %rax, %rsi
movq %r15, %rdi
callq 0x4580
leaq 0x58(%rbx), %rsi
leaq 0x28(%rsp), %rdi
callq 0x4450
leaq 0x117ce(%rip), %rsi     # 0x34461
leaq 0x28(%rsp), %rdi
callq 0x4580
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x22cc4
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x22ccc
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x4110
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x22d0d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4300
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x22d28
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4300
movl (%r12), %eax
movl %eax, 0x208(%rbx)
xorl %eax, %eax
movq %rax, 0x248(%rbx)
movw $0x0, 0x250(%rbx)
movl %eax, 0x254(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x20c(%rbx)
movl %eax, 0x21c(%rbx)
movq %rax, 0x238(%rbx)
movb $0x0, 0x240(%rbx)
movss 0x10a60(%rip), %xmm0    # 0x337d0
movups %xmm0, 0x258(%rbx)
movb $0x1, 0x268(%rbx)
leaq 0x19737(%rip), %rcx     # 0x3c4bc
movslq (%rcx), %rsi
leaq 0x28(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rcx
callq 0x264bc
leaq 0x8(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x265fa
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x22dc4
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x4300
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x22e13
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x22df4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x4300
jmp 0x22df4
movq %rax, %r15
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x22e16
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x4300
jmp 0x22e16
jmp 0x22e13
movq %rax, %r15
leaq 0x220(%rbx), %r12
movq (%r14), %rdi
testq %rdi, %rdi
je 0x22e34
movq 0x280(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq (%r12), %rdi
testq %rdi, %rdi
je 0x22e4c
movq 0x230(%rbx), %rsi
subq %rdi, %rsi
callq 0x4300
movq %rbx, %rdi
callq 0x26586
movq %r15, %rdi
callq 0x4540