// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/tcp_out.c
// Function: tcp_write_checks
static err_t
tcp_write_checks(struct tcp_pcb *pcb, u16_t len)
{
  LWIP_ASSERT("tcp_write_checks: invalid pcb", pcb != NULL);

  /* connection is in invalid state for data transmission? */
  if ((pcb->state != ESTABLISHED) &&
      (pcb->state != CLOSE_WAIT) &&
      (pcb->state != SYN_SENT) &&
      (pcb->state != SYN_RCVD)) {
    LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_STATE | LWIP_DBG_LEVEL_SEVERE, ("tcp_write() called in invalid state\n"));
    return ERR_CONN;
  } else if (len == 0) {
    return ERR_OK;
  }

  /* fail on too much data */
  if (len > pcb->snd_buf) {
    LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("tcp_write: too much data (len=%"U16_F" > snd_buf=%"TCPWNDSIZE_F")\n",
                len, pcb->snd_buf));
    tcp_set_flags(pcb, TF_NAGLEMEMERR);
    return ERR_MEM;
  }

  LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_write: queuelen: %"TCPWNDSIZE_F"\n", (tcpwnd_size_t)pcb->snd_queuelen));

  /* If total number of pbufs on the unsent/unacked queues exceeds the
   * configured maximum, return an error */
  /* check for configured max queuelen and possible overflow */
  if (pcb->snd_queuelen >= LWIP_MIN(TCP_SND_QUEUELEN, (TCP_SNDQUEUELEN_OVERFLOW + 1))) {
    LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SEVERE, ("tcp_write: too long queue %"U16_F" (max %"U16_F")\n",
                pcb->snd_queuelen, (u16_t)TCP_SND_QUEUELEN));
    TCP_STATS_INC(tcp.memerr);
    tcp_set_flags(pcb, TF_NAGLEMEMERR);
    return ERR_MEM;
  }
  if (pcb->snd_queuelen != 0) {
    LWIP_ASSERT("tcp_write: pbufs on queue => at least one queue non-empty",
                pcb->unacked != NULL || pcb->unsent != NULL);
  } else {
    LWIP_ASSERT("tcp_write: no pbufs on queue => both queues empty",
                pcb->unacked == NULL && pcb->unsent == NULL);
  }
  return ERR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movw %si, %ax
movq %rdi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x139db
jmp 0x139ac
leaq 0x13919(%rip), %rdi     # 0x272cc
leaq 0x155c2(%rip), %rsi     # 0x28f7c
movl $0x133, %edx            # imm = 0x133
leaq 0x1500c(%rip), %rcx     # 0x289d2
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x139dd
movq -0x10(%rbp), %rax
cmpl $0x4, 0x48(%rax)
je 0x13a12
movq -0x10(%rbp), %rax
cmpl $0x7, 0x48(%rax)
je 0x13a12
movq -0x10(%rbp), %rax
cmpl $0x2, 0x48(%rax)
je 0x13a12
movq -0x10(%rbp), %rax
cmpl $0x3, 0x48(%rax)
je 0x13a12
jmp 0x13a07
jmp 0x13a09
movb $-0xb, -0x1(%rbp)
jmp 0x13b55
movzwl -0x12(%rbp), %eax
cmpl $0x0, %eax
jne 0x13a24
movb $0x0, -0x1(%rbp)
jmp 0x13b55
jmp 0x13a26
movzwl -0x12(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x9c(%rcx), %ecx
cmpl %ecx, %eax
jle 0x13a60
jmp 0x13a3b
jmp 0x13a3d
jmp 0x13a3f
movq -0x10(%rbp), %rax
movzwl 0x52(%rax), %eax
orl $0x80, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x52(%rax)
movb $-0x1, -0x1(%rbp)
jmp 0x13b55
jmp 0x13a62
jmp 0x13a64
movq -0x10(%rbp), %rax
movzwl 0x9e(%rax), %eax
cmpl $0x5a, %eax
jb 0x13a9b
jmp 0x13a76
jmp 0x13a78
jmp 0x13a7a
movq -0x10(%rbp), %rax
movzwl 0x52(%rax), %eax
orl $0x80, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x52(%rax)
movb $-0x1, -0x1(%rbp)
jmp 0x13b55
movq -0x10(%rbp), %rax
movzwl 0x9e(%rax), %eax
cmpl $0x0, %eax
je 0x13afe
jmp 0x13aad
movq -0x10(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
jne 0x13afa
movq -0x10(%rbp), %rax
cmpq $0x0, 0xa8(%rax)
jne 0x13afa
jmp 0x13acb
leaq 0x137fa(%rip), %rdi     # 0x272cc
leaq 0x154c1(%rip), %rsi     # 0x28f9a
movl $0x156, %edx            # imm = 0x156
leaq 0x14eed(%rip), %rcx     # 0x289d2
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x13afc
jmp 0x13b51
jmp 0x13b00
movq -0x10(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
jne 0x13b1c
movq -0x10(%rbp), %rax
cmpq $0x0, 0xa8(%rax)
je 0x13b4d
jmp 0x13b1e
leaq 0x137a7(%rip), %rdi     # 0x272cc
leaq 0x154a8(%rip), %rsi     # 0x28fd4
movl $0x159, %edx            # imm = 0x159
leaq 0x14e9a(%rip), %rcx     # 0x289d2
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x13b4f
jmp 0x13b51
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x20, %rsp
popq %rbp
retq
nop