// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_loop_output
err_t
netif_loop_output(struct netif *netif, struct pbuf *p)
{
  struct pbuf *r;
  err_t err;
  struct pbuf *last;
#if LWIP_LOOPBACK_MAX_PBUFS
  u16_t clen = 0;
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
  /* If we have a loopif, SNMP counters are adjusted for it,
   * if not they are adjusted for 'netif'. */
#if MIB2_STATS
#if LWIP_HAVE_LOOPIF
  struct netif *stats_if = &loop_netif;
#else /* LWIP_HAVE_LOOPIF */
  struct netif *stats_if = netif;
#endif /* LWIP_HAVE_LOOPIF */
#endif /* MIB2_STATS */
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
  u8_t schedule_poll = 0;
#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
  SYS_ARCH_DECL_PROTECT(lev);

  LWIP_ASSERT("netif_loop_output: invalid netif", netif != NULL);
  LWIP_ASSERT("netif_loop_output: invalid pbuf", p != NULL);

  /* Allocate a new pbuf */
  r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
  if (r == NULL) {
    LINK_STATS_INC(link.memerr);
    LINK_STATS_INC(link.drop);
    MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards);
    return ERR_MEM;
  }
#if LWIP_LOOPBACK_MAX_PBUFS
  clen = pbuf_clen(r);
  /* check for overflow or too many pbuf on queue */
  if (((netif->loop_cnt_current + clen) < netif->loop_cnt_current) ||
      ((netif->loop_cnt_current + clen) > LWIP_MIN(LWIP_LOOPBACK_MAX_PBUFS, 0xFFFF))) {
    pbuf_free(r);
    LINK_STATS_INC(link.memerr);
    LINK_STATS_INC(link.drop);
    MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards);
    return ERR_MEM;
  }
  netif->loop_cnt_current = (u16_t)(netif->loop_cnt_current + clen);
#endif /* LWIP_LOOPBACK_MAX_PBUFS */

  /* Copy the whole pbuf queue p into the single pbuf r */
  if ((err = pbuf_copy(r, p)) != ERR_OK) {
    pbuf_free(r);
    LINK_STATS_INC(link.memerr);
    LINK_STATS_INC(link.drop);
    MIB2_STATS_NETIF_INC(stats_if, ifoutdiscards);
    return err;
  }

  /* Put the packet on a linked list which gets emptied through calling
     netif_poll(). */

  /* let last point to the last pbuf in chain r */
  for (last = r; last->next != NULL; last = last->next) {
    /* nothing to do here, just get to the last pbuf */
  }

  SYS_ARCH_PROTECT(lev);
  if (netif->loop_first != NULL) {
    LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL);
    netif->loop_last->next = r;
    netif->loop_last = last;
  } else {
    netif->loop_first = r;
    netif->loop_last = last;
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
    /* No existing packets queued, schedule poll */
    schedule_poll = 1;
#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */
  }
  SYS_ARCH_UNPROTECT(lev);

  LINK_STATS_INC(link.xmit);
  MIB2_STATS_NETIF_ADD(stats_if, ifoutoctets, p->tot_len);
  MIB2_STATS_NETIF_INC(stats_if, ifoutucastpkts);

#if LWIP_NETIF_LOOPBACK_MULTITHREADING
  /* For multithreading environment, schedule a call to netif_poll */
  if (schedule_poll) {
    tcpip_try_callback((tcpip_callback_fn)netif_poll, netif);
  }
#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */

  return ERR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x5cd8
jmp 0x5ca9
leaq 0x2161c(%rip), %rdi     # 0x272cc
leaq 0x21965(%rip), %rsi     # 0x2761c
movl $0x44b, %edx            # imm = 0x44B
leaq 0x217ca(%rip), %rcx     # 0x2748d
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x5cda
jmp 0x5cdc
cmpq $0x0, -0x18(%rbp)
jne 0x5d14
jmp 0x5ce5
leaq 0x215e0(%rip), %rdi     # 0x272cc
leaq 0x2194a(%rip), %rsi     # 0x2763d
movl $0x44c, %edx            # imm = 0x44C
leaq 0x2178e(%rip), %rcx     # 0x2748d
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x5d16
movq -0x18(%rbp), %rax
movl $0xe, %edi
movl $0x280, %edx            # imm = 0x280
movzwl 0x10(%rax), %esi
callq 0x6e20
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x5d41
movb $-0x1, -0x1(%rbp)
jmp 0x5e24
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x7f70
movb %al, -0x21(%rbp)
movsbl %al, %eax
cmpl $0x0, %eax
je 0x5d6d
movq -0x20(%rbp), %rdi
callq 0x7260
movb -0x21(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x5e24
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x5d8e
jmp 0x5d81
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x5d75
movq -0x10(%rbp), %rax
cmpq $0x0, 0xf8(%rax)
je 0x5e02
jmp 0x5d9e
movq -0x10(%rbp), %rax
cmpq $0x0, 0x100(%rax)
jne 0x5ddd
jmp 0x5dae
leaq 0x21517(%rip), %rdi     # 0x272cc
leaq 0x218a1(%rip), %rsi     # 0x2765d
movl $0x477, %edx            # imm = 0x477
leaq 0x216c5(%rip), %rcx     # 0x2748d
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x5ddf
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x100(%rax), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x100(%rax)
jmp 0x5e20
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xf8(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x100(%rax)
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)