// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movb %r9b, %al
movb 0x10(%rbp), %r9b
movl %edi, -0xc(%rbp)
movw %si, -0xe(%rbp)
movw %dx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movb %al, -0x21(%rbp)
movw -0xe(%rbp), %ax
movw %ax, -0x32(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x13bc5
jmp 0x13b96
leaq 0x1372f(%rip), %rdi     # 0x272cc
leaq 0x15462(%rip), %rsi     # 0x29006
movl $0xe8, %edx
leaq 0x14e22(%rip), %rcx     # 0x289d2
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x13bc7
jmp 0x13bc9
cmpq $0x0, -0x20(%rbp)
jne 0x13c01
jmp 0x13bd2
leaq 0x136f3(%rip), %rdi     # 0x272cc
leaq 0x1544a(%rip), %rsi     # 0x2902a
movl $0xe9, %edx
leaq 0x14de6(%rip), %rcx     # 0x289d2
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x13c03
movzwl -0xe(%rbp), %eax
movzwl -0x10(%rbp), %ecx
cmpl %ecx, %eax
jge 0x13c93
movzbl -0x21(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x13c51
movq -0x20(%rbp), %rax
movzwl 0x52(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x13c91
cmpb $0x0, 0x10(%rbp)
je 0x13c51
movq -0x20(%rbp), %rax
cmpq $0x0, 0xa8(%rax)
jne 0x13c51
movq -0x20(%rbp), %rax
cmpq $0x0, 0xb0(%rax)
je 0x13c91
movzwl -0x10(%rbp), %eax
movzwl -0xe(%rbp), %ecx
addl $0x5b4, %ecx            # imm = 0x5B4
addl $0x1, %ecx
subl $0x1, %ecx
andl $-0x1, %ecx
cmpl %ecx, %eax
jae 0x13c75
movzwl -0x10(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x13c8a
movzwl -0xe(%rbp), %eax
addl $0x5b4, %eax            # imm = 0x5B4
addl $0x1, %eax
subl $0x1, %eax
andl $-0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movw %ax, -0x32(%rbp)
jmp 0x13c93
movl -0xc(%rbp), %edi
movl $0x280, %edx            # imm = 0x280
movzwl -0x32(%rbp), %esi
callq 0x6e20
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x13cb9
movq $0x0, -0x8(%rbp)
jmp 0x13d2c
jmp 0x13cbb
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x13cf6
jmp 0x13cc7
leaq 0x135fe(%rip), %rdi     # 0x272cc
leaq 0x15374(%rip), %rsi     # 0x29049
movl $0x10b, %edx            # imm = 0x10B
leaq 0x14cf1(%rip), %rcx     # 0x289d2
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x13cf8
movq -0x30(%rbp), %rax
movzwl 0x12(%rax), %eax
movzwl -0xe(%rbp), %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
movw -0xe(%rbp), %cx
movq -0x30(%rbp), %rax
movw %cx, 0x10(%rax)
movq -0x30(%rbp), %rax
movw %cx, 0x12(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)