LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_shutdown
err_t
tcp_shutdown(struct tcp_pcb *pcb, int shut_rx, int shut_tx)
{
  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ERROR("tcp_shutdown: invalid pcb", pcb != NULL, return ERR_ARG);

  if (pcb->state == LISTEN) {
    return ERR_CONN;
  }
  if (shut_rx) {
    /* shut down the receive side: set a flag not to receive any more data... */
    tcp_set_flags(pcb, TF_RXCLOSED);
    if (shut_tx) {
      /* shutting down the tx AND rx side is the same as closing for the raw API */
      return tcp_close_shutdown(pcb, 1);
    }
    /* ... and free buffered data */
    if (pcb->refused_data != NULL) {
      pbuf_free(pcb->refused_data);
      pcb->refused_data = NULL;
    }
  }
  if (shut_tx) {
    /* This can't happen twice since if it succeeds, the pcb's state is changed.
       Only close in these states as the others directly deallocate the PCB */
    switch (pcb->state) {
      case SYN_RCVD:
      case ESTABLISHED:
      case CLOSE_WAIT:
        return tcp_close_shutdown(pcb, (u8_t)shut_rx);
      default:
        /* Not (yet?) connected, cannot shutdown the TX side as that would bring us
          into CLOSED state, where the PCB is deallocated. */
        return ERR_CONN;
    }
  }
  return ERR_OK;
}

// Assembly:
pushq %rbx
testq %rdi, %rdi
je 0x7126
movq %rdi, %rbx
movl 0x48(%rdi), %ecx
movb $-0xb, %al
cmpl $0x1, %ecx
je 0x7124
testl %esi, %esi
je 0x70e8
orb $0x10, 0x52(%rbx)
testl %edx, %edx
je 0x7106
movq %rbx, %rdi
movl $0x1, %esi
jmp 0x7100
testl %edx, %edx
je 0x7122
cmpl $0x7, %ecx
ja 0x7124
movl $0x98, %edx
btl %ecx, %edx
jae 0x7124
movq %rbx, %rdi
xorl %esi, %esi
popq %rbx
jmp 0x6ebc
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x7122
callq 0x4fdf
movq $0x0, 0xc0(%rbx)
xorl %eax, %eax
popq %rbx
retq
leaq 0xd19f(%rip), %rdi      # 0x142cc
leaq 0xdb85(%rip), %rsi      # 0x14cb9
leaq 0xdb4d(%rip), %rcx      # 0x14c88
movl $0x207, %edx            # imm = 0x207
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_pcb_remove
void
tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
{
  LWIP_ASSERT("tcp_pcb_remove: invalid pcb", pcb != NULL);
  LWIP_ASSERT("tcp_pcb_remove: invalid pcblist", pcblist != NULL);

  TCP_RMV(pcblist, pcb);

  tcp_pcb_purge(pcb);

  /* if there is an outstanding delayed ACKs, send it */
  if ((pcb->state != TIME_WAIT) &&
      (pcb->state != LISTEN) &&
      (pcb->flags & TF_ACK_DELAY)) {
    tcp_ack_now(pcb);
    tcp_output(pcb);
  }

  if (pcb->state != LISTEN) {
    LWIP_ASSERT("unsent segments leaking", pcb->unsent == NULL);
    LWIP_ASSERT("unacked segments leaking", pcb->unacked == NULL);
#if TCP_QUEUE_OOSEQ
    LWIP_ASSERT("ooseq segments leaking", pcb->ooseq == NULL);
#endif /* TCP_QUEUE_OOSEQ */
  }

  pcb->state = CLOSED;
  /* reset the local port to prevent the pcb from being 'bound' */
  pcb->local_port = 0;

  LWIP_ASSERT("tcp_pcb_remove: tcp_pcbs_sane()", tcp_pcbs_sane());
}

// Assembly:
pushq %rbx
testq %rsi, %rsi
je 0x73db
testq %rdi, %rdi
je 0x73f7
movq %rsi, %rbx
movq (%rdi), %rax
cmpq %rsi, %rax
je 0x7363
testq %rax, %rax
je 0x736a
movq %rax, %rdi
movq 0x38(%rax), %rax
cmpq %rbx, %rax
jne 0x734b
addq $0x38, %rdi
movq %rbx, %rax
movq 0x38(%rax), %rax
movq %rax, (%rdi)
movq $0x0, 0x38(%rbx)
movq %rbx, %rdi
callq 0x7eb3
movl 0x48(%rbx), %eax
cmpl $0x1, %eax
je 0x73a1
cmpl $0xa, %eax
je 0x73a1
movzwl 0x52(%rbx), %eax
testb $0x1, %al
je 0x73a6
orl $0x2, %eax
movw %ax, 0x52(%rbx)
movq %rbx, %rdi
callq 0xbd02
movl 0x48(%rbx), %eax
cmpl $0x1, %eax
je 0x73c8
cmpq $0x0, 0xa8(%rbx)
jne 0x7413
cmpq $0x0, 0xb0(%rbx)
jne 0x742f
cmpq $0x0, 0xb8(%rbx)
jne 0x744b
movl $0x0, 0x48(%rbx)
movw $0x0, 0x4e(%rbx)
popq %rbx
jmp 0x8612
leaq 0xceea(%rip), %rdi      # 0x142cc
leaq 0xdda7(%rip), %rsi      # 0x15190
leaq 0xd898(%rip), %rcx      # 0x14c88
movl $0x883, %edx            # imm = 0x883
jmp 0x7465
leaq 0xcece(%rip), %rdi      # 0x142cc
leaq 0xdda7(%rip), %rsi      # 0x151ac
leaq 0xd87c(%rip), %rcx      # 0x14c88
movl $0x884, %edx            # imm = 0x884
jmp 0x7465
leaq 0xceb2(%rip), %rdi      # 0x142cc
leaq 0xddab(%rip), %rsi      # 0x151cc
leaq 0xd860(%rip), %rcx      # 0x14c88
movl $0x893, %edx            # imm = 0x893
jmp 0x7465
leaq 0xce96(%rip), %rdi      # 0x142cc
leaq 0xdda7(%rip), %rsi      # 0x151e4
leaq 0xd844(%rip), %rcx      # 0x14c88
movl $0x894, %edx            # imm = 0x894
jmp 0x7465
leaq 0xce7a(%rip), %rdi      # 0x142cc
leaq 0xdda4(%rip), %rsi      # 0x151fd
leaq 0xd828(%rip), %rcx      # 0x14c88
movl $0x896, %edx            # imm = 0x896
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_segs_free
void
tcp_segs_free(struct tcp_seg *seg)
{
  while (seg != NULL) {
    struct tcp_seg *next = seg->next;
    tcp_seg_free(seg);
    seg = next;
  }
}

