// File: /workspace/github_c_makefile_star2_O3/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 0x72e4
movq %rdi, %rbx
movl 0x48(%rdi), %eax
cmpl $0xa, %eax
je 0x71c5
cmpl $0x1, %eax
je 0x7300
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 0x71ea
movl %esi, %r12d
leaq 0x1575b(%rip), %rdi     # 0x1c908
movq %rbx, %rsi
callq 0x732d
movb $0x1, 0x1575d(%rip)     # 0x1c919
testl %r12d, %r12d
sete %r12b
jmp 0x7232
leaq 0x15744(%rip), %rdi     # 0x1c910
movq %rbx, %rsi
callq 0x732d
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6780
movb $0x1, %r12b
testw %r13w, %r13w
je 0x722f
movq 0x15706(%rip), %rcx     # 0x1c900
cmpq %rbx, %rcx
je 0x7219
testq %rcx, %rcx
je 0x7227
movq %rcx, %rax
movq 0x38(%rcx), %rcx
cmpq %rbx, %rcx
jne 0x71ff
addq $0x38, %rax
movq %rbx, %rcx
jmp 0x7220
leaq 0x156e0(%rip), %rax     # 0x1c900
movq 0x38(%rcx), %rcx
movq %rcx, (%rax)
movq $0x0, 0x38(%rbx)
xorl %r13d, %r13d
movq 0xb0(%rbx), %rdi
testq %rdi, %rdi
je 0x724e
movq (%rdi), %r15
callq 0x817c
movq %r15, %rdi
testq %r15, %r15
jne 0x723e
movq 0xa8(%rbx), %rdi
testq %rdi, %rdi
je 0x726a
movq (%rdi), %r15
callq 0x817c
movq %r15, %rdi
testq %r15, %r15
jne 0x725a
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x7286
movq (%rdi), %r15
callq 0x817c
movq %r15, %rdi
testq %r15, %r15
jne 0x7276
testb %r12b, %r12b
jne 0x72ad
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 0xc757
movq %rbx, %rdi
callq 0x6780
testq %rbp, %rbp
je 0x72d5
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 0xcfe1(%rip), %rdi      # 0x142cc
leaq 0xd9e1(%rip), %rsi      # 0x14cd3
leaq 0xd98f(%rip), %rcx      # 0x14c88
movl $0x23d, %edx            # imm = 0x23D
jmp 0x731a
leaq 0xcfc5(%rip), %rdi      # 0x142cc
leaq 0xd9de(%rip), %rsi      # 0x14cec
leaq 0xd973(%rip), %rcx      # 0x14c88
movl $0x241, %edx            # imm = 0x241
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050