// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_add
struct netif *
netif_add(struct netif *netif,
#if LWIP_IPV4
          const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw,
#endif /* LWIP_IPV4 */
          void *state, netif_init_fn init, netif_input_fn input)
{
#if LWIP_IPV6
  s8_t i;
#endif

  LWIP_ASSERT_CORE_LOCKED();

#if LWIP_SINGLE_NETIF
  if (netif_default != NULL) {
    LWIP_ASSERT("single netif already set", 0);
    return NULL;
  }
#endif

  LWIP_ERROR("netif_add: invalid netif", netif != NULL, return NULL);
  LWIP_ERROR("netif_add: No init function given", init != NULL, return NULL);

#if LWIP_IPV4
  if (ipaddr == NULL) {
    ipaddr = ip_2_ip4(IP4_ADDR_ANY);
  }
  if (netmask == NULL) {
    netmask = ip_2_ip4(IP4_ADDR_ANY);
  }
  if (gw == NULL) {
    gw = ip_2_ip4(IP4_ADDR_ANY);
  }

  /* reset new interface configuration state */
  ip_addr_set_zero_ip4(&netif->ip_addr);
  ip_addr_set_zero_ip4(&netif->netmask);
  ip_addr_set_zero_ip4(&netif->gw);
  netif->output = netif_null_output_ip4;
#endif /* LWIP_IPV4 */
#if LWIP_IPV6
  for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
    ip_addr_set_zero_ip6(&netif->ip6_addr[i]);
    netif->ip6_addr_state[i] = IP6_ADDR_INVALID;
#if LWIP_IPV6_ADDRESS_LIFETIMES
    netif->ip6_addr_valid_life[i] = IP6_ADDR_LIFE_STATIC;
    netif->ip6_addr_pref_life[i] = IP6_ADDR_LIFE_STATIC;
#endif /* LWIP_IPV6_ADDRESS_LIFETIMES */
  }
  netif->output_ip6 = netif_null_output_ip6;
#endif /* LWIP_IPV6 */
  NETIF_SET_CHECKSUM_CTRL(netif, NETIF_CHECKSUM_ENABLE_ALL);
  netif->mtu = 0;
  netif->flags = 0;
#ifdef netif_get_client_data
  memset(netif->client_data, 0, sizeof(netif->client_data));
#endif /* LWIP_NUM_NETIF_CLIENT_DATA */
#if LWIP_IPV6
#if LWIP_IPV6_AUTOCONFIG
  /* IPv6 address autoconfiguration not enabled by default */
  netif->ip6_autoconfig_enabled = 0;
#endif /* LWIP_IPV6_AUTOCONFIG */
  nd6_restart_netif(netif);
#endif /* LWIP_IPV6 */
#if LWIP_NETIF_STATUS_CALLBACK
  netif->status_callback = NULL;
#endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK
  netif->link_callback = NULL;
#endif /* LWIP_NETIF_LINK_CALLBACK */
#if LWIP_IGMP
  netif->igmp_mac_filter = NULL;
#endif /* LWIP_IGMP */
#if LWIP_IPV6 && LWIP_IPV6_MLD
  netif->mld_mac_filter = NULL;
#endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
#if ENABLE_LOOPBACK
  netif->loop_first = NULL;
  netif->loop_last = NULL;
#endif /* ENABLE_LOOPBACK */

  /* remember netif specific state information data */
  netif->state = state;
  netif->num = netif_num;
  netif->input = input;

  NETIF_RESET_HINTS(netif);
#if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS
  netif->loop_cnt_current = 0;
#endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */

#if LWIP_IPV4
  netif_set_addr(netif, ipaddr, netmask, gw);
#endif /* LWIP_IPV4 */

  /* call user specified initialization function for netif */
  if (init(netif) != ERR_OK) {
    return NULL;
  }
#if LWIP_IPV6 && LWIP_ND6_ALLOW_RA_UPDATES
  /* Initialize the MTU for IPv6 to the one set by the netif driver.
     This can be updated later by RA. */
  netif->mtu6 = netif->mtu;
#endif /* LWIP_IPV6 && LWIP_ND6_ALLOW_RA_UPDATES */

