// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0xb797
jmp 0xb768
leaq 0x1bb5d(%rip), %rdi     # 0x272cc
leaq 0x1c640(%rip), %rsi     # 0x27db6
movl $0x23d, %edx            # imm = 0x23D
leaq 0x1c5e9(%rip), %rcx     # 0x27d6b
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0xb799
jmp 0xb79b
movq -0x8(%rbp), %rax
cmpl $0x1, 0x48(%rax)
jne 0xb7d6
jmp 0xb7a7
leaq 0x1bb1e(%rip), %rdi     # 0x272cc
leaq 0x1c61a(%rip), %rsi     # 0x27dcf
movl $0x241, %edx            # imm = 0x241
leaq 0x1c5aa(%rip), %rcx     # 0x27d6b
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0xb7d8
movq -0x8(%rbp), %rax
cmpl $0xa, 0x48(%rax)
jne 0xb800
movq -0x8(%rbp), %rsi
leaq 0x24123(%rip), %rdi     # 0x2f910
callq 0xb9d0
movq -0x8(%rbp), %rdi
callq 0xa630
jmp 0xb9bc
movl $0x0, -0x2c(%rbp)
movw $0x0, -0x2e(%rbp)
movq -0x8(%rbp), %rax
movl 0x88(%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0xf0(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jne 0xb8d1
movq -0x8(%rbp), %rax
movzwl 0x4e(%rax), %eax
cmpl $0x0, %eax
je 0xb8cf
jmp 0xb85c
movq 0x2409d(%rip), %rax     # 0x2f900
cmpq -0x8(%rbp), %rax
jne 0xb87d
movq 0x24090(%rip), %rax     # 0x2f900
movq 0x38(%rax), %rax
movq %rax, 0x24085(%rip)     # 0x2f900
jmp 0xb8c1
movq 0x2407c(%rip), %rax     # 0x2f900
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xb8bf
movq -0x40(%rbp), %rax
movq 0x38(%rax), %rax
cmpq -0x8(%rbp), %rax
jne 0xb8af
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0xb8bf
jmp 0xb8b1
movq -0x40(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0xb888
jmp 0xb8c1
movq -0x8(%rbp), %rax
movq $0x0, 0x38(%rax)
jmp 0xb8cf
jmp 0xb8fc
movl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movw 0x4e(%rax), %ax
movw %ax, -0x2e(%rbp)
movq -0x8(%rbp), %rsi
leaq 0x2401a(%rip), %rdi     # 0x2f908
callq 0xb9d0
movb $0x1, 0x2401f(%rip)     # 0x2f919
jmp 0xb8fc
movq -0x8(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
je 0xb91a
movq -0x8(%rbp), %rax
movq 0xb0(%rax), %rdi
callq 0xbc50
movq -0x8(%rbp), %rax
cmpq $0x0, 0xa8(%rax)
je 0xb938
movq -0x8(%rbp), %rax
movq 0xa8(%rax), %rdi
callq 0xbc50
movq -0x8(%rbp), %rax
cmpq $0x0, 0xb8(%rax)
je 0xb956
movq -0x8(%rbp), %rax
movq 0xb8(%rax), %rdi
callq 0xbc50
cmpl $0x0, -0x2c(%rbp)
je 0xb98f
jmp 0xb95e
jmp 0xb960
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movq -0x8(%rbp), %rcx
movq -0x8(%rbp), %r8
addq $0x18, %r8
movw -0x2e(%rbp), %r9w
movq -0x8(%rbp), %rax
movzwl %r9w, %r9d
movzwl 0x50(%rax), %eax
movl %eax, (%rsp)
callq 0x16110
movq -0x8(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa630
cmpq $0x0, -0x20(%rbp)
je 0xb9b8
movq -0x20(%rbp), %rax
movq -0x28(%rbp), %rdi
movl $0xfffffff3, %esi       # imm = 0xFFFFFFF3
callq *%rax
jmp 0xb9ba
jmp 0xb9bc
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)