// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_add_ip6_address
err_t
netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chosen_idx)
{
  s8_t i;

  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ASSERT("netif_add_ip6_address: invalid netif", netif != NULL);
  LWIP_ASSERT("netif_add_ip6_address: invalid ip6addr", ip6addr != NULL);

  i = netif_get_ip6_addr_match(netif, ip6addr);
  if (i >= 0) {
    /* Address already added */
    if (chosen_idx != NULL) {
      *chosen_idx = i;
    }
    return ERR_OK;
  }

  /* Find a free slot. The first one is reserved for link-local addresses. */
  for (i = ip6_addr_islinklocal(ip6addr) ? 0 : 1; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
    if (ip6_addr_isinvalid(netif_ip6_addr_state(netif, i))) {
      ip_addr_copy_from_ip6(netif->ip6_addr[i], *ip6addr);
      ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[i]), IP6_UNICAST, netif);
      netif_ip6_addr_set_state(netif, i, IP6_ADDR_TENTATIVE);
      if (chosen_idx != NULL) {
        *chosen_idx = i;
      }
      return ERR_OK;
    }
  }

  if (chosen_idx != NULL) {
    *chosen_idx = -1;
  }
  return ERR_VAL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x694c
jmp 0x691d
leaq 0x209a8(%rip), %rdi     # 0x272cc
leaq 0x20eb1(%rip), %rsi     # 0x277dc
movl $0x623, %edx            # imm = 0x623
leaq 0x20b56(%rip), %rcx     # 0x2748d
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x694e
jmp 0x6950
cmpq $0x0, -0x18(%rbp)
jne 0x6988
jmp 0x6959
leaq 0x2096c(%rip), %rdi     # 0x272cc
leaq 0x20e9a(%rip), %rsi     # 0x27801
movl $0x624, %edx            # imm = 0x624
leaq 0x20b1a(%rip), %rcx     # 0x2748d
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x698a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6570
movb %al, -0x21(%rbp)
movsbl -0x21(%rbp), %eax
cmpl $0x0, %eax
jl 0x69bc
cmpq $0x0, -0x20(%rbp)
je 0x69b3
movb -0x21(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
movb $0x0, -0x1(%rbp)
jmp 0x6b60
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, %edx
andq $0xc0ff, %rdx           # imm = 0xC0FF
movl $0x1, %eax
xorl %ecx, %ecx
cmpq $0x80fe, %rdx           # imm = 0x80FE
cmovel %ecx, %eax
movb %al, -0x21(%rbp)
movsbl -0x21(%rbp), %eax
cmpl $0x3, %eax
jge 0x6b4e
movq -0x10(%rbp), %rax
movsbq -0x21(%rbp), %rcx
movzbl 0x98(%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x6b3f
jmp 0x6a08
jmp 0x6a0a
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x21(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x21(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x21(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x21(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
movb 0x10(%rax), %cl
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x21(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x10(%rax)
jmp 0x6aa0
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x21(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movb $0x6, 0x14(%rax)
jmp 0x6aba
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x21(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andq $0xc0ff, %rax           # imm = 0xC0FF
cmpq $0x80fe, %rax           # imm = 0x80FE
jne 0x6af4
movq -0x10(%rbp), %rax
movzbl 0xee(%rax), %eax
addl $0x1, %eax
movzbl %al, %eax
movl %eax, -0x28(%rbp)
jmp 0x6afb
xorl %eax, %eax
movl %eax, -0x28(%rbp)
jmp 0x6afb
movl -0x28(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
addq $0x50, %rax
movsbq -0x21(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x10(%rax)
movq -0x10(%rbp), %rdi
movl $0x8, %edx
movsbl -0x21(%rbp), %esi
callq 0x6420
cmpq $0x0, -0x20(%rbp)
je 0x6b39
movb -0x21(%rbp), %cl
movq -0x20(%rbp), %rax
movb %cl, (%rax)
movb $0x0, -0x1(%rbp)
jmp 0x6b60
jmp 0x6b41
movb -0x21(%rbp), %al
addb $0x1, %al
movb %al, -0x21(%rbp)
jmp 0x69df
cmpq $0x0, -0x20(%rbp)
je 0x6b5c
movq -0x20(%rbp), %rax
movb $-0x1, (%rax)
movb $-0x6, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)