// File: 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
movq %rsp, %rbp
subq $0xd0, %rsp
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
andb $0x1, %al
movb %al, -0x1d(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x2a2ac(%rip), %rax     # 0x66558
movl (%rax), %ecx
movzbl -0x1d(%rbp), %r8d
andl $0x1, %r8d
callq 0x40430
movq -0xa0(%rbp), %rdi
leaq 0x29956(%rip), %rax     # 0x65c20
movq %rax, (%rdi)
movl -0x1c(%rbp), %eax
movl %eax, 0x204(%rdi)
addq $0x220, %rdi            # imm = 0x220
movq %rdi, -0xb0(%rbp)
callq 0x295c0
movq -0xa0(%rbp), %rdi
addq $0x270, %rdi            # imm = 0x270
movq %rdi, -0xa8(%rbp)
callq 0x295c0
movq -0xa0(%rbp), %rax
movq %rax, %rdi
addq $0x50, %rdi
movl 0x204(%rax), %esi
callq 0x44c0
jmp 0x3c31e
movq -0xa0(%rbp), %rdi
addq $0x20, %rdi
leaq 0x173db(%rip), %rsi     # 0x5370b
callq 0x44e0
jmp 0x3c337
movq -0xa0(%rbp), %rax
testb $0x1, 0x1cc(%rax)
je 0x3c357
leaq 0x1815f(%rip), %rax     # 0x544ad
movq %rax, -0xb8(%rbp)
jmp 0x3c367
leaq 0x16bbd(%rip), %rax     # 0x52f1b
movq %rax, -0xb8(%rbp)
jmp 0x3c367
movq -0xa0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
addq $0x20, %rdi
callq 0x4350
jmp 0x3c380
movq -0xa0(%rbp), %rsi
addq $0x40, %rsi
leaq -0x70(%rbp), %rdi
callq 0x4370
jmp 0x3c396
leaq 0x17fdc(%rip), %rdx     # 0x54379
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x18020
jmp 0x3c3ac
movq -0xa0(%rbp), %rdi
addq $0x20, %rdi
leaq -0x50(%rbp), %rsi
callq 0x44a0
jmp 0x3c3c2
leaq -0x50(%rbp), %rdi
callq 0x46e8
leaq -0x70(%rbp), %rdi
callq 0x46e8
movq -0xa0(%rbp), %rax
leaq 0x2a176(%rip), %rcx     # 0x66558
movl (%rcx), %ecx
movl %ecx, 0x208(%rax)
movl $0x0, 0x20c(%rax)
movq $0x0, 0x210(%rax)
movq $0x0, 0x218(%rax)
movl $0x0, 0x238(%rax)
movl $0x0, 0x23c(%rax)
movb $0x0, 0x240(%rax)
movq $0x0, 0x248(%rax)
movb $0x0, 0x250(%rax)
movb $0x0, 0x251(%rax)
movl $0x0, 0x254(%rax)
movl $0x1, 0x258(%rax)
movl $0x0, 0x25c(%rax)
movl $0x0, 0x260(%rax)
movl $0x0, 0x264(%rax)
movb $0x1, 0x268(%rax)
leaq 0x2a0de(%rip), %rax     # 0x6655c
movslq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq $0x0, -0x90(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x2a190
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rcx
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x40500
jmp 0x3c4c9
movq -0xa0(%rbp), %rdi
addq $0x270, %rdi            # imm = 0x270
leaq -0x88(%rbp), %rsi
callq 0x40580
leaq -0x88(%rbp), %rdi
callq 0x29880
leaq -0x91(%rbp), %rdi
callq 0x2ab40
addq $0xd0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x3c558
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x3c535
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x46e8
leaq -0x70(%rbp), %rdi
callq 0x46e8
jmp 0x3c558
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x2ab40
movq -0xa8(%rbp), %rdi
callq 0x29880
movq -0xb0(%rbp), %rdi
callq 0x29880
movq -0xa0(%rbp), %rdi
callq 0x406e0
movq -0x28(%rbp), %rdi
callq 0x4630
nopw %cs:(%rax,%rax)