// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/ipv6/nd6.c
// Function: nd6_tmr
void
nd6_tmr(void)
{
  s8_t i;
  struct netif *netif;

  /* Process neighbor entries. */
  for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
    switch (neighbor_cache[i].state) {
    case ND6_INCOMPLETE:
      if ((neighbor_cache[i].counter.probes_sent >= LWIP_ND6_MAX_MULTICAST_SOLICIT) &&
          (!neighbor_cache[i].isrouter)) {
        /* Retries exceeded. */
        nd6_free_neighbor_cache_entry(i);
      } else {
        /* Send a NS for this entry. */
        neighbor_cache[i].counter.probes_sent++;
        nd6_send_neighbor_cache_probe(&neighbor_cache[i], ND6_SEND_FLAG_MULTICAST_DEST);
      }
      break;
    case ND6_REACHABLE:
      /* Send queued packets, if any are left. Should have been sent already. */
      if (neighbor_cache[i].q != NULL) {
        nd6_send_q(i);
      }
      if (neighbor_cache[i].counter.reachable_time <= ND6_TMR_INTERVAL) {
        /* Change to stale state. */
        neighbor_cache[i].state = ND6_STALE;
        neighbor_cache[i].counter.stale_time = 0;
      } else {
        neighbor_cache[i].counter.reachable_time -= ND6_TMR_INTERVAL;
      }
      break;
    case ND6_STALE:
      neighbor_cache[i].counter.stale_time++;
      break;
    case ND6_DELAY:
      if (neighbor_cache[i].counter.delay_time <= 1) {
        /* Change to PROBE state. */
        neighbor_cache[i].state = ND6_PROBE;
        neighbor_cache[i].counter.probes_sent = 0;
      } else {
        neighbor_cache[i].counter.delay_time--;
      }
      break;
    case ND6_PROBE:
      if ((neighbor_cache[i].counter.probes_sent >= LWIP_ND6_MAX_MULTICAST_SOLICIT) &&
          (!neighbor_cache[i].isrouter)) {
        /* Retries exceeded. */
        nd6_free_neighbor_cache_entry(i);
      } else {
        /* Send a NS for this entry. */
        neighbor_cache[i].counter.probes_sent++;
        nd6_send_neighbor_cache_probe(&neighbor_cache[i], 0);
      }
      break;
    case ND6_NO_ENTRY:
    default:
      /* Do nothing. */
      break;
    }
  }

  /* Process destination entries. */
  for (i = 0; i < LWIP_ND6_NUM_DESTINATIONS; i++) {
    destination_cache[i].age++;
  }

  /* Process router entries. */
  for (i = 0; i < LWIP_ND6_NUM_ROUTERS; i++) {
    if (default_router_list[i].neighbor_entry != NULL) {
      /* Active entry. */
      if (default_router_list[i].invalidation_timer <= ND6_TMR_INTERVAL / 1000) {
        /* No more than 1 second remaining. Clear this entry. Also clear any of
         * its destination cache entries, as per RFC 4861 Sec. 5.3 and 6.3.5. */
        s8_t j;
        for (j = 0; j < LWIP_ND6_NUM_DESTINATIONS; j++) {
          if (ip6_addr_cmp(&destination_cache[j].next_hop_addr,
               &default_router_list[i].neighbor_entry->next_hop_address)) {
             ip6_addr_set_any(&destination_cache[j].destination_addr);
          }
        }
        default_router_list[i].neighbor_entry->isrouter = 0;
        default_router_list[i].neighbor_entry = NULL;
        default_router_list[i].invalidation_timer = 0;
        default_router_list[i].flags = 0;
      } else {
        default_router_list[i].invalidation_timer -= ND6_TMR_INTERVAL / 1000;
      }
    }
  }

  /* Process prefix entries. */
  for (i = 0; i < LWIP_ND6_NUM_PREFIXES; i++) {
    if (prefix_list[i].netif != NULL) {
      if (prefix_list[i].invalidation_timer <= ND6_TMR_INTERVAL / 1000) {
        /* Entry timed out, remove it */
        prefix_list[i].invalidation_timer = 0;
        prefix_list[i].netif = NULL;
      } else {
        prefix_list[i].invalidation_timer -= ND6_TMR_INTERVAL / 1000;
      }
    }
  }

  /* Process our own addresses, updating address lifetimes and/or DAD state. */
  NETIF_FOREACH(netif) {
    for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; ++i) {
      u8_t addr_state;
#if LWIP_IPV6_ADDRESS_LIFETIMES
      /* Step 1: update address lifetimes (valid and preferred). */
      addr_state = netif_ip6_addr_state(netif, i);
      /* RFC 4862 is not entirely clear as to whether address lifetimes affect
       * tentative addresses, and is even less clear as to what should happen
       * with duplicate addresses. We choose to track and update lifetimes for
       * both those types, although for different reasons:
       * - for tentative addresses, the line of thought of Sec. 5.7 combined
       *   with the potentially long period that an address may be in tentative
       *   state (due to the interface being down) suggests that lifetimes
       *   should be independent of external factors which would include DAD;
       * - for duplicate addresses, retiring them early could result in a new
       *   but unwanted attempt at marking them as valid, while retiring them
       *   late/never could clog up address slots on the netif.
       * As a result, we may end up expiring addresses of either type here.
       */
      if (!ip6_addr_isinvalid(addr_state) &&
          !netif_ip6_addr_isstatic(netif, i)) {
        u32_t life = netif_ip6_addr_valid_life(netif, i);
        if (life <= ND6_TMR_INTERVAL / 1000) {
          /* The address has expired. */
          netif_ip6_addr_set_valid_life(netif, i, 0);
          netif_ip6_addr_set_pref_life(netif, i, 0);
          netif_ip6_addr_set_state(netif, i, IP6_ADDR_INVALID);
        } else {
          if (!ip6_addr_life_isinfinite(life)) {
            life -= ND6_TMR_INTERVAL / 1000;
            LWIP_ASSERT("bad valid lifetime", life != IP6_ADDR_LIFE_STATIC);
            netif_ip6_addr_set_valid_life(netif, i, life);
          }
          /* The address is still here. Update the preferred lifetime too. */
          life = netif_ip6_addr_pref_life(netif, i);
          if (life <= ND6_TMR_INTERVAL / 1000) {
            /* This case must also trigger if 'life' was already zero, so as to
             * deal correctly with advertised preferred-lifetime reductions. */
            netif_ip6_addr_set_pref_life(netif, i, 0);
            if (addr_state == IP6_ADDR_PREFERRED)
              netif_ip6_addr_set_state(netif, i, IP6_ADDR_DEPRECATED);
          } else if (!ip6_addr_life_isinfinite(life)) {
            life -= ND6_TMR_INTERVAL / 1000;
            netif_ip6_addr_set_pref_life(netif, i, life);
          }
        }
      }
      /* The address state may now have changed, so reobtain it next. */
#endif /* LWIP_IPV6_ADDRESS_LIFETIMES */
      /* Step 2: update DAD state. */
      addr_state = netif_ip6_addr_state(netif, i);
      if (ip6_addr_istentative(addr_state)) {
        if ((addr_state & IP6_ADDR_TENTATIVE_COUNT_MASK) >= LWIP_IPV6_DUP_DETECT_ATTEMPTS) {
          /* No NA received in response. Mark address as valid. For dynamic
           * addresses with an expired preferred lifetime, the state is set to
           * deprecated right away. That should almost never happen, though. */
          addr_state = IP6_ADDR_PREFERRED;
#if LWIP_IPV6_ADDRESS_LIFETIMES
          if (!netif_ip6_addr_isstatic(netif, i) &&
              netif_ip6_addr_pref_life(netif, i) == 0) {
            addr_state = IP6_ADDR_DEPRECATED;
          }
#endif /* LWIP_IPV6_ADDRESS_LIFETIMES */
          netif_ip6_addr_set_state(netif, i, addr_state);
        } else if (netif_is_up(netif) && netif_is_link_up(netif)) {
          /* tentative: set next state by increasing by one */
          netif_ip6_addr_set_state(netif, i, addr_state + 1);
          /* Send a NS for this address. Use the unspecified address as source
           * address in all cases (RFC 4862 Sec. 5.4.2), not in the least
           * because as it is, we only consider multicast replies for DAD. */
          nd6_send_ns(netif, netif_ip6_addr(netif, i),
            ND6_SEND_FLAG_MULTICAST_DEST | ND6_SEND_FLAG_ANY_SRC);
        }
      }
    }
  }