#if !LWIP_SINGLE_NETIF
  /* Assign a unique netif number in the range [0..254], so that (num+1) can
     serve as an interface index that fits in a u8_t.
     We assume that the new netif has not yet been added to the list here.
     This algorithm is O(n^2), but that should be OK for lwIP.
     */
  {
    struct netif *netif2;
    int num_netifs;
    do {
      if (netif->num == 255) {
        netif->num = 0;
      }
      num_netifs = 0;
      for (netif2 = netif_list; netif2 != NULL; netif2 = netif2->next) {
        LWIP_ASSERT("netif already added", netif2 != netif);
        num_netifs++;
        LWIP_ASSERT("too many netifs, max. supported number is 255", num_netifs <= 255);
        if (netif2->num == netif->num) {
          netif->num++;
          break;
        }
      }
    } while (netif2 != NULL);
  }
  if (netif->num == 254) {
    netif_num = 0;
  } else {
    netif_num = (u8_t)(netif->num + 1);
  }

  /* add this netif to the list */
  netif->next = netif_list;
  netif_list = netif;
#endif /* "LWIP_SINGLE_NETIF */
  mib2_netif_added(netif);

#if LWIP_IGMP
  /* start IGMP processing */
  if (netif->flags & NETIF_FLAG_IGMP) {
    igmp_start(netif);
  }
#endif /* LWIP_IGMP */

  LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP",
                            netif->name[0], netif->name[1]));
#if LWIP_IPV4
  LWIP_DEBUGF(NETIF_DEBUG, (" addr "));
  ip4_addr_debug_print(NETIF_DEBUG, ipaddr);
  LWIP_DEBUGF(NETIF_DEBUG, (" netmask "));
  ip4_addr_debug_print(NETIF_DEBUG, netmask);
  LWIP_DEBUGF(NETIF_DEBUG, (" gw "));
  ip4_addr_debug_print(NETIF_DEBUG, gw);
#endif /* LWIP_IPV4 */
  LWIP_DEBUGF(NETIF_DEBUG, ("\n"));

  netif_invoke_ext_callback(netif, LWIP_NSC_NETIF_ADDED, NULL);

  return netif;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x4bfc