// Assembly:
testq %rdi, %rdi
je 0x748f
pushq %rbx
movq (%rdi), %rbx
callq 0x817c
movq %rbx, %rdi
testq %rbx, %rbx
jne 0x747e
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_new_port
static u16_t
tcp_new_port(void)
{
  u8_t i;
  u16_t n = 0;
  struct tcp_pcb *pcb;

again:
  tcp_port++;
  if (tcp_port == TCP_LOCAL_PORT_RANGE_END) {
    tcp_port = TCP_LOCAL_PORT_RANGE_START;
  }
  /* Check all PCB lists. */
  for (i = 0; i < NUM_TCP_PCB_LISTS; i++) {
    for (pcb = *tcp_pcb_lists[i]; pcb != NULL; pcb = pcb->next) {
      if (pcb->local_port == tcp_port) {
        n++;
        if (n > (TCP_LOCAL_PORT_RANGE_END - TCP_LOCAL_PORT_RANGE_START)) {
          return 0;
        }
        goto again;
      }
    }
  }
  return tcp_port;
}

// Assembly:
movzwl 0x149f0(%rip), %ecx     # 0x1c148
xorl %eax, %eax
movl $0xc000, %edx           # imm = 0xC000
leaq 0x145fa(%rip), %rsi     # 0x1bd60
incl %ecx
cmpw $-0x1, %cx
cmovel %edx, %ecx
xorl %edi, %edi
movq (%rsi,%rdi,8), %r8
movq (%r8), %r8
testq %r8, %r8
je 0x778a
cmpw %cx, 0x4e(%r8)
je 0x7795
movq 0x38(%r8), %r8
jmp 0x7778
incq %rdi
cmpq $0x4, %rdi
jne 0x7771
jmp 0x77a6
incl %eax
movzwl %ax, %edi
cmpl $0x4000, %edi           # imm = 0x4000
jne 0x7766
xorl %eax, %eax
jmp 0x77a8
movl %ecx, %eax
movw %cx, 0x14999(%rip)      # 0x1c148
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_accept_null
static err_t
tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err)
{
  LWIP_UNUSED_ARG(arg);
  LWIP_UNUSED_ARG(err);

  LWIP_ASSERT("tcp_accept_null: invalid pcb", pcb != NULL);

  tcp_abort(pcb);

  return ERR_ABRT;
}

// Assembly:
pushq %rax
testq %rsi, %rsi
je 0x796e
movq %rsi, %rdi
movl $0x1, %esi
callq 0x7153
movb $-0xd, %al
popq %rcx
retq
leaq 0xc957(%rip), %rdi      # 0x142cc
leaq 0xd9b9(%rip), %rsi      # 0x15335
leaq 0xd305(%rip), %rcx      # 0x14c88
movl $0x30f, %edx            # imm = 0x30F
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_update_rcv_ann_wnd
u32_t
tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb)
{
  u32_t new_right_edge;

  LWIP_ASSERT("tcp_update_rcv_ann_wnd: invalid pcb", pcb != NULL);
  new_right_edge = pcb->rcv_nxt + pcb->rcv_wnd;

  if (TCP_SEQ_GEQ(new_right_edge, pcb->rcv_ann_right_edge + LWIP_MIN((TCP_WND / 2), pcb->mss))) {
    /* we can advertise more window */
    pcb->rcv_ann_wnd = pcb->rcv_wnd;
    return new_right_edge - pcb->rcv_ann_right_edge;
  } else {
    if (TCP_SEQ_GT(pcb->rcv_nxt, pcb->rcv_ann_right_edge)) {
      /* Can happen due to other end sending out of advertised window,
       * but within actual available (but not yet advertised) window */
      pcb->rcv_ann_wnd = 0;
    } else {
      /* keep the right edge of window constant */
      u32_t new_rcv_ann_wnd = pcb->rcv_ann_right_edge - pcb->rcv_nxt;
#if !LWIP_WND_SCALE
      LWIP_ASSERT("new_rcv_ann_wnd <= 0xffff", new_rcv_ann_wnd <= 0xffff);
#endif
      pcb->rcv_ann_wnd = (tcpwnd_size_t)new_rcv_ann_wnd;
    }
    return 0;
  }
}

// Assembly:
pushq %rax
testq %rdi, %rdi
je 0x79f2
movl 0x5c(%rdi), %edx
movl 0x64(%rdi), %ecx
movzwl 0x60(%rdi), %esi
leal (%rdx,%rsi), %eax
movzwl 0x6a(%rdi), %r8d
movl $0x4000, %r9d           # imm = 0x4000
cmpl %r9d, %r8d
cmovbl %r8d, %r9d
addl %ecx, %r9d
cmpl %r9d, %eax
js 0x79d0
movw %si, 0x62(%rdi)
subl %ecx, %eax
jmp 0x79f0
movl %edx, %eax
subl %ecx, %eax
testl %eax, %eax
jle 0x79e0
movw $0x0, 0x62(%rdi)
jmp 0x79ee
subl %edx, %ecx
cmpl $0x10000, %ecx          # imm = 0x10000
jae 0x7a1f
movw %cx, 0x62(%rdi)
xorl %eax, %eax
popq %rcx
retq
leaq 0xc8d3(%rip), %rdi      # 0x142cc
leaq 0xd3bf(%rip), %rsi      # 0x14dbf
leaq 0xd281(%rip), %rcx      # 0x14c88
movl $0x3a6, %edx            # imm = 0x3A6
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
leaq 0xc8a6(%rip), %rdi      # 0x142cc
leaq 0xd3b6(%rip), %rsi      # 0x14de3
leaq 0xd254(%rip), %rcx      # 0x14c88
movl $0x3b6, %edx            # imm = 0x3B6
jmp 0x7a0c
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_recved
void
tcp_recved(struct tcp_pcb *pcb, u16_t len)
{
  u32_t wnd_inflation;
  tcpwnd_size_t rcv_wnd;

  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ERROR("tcp_recved: invalid pcb", pcb != NULL, return);

  /* pcb->state LISTEN not allowed here */
  LWIP_ASSERT("don't call tcp_recved for listen-pcbs",
              pcb->state != LISTEN);

  rcv_wnd = (tcpwnd_size_t)(pcb->rcv_wnd + len);
  if ((rcv_wnd > TCP_WND_MAX(pcb)) || (rcv_wnd < pcb->rcv_wnd)) {
    /* window got too big or tcpwnd_size_t overflow */
    LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: window got too big or tcpwnd_size_t overflow\n"));
    pcb->rcv_wnd = TCP_WND_MAX(pcb);
  } else  {
    pcb->rcv_wnd = rcv_wnd;
  }

  wnd_inflation = tcp_update_rcv_ann_wnd(pcb);

  /* If the change in the right edge of window is significant (default
   * watermark is TCP_WND/4), then send an explicit update now.
   * Otherwise wait for a packet to be sent in the normal course of
   * events (or more window to be available later) */
  if (wnd_inflation >= TCP_WND_UPDATE_THRESHOLD) {
    tcp_ack_now(pcb);
    tcp_output(pcb);
  }

  LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: received %"U16_F" bytes, wnd %"TCPWNDSIZE_F" (%"TCPWNDSIZE_F").\n",
                          len, pcb->rcv_wnd, (u16_t)(TCP_WND_MAX(pcb) - pcb->rcv_wnd)));
}

