// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r12
leaq 0xd90f(%rip), %rsi      # 0x11280
movq %r15, %rdi
callq 0x3b13
testl %eax, %eax
jne 0x3adf
movq %rbx, 0x10(%rsp)
movl 0xd91c(%rip), %eax      # 0x112a8
xorl %r14d, %r14d
testl %eax, %eax
movl %eax, 0xc(%rsp)
cmovgl %eax, %r14d
leaq 0xe504(%rip), %r13      # 0x11ea4
movq %r14, %rbx
subq $0x1, %rbx
jb 0x39cf
cmpq %r12, -0x14(%r13)
jne 0x39c9
leaq -0xc(%r13), %rdi
movq %r15, %rsi
callq 0x3b13
testl %eax, %eax
je 0x39c9
cmpl %ebp, -0x8(%r13)
je 0x3a65
addq $0x40, %r13
jmp 0x39a3
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
sete %al
movl 0xc(%rsp), %esi
cmpl $0x28, %esi
setge %cl
orb %al, %cl
je 0x39ef
xorl %ebx, %ebx
jmp 0x3acd
shlq $0x6, %r14
leaq 0xe496(%rip), %rax      # 0x11e90
leaq (%rax,%r14), %rbx
xorps %xmm0, %xmm0
movaps %xmm0, (%r14,%rax)
movaps %xmm0, 0x30(%r14,%rax)
movaps %xmm0, 0x20(%r14,%rax)
movaps %xmm0, 0x10(%r14,%rax)
movq %r12, (%r14,%rax)
movl (%r15), %ecx
movl %ecx, 0x8(%r14,%rax)
movl %ebp, 0xc(%r14,%rax)
movups 0x8(%rdx), %xmm0
movups %xmm0, 0x14(%r14,%rax)
movzwl 0x2(%rdx), %ecx
rolw $0x8, %cx
movw %cx, 0x10(%r14,%rax)
leaq 0xd828(%rip), %rcx      # 0x11270
movups (%rcx), %xmm0
movups %xmm0, 0x28(%r14,%rax)
incl %esi
movl %esi, 0xd84f(%rip)      # 0x112a8
pushq $0x1
popq %rdi
movl %edi, %esi
callq 0x3b1d
jmp 0x3acd
leaq -0x14(%r13), %r14
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0x3aca
movdqu 0x8(%rbx), %xmm0
movdqu (%r13), %xmm1
pcmpeqb %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x3aca
movzwl 0x2(%rbx), %eax
rolw $0x8, %ax
cmpw %ax, -0x4(%r13)
jne 0x3aca
leaq 0xd7b5(%rip), %rax      # 0x11258
cmpl $0x2, (%rax)
jge 0x3b00
movdqu (%rbx), %xmm0
movdqu 0xc(%rbx), %xmm1
movdqu %xmm1, 0xc(%r13)
movdqu %xmm0, (%r13)
movzwl 0x2(%rbx), %eax
rolw $0x8, %ax
movw %ax, -0x4(%r13)
movq %r14, %rbx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xd512(%rip), %rax      # 0x10ff8
movq (%rax), %rcx
leaq 0x89ae(%rip), %rdi      # 0xc49e
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0x2340
jmp 0x39e8
leaq 0x89b3(%rip), %rsi      # 0xc4ba
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x23c0
jmp 0x3aa8