#if LWIP_IPV6_SEND_ROUTER_SOLICIT
  /* Send router solicitation messages, if necessary. */
  if (!nd6_tmr_rs_reduction) {
    nd6_tmr_rs_reduction = (ND6_RTR_SOLICITATION_INTERVAL / ND6_TMR_INTERVAL) - 1;
    NETIF_FOREACH(netif) {
      if ((netif->rs_count > 0) && netif_is_up(netif) &&
          netif_is_link_up(netif) &&
          !ip6_addr_isinvalid(netif_ip6_addr_state(netif, 0)) &&
          !ip6_addr_isduplicated(netif_ip6_addr_state(netif, 0))) {
        if (nd6_send_rs(netif) == ERR_OK) {
          netif->rs_count--;
        }
      }
    }
  } else {
    nd6_tmr_rs_reduction--;
  }
#endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */

}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0xa328(%rip), %rbx      # 0x1ca10
xorl %r14d, %r14d
leaq 0x4076(%rip), %r15      # 0x16768
movzbl 0x30(%rbx), %eax
decl %eax
cmpl $0x4, %eax
ja 0x1279f
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movl 0x34(%rbx), %eax
cmpl $0x3, %eax
jb 0x12718
cmpb $0x0, 0x31(%rbx)
je 0x12796
incl %eax
movl %eax, 0x34(%rbx)
movq 0x18(%rbx), %rdi
movq %rbx, %rsi
movl $0x1, %edx
jmp 0x12747
movl 0x34(%rbx), %eax
cmpl $0x3, %eax
jb 0x12739
cmpb $0x0, 0x31(%rbx)
je 0x12796
incl %eax
movl %eax, 0x34(%rbx)
movq 0x18(%rbx), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x12a9b
jmp 0x1279f
incl 0x34(%rbx)
jmp 0x1279f
movl 0x34(%rbx), %eax
cmpl $0x1, %eax
ja 0x12788
movb $0x5, 0x30(%rbx)
jmp 0x1277f
cmpq $0x0, 0x28(%rbx)
je 0x12771
movsbl %r14b, %edi
callq 0x11e7d
movl 0x34(%rbx), %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
ja 0x1278c
movb $0x3, 0x30(%rbx)
movl $0x0, 0x34(%rbx)
jmp 0x1279f
decl %eax
jmp 0x12791
addl $0xfffffc18, %eax       # imm = 0xFFFFFC18
movl %eax, 0x34(%rbx)
jmp 0x1279f
movsbl %r14b, %edi
callq 0x12a44
incq %r14
addq $0x38, %rbx
cmpq $0xa, %r14
jne 0x126f2
xorl %ecx, %ecx
leaq 0xa5a7(%rip), %rax      # 0x1cd60
incl 0x2c(%rcx,%rax)
addq $0x30, %rcx
cmpq $0x1e0, %rcx            # imm = 0x1E0
jne 0x127b9
xorl %ecx, %ecx
leaq 0xa46d(%rip), %rdx      # 0x1cc40
xorps %xmm0, %xmm0
xorl %esi, %esi
movq %rsi, %rdi
shlq $0x4, %rdi
movq (%rdi,%rdx), %r8
testq %r8, %r8
je 0x12866
addq %rdx, %rdi
movl 0x8(%rdi), %r9d
cmpl $0x1, %r9d
ja 0x1285f
xorl %r9d, %r9d
movl 0x14(%r9,%rax), %r10d
cmpl (%r8), %r10d
jne 0x1283b
movl 0x18(%r9,%rax), %r10d
cmpl 0x4(%r8), %r10d
jne 0x1283b
movl 0x1c(%r9,%rax), %r10d
cmpl 0x8(%r8), %r10d
jne 0x1283b
movl 0x20(%r9,%rax), %r10d
cmpl 0xc(%r8), %r10d
jne 0x1283b
movb 0x24(%r9,%rax), %r10b
cmpb 0x10(%r8), %r10b
jne 0x1283b
leaq (%rax,%r9), %r10
movaps %xmm0, (%r10)
movb $0x0, 0x10(%r10)
addq $0x30, %r9
cmpq $0x1e0, %r9             # imm = 0x1E0
jne 0x127f8
movb %cl, 0x31(%r8)
movq $0x0, (%rdi)
movl $0x0, 0x8(%rdi)
movb %cl, 0xc(%rdi)
jmp 0x12866
decl %r9d
movl %r9d, 0x8(%rdi)
incq %rsi
cmpq $0x3, %rsi
jne 0x127d8
movl $0x20, %eax
leaq 0xa411(%rip), %rcx      # 0x1cc90
cmpq $0x0, -0x8(%rax,%rcx)
je 0x128a6
movl (%rax,%rcx), %edx
cmpl $0x1, %edx
ja 0x128a1
movl $0x0, (%rax,%rcx)
movq $0x0, -0x8(%rax,%rcx)
jmp 0x128a6
decl %edx
movl %edx, (%rax,%rcx)
addq $0x28, %rax
cmpq $0xe8, %rax
jne 0x1287f
leaq 0xa01f(%rip), %r15      # 0x1c8d8
movq (%r15), %rbx
testq %rbx, %rbx
je 0x129e2
xorl %r12d, %r12d
leaq 0x50(%rbx), %r14
xorl %r13d, %r13d
movb 0x98(%rbx,%r13), %al
testb %al, %al
je 0x12955
movl 0x9c(%rbx,%r13,4), %ecx
cmpl $-0x1, %ecx
je 0x12916
testl %ecx, %ecx
je 0x12955
cmpl $0x1, %ecx
jne 0x1290c
movl %r12d, 0x9c(%rbx,%r13,4)
movl %r12d, 0xa8(%rbx,%r13,4)
movsbl %r13b, %esi
movq %rbx, %rdi
xorl %edx, %edx
jmp 0x1293f
decl %ecx
movl %ecx, 0x9c(%rbx,%r13,4)
movl 0xa8(%rbx,%r13,4), %ecx
cmpl $0x1, %ecx
ja 0x12946
movl $0x0, 0xa8(%rbx,%r13,4)
cmpb $0x30, %al
jne 0x12955
movsbl %r13b, %esi
movq %rbx, %rdi
movl $0x10, %edx
callq 0x490e
jmp 0x12955
cmpl $-0x1, %ecx
je 0x12955
decl %ecx
movl %ecx, 0xa8(%rbx,%r13,4)
movzbl 0x98(%rbx,%r13), %eax
testb $0x8, %al
je 0x129c5
testb $0x7, %al
je 0x12984
cmpl $0x0, 0x9c(%rbx,%r13,4)
je 0x129b4
cmpl $0x0, 0xa8(%rbx,%r13,4)
setne %al
shlb $0x5, %al
orb $0x10, %al
jmp 0x129b6
movb 0xeb(%rbx), %cl
notb %cl
testb $0x5, %cl
jne 0x129c5
orb $0x1, %al
movsbl %r13b, %esi
movzbl %al, %edx
movq %rbx, %rdi
callq 0x490e
movq %rbx, %rdi
movq %r14, %rsi
movl $0x5, %edx
callq 0x12a9b
jmp 0x129c5
movb $0x30, %al
movzbl %al, %edx
movsbl %r13b, %esi
movq %rbx, %rdi
callq 0x490e
incq %r13
addq $0x18, %r14
cmpq $0x3, %r13
jne 0x128cf
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x128c8
movb 0xa558(%rip), %al       # 0x1cf40
testb %al, %al
je 0x129fe
decb %al
movb %al, 0xa54c(%rip)       # 0x1cf40
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movb $0x3, 0xa53b(%rip)      # 0x1cf40
movq (%r15), %rbx
testq %rbx, %rbx
je 0x129f4
cmpb $0x0, 0xf0(%rbx)
je 0x12a3f
movb 0xeb(%rbx), %al
notb %al
testb $0x5, %al
jne 0x12a3f
movzbl 0x98(%rbx), %eax
testb $-0x41, %al
je 0x12a3f
movq %rbx, %rdi
callq 0x1223c
testb %al, %al
jne 0x12a3f
decb 0xf0(%rbx)
movq (%rbx), %rbx
jmp 0x12a08