// Assembly:
pushq %rbx
testq %rdi, %rdi
je 0x7a86
movq %rdi, %rbx
cmpl $0x1, 0x48(%rdi)
je 0x7aa2
movzwl 0x60(%rbx), %eax
leal (%rsi,%rax), %ecx
movzwl %cx, %edx
movl $0x8000, %edi           # imm = 0x8000
cmpl %edi, %edx
cmovael %edi, %ecx
addw %ax, %si
cmovbl %edi, %ecx
movw %cx, 0x60(%rbx)
movq %rbx, %rdi
callq 0x799b
cmpl $0x16d0, %eax           # imm = 0x16D0
jb 0x7a84
orb $0x2, 0x52(%rbx)
movq %rbx, %rdi
popq %rbx
jmp 0xbd02
popq %rbx
retq
leaq 0xc83f(%rip), %rdi      # 0x142cc
leaq 0xd369(%rip), %rsi      # 0x14dfd
leaq 0xd1ed(%rip), %rcx      # 0x14c88
movl $0x3cf, %edx            # imm = 0x3CF
jmp 0x7abc
leaq 0xc823(%rip), %rdi      # 0x142cc
leaq 0xd365(%rip), %rsi      # 0x14e15
leaq 0xd1d1(%rip), %rcx      # 0x14c88
movl $0x3d3, %edx            # imm = 0x3D3
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_next_iss
u32_t
tcp_next_iss(struct tcp_pcb *pcb)
{
#ifdef LWIP_HOOK_TCP_ISN
  LWIP_ASSERT("tcp_next_iss: invalid pcb", pcb != NULL);
  return LWIP_HOOK_TCP_ISN(&pcb->local_ip, pcb->local_port, &pcb->remote_ip, pcb->remote_port);
#else /* LWIP_HOOK_TCP_ISN */
  static u32_t iss = 6510;

  LWIP_ASSERT("tcp_next_iss: invalid pcb", pcb != NULL);
  LWIP_UNUSED_ARG(pcb);

  iss += tcp_ticks;       /* XXX */
  return iss;
#endif /* LWIP_HOOK_TCP_ISN */
}

// Assembly:
testq %rdi, %rdi
je 0x7dc0
movl 0x14399(%rip), %eax     # 0x1c14c
addl 0x14b63(%rip), %eax     # 0x1c91c
movl %eax, 0x1438d(%rip)     # 0x1c14c
retq
pushq %rax
leaq 0xc504(%rip), %rdi      # 0x142cc
leaq 0xd445(%rip), %rsi      # 0x15214
leaq 0xceb2(%rip), %rcx      # 0x14c88
movl $0x8af, %edx            # imm = 0x8AF
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_free_ooseq
void
tcp_free_ooseq(struct tcp_pcb *pcb)
{
  if (pcb->ooseq) {
    tcp_segs_free(pcb->ooseq);
    pcb->ooseq = NULL;
#if LWIP_TCP_SACK_OUT
    memset(pcb->rcv_sacks, 0, sizeof(pcb->rcv_sacks));
#endif /* LWIP_TCP_SACK_OUT */
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0xb8(%rdi), %rdi
testq %rdi, %rdi
je 0x7eab
movq (%rdi), %r14
callq 0x817c
movq %r14, %rdi
testq %r14, %r14
jne 0x7e90
movq $0x0, 0xb8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_pcb_purge
void
tcp_pcb_purge(struct tcp_pcb *pcb)
{
  LWIP_ERROR("tcp_pcb_purge: invalid pcb", pcb != NULL, return);

  if (pcb->state != CLOSED &&
      pcb->state != TIME_WAIT &&
      pcb->state != LISTEN) {

    LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge\n"));

    tcp_backlog_accepted(pcb);

    if (pcb->refused_data != NULL) {
      LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->refused_data\n"));
      pbuf_free(pcb->refused_data);
      pcb->refused_data = NULL;
    }
    if (pcb->unsent != NULL) {
      LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: not all data sent\n"));
    }
    if (pcb->unacked != NULL) {
      LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->unacked\n"));
    }
#if TCP_QUEUE_OOSEQ
    if (pcb->ooseq != NULL) {
      LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->ooseq\n"));
      tcp_free_ooseq(pcb);
    }
#endif /* TCP_QUEUE_OOSEQ */

    /* Stop the retransmission timer as it will expect data on unacked
       queue if it fires */
    pcb->rtime = -1;

    tcp_segs_free(pcb->unsent);
    tcp_segs_free(pcb->unacked);
    pcb->unacked = pcb->unsent = NULL;
#if TCP_OVERSIZE
    pcb->unsent_oversize = 0;
#endif /* TCP_OVERSIZE */
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x7f78
movq %rdi, %rbx
movl 0x48(%rdi), %eax
cmpl $0xa, %eax
ja 0x7eda
movl $0x403, %ecx            # imm = 0x403
btl %eax, %ecx
jb 0x7f72
movq 0xc0(%rbx), %rdi
testq %rdi, %rdi
je 0x7ef6
callq 0x4fdf
movq $0x0, 0xc0(%rbx)
movq 0xb8(%rbx), %rdi
testq %rdi, %rdi
je 0x7f1d
movq (%rdi), %r14
callq 0x817c
movq %r14, %rdi
testq %r14, %r14
jne 0x7f02
movq $0x0, 0xb8(%rbx)
movw $0xffff, 0x68(%rbx)     # imm = 0xFFFF
movq 0xa8(%rbx), %rdi
testq %rdi, %rdi
je 0x7f3f
movq (%rdi), %r14
callq 0x817c
movq %r14, %rdi
testq %r14, %r14
jne 0x7f2f
leaq 0xa8(%rbx), %r14
movq 0xb0(%rbx), %rdi
testq %rdi, %rdi
je 0x7f62
movq (%rdi), %r15
callq 0x817c
movq %r15, %rdi
testq %r15, %r15
jne 0x7f52
movw $0x0, 0xa0(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
popq %rbx
popq %r14
popq %r15
retq
leaq 0xc34d(%rip), %rdi      # 0x142cc
leaq 0xd1ef(%rip), %rsi      # 0x15175
leaq 0xccfb(%rip), %rcx      # 0x14c88
movl $0x851, %edx            # imm = 0x851
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_txnow
void
tcp_txnow(void)
{
  struct tcp_pcb *pcb;

  for (pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
    if (pcb->flags & TF_NAGLEMEMERR) {
      tcp_output(pcb);
    }
  }
}

// Assembly:
pushq %rbx
movq 0x1481a(%rip), %rbx     # 0x1c908
testq %rbx, %rbx
je 0x8107
testb $-0x80, 0x52(%rbx)
je 0x8101
movq %rbx, %rdi
callq 0xbd02
movq 0x38(%rbx), %rbx
jmp 0x80ee
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_recv_null
err_t
tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
  LWIP_UNUSED_ARG(arg);

  LWIP_ERROR("tcp_recv_null: invalid pcb", pcb != NULL, return ERR_ARG);

  if (p != NULL) {
    tcp_recved(pcb, p->tot_len);
    pbuf_free(p);
  } else if (err == ERR_OK) {
    return tcp_close(pcb);
  }
  return ERR_OK;
}

// Assembly:
pushq %rbx
testq %rsi, %rsi
je 0x814f
movq %rdx, %rbx
testq %rdx, %rdx
je 0x812f
movzwl 0x10(%rbx), %eax
movq %rsi, %rdi
movl %eax, %esi
callq 0x7a3b
movq %rbx, %rdi
callq 0x4fdf
jmp 0x8133
testb %cl, %cl
je 0x8137
xorl %eax, %eax
popq %rbx
retq
cmpl $0x1, 0x48(%rsi)
je 0x8141
orb $0x10, 0x52(%rsi)
movq %rsi, %rdi
movl $0x1, %esi
popq %rbx
jmp 0x6ebc
leaq 0xc176(%rip), %rdi      # 0x142cc
leaq 0xcf55(%rip), %rsi      # 0x150b2
leaq 0xcb24(%rip), %rcx      # 0x14c88
movl $0x698, %edx            # imm = 0x698
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_seg_free
void
tcp_seg_free(struct tcp_seg *seg)
{
  if (seg != NULL) {
    if (seg->p != NULL) {
      pbuf_free(seg->p);
#if TCP_DEBUG
      seg->p = NULL;
#endif /* TCP_DEBUG */
    }
    memp_free(MEMP_TCP_SEG, seg);
  }
}

// Assembly:
testq %rdi, %rdi
je 0x81a9
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x819b
callq 0x4fdf
movq $0x0, 0x8(%rbx)
movl $0x4, %edi
movq %rbx, %rsi
popq %rbx
jmp 0x3cf8
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_seg_copy
struct tcp_seg *
tcp_seg_copy(struct tcp_seg *seg)
{
  struct tcp_seg *cseg;

  LWIP_ASSERT("tcp_seg_copy: invalid seg", seg != NULL);

  cseg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG);
  if (cseg == NULL) {
    return NULL;
  }
  SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg));
  pbuf_ref(cseg->p);
  return cseg;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x8224
movq %rdi, %r14
movl $0x4, %edi
callq 0x3c6e
movq %rax, %rbx
testq %rax, %rax
je 0x8219
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm0, (%rbx)
movups %xmm1, 0x10(%rbx)
movq 0x8(%rbx), %rdi
callq 0x53ad
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xc0a1(%rip), %rdi      # 0x142cc
leaq 0xce66(%rip), %rsi      # 0x15098
leaq 0xca4f(%rip), %rcx      # 0x14c88
movl $0x682, %edx            # imm = 0x682
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_kill_state
static void
tcp_kill_state(enum tcp_state state)
{
  struct tcp_pcb *pcb, *inactive;
  u32_t inactivity;

  LWIP_ASSERT("invalid state", (state == CLOSING) || (state == LAST_ACK));

  inactivity = 0;
  inactive = NULL;
  /* Go through the list of active pcbs and get the oldest pcb that is in state
     CLOSING/LAST_ACK. */
  for (pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
    if (pcb->state == state) {
      if ((u32_t)(tcp_ticks - pcb->tmr) >= inactivity) {
        inactivity = tcp_ticks - pcb->tmr;
        inactive = pcb;
      }
    }
  }
  if (inactive != NULL) {
    LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_closing: killing oldest %s PCB %p (%"S32_F")\n",
                            tcp_state_str[state], (void *)inactive, inactivity));
    /* Don't send a RST, since no data is lost. */
    tcp_abandon(inactive, 0);
  }
}

