// File: /workspace/github_c_makefile_star2_O1/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_abandon
void
tcp_abandon(struct tcp_pcb *pcb, int reset)
{
  u32_t seqno, ackno;
#if LWIP_CALLBACK_API
  tcp_err_fn errf;
#endif /* LWIP_CALLBACK_API */
  void *errf_arg;

  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ERROR("tcp_abandon: invalid pcb", pcb != NULL, return);

  /* pcb->state LISTEN not allowed here */
  LWIP_ASSERT("don't call tcp_abort/tcp_abandon for listen-pcbs",
              pcb->state != LISTEN);
  /* Figure out on which TCP PCB list we are, and remove us. If we
     are in an active state, call the receive function associated with
     the PCB with a NULL argument, and send an RST to the remote end. */
  if (pcb->state == TIME_WAIT) {
    tcp_pcb_remove(&tcp_tw_pcbs, pcb);
    tcp_free(pcb);
  } else {
    int send_rst = 0;
    u16_t local_port = 0;
    enum tcp_state last_state;
    seqno = pcb->snd_nxt;
    ackno = pcb->rcv_nxt;
#if LWIP_CALLBACK_API
    errf = pcb->errf;
#endif /* LWIP_CALLBACK_API */
    errf_arg = pcb->callback_arg;
    if (pcb->state == CLOSED) {
      if (pcb->local_port != 0) {
        /* bound, not yet opened */
        TCP_RMV(&tcp_bound_pcbs, pcb);
      }
    } else {
      send_rst = reset;
      local_port = pcb->local_port;
      TCP_PCB_REMOVE_ACTIVE(pcb);
    }
    if (pcb->unacked != NULL) {
      tcp_segs_free(pcb->unacked);
    }
    if (pcb->unsent != NULL) {
      tcp_segs_free(pcb->unsent);
    }
#if TCP_QUEUE_OOSEQ
    if (pcb->ooseq != NULL) {
      tcp_segs_free(pcb->ooseq);
    }
#endif /* TCP_QUEUE_OOSEQ */
    tcp_backlog_accepted(pcb);
    if (send_rst) {
      LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abandon: sending RST\n"));
      tcp_rst(pcb, seqno, ackno, &pcb->local_ip, &pcb->remote_ip, local_port, pcb->remote_port);
    }
    last_state = pcb->state;
    tcp_free(pcb);
    TCP_EVENT_ERR(last_state, errf, errf_arg, ERR_ABRT);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x73f4
movq %rdi, %rbx
movl 0x48(%rdi), %eax
cmpl $0xa, %eax
je 0x72d5
cmpl $0x1, %eax
je 0x7410
movl 0x88(%rbx), %ecx
movl %ecx, 0x14(%rsp)
movl 0x5c(%rbx), %ecx
movl %ecx, 0x10(%rsp)
movq 0xf0(%rbx), %rbp
movq 0x40(%rbx), %r14
movzwl 0x4e(%rbx), %r13d
testl %eax, %eax
je 0x72fa
movl %esi, %r12d
leaq 0x1664b(%rip), %rdi     # 0x1d908
movq %rbx, %rsi
callq 0x743d
movb $0x1, 0x1664d(%rip)     # 0x1d919
testl %r12d, %r12d
sete %r12b
jmp 0x7342
leaq 0x16634(%rip), %rdi     # 0x1d910
movq %rbx, %rsi
callq 0x743d
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x685c
movb $0x1, %r12b
testw %r13w, %r13w
je 0x733f
movq 0x165f6(%rip), %rcx     # 0x1d900
cmpq %rbx, %rcx
je 0x7329
testq %rcx, %rcx
je 0x7337
movq %rcx, %rax
movq 0x38(%rcx), %rcx
cmpq %rbx, %rcx
jne 0x730f
addq $0x38, %rax
movq %rbx, %rcx
jmp 0x7330
leaq 0x165d0(%rip), %rax     # 0x1d900
movq 0x38(%rcx), %rcx
movq %rcx, (%rax)
movq $0x0, 0x38(%rbx)
xorl %r13d, %r13d
movq 0xb0(%rbx), %rdi
testq %rdi, %rdi
je 0x735e
movq (%rdi), %r15
callq 0x828a
movq %r15, %rdi
testq %r15, %r15
jne 0x734e
movq 0xa8(%rbx), %rdi
testq %rdi, %rdi
je 0x737a
movq (%rdi), %r15
callq 0x828a
movq %r15, %rdi
testq %r15, %r15
jne 0x736a
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x7396
movq (%rdi), %r15
callq 0x828a
movq %r15, %rdi
testq %r15, %r15
jne 0x7386
testb %r12b, %r12b
jne 0x73bd
leaq 0x18(%rbx), %r8
movzwl 0x50(%rbx), %eax
movl %eax, (%rsp)
movzwl %r13w, %r9d
movq %rbx, %rdi
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edx
movq %rbx, %rcx
callq 0xc9d6
movq %rbx, %rdi
callq 0x685c
testq %rbp, %rbp
je 0x73e5
movq %rbp, %rax
movq %r14, %rdi
movl $0xfffffff3, %esi       # imm = 0xFFFFFFF3
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xded1(%rip), %rdi      # 0x152cc
leaq 0xe8e8(%rip), %rsi      # 0x15cea
leaq 0xe896(%rip), %rcx      # 0x15c9f
movl $0x23d, %edx            # imm = 0x23D
jmp 0x742a
leaq 0xdeb5(%rip), %rdi      # 0x152cc
leaq 0xe8e5(%rip), %rsi      # 0x15d03
leaq 0xe87a(%rip), %rcx      # 0x15c9f
movl $0x241, %edx            # imm = 0x241
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050