// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/ipv6/nd6.c
// Function: nd6_new_neighbor_cache_entry
static s8_t
nd6_new_neighbor_cache_entry(void)
{
  s8_t i;
  s8_t j;
  u32_t time;


  /* First, try to find an empty entry. */
  for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
    if (neighbor_cache[i].state == ND6_NO_ENTRY) {
      return i;
    }
  }

  /* We need to recycle an entry. in general, do not recycle if it is a router. */

  /* Next, try to find a Stale entry. */
  for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
    if ((neighbor_cache[i].state == ND6_STALE) &&
        (!neighbor_cache[i].isrouter)) {
      nd6_free_neighbor_cache_entry(i);
      return i;
    }
  }

  /* Next, try to find a Probe entry. */
  for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
    if ((neighbor_cache[i].state == ND6_PROBE) &&
        (!neighbor_cache[i].isrouter)) {
      nd6_free_neighbor_cache_entry(i);
      return i;
    }
  }

  /* Next, try to find a Delayed entry. */
  for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
    if ((neighbor_cache[i].state == ND6_DELAY) &&
        (!neighbor_cache[i].isrouter)) {
      nd6_free_neighbor_cache_entry(i);
      return i;
    }
  }

  /* Next, try to find the oldest reachable entry. */
  time = 0xfffffffful;
  j = -1;
  for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
    if ((neighbor_cache[i].state == ND6_REACHABLE) &&
        (!neighbor_cache[i].isrouter)) {
      if (neighbor_cache[i].counter.reachable_time < time) {
        j = i;
        time = neighbor_cache[i].counter.reachable_time;
      }
    }
  }
  if (j >= 0) {
    nd6_free_neighbor_cache_entry(j);
    return j;
  }

  /* Next, find oldest incomplete entry without queued packets. */
  time = 0;
  j = -1;
  for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
    if (
        (neighbor_cache[i].q == NULL) &&
        (neighbor_cache[i].state == ND6_INCOMPLETE) &&
        (!neighbor_cache[i].isrouter)) {
      if (neighbor_cache[i].counter.probes_sent >= time) {
        j = i;
        time = neighbor_cache[i].counter.probes_sent;
      }
    }
  }
  if (j >= 0) {
    nd6_free_neighbor_cache_entry(j);
    return j;
  }

  /* Next, find oldest incomplete entry with queued packets. */
  time = 0;
  j = -1;
  for (i = 0; i < LWIP_ND6_NUM_NEIGHBORS; i++) {
    if ((neighbor_cache[i].state == ND6_INCOMPLETE) &&
        (!neighbor_cache[i].isrouter)) {
      if (neighbor_cache[i].counter.probes_sent >= time) {
        j = i;
        time = neighbor_cache[i].counter.probes_sent;
      }
    }
  }
  if (j >= 0) {
    nd6_free_neighbor_cache_entry(j);
    return j;
  }

  /* No more entries to try. */
  return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movb $0x0, -0x2(%rbp)