// Assembly:
pushq %rax
movl %edi, %eax
andl $-0x2, %eax
cmpl $0x8, %eax
jne 0x8411
movq 0x14538(%rip), %rcx     # 0x1c908
testq %rcx, %rcx
je 0x840f
xorl %edx, %edx
movl 0x1453f(%rip), %esi     # 0x1c91c
xorl %eax, %eax
cmpl %edi, 0x48(%rcx)
jne 0x83f6
movl %esi, %r8d
subl 0x58(%rcx), %r8d
cmpl %edx, %r8d
cmovaeq %rcx, %rax
cmoval %r8d, %edx
movq 0x38(%rcx), %rcx
testq %rcx, %rcx
jne 0x83df
testq %rax, %rax
je 0x840f
movq %rax, %rdi
xorl %esi, %esi
popq %rax
jmp 0x7153
popq %rax
retq
leaq 0xbeb4(%rip), %rdi      # 0x142cc
leaq 0xcf33(%rip), %rsi      # 0x15352
leaq 0xc862(%rip), %rcx      # 0x14c88
movl $0x6dd, %edx            # imm = 0x6DD
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_recv
void
tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv)
{
  LWIP_ASSERT_CORE_LOCKED();
  if (pcb != NULL) {
    LWIP_ASSERT("invalid socket state for recv callback", pcb->state != LISTEN);
    pcb->recv = recv;
  }
}

// Assembly:
testq %rdi, %rdi
je 0x84f0
cmpl $0x1, 0x48(%rdi)
je 0x84f1
movq %rsi, 0xd8(%rdi)
retq
pushq %rax
leaq 0xbdd3(%rip), %rdi      # 0x142cc
leaq 0xcbcd(%rip), %rsi      # 0x150cd
leaq 0xc781(%rip), %rcx      # 0x14c88
movl $0x7df, %edx            # imm = 0x7DF
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_sent
void
tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent)
{
  LWIP_ASSERT_CORE_LOCKED();
  if (pcb != NULL) {
    LWIP_ASSERT("invalid socket state for sent callback", pcb->state != LISTEN);
    pcb->sent = sent;
  }
}

// Assembly:
testq %rdi, %rdi
je 0x8531
cmpl $0x1, 0x48(%rdi)
je 0x8532
movq %rsi, 0xd0(%rdi)
retq
pushq %rax
leaq 0xbd92(%rip), %rdi      # 0x142cc
leaq 0xcbb3(%rip), %rsi      # 0x150f4
leaq 0xc740(%rip), %rcx      # 0x14c88
movl $0x7f3, %edx            # imm = 0x7F3
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_err
void
tcp_err(struct tcp_pcb *pcb, tcp_err_fn err)
{
  LWIP_ASSERT_CORE_LOCKED();
  if (pcb != NULL) {
    LWIP_ASSERT("invalid socket state for err callback", pcb->state != LISTEN);
    pcb->errf = err;
  }
}

// Assembly:
testq %rdi, %rdi
je 0x8572
cmpl $0x1, 0x48(%rdi)
je 0x8573
movq %rsi, 0xf0(%rdi)
retq
pushq %rax
leaq 0xbd51(%rip), %rdi      # 0x142cc
leaq 0xcb99(%rip), %rsi      # 0x1511b
leaq 0xc6ff(%rip), %rcx      # 0x14c88
movl $0x80d, %edx            # imm = 0x80D
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_poll
void
tcp_poll(struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)
{
  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ERROR("tcp_poll: invalid pcb", pcb != NULL, return);
  LWIP_ASSERT("invalid socket state for poll", pcb->state != LISTEN);

#if LWIP_CALLBACK_API
  pcb->poll = poll;
#else /* LWIP_CALLBACK_API */
  LWIP_UNUSED_ARG(poll);
#endif /* LWIP_CALLBACK_API */
  pcb->pollinterval = interval;
}

