// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp_out.c
// Function: tcp_rexmit_rto_prepare
err_t
tcp_rexmit_rto_prepare(struct tcp_pcb *pcb)
{
  struct tcp_seg *seg;

  LWIP_ASSERT("tcp_rexmit_rto_prepare: invalid pcb", pcb != NULL);

  if (pcb->unacked == NULL) {
    return ERR_VAL;
  }

  /* Move all unacked segments to the head of the unsent queue.
     However, give up if any of the unsent pbufs are still referenced by the
     netif driver due to deferred transmission. No point loading the link further
     if it is struggling to flush its buffered writes. */
  for (seg = pcb->unacked; seg->next != NULL; seg = seg->next) {
    if (tcp_output_segment_busy(seg)) {
      LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_rexmit_rto: segment busy\n"));
      return ERR_VAL;
    }
  }
  if (tcp_output_segment_busy(seg)) {
    LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_rexmit_rto: segment busy\n"));
    return ERR_VAL;
  }
  /* concatenate unsent queue after unacked queue */
  seg->next = pcb->unsent;
#if TCP_OVERSIZE_DBGCHECK
  /* if last unsent changed, we need to update unsent_oversize */
  if (pcb->unsent == NULL) {
    pcb->unsent_oversize = seg->oversize_left;
  }
#endif /* TCP_OVERSIZE_DBGCHECK */
  /* unsent queue is the concatenated queue (of unacked, unsent) */
  pcb->unsent = pcb->unacked;
  /* unacked queue is now empty */
  pcb->unacked = NULL;

  /* Mark RTO in-progress */
  tcp_set_flags(pcb, TF_RTO);
  /* Record the next byte following retransmit */
  pcb->rto_end = lwip_ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg);
  /* Don't take any RTT measurements after retransmitting. */
  pcb->rttest = 0;

  return ERR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x15b74
jmp 0x15b45
leaq 0x11780(%rip), %rdi     # 0x272cc
leaq 0x132fe(%rip), %rsi     # 0x28e51
movl $0x663, %edx            # imm = 0x663
leaq 0x12e73(%rip), %rcx     # 0x289d2
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x15b76
movq -0x10(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
jne 0x15b8d
movb $-0x6, -0x1(%rbp)
jmp 0x15cc9
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
je 0x15bd0
movq -0x18(%rbp), %rdi
callq 0x15ce0
cmpl $0x0, %eax
je 0x15bc1
jmp 0x15bb6
jmp 0x15bb8
movb $-0x6, -0x1(%rbp)
jmp 0x15cc9
jmp 0x15bc3
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x15b9c
movq -0x18(%rbp), %rdi
callq 0x15ce0
cmpl $0x0, %eax
je 0x15beb
jmp 0x15be0
jmp 0x15be2
movb $-0x6, -0x1(%rbp)
jmp 0x15cc9
movq -0x10(%rbp), %rax
movq 0xa8(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0xa8(%rax)
jne 0x15c1e
movq -0x18(%rbp), %rax
movw 0x12(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xa0(%rax)
movq -0x10(%rbp), %rax
movq 0xb0(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xb0(%rax)
movq -0x10(%rbp), %rax
movzwl 0x52(%rax), %eax
orl $0x800, %eax            # imm = 0x800
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x52(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x4(%rax), %edi
callq 0x251f0
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x10(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movzwl 0xc(%rax), %edi
callq 0x251c0
movl -0x20(%rbp), %ecx
movw %ax, %dx
movl -0x1c(%rbp), %eax
movzwl %dx, %edx
andl $0x3f, %edx
movzbl %dl, %edi
andl $0x3, %edi
xorl %edx, %edx
movl $0x1, %esi
cmpl $0x0, %edi
cmovnel %esi, %edx
addl %edx, %eax
addl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x84(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x6c(%rax)
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)