movsbl -0x2(%rbp), %eax
cmpl $0xa, %eax
jge 0x216c8
movsbq -0x2(%rbp), %rcx
leaq 0xe37f(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movzbl 0x30(%rax), %eax
cmpl $0x0, %eax
jne 0x216bc
movb -0x2(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x21a34
jmp 0x216be
movb -0x2(%rbp), %al
addb $0x1, %al
movb %al, -0x2(%rbp)
jmp 0x2168c
movb $0x0, -0x2(%rbp)
movsbl -0x2(%rbp), %eax
cmpl $0xa, %eax
jge 0x2172a
movsbq -0x2(%rbp), %rcx
leaq 0xe33f(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movzbl 0x30(%rax), %eax
cmpl $0x3, %eax
jne 0x2171e
movsbq -0x2(%rbp), %rcx
leaq 0xe323(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, 0x31(%rax)
jne 0x2171e
movsbl -0x2(%rbp), %edi
callq 0x23300
movb -0x2(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x21a34
jmp 0x21720
movb -0x2(%rbp), %al
addb $0x1, %al
movb %al, -0x2(%rbp)
jmp 0x216cc
movb $0x0, -0x2(%rbp)
movsbl -0x2(%rbp), %eax
cmpl $0xa, %eax
jge 0x2178c
movsbq -0x2(%rbp), %rcx
leaq 0xe2dd(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movzbl 0x30(%rax), %eax
cmpl $0x5, %eax
jne 0x21780
movsbq -0x2(%rbp), %rcx
leaq 0xe2c1(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, 0x31(%rax)
jne 0x21780
movsbl -0x2(%rbp), %edi
callq 0x23300
movb -0x2(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x21a34
jmp 0x21782
movb -0x2(%rbp), %al
addb $0x1, %al
movb %al, -0x2(%rbp)
jmp 0x2172e
movb $0x0, -0x2(%rbp)
movsbl -0x2(%rbp), %eax
cmpl $0xa, %eax
jge 0x217ee
movsbq -0x2(%rbp), %rcx
leaq 0xe27b(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movzbl 0x30(%rax), %eax
cmpl $0x4, %eax
jne 0x217e2
movsbq -0x2(%rbp), %rcx
leaq 0xe25f(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, 0x31(%rax)
jne 0x217e2
movsbl -0x2(%rbp), %edi
callq 0x23300
movb -0x2(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x21a34
jmp 0x217e4
movb -0x2(%rbp), %al
addb $0x1, %al
movb %al, -0x2(%rbp)
jmp 0x21790
movl $0xffffffff, -0x8(%rbp) # imm = 0xFFFFFFFF
movb $-0x1, -0x3(%rbp)
movb $0x0, -0x2(%rbp)
movsbl -0x2(%rbp), %eax
cmpl $0xa, %eax
jge 0x2188a
movsbq -0x2(%rbp), %rcx
leaq 0xe20a(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movzbl 0x30(%rax), %eax
cmpl $0x2, %eax
jne 0x2187b
movsbq -0x2(%rbp), %rcx
leaq 0xe1ee(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, 0x31(%rax)
jne 0x2187b
movsbq -0x2(%rbp), %rcx
leaq 0xe1d5(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x34(%rax), %eax
cmpl -0x8(%rbp), %eax
jae 0x21879
movb -0x2(%rbp), %al
movb %al, -0x3(%rbp)
movsbq -0x2(%rbp), %rcx
leaq 0xe1b4(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x34(%rax), %eax
movl %eax, -0x8(%rbp)
jmp 0x2187b
jmp 0x2187d
movb -0x2(%rbp), %al
addb $0x1, %al
movb %al, -0x2(%rbp)
jmp 0x217fd
movsbl -0x3(%rbp), %eax
cmpl $0x0, %eax
jl 0x218a7
movsbl -0x3(%rbp), %edi
callq 0x23300
movb -0x3(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x21a34
movl $0x0, -0x8(%rbp)
movb $-0x1, -0x3(%rbp)
movb $0x0, -0x2(%rbp)
movsbl -0x2(%rbp), %eax
cmpl $0xa, %eax
jge 0x2195d
movsbq -0x2(%rbp), %rcx
leaq 0xe151(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x28(%rax)
jne 0x2194e
movsbq -0x2(%rbp), %rcx
leaq 0xe137(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movzbl 0x30(%rax), %eax
cmpl $0x1, %eax
jne 0x2194e
movsbq -0x2(%rbp), %rcx
leaq 0xe11b(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, 0x31(%rax)
jne 0x2194e
movsbq -0x2(%rbp), %rcx
leaq 0xe102(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x34(%rax), %eax
cmpl -0x8(%rbp), %eax
jb 0x2194c
movb -0x2(%rbp), %al
movb %al, -0x3(%rbp)
movsbq -0x2(%rbp), %rcx
leaq 0xe0e1(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x34(%rax), %eax
movl %eax, -0x8(%rbp)
jmp 0x2194e
jmp 0x21950
movb -0x2(%rbp), %al
addb $0x1, %al
movb %al, -0x2(%rbp)
jmp 0x218b6
movsbl -0x3(%rbp), %eax
cmpl $0x0, %eax
jl 0x2197a
movsbl -0x3(%rbp), %edi
callq 0x23300
movb -0x3(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x21a34
movl $0x0, -0x8(%rbp)
movb $-0x1, -0x3(%rbp)
movb $0x0, -0x2(%rbp)
movsbl -0x2(%rbp), %eax
cmpl $0xa, %eax
jge 0x21a16
movsbq -0x2(%rbp), %rcx
leaq 0xe07e(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movzbl 0x30(%rax), %eax
cmpl $0x1, %eax
jne 0x21a07
movsbq -0x2(%rbp), %rcx
leaq 0xe062(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, 0x31(%rax)
jne 0x21a07
movsbq -0x2(%rbp), %rcx
leaq 0xe049(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x34(%rax), %eax
cmpl -0x8(%rbp), %eax
jb 0x21a05
movb -0x2(%rbp), %al
movb %al, -0x3(%rbp)
movsbq -0x2(%rbp), %rcx
leaq 0xe028(%rip), %rax      # 0x2fa20
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x34(%rax), %eax
movl %eax, -0x8(%rbp)
jmp 0x21a07
jmp 0x21a09
movb -0x2(%rbp), %al
addb $0x1, %al
movb %al, -0x2(%rbp)
jmp 0x21989
movsbl -0x3(%rbp), %eax
cmpl $0x0, %eax
jl 0x21a30
movsbl -0x3(%rbp), %edi
callq 0x23300
movb -0x3(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x21a34
movb $-0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)