// Assembly:
pushq %rax
testq %rdi, %rdi
je 0x85c9
cmpl $0x1, 0x48(%rdi)
je 0x85e5
movq %rsi, 0xe8(%rdi)
movb %dl, 0x55(%rdi)
popq %rax
retq
leaq 0xbcfc(%rip), %rdi      # 0x142cc
leaq 0xcb6a(%rip), %rsi      # 0x15141
leaq 0xc6aa(%rip), %rcx      # 0x14c88
movl $0x83d, %edx            # imm = 0x83D
jmp 0x85ff
leaq 0xbce0(%rip), %rdi      # 0x142cc
leaq 0xcb64(%rip), %rsi      # 0x15157
leaq 0xc68e(%rip), %rcx      # 0x14c88
movl $0x83e, %edx            # imm = 0x83E
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_pcbs_sane
s16_t
tcp_pcbs_sane(void)
{
  struct tcp_pcb *pcb;
  for (pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
    LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != CLOSED", pcb->state != CLOSED);
    LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != LISTEN", pcb->state != LISTEN);
    LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT);
  }
  for (pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
    LWIP_ASSERT("tcp_pcbs_sane: tw pcb->state == TIME-WAIT", pcb->state == TIME_WAIT);
  }
  return 1;
}

// Assembly:
pushq %rax
movq 0x142ee(%rip), %rax     # 0x1c908
testq %rax, %rax
je 0x863a
movl 0x48(%rax), %ecx
cmpl $0xa, %ecx
je 0x86ac
cmpl $0x1, %ecx
je 0x8658
testl %ecx, %ecx
je 0x8674
movq 0x38(%rax), %rax
jmp 0x861a
movq 0x142cf(%rip), %rax     # 0x1c910
testq %rax, %rax
je 0x8652
cmpl $0xa, 0x48(%rax)
jne 0x8690
movq 0x38(%rax), %rax
jmp 0x8641
movw $0x1, %ax
popq %rcx
retq
leaq 0xbc6d(%rip), %rdi      # 0x142cc
leaq 0xcc1a(%rip), %rsi      # 0x15280
leaq 0xc61b(%rip), %rcx      # 0x14c88
movl $0x9da, %edx            # imm = 0x9DA
jmp 0x86c6
leaq 0xbc51(%rip), %rdi      # 0x142cc
leaq 0xcbd3(%rip), %rsi      # 0x15255
leaq 0xc5ff(%rip), %rcx      # 0x14c88
movl $0x9d9, %edx            # imm = 0x9D9
jmp 0x86c6
leaq 0xbc35(%rip), %rdi      # 0x142cc
leaq 0xcc3b(%rip), %rsi      # 0x152d9
leaq 0xc5e3(%rip), %rcx      # 0x14c88
movl $0x9de, %edx            # imm = 0x9DE
jmp 0x86c6
leaq 0xbc19(%rip), %rdi      # 0x142cc
leaq 0xcbf1(%rip), %rsi      # 0x152ab
leaq 0xc5c7(%rip), %rcx      # 0x14c88
movl $0x9db, %edx            # imm = 0x9DB
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_netif_ip_addr_changed
void
tcp_netif_ip_addr_changed(const ip_addr_t *old_addr, const ip_addr_t *new_addr)
{
  struct tcp_pcb_listen *lpcb;

  if (!ip_addr_isany(old_addr)) {
    tcp_netif_ip_addr_changed_pcblist(old_addr, tcp_active_pcbs);
    tcp_netif_ip_addr_changed_pcblist(old_addr, tcp_bound_pcbs);

    if (!ip_addr_isany(new_addr)) {
      /* PCB bound to current local interface address? */
      for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
        /* PCB bound to current local interface address? */
        if (ip_addr_cmp(&lpcb->local_ip, old_addr)) {
          /* The PCB is listening to the old ipaddr and
            * is set to listen to the new one instead */
          ip_addr_copy(lpcb->local_ip, *new_addr);
        }
      }
    }
  }
}

// Assembly:
testq %rdi, %rdi
je 0x87fc
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
cmpb $0x6, 0x14(%rdi)
movl (%rdi), %eax
jne 0x8712
testl %eax, %eax
jne 0x871a
cmpl $0x0, 0x4(%r14)
jne 0x871a
cmpl $0x0, 0x8(%r14)
jne 0x871a
cmpl $0x0, 0xc(%r14)
jne 0x871a
jmp 0x87f5
testl %eax, %eax
je 0x87f5
movq 0x141e7(%rip), %rsi     # 0x1c908
movq %r14, %rdi
callq 0x87fd
movq 0x141d0(%rip), %rsi     # 0x1c900
movq %r14, %rdi
callq 0x87fd
testq %rbx, %rbx
je 0x87f5
cmpb $0x6, 0x14(%rbx)
movl (%rbx), %eax
jne 0x8764
testl %eax, %eax
jne 0x876c
cmpl $0x0, 0x4(%rbx)
jne 0x876c
cmpl $0x0, 0x8(%rbx)
jne 0x876c
cmpl $0x0, 0xc(%rbx)
jne 0x876c
jmp 0x87f5
testl %eax, %eax
je 0x87f5
movq 0x14185(%rip), %rax     # 0x1c8f8
testq %rax, %rax
je 0x87f5
xorl %ecx, %ecx
movb 0x14(%rax), %dl
cmpb 0x14(%r14), %dl
jne 0x87ec
movl (%rax), %esi
movl (%r14), %edi
cmpb $0x6, %dl
jne 0x87b7
cmpl %edi, %esi
jne 0x87ec
movl 0x4(%rax), %edx
cmpl 0x4(%r14), %edx
jne 0x87ec
movl 0x8(%rax), %edx
cmpl 0x8(%r14), %edx
jne 0x87ec
movl 0xc(%rax), %edx
cmpl 0xc(%r14), %edx
jne 0x87ec
movb 0x10(%rax), %dl
cmpb 0x10(%r14), %dl
je 0x87bb
jmp 0x87ec
cmpl %edi, %esi
jne 0x87ec
movb 0x14(%rbx), %dl
movb %dl, 0x14(%rax)
movl (%rbx), %esi
movl %esi, (%rax)
cmpb $0x6, %dl
jne 0x87e4
movl 0x4(%rbx), %edx
movl %edx, 0x4(%rax)
movl 0x8(%rbx), %edx
movl %edx, 0x8(%rax)
movl 0xc(%rbx), %edx
movl %edx, 0xc(%rax)
movb 0x10(%rbx), %dl
movb %dl, 0x10(%rax)
jmp 0x87ec
movq %rcx, 0x9(%rax)
movq %rcx, 0x4(%rax)
movq 0x38(%rax), %rax
testq %rax, %rax
jne 0x877a
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_netif_ip_addr_changed_pcblist
static void
tcp_netif_ip_addr_changed_pcblist(const ip_addr_t *old_addr, struct tcp_pcb *pcb_list)
{
  struct tcp_pcb *pcb;
  pcb = pcb_list;

  LWIP_ASSERT("tcp_netif_ip_addr_changed_pcblist: invalid old_addr", old_addr != NULL);

  while (pcb != NULL) {
    /* PCB bound to current local interface address? */
    if (ip_addr_cmp(&pcb->local_ip, old_addr)
#if LWIP_AUTOIP
        /* connections to link-local addresses must persist (RFC3927 ch. 1.9) */
        && (!IP_IS_V4_VAL(pcb->local_ip) || !ip4_addr_islinklocal(ip_2_ip4(&pcb->local_ip)))
#endif /* LWIP_AUTOIP */
       ) {
      /* this connection must be aborted */
      struct tcp_pcb *next = pcb->next;
      LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: aborting TCP pcb %p\n", (void *)pcb));
      tcp_abort(pcb);
      pcb = next;
    } else {
      pcb = pcb->next;
    }
  }
}

