// File: /workspace/github_c_makefile_star2_O2/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 0x704e
movq %rdi, %rbx
movl 0x48(%rdi), %eax
cmpl $0xa, %eax
je 0x6f57
cmpl $0x1, %eax
je 0x706a
movl 0x88(%rbx), %edx
movl 0x5c(%rbx), %ebp
movq 0xf0(%rbx), %r14
movq 0x40(%rbx), %r15
movzwl 0x4e(%rbx), %r13d
testl %eax, %eax
movl %edx, 0x14(%rsp)
je 0x6f7c
movl %esi, %r12d
leaq 0x169c9(%rip), %rdi     # 0x1d908
movq %rbx, %rsi
callq 0x7097
movb $0x1, 0x169cb(%rip)     # 0x1d919
testl %r12d, %r12d
sete %r12b
jmp 0x6fc1
leaq 0x169b2(%rip), %rdi     # 0x1d910
movq %rbx, %rsi
callq 0x7097
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6530
movb $0x1, %r12b
testw %r13w, %r13w
je 0x6fbe
movq 0x16974(%rip), %rcx     # 0x1d900
cmpq %rbx, %rcx
je 0x6fab
testq %rcx, %rcx
je 0x6fb9
movq %rcx, %rax
movq 0x38(%rcx), %rcx
cmpq %rbx, %rcx
jne 0x6f91
addq $0x38, %rax
movq %rbx, %rcx
jmp 0x6fb2
leaq 0x1694e(%rip), %rax     # 0x1d900
movq 0x38(%rcx), %rcx
movq %rcx, (%rax)
andq $0x0, 0x38(%rbx)
xorl %r13d, %r13d
movq 0xb0(%rbx), %rdi
testq %rdi, %rdi
je 0x6fd2
callq 0x71d7
movq 0xa8(%rbx), %rdi
testq %rdi, %rdi
je 0x6fe3
callq 0x71d7
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x6ff4
callq 0x71d7
testb %r12b, %r12b
jne 0x7019
leaq 0x18(%rbx), %r8
movzwl 0x50(%rbx), %eax
movl %eax, (%rsp)
movzwl %r13w, %r9d
movq %rbx, %rdi
movl 0x14(%rsp), %esi
movl %ebp, %edx
movq %rbx, %rcx
callq 0xc200
movq %rbx, %rdi
callq 0x6530
testq %r14, %r14
je 0x703f
movq %r14, %rax
pushq $-0xd
popq %rsi
movq %r15, %rdi
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 0xd277(%rip), %rdi      # 0x142cc
leaq 0xdc8e(%rip), %rsi      # 0x14cea
leaq 0xdc3c(%rip), %rcx      # 0x14c9f
movl $0x23d, %edx            # imm = 0x23D
jmp 0x7084
leaq 0xd25b(%rip), %rdi      # 0x142cc
leaq 0xdc8b(%rip), %rsi      # 0x14d03
leaq 0xdc20(%rip), %rcx      # 0x14c9f
movl $0x241, %edx            # imm = 0x241
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050