// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/tcp.c
// Function: tun_tcp_recv
static err_t tun_tcp_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
                          err_t err) {
  ELOG(__FUNCTION__);

  ASSERT(err == ERR_OK);

  tun_data_t *data;
  int n;

  data = (tun_data_t *)arg;

  /* closed, peer will send no data */
  if (!p) {
    ELOG("client closed");

    if (data->server_status == TUN_CLOSE) {
      tun_tcp_close(data);
      return ERR_OK;
    } else {
      data->client_status = TUN_CLOSE;
    }
  }
  /* save pbuf to data->client_buf */
  else {
    if ((p->tot_len + data->client_buf_len) > TUN_TCP_SIZE) {
      ELOG("out of TUN_TCP_SIZE");
      tun_tcp_close(data);
      return ERR_OK;
    }

    n = pbuf_copy_partial(p, data->client_buf + data->client_buf_len,
                          p->tot_len, 0);
    if (n != p->tot_len) {
      ELOG("pbuf_copy_partial()");
      tun_tcp_close(data);
      return ERR_OK;
    }
    data->client_buf_len += n;
    pbuf_free(p);
  }

  /* can't do anything if server is TUN_CONNECTING */
  if (data->server_status == TUN_CONNECTED ||
      data->server_status == TUN_CLOSE) {
    lwip_to_epoll(data);
  }

  return ERR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %cl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movb %al, -0x21(%rbp)
movq 0x2b8a8(%rip), %rax     # 0x2eff8
movq (%rax), %rdi
leaq 0x23910(%rip), %rsi     # 0x2706a
leaq 0x2461e(%rip), %rdx     # 0x27d7f
movl $0x55, %ecx
leaq 0x239ec(%rip), %r8      # 0x27159
movb $0x0, %al
callq 0x2170
jmp 0x3776
movsbl -0x21(%rbp), %eax
cmpl $0x0, %eax
je 0x37bf
movq 0x2b872(%rip), %rax     # 0x2eff8
movq (%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x2050
movl (%rax), %edi
callq 0x2220
movq -0x40(%rbp), %rdi
movq %rax, %r8
leaq 0x2385d(%rip), %rsi     # 0x27004
leaq 0x245d1(%rip), %rdx     # 0x27d7f
movl $0x57, %ecx
movb $0x0, %al
callq 0x2170
callq 0x2040
jmp 0x37c1
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x3829
jmp 0x37d2
movq 0x2b81f(%rip), %rax     # 0x2eff8
movq (%rax), %rdi
leaq 0x23887(%rip), %rsi     # 0x2706a
leaq 0x24595(%rip), %rdx     # 0x27d7f
movl $0x60, %ecx
leaq 0x23970(%rip), %r8      # 0x27166
movb $0x0, %al
callq 0x2170
movq -0x30(%rbp), %rax
cmpl $0x2, 0x14(%rax)
jne 0x3819
movq -0x30(%rbp), %rdi
callq 0x3610
movb $0x0, -0x1(%rbp)
jmp 0x392c
movq -0x30(%rbp), %rax
movl $0x2, 0x10(%rax)
jmp 0x390b
movq -0x20(%rbp), %rax
movzwl 0x10(%rax), %eax
movq -0x30(%rbp), %rcx
addl 0x28(%rcx), %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
jle 0x387e
jmp 0x3841
movq 0x2b7b0(%rip), %rax     # 0x2eff8
movq (%rax), %rdi
leaq 0x23818(%rip), %rsi     # 0x2706a
leaq 0x24526(%rip), %rdx     # 0x27d7f
movl $0x6c, %ecx
leaq 0x2390f(%rip), %r8      # 0x27174
movb $0x0, %al
callq 0x2170
movq -0x30(%rbp), %rdi
callq 0x3610
movb $0x0, -0x1(%rbp)
jmp 0x392c
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x30(%rbp), %rax
movslq 0x28(%rax), %rax
addq %rax, %rsi
movq -0x20(%rbp), %rax
xorl %ecx, %ecx
movzwl 0x10(%rax), %edx
callq 0x8250
movzwl %ax, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
movzwl 0x10(%rcx), %ecx
cmpl %ecx, %eax
je 0x38f5
jmp 0x38bb
movq 0x2b736(%rip), %rax     # 0x2eff8
movq (%rax), %rdi
leaq 0x2379e(%rip), %rsi     # 0x2706a
leaq 0x244ac(%rip), %rdx     # 0x27d7f
movl $0x74, %ecx
leaq 0x238a9(%rip), %r8      # 0x27188
movb $0x0, %al
callq 0x2170
movq -0x30(%rbp), %rdi
callq 0x3610
movb $0x0, -0x1(%rbp)
jmp 0x392c
movl -0x34(%rbp), %ecx
movq -0x30(%rbp), %rax
addl 0x28(%rax), %ecx
movl %ecx, 0x28(%rax)
movq -0x20(%rbp), %rdi
callq 0x7260
movq -0x30(%rbp), %rax
cmpl $0x1, 0x14(%rax)
je 0x391f
movq -0x30(%rbp), %rax
cmpl $0x2, 0x14(%rax)
jne 0x3928
movq -0x30(%rbp), %rdi
callq 0x3c50
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)