jmp 0x4bcd
leaq 0x226f8(%rip), %rdi     # 0x272cc
leaq 0x228e9(%rip), %rsi     # 0x274c4
movl $0x127, %edx            # imm = 0x127
leaq 0x228a6(%rip), %rcx     # 0x2748d
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x4bfe
jmp 0x4c00
cmpq $0x0, -0x38(%rbp)
jne 0x4c38
jmp 0x4c09
leaq 0x226bc(%rip), %rdi     # 0x272cc
leaq 0x228c6(%rip), %rsi     # 0x274dd
movl $0x128, %edx            # imm = 0x128
leaq 0x2286a(%rip), %rcx     # 0x2748d
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x4c3a
cmpq $0x0, -0x18(%rbp)
jne 0x4c4c
leaq 0x24b04(%rip), %rax     # 0x2974c
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x4c5e
leaq 0x24af2(%rip), %rax     # 0x2974c
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x4c70
leaq 0x24ae0(%rip), %rax     # 0x2974c
movq %rax, -0x28(%rbp)
jmp 0x4c72
jmp 0x4c74
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0xc(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x18(%rax)
jmp 0x4caa
movq -0x10(%rbp), %rax
addq $0x8, %rax
cmpq $0x0, %rax
je 0x4cc4
jmp 0x4cba
movq -0x10(%rbp), %rax
movb $0x0, 0x1c(%rax)
jmp 0x4cc4
jmp 0x4cc6
jmp 0x4cc8
jmp 0x4cca
jmp 0x4ccc
movq -0x10(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x30(%rax)
jmp 0x4d02
movq -0x10(%rbp), %rax
addq $0x20, %rax
cmpq $0x0, %rax
je 0x4d1c
jmp 0x4d12
movq -0x10(%rbp), %rax
movb $0x0, 0x34(%rax)
jmp 0x4d1c
jmp 0x4d1e
jmp 0x4d20
jmp 0x4d22
jmp 0x4d24
movq -0x10(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x3c(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x44(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x48(%rax)
jmp 0x4d5a
movq -0x10(%rbp), %rax
addq $0x38, %rax
cmpq $0x0, %rax
je 0x4d74
jmp 0x4d6a
movq -0x10(%rbp), %rax
movb $0x0, 0x4c(%rax)
jmp 0x4d74
jmp 0x4d76
jmp 0x4d78
movq -0x10(%rbp), %rax
leaq 0x62d(%rip), %rcx       # 0x53b0
movq %rcx, 0xc0(%rax)
movb $0x0, -0x39(%rbp)
movsbl -0x39(%rbp), %eax
cmpl $0x3, %eax
jge 0x4ea4
jmp 0x4d9d
jmp 0x4d9f
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x39(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x39(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x39(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x39(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl $0x0, 0xc(%rax)
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x39(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x10(%rax)
jmp 0x4e24
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x39(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, %rax
je 0x4e5a
jmp 0x4e40
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x39(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movb $0x6, 0x14(%rax)
jmp 0x4e5a
jmp 0x4e5c
jmp 0x4e5e
movq -0x10(%rbp), %rax
movsbq -0x39(%rbp), %rcx
movb $0x0, 0x98(%rax,%rcx)
movq -0x10(%rbp), %rax
movsbq -0x39(%rbp), %rcx
movl $0x0, 0x9c(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movsbq -0x39(%rbp), %rcx
movl $0x0, 0xa8(%rax,%rcx,4)
movb -0x39(%rbp), %al
addb $0x1, %al
movb %al, -0x39(%rbp)
jmp 0x4d8e
movq -0x10(%rbp), %rax
leaq 0x521(%rip), %rcx       # 0x53d0
movq %rcx, 0xd0(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0xe0(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0xeb(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0xef(%rax)
movq -0x10(%rbp), %rdi
callq 0x24d90
movq -0x10(%rbp), %rax
movq $0x0, 0xf8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x100(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xd8(%rax)
movb 0x2a9bb(%rip), %cl      # 0x2f8d0
movq -0x10(%rbp), %rax
movb %cl, 0xee(%rax)
movq 0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x53f0
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movsbl %al, %eax
cmpl $0x0, %eax
je 0x4f62
movq $0x0, -0x8(%rbp)
jmp 0x50f2
movq -0x10(%rbp), %rax
movw 0xe0(%rax), %cx
movq -0x10(%rbp), %rax
movw %cx, 0xe2(%rax)
movq -0x10(%rbp), %rax
movzbl 0xee(%rax), %eax
cmpl $0xff, %eax
jne 0x4f95
movq -0x10(%rbp), %rax
movb $0x0, 0xee(%rax)
movl $0x0, -0x4c(%rbp)
movq 0x2a935(%rip), %rax     # 0x2f8d8
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x5077
jmp 0x4fb4
movq -0x48(%rbp), %rax
cmpq -0x10(%rbp), %rax
jne 0x4fef
jmp 0x4fc0
leaq 0x22305(%rip), %rdi     # 0x272cc
leaq 0x22531(%rip), %rsi     # 0x274ff
movl $0x18b, %edx            # imm = 0x18B
leaq 0x224b3(%rip), %rcx     # 0x2748d
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x4ff1
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
cmpl $0xff, -0x4c(%rbp)
jle 0x5034
jmp 0x5005
leaq 0x222c0(%rip), %rdi     # 0x272cc
leaq 0x22500(%rip), %rsi     # 0x27513
movl $0x18d, %edx            # imm = 0x18D
leaq 0x2246e(%rip), %rcx     # 0x2748d
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x5036
movq -0x48(%rbp), %rax
movzbl 0xee(%rax), %eax
movq -0x10(%rbp), %rcx
movzbl 0xee(%rcx), %ecx
cmpl %ecx, %eax
jne 0x5065
movq -0x10(%rbp), %rax
movb 0xee(%rax), %cl
addb $0x1, %cl
movb %cl, 0xee(%rax)
jmp 0x5077
jmp 0x5067
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x4fa7
jmp 0x5079
cmpq $0x0, -0x48(%rbp)
jne 0x4f78
movq -0x10(%rbp), %rax
movzbl 0xee(%rax), %eax
cmpl $0xfe, %eax
jne 0x509f
movb $0x0, 0x2a833(%rip)     # 0x2f8d0
jmp 0x50b3
movq -0x10(%rbp), %rax
movzbl 0xee(%rax), %eax
addl $0x1, %eax
movb %al, 0x2a81d(%rip)      # 0x2f8d0
movq 0x2a81e(%rip), %rcx     # 0x2f8d8
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq %rax, 0x2a80c(%rip)     # 0x2f8d8
jmp 0x50ce
jmp 0x50d0
jmp 0x50d2
jmp 0x50d4
jmp 0x50d6
jmp 0x50d8
jmp 0x50da
jmp 0x50dc
jmp 0x50de
jmp 0x50e0
jmp 0x50e2
jmp 0x50e4
jmp 0x50e6
jmp 0x50e8
jmp 0x50ea
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)