// Assembly:
testq %rsi, %rsi
je 0x8869
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb 0x14(%rsi), %al
cmpb 0x14(%rbx), %al
jne 0x883d
movl (%rsi), %ecx
movl (%rbx), %edx
cmpb $0x6, %al
jne 0x8848
cmpl %edx, %ecx
jne 0x883d
movl 0x4(%rsi), %eax
cmpl 0x4(%rbx), %eax
jne 0x883d
movl 0x8(%rsi), %eax
cmpl 0x8(%rbx), %eax
jne 0x883d
movl 0xc(%rsi), %eax
cmpl 0xc(%rbx), %eax
jne 0x883d
movb 0x10(%rsi), %al
cmpb 0x10(%rbx), %al
je 0x884c
movq 0x38(%rsi), %rsi
testq %rsi, %rsi
jne 0x8809
jmp 0x8862
cmpl %edx, %ecx
jne 0x883d
movq 0x38(%rsi), %r14
movq %rsi, %rdi
movl $0x1, %esi
callq 0x7153
movq %r14, %rsi
jmp 0x8841
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp.c
// Function: tcp_tcp_get_tcp_addrinfo
err_t
tcp_tcp_get_tcp_addrinfo(struct tcp_pcb *pcb, int local, ip_addr_t *addr, u16_t *port)
{
  if (pcb) {
    if (local) {
      if (addr) {
        *addr = pcb->local_ip;
      }
      if (port) {
        *port = pcb->local_port;
      }
    } else {
      if (addr) {
        *addr = pcb->remote_ip;
      }
      if (port) {
        *port = pcb->remote_port;
      }
    }
    return ERR_OK;
  }
  return ERR_VAL;
}

// Assembly:
testq %rdi, %rdi
je 0x889e
testl %esi, %esi
je 0x88a1
testq %rdx, %rdx
je 0x8897
movq 0x10(%rdi), %rax
movq %rax, 0x10(%rdx)
movups (%rdi), %xmm0
movups %xmm0, (%rdx)
movl $0x4e, %eax
jmp 0x88ba
movb $-0x6, %al
retq
testq %rdx, %rdx
je 0x88b5
movq 0x28(%rdi), %rax
movq %rax, 0x10(%rdx)
movups 0x18(%rdi), %xmm0
movups %xmm0, (%rdx)
movl $0x50, %eax
testq %rcx, %rcx
je 0x88c6
movzwl (%rdi,%rax), %eax
movw %ax, (%rcx)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp_in.c
// Function: tcp_timewait_input
static void
tcp_timewait_input(struct tcp_pcb *pcb)
{
  /* RFC 1337: in TIME_WAIT, ignore RST and ACK FINs + any 'acceptable' segments */
  /* RFC 793 3.9 Event Processing - Segment Arrives:
   * - first check sequence number - we skip that one in TIME_WAIT (always
   *   acceptable since we only send ACKs)
   * - second check the RST bit (... return) */
  if (flags & TCP_RST) {
    return;
  }

  LWIP_ASSERT("tcp_timewait_input: invalid pcb", pcb != NULL);

  /* - fourth, check the SYN bit, */
  if (flags & TCP_SYN) {
    /* If an incoming segment is not acceptable, an acknowledgment
       should be sent in reply */
    if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd)) {
      /* If the SYN is in the window it is an error, send a reset */
      tcp_rst(pcb, ackno, seqno + tcplen, ip_current_dest_addr(),
              ip_current_src_addr(), tcphdr->dest, tcphdr->src);
      return;
    }
  } else if (flags & TCP_FIN) {
    /* - eighth, check the FIN bit: Remain in the TIME-WAIT state.
         Restart the 2 MSL time-wait timeout.*/
    pcb->tmr = tcp_ticks;
  }

  if ((tcplen > 0)) {
    /* Acknowledge data, FIN or out-of-window SYN */
    tcp_ack_now(pcb);
    tcp_output(pcb);
  }
  return;
}

// Assembly:
movzbl 0x13703(%rip), %eax     # 0x1c94c
testb $0x4, %al
jne 0x9291
testb $0x2, %al
jne 0x9263
testb $0x1, %al
je 0x927e
leaq 0x136c0(%rip), %rax     # 0x1c91c
movl (%rax), %eax
movl %eax, 0x58(%rdi)
jmp 0x927e
movl 0x136db(%rip), %edx     # 0x1c944
movl 0x5c(%rdi), %eax
cmpl %eax, %edx
js 0x927e
movzwl 0x60(%rdi), %ecx
addl %ecx, %eax
movl %edx, %ecx
subl %eax, %ecx
testl %ecx, %ecx
jle 0x9292
cmpw $0x0, 0x136c8(%rip)     # 0x1c94e
je 0x9291
orb $0x2, 0x52(%rdi)
jmp 0xbd02
retq
pushq %rax
movl 0x136af(%rip), %esi     # 0x1c948
movzwl 0x136ae(%rip), %eax     # 0x1c94e
addl %eax, %edx
movq 0x1367f(%rip), %rax     # 0x1c928
movzwl 0x2(%rax), %r9d
movzwl (%rax), %eax
movl %eax, (%rsp)
leaq 0x134b5(%rip), %r8      # 0x1c770
leaq 0x3c(%r8), %rcx
addq $0x24, %r8
callq 0xc757
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp_in.c
// Function: tcp_input_delayed_close
static int
tcp_input_delayed_close(struct tcp_pcb *pcb)
{
  LWIP_ASSERT("tcp_input_delayed_close: invalid pcb", pcb != NULL);

  if (recv_flags & TF_CLOSED) {
    /* The connection has been closed and we will deallocate the
        PCB. */
    if (!(pcb->flags & TF_RXCLOSED)) {
      /* Connection closed although the application has only shut down the
          tx side: call the PCB's err callback and indicate the closure to
          ensure the application doesn't continue using the PCB. */
      TCP_EVENT_ERR(pcb->state, pcb->errf, pcb->callback_arg, ERR_CLSD);
    }
    tcp_pcb_remove(&tcp_active_pcbs, pcb);
    tcp_free(pcb);
    return 1;
  }
  return 0;
}

// Assembly:
xorl %eax, %eax
testb $0x10, 0x12e5e(%rip)    # 0x1c978
je 0x9b5a
pushq %rbx
movq %rdi, %rbx
testb $0x10, 0x52(%rdi)
jne 0x9b3d
movq 0xf0(%rbx), %rax
testq %rax, %rax
je 0x9b3d
movq 0x40(%rbx), %rdi
movl $0xfffffff1, %esi       # imm = 0xFFFFFFF1
callq *%rax
leaq 0x12dc4(%rip), %rdi     # 0x1c908
movq %rbx, %rsi
callq 0x732d
movq %rbx, %rdi
callq 0x6780
movl $0x1, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp_in.c
// Function: tcp_free_acked_segments
static struct tcp_seg *
tcp_free_acked_segments(struct tcp_pcb *pcb, struct tcp_seg *seg_list, const char *dbg_list_name,
                        struct tcp_seg *dbg_other_seg_list)
{
  struct tcp_seg *next;
  u16_t clen;

