// File: /workspace/github_c_makefile_star2_O0/jech[P]shncpd/state.c
// Function: find_neighbour
struct neighbour *
find_neighbour(struct interface *interface, const unsigned char *id,
               unsigned int eid, const struct sockaddr_in6 *create)
{
    int i;

    if(id_eq(id, myid)) {
        fprintf(stderr, "Attempting to find myself.\n");
        return NULL;
    }

    for(i = 0; i < numneighs; i++) {
        if(neighs[i].interface == interface &&
           id_eq(neighs[i].id, id) && neighs[i].eid == eid) {
            if(create &&
               memcmp(&neighs[i].addr,
                      &create->sin6_addr, sizeof(create->sin6_addr)) != 0 &&
               neighs[i].port == ntohs(create->sin6_port)) {
                debugf("Neighbour changed address.\n");
                memcpy(&neighs[i].addr, create, sizeof(*create));
                neighs[i].port = ntohs(create->sin6_port);
            }
            return &neighs[i];
        }
    }

    if(!create || numneighs >= MAXNEIGHS)
        return NULL;

    memset(&neighs[i], 0, sizeof(struct neighbour));
    neighs[i].interface = interface;
    memcpy(neighs[i].id, id, 4);
    neighs[i].eid = eid;
    memcpy(&neighs[i].addr, &create->sin6_addr, sizeof(create->sin6_addr));
    neighs[i].port = ntohs(create->sin6_port);
    neighs[i].last_contact = now;

    numneighs++;

    republish(1, 1);
    return &neighs[i];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x11cee(%rip), %rsi     # 0x16290
callq 0x48b0
cmpl $0x0, %eax
je 0x45d1
movq 0x11a45(%rip), %rax     # 0x15ff8
movq (%rax), %rdi
leaq 0xdf81(%rip), %rsi      # 0x1253e
movb $0x0, %al
callq 0x21f0
movq $0x0, -0x8(%rbp)
jmp 0x489d
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl 0x11cd7(%rip), %eax     # 0x162b8
jge 0x4771
movslq -0x2c(%rbp), %rcx
leaq 0x128ae(%rip), %rax     # 0x16ea0
shlq $0x6, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
jne 0x4761
movslq -0x2c(%rbp), %rax
leaq 0x1288f(%rip), %rdi     # 0x16ea0
shlq $0x6, %rax
addq %rax, %rdi
addq $0x8, %rdi
movq -0x18(%rbp), %rsi
callq 0x48b0
cmpl $0x0, %eax
je 0x4761
movslq -0x2c(%rbp), %rcx
leaq 0x12867(%rip), %rax     # 0x16ea0
shlq $0x6, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0x4761
cmpq $0x0, -0x28(%rbp)
je 0x4746
movslq -0x2c(%rbp), %rcx
leaq 0x1283e(%rip), %rax     # 0x16ea0
shlq $0x6, %rcx
addq %rcx, %rax
addq $0x14, %rax
movq -0x28(%rbp), %rcx
addq $0x8, %rcx
movups (%rcx), %xmm1
movups (%rax), %xmm0
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
subl $0xffff, %eax           # imm = 0xFFFF
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x4746
movslq -0x2c(%rbp), %rcx
leaq 0x127fe(%rip), %rax     # 0x16ea0
shlq $0x6, %rcx
addq %rcx, %rax
movzwl 0x10(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x22b0
movw %ax, %cx
movl -0x30(%rbp), %eax
movzwl %cx, %ecx
cmpl %ecx, %eax
jne 0x4746
jmp 0x46cc
leaq 0x11b95(%rip), %rax     # 0x16268
cmpl $0x2, (%rax)
jl 0x46eb
movl $0x2, %edi
leaq 0xde76(%rip), %rsi      # 0x1255a
movb $0x0, %al
callq 0xfda0
jmp 0x46ed
movslq -0x2c(%rbp), %rcx
leaq 0x127a8(%rip), %rax     # 0x16ea0
shlq $0x6, %rcx
addq %rcx, %rax
movq -0x28(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x14(%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x1c(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x24(%rax)
movl 0x18(%rcx), %ecx
movl %ecx, 0x2c(%rax)
movq -0x28(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x22b0
movw %ax, %cx
movslq -0x2c(%rbp), %rdx
leaq 0x12765(%rip), %rax     # 0x16ea0
shlq $0x6, %rdx
addq %rdx, %rax
movw %cx, 0x10(%rax)
movslq -0x2c(%rbp), %rcx
leaq 0x1274f(%rip), %rax     # 0x16ea0
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x489d
jmp 0x4763
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x45d8
cmpq $0x0, -0x28(%rbp)
je 0x4781
cmpl $0x28, 0x11b39(%rip)    # 0x162b8
jl 0x478e
movq $0x0, -0x8(%rbp)
jmp 0x489d
movslq -0x2c(%rbp), %rax
leaq 0x12707(%rip), %rdi     # 0x16ea0
shlq $0x6, %rax
addq %rax, %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2170
movq -0x10(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
leaq 0x126e5(%rip), %rax     # 0x16ea0
shlq $0x6, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movslq -0x2c(%rbp), %rcx
leaq 0x126d0(%rip), %rax     # 0x16ea0
shlq $0x6, %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, 0x8(%rax)
movl -0x1c(%rbp), %ecx
movslq -0x2c(%rbp), %rdx
leaq 0x126b2(%rip), %rax     # 0x16ea0
shlq $0x6, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movslq -0x2c(%rbp), %rcx
leaq 0x1269d(%rip), %rax     # 0x16ea0
shlq $0x6, %rcx
addq %rcx, %rax
movq -0x28(%rbp), %rcx
movq 0x8(%rcx), %rdx
movq %rdx, 0x14(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x1c(%rax)
movq -0x28(%rbp), %rax
movzwl 0x2(%rax), %edi
callq 0x22b0
movw %ax, %cx
movslq -0x2c(%rbp), %rdx
leaq 0x12667(%rip), %rax     # 0x16ea0
shlq $0x6, %rdx
addq %rdx, %rax
movw %cx, 0x10(%rax)
movslq -0x2c(%rbp), %rcx
leaq 0x12651(%rip), %rax     # 0x16ea0
shlq $0x6, %rcx
addq %rcx, %rax
leaq 0x11a23(%rip), %rcx     # 0x16280
movq (%rcx), %rdx
movq %rdx, 0x28(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x30(%rax)
movl 0x11a46(%rip), %eax     # 0x162b8
addl $0x1, %eax
movl %eax, 0x11a3d(%rip)     # 0x162b8
movl $0x1, %esi
movl %esi, %edi
callq 0x48e0
movslq -0x2c(%rbp), %rcx
leaq 0x1260e(%rip), %rax     # 0x16ea0
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)