// File: estwings57[P]CasHMC/sources/LinkMaster.cpp
// Function: CasHMC::LinkMaster::StartRetry(CasHMC::Packet*)
void LinkMaster::StartRetry(Packet *packet)
{
	startRetryTimer = true;
	retryTimer = 0;
	for(int i=0; i<NUM_OF_IRTRY; i++) {
		if(currentState == LINK_RETRY) {
			readyStartRetry = true;
		}
		else {
			//packet, cmd, addr, cub, lng, *lat
			Packet *packetIRTRY = new Packet(FLOW, IRTRY, 0, 0, 1, NULL);
			packetIRTRY->TAG = packet->TAG;
			packetIRTRY->RRP = lastestRRP;
			packetIRTRY->FRP = 1;		//StartRetry flag is set with FRP[0] = 1
			if(downstream)	packetIRTRY->bufPopDelay = 0;
			linkRxTx.insert(linkRxTx.begin(), packetIRTRY);
			currentState = START_RETRY;
			header.erase(header.find(")"));
			header += ") ST_RT";
		}
	}
	if(currentState == LINK_RETRY) {
		DEBUG(ALI(18)<<header<<ALI(15)<<*packet<<(downstream ? "Down) " : "Up)   ")<<"START RETRY sequence is delayed until LINK RETRY");
	}
	else {
		DEBUG(ALI(18)<<header<<ALI(15)<<*packet<<(downstream ? "Down) " : "Up)   ")<<"START RETRY sequence is initiated");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
movb $0x1, 0x251(%rax)
movl $0x0, 0x254(%rax)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
leaq 0x28e5b(%rip), %rcx     # 0x66578
cmpl (%rcx), %eax
jge 0x3d89d
movq -0x70(%rbp), %rax
cmpl $0xb, 0x200(%rax)
jne 0x3d742
movq -0x70(%rbp), %rax
movb $0x1, 0x250(%rax)
jmp 0x3d88d
movl $0x468, %edi            # imm = 0x468
callq 0x4390
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x78(%rbp)
movq %rsp, %rax
movq $0x0, (%rax)
xorl %r8d, %r8d
movl %r8d, %ecx
movl $0x2, %esi
movl $0x3, %edx
movl $0x1, %r9d
callq 0x43a90
jmp 0x3d77d
movq -0x70(%rbp), %rax
movq -0x78(%rbp), %rcx
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rcx
movl 0x42c(%rcx), %edx
movq -0x20(%rbp), %rcx
movl %edx, 0x42c(%rcx)
movl 0x20c(%rax), %edx
movq -0x20(%rbp), %rcx
movl %edx, 0x44c(%rcx)
movq -0x20(%rbp), %rcx
movl $0x1, 0x448(%rcx)
testb $0x1, 0x1cc(%rax)
je 0x3d7f0
movq -0x20(%rbp), %rax
movl $0x0, 0x14(%rax)
jmp 0x3d7f0
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x468, %esi            # imm = 0x468
callq 0x43a0
jmp 0x3db14
movq -0x70(%rbp), %rdi
movq %rdi, %rax
addq $0x1e8, %rax            # imm = 0x1E8
movq %rax, -0x88(%rbp)
addq $0x1e8, %rdi            # imm = 0x1E8
callq 0x299f0
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x29a60
movq -0x88(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x20(%rbp), %rdx
callq 0x29aa0
movq -0x70(%rbp), %rdi
movq %rax, -0x48(%rbp)
movl $0xa, 0x200(%rdi)
movq %rdi, %rax
addq $0x20, %rax
movq %rax, -0x80(%rbp)
addq $0x20, %rdi
leaq 0x16b1c(%rip), %rsi     # 0x54379
xorl %eax, %eax
movl %eax, %edx
callq 0x46d0
movq -0x80(%rbp), %rdi
movq %rax, %rsi
movq $-0x1, %rdx
callq 0x40e0
movq -0x70(%rbp), %rdi
addq $0x20, %rdi
leaq 0x15fd1(%rip), %rsi     # 0x53859
callq 0x4350
jmp 0x3d88f
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x3d713
movq -0x70(%rbp), %rax
cmpl $0xb, 0x200(%rax)
jne 0x3d9de
leaq 0x28c73(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x3d9d9
leaq 0x28c64(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x3d9d9
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %esi
movq 0x286eb(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0xa8(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0xa8(%rbp), %rdi
movb %al, -0x4d(%rbp)
movzbl -0x4d(%rbp), %esi
callq 0x4550
movq -0x70(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0xa0(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0xa0(%rbp), %rdi
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %esi
callq 0x4440
movq %rax, -0x98(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0x98(%rbp), %rdi
movb %al, -0x55(%rbp)
movzbl -0x55(%rbp), %esi
callq 0x4550
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x44960
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, -0x90(%rbp)
testb $0x1, 0x1cc(%rax)
je 0x3d998
leaq 0x15cb9(%rip), %rax     # 0x53648
movq %rax, -0xb0(%rbp)
jmp 0x3d9a8
leaq 0x15cb0(%rip), %rax     # 0x5364f
movq %rax, -0xb0(%rbp)
jmp 0x3d9a8
movq -0x90(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x4380
movq %rax, %rdi
leaq 0x15e9c(%rip), %rsi     # 0x53861
callq 0x4380
movq %rax, %rdi
movq 0x285dc(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x3db0b
leaq 0x28b43(%rip), %rax     # 0x66528
testb $0x1, (%rax)
je 0x3db09
leaq 0x28b34(%rip), %rax     # 0x66529
testb $0x1, (%rax)
jne 0x3db09
movl $0x12, %edi
callq 0x177b0
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %esi
movq 0x285bb(%rip), %rdi     # 0x65fd0
callq 0x4440
movq %rax, -0xd0(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0xd0(%rbp), %rdi
movb %al, -0x5d(%rbp)
movzbl -0x5d(%rbp), %esi
callq 0x4550
movq -0x70(%rbp), %rsi
movq %rax, %rdi
addq $0x20, %rsi
callq 0x4320
movq %rax, -0xc8(%rbp)
movl $0xf, %edi
callq 0x177b0
movq -0xc8(%rbp), %rdi
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %esi
callq 0x4440
movq %rax, -0xc0(%rbp)
movl $0x20, %edi
callq 0x177d0
movq -0xc0(%rbp), %rdi
movb %al, -0x65(%rbp)
movzbl -0x65(%rbp), %esi
callq 0x4550
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x44960
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, -0xb8(%rbp)
testb $0x1, 0x1cc(%rax)
je 0x3dac8
leaq 0x15b89(%rip), %rax     # 0x53648
movq %rax, -0xd8(%rbp)
jmp 0x3dad8
leaq 0x15b80(%rip), %rax     # 0x5364f
movq %rax, -0xd8(%rbp)
jmp 0x3dad8
movq -0xb8(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x4380
movq %rax, %rdi
leaq 0x15d9d(%rip), %rsi     # 0x53892
callq 0x4380
movq %rax, %rdi
movq 0x284ac(%rip), %rsi     # 0x65fb0
callq 0x43c0
jmp 0x3db0b
addq $0xe0, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x4630
nopl (%rax)