  LWIP_UNUSED_ARG(dbg_list_name);
  LWIP_UNUSED_ARG(dbg_other_seg_list);

  while (seg_list != NULL &&
         TCP_SEQ_LEQ(lwip_ntohl(seg_list->tcphdr->seqno) +
                     TCP_TCPLEN(seg_list), ackno)) {
    LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->%s\n",
                                  lwip_ntohl(seg_list->tcphdr->seqno),
                                  lwip_ntohl(seg_list->tcphdr->seqno) + TCP_TCPLEN(seg_list),
                                  dbg_list_name));

    next = seg_list;
    seg_list = seg_list->next;

    clen = pbuf_clen(next->p);
    LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"TCPWNDSIZE_F" ... ",
                                 (tcpwnd_size_t)pcb->snd_queuelen));
    LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= clen));

    pcb->snd_queuelen = (u16_t)(pcb->snd_queuelen - clen);
    recv_acked = (tcpwnd_size_t)(recv_acked + next->len);
    tcp_seg_free(next);

    LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%"TCPWNDSIZE_F" (after freeing %s)\n",
                                 (tcpwnd_size_t)pcb->snd_queuelen,
                                 dbg_list_name));
    if (pcb->snd_queuelen != 0) {
      LWIP_ASSERT("tcp_receive: valid queue length",
                  seg_list != NULL || dbg_other_seg_list != NULL);
    }
  }
  return seg_list;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rsi, %rsi
je 0xa98d
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq %r12, %r15
movq 0x18(%r12), %rax
movl 0x4(%rax), %edi
callq 0x135bb
movl %eax, %ebp
movzwl 0x10(%r12), %r12d
movq 0x18(%r15), %rax
movzwl 0xc(%rax), %edi
callq 0x135b4
andl $0x3, %eax
addl %ebp, %r12d
subl 0x1201d(%rip), %r12d    # 0x1c948
cmpw $0x1, %ax
sbbl $-0x1, %r12d
testl %r12d, %r12d
jg 0xa990
movq (%r15), %r12
movq 0x8(%r15), %rdi
callq 0x539e
movzwl 0x9e(%r14), %ecx
cmpw %ax, %cx
jb 0xa9b8
subl %eax, %ecx
movw %cx, 0x9e(%r14)
movzwl 0x10(%r15), %eax
addw %ax, 0x12013(%rip)      # 0x1c97a
movq %r15, %rdi
callq 0x817c
cmpw $0x0, 0x9e(%r14)
je 0xa984
testq %rbx, %rbx
jne 0xa984
testq %r12, %r12
je 0xa99c
testq %r12, %r12
jne 0xa8f9
xorl %r15d, %r15d
movq %r15, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9929(%rip), %rdi      # 0x142cc
leaq 0xad9e(%rip), %rsi      # 0x15748
leaq 0xaa83(%rip), %rcx      # 0x15434
movl $0x472, %edx            # imm = 0x472
jmp 0xa9d2
leaq 0x990d(%rip), %rdi      # 0x142cc
leaq 0xad5a(%rip), %rsi      # 0x15720
leaq 0xaa67(%rip), %rcx      # 0x15434
movl $0x467, %edx            # imm = 0x467
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp_in.c
// Function: tcp_oos_insert_segment
static void
tcp_oos_insert_segment(struct tcp_seg *cseg, struct tcp_seg *next)
{
  struct tcp_seg *old_seg;

  LWIP_ASSERT("tcp_oos_insert_segment: invalid cseg", cseg != NULL);

  if (TCPH_FLAGS(cseg->tcphdr) & TCP_FIN) {
    /* received segment overlaps all following segments */
    tcp_segs_free(next);
    next = NULL;
  } else {
    /* delete some following segments
       oos queue may have segments with FIN flag */
    while (next &&
           TCP_SEQ_GEQ((seqno + cseg->len),
                       (next->tcphdr->seqno + next->len))) {
      /* cseg with FIN already processed */
      if (TCPH_FLAGS(next->tcphdr) & TCP_FIN) {
        TCPH_SET_FLAG(cseg->tcphdr, TCP_FIN);
      }
      old_seg = next;
      next = next->next;
      tcp_seg_free(old_seg);
    }
    if (next &&
        TCP_SEQ_GT(seqno + cseg->len, next->tcphdr->seqno)) {
      /* We need to trim the incoming segment. */
      cseg->len = (u16_t)(next->tcphdr->seqno - seqno);
      pbuf_realloc(cseg->p, cseg->len);
    }
  }
  cseg->next = next;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x18(%rdi), %rax
movzwl 0xc(%rax), %edi
callq 0x135b4
testb $0x1, %al
jne 0xaa65
testq %r14, %r14
je 0xaa6d
movl 0x11f36(%rip), %eax     # 0x1c944
movzwl 0x10(%rbx), %edx
addl %eax, %edx
movq 0x18(%r14), %rsi
movl 0x4(%rsi), %ecx
movzwl 0x10(%r14), %edi
addl %ecx, %edi
cmpl %edi, %edx
js 0xaa7e
movzwl 0xc(%rsi), %edi
callq 0x135b4
testb $0x1, %al
je 0xaa50
movq 0x18(%rbx), %rax
movzwl 0xc(%rax), %ebp
movl $0x1, %edi
callq 0x135b4
orw %bp, %ax
movq 0x18(%rbx), %rcx
movw %ax, 0xc(%rcx)
movq (%r14), %r15
movq %r14, %rdi
callq 0x817c
movq %r15, %r14
testq %r15, %r15
jne 0xaa08
jmp 0xaa6d
movq %r14, %rdi
callq 0x7478
xorl %r14d, %r14d
movq %r14, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
subl %ecx, %edx
testl %edx, %edx
jle 0xaa70
subl %eax, %ecx
movw %cx, 0x10(%rbx)
movq 0x8(%rbx), %rdi
movzwl %cx, %esi
callq 0x511b
jmp 0xaa70
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp_out.c
// Function: tcp_pbuf_prealloc
static struct pbuf *
tcp_pbuf_prealloc(pbuf_layer layer, u16_t length, u16_t max_length,
                  u16_t *oversize, const struct tcp_pcb *pcb, u8_t apiflags,
                  u8_t first_seg)
{
  struct pbuf *p;
  u16_t alloc = length;

  LWIP_ASSERT("tcp_pbuf_prealloc: invalid oversize", oversize != NULL);
  LWIP_ASSERT("tcp_pbuf_prealloc: invalid pcb", pcb != NULL);

#if LWIP_NETIF_TX_SINGLE_PBUF
  LWIP_UNUSED_ARG(max_length);
  LWIP_UNUSED_ARG(pcb);
  LWIP_UNUSED_ARG(apiflags);
  LWIP_UNUSED_ARG(first_seg);
  alloc = max_length;
#else /* LWIP_NETIF_TX_SINGLE_PBUF */
  if (length < max_length) {
    /* Should we allocate an oversized pbuf, or just the minimum
     * length required? If tcp_write is going to be called again
     * before this segment is transmitted, we want the oversized
     * buffer. If the segment will be transmitted immediately, we can
     * save memory by allocating only length. We use a simple
     * heuristic based on the following information:
     *
     * Did the user set TCP_WRITE_FLAG_MORE?
     *
     * Will the Nagle algorithm defer transmission of this segment?
     */
    if ((apiflags & TCP_WRITE_FLAG_MORE) ||
        (!(pcb->flags & TF_NODELAY) &&
         (!first_seg ||
          pcb->unsent != NULL ||
          pcb->unacked != NULL))) {
      alloc = LWIP_MIN(max_length, LWIP_MEM_ALIGN_SIZE(TCP_OVERSIZE_CALC_LENGTH(length)));
    }
  }
#endif /* LWIP_NETIF_TX_SINGLE_PBUF */
  p = pbuf_alloc(layer, alloc, PBUF_RAM);
  if (p == NULL) {
    return NULL;
  }
  LWIP_ASSERT("need unchained pbuf", p->next == NULL);
  *oversize = p->len - length;
  /* trim p->len to the currently used size */
  p->len = p->tot_len = length;
  return p;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
testq %rcx, %rcx
je 0xb5c7
movq %rcx, %rbx
movl %esi, %ebp
movl %ebp, %eax
cmpw %dx, %bp
jae 0xb597
testb $0x2, %r9b
jne 0xb585
testb $0x40, 0x52(%r8)
movl %ebp, %eax
jne 0xb597
cmpb $0x0, 0x20(%rsp)
je 0xb585
cmpq $0x0, 0xa8(%r8)
jne 0xb585
cmpq $0x0, 0xb0(%r8)
movl %ebp, %eax
je 0xb597
movzwl %bp, %eax
movzwl %dx, %ecx
addl $0x5b4, %eax            # imm = 0x5B4
cmpl %ecx, %eax
cmovbel %eax, %edx
movl %edx, %eax
movzwl %ax, %esi
movl $0x280, %edx            # imm = 0x280
callq 0x4df7
testq %rax, %rax
je 0xb5c0
cmpq $0x0, (%rax)
jne 0xb5e3
movzwl 0x12(%rax), %ecx
subl %ebp, %ecx
movw %cx, (%rbx)
movw %bp, 0x10(%rax)
movw %bp, 0x12(%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x8cfe(%rip), %rdi      # 0x142cc
leaq 0xa770(%rip), %rsi      # 0x15d45
leaq 0xa1a3(%rip), %rcx      # 0x1577f
movl $0xe8, %edx
jmp 0xb5fd
leaq 0x8ce2(%rip), %rdi      # 0x142cc
leaq 0xa778(%rip), %rsi      # 0x15d69
leaq 0xa187(%rip), %rcx      # 0x1577f
movl $0x10b, %edx            # imm = 0x10B
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp_out.c
// Function: tcp_send_fin
err_t
tcp_send_fin(struct tcp_pcb *pcb)
{
  LWIP_ASSERT("tcp_send_fin: invalid pcb", pcb != NULL);

  /* first, try to add the fin to the last unsent segment */
  if (pcb->unsent != NULL) {
    struct tcp_seg *last_unsent;
    for (last_unsent = pcb->unsent; last_unsent->next != NULL;
         last_unsent = last_unsent->next);

    if ((TCPH_FLAGS(last_unsent->tcphdr) & (TCP_SYN | TCP_FIN | TCP_RST)) == 0) {
      /* no SYN/FIN/RST flag in the header, we can add the FIN flag */
      TCPH_SET_FLAG(last_unsent->tcphdr, TCP_FIN);
      tcp_set_flags(pcb, TF_FIN);
      return ERR_OK;
    }
  }
  /* no data, no length, flags, copy=1, no optdata */
  return tcp_enqueue_flags(pcb, TCP_FIN);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0xbb4b
movq %rdi, %rbx
movq 0xa8(%rdi), %rax
testq %rax, %rax
je 0xbb12
movq %rax, %r14
movq (%rax), %rax
testq %rax, %rax
jne 0xbaf6
movq 0x18(%r14), %rax
movzwl 0xc(%rax), %edi
callq 0x135b4
testb $0x7, %al
je 0xbb23
movq %rbx, %rdi
movl $0x1, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0xbb78
movq 0x18(%r14), %rax
movzwl 0xc(%rax), %ebp
movl $0x1, %edi
callq 0x135b4
orw %bp, %ax
movq 0x18(%r14), %rcx
movw %ax, 0xc(%rcx)
orb $0x20, 0x52(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x877a(%rip), %rdi      # 0x142cc
leaq 0x9ee7(%rip), %rsi      # 0x15a40
leaq 0x9c1f(%rip), %rcx      # 0x1577f
movl $0x3eb, %edx            # imm = 0x3EB
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xc4ca
movq %rdi, %rbx
movq 0xb0(%rdi), %rcx
movb $-0x6, %al
testq %rcx, %rcx
je 0xc4bf
movq %rcx, %r14
movq (%r14), %rdx
movq 0x8(%r14), %rsi
movb 0x16(%rsi), %sil
testq %rdx, %rdx
je 0xc44a
movq %rdx, %r14
cmpb $0x1, %sil
je 0xc42f
jmp 0xc4bf
cmpb $0x1, %sil
jne 0xc4bf
movq 0xa8(%rbx), %rax
movq %rax, (%r14)
testq %rax, %rax
jne 0xc46b
movzwl 0x12(%r14), %eax
movw %ax, 0xa0(%rbx)
movq %rcx, 0xa8(%rbx)
movq $0x0, 0xb0(%rbx)
orb $0x8, 0x53(%rbx)
movq 0x18(%r14), %rax
movl 0x4(%rax), %edi
callq 0x135bb
movl %eax, %ebp
movzwl 0x10(%r14), %r15d
movq 0x18(%r14), %rax
movzwl 0xc(%rax), %edi
callq 0x135b4
andl $0x3, %eax
addl %ebp, %r15d
cmpw $0x1, %ax
sbbl $-0x1, %r15d
movl %r15d, 0x84(%rbx)
movl $0x0, 0x6c(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7dfb(%rip), %rdi      # 0x142cc
leaq 0x96d6(%rip), %rsi      # 0x15bae
leaq 0x92a0(%rip), %rcx      # 0x1577f
movl $0x663, %edx            # imm = 0x663
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp_out.c
// Function: tcp_rexmit_rto_commit
void
tcp_rexmit_rto_commit(struct tcp_pcb *pcb)
{
  LWIP_ASSERT("tcp_rexmit_rto_commit: invalid pcb", pcb != NULL);

  /* increment number of retransmissions */
  if (pcb->nrtx < 0xFF) {
    ++pcb->nrtx;
  }
  /* Do the actual retransmission */
  tcp_output(pcb);
}

// Assembly:
testq %rdi, %rdi
je 0xc552
movb 0x7a(%rdi), %al
cmpb $-0x1, %al
je 0xbd02
incb %al
movb %al, 0x7a(%rdi)
jmp 0xbd02
pushq %rax
leaq 0x7d72(%rip), %rdi      # 0x142cc
leaq 0x9671(%rip), %rsi      # 0x15bd2
leaq 0x9217(%rip), %rcx      # 0x1577f
movl $0x698, %edx            # imm = 0x698
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050