// File: /workspace/github_c_makefile_star2_O2/jech[P]shncpd/prefix.c
// Function: link_assigned_prefixes
struct prefix_list *
link_assigned_prefixes(struct interface *interface,
                       const struct prefix *overlaps)
{
    int i, j;
    struct prefix_list *pl;

    if(interface->type == INTERFACE_ADHOC || interface->type == INTERFACE_MESH)
        return NULL;

    pl = create_prefix_list();
    if(pl == NULL)
        return NULL;

    for(i = 0; i < numneighs; i++) {
        struct node *node;
        unsigned int his_id = ~0;
        if(neighs[i].interface->ifindex != interface->ifindex)
            continue;
        node = find_node(neighs[i].id, 0);
        if(node == NULL || node->neighs == NULL || node->assigned == NULL)
            continue;
        for(j = 0; j < node->numneighs; j++)
            if(id_eq(node->neighs[j].neigh, myid)) {
                his_id = node->neighs[j].lei;
                break;
            }
        if(j == node->numneighs)
            continue;

        for(j = 0; j < node->assigned->numprefixes; j++) {
            struct prefix *p;
            if(node->assigned == NULL)
                continue;
            p = &node->assigned->prefixes[j];
            if(p->eid == his_id &&
               (!overlaps || prefix_overlaps(p, overlaps))) {
                struct prefix_list *pl2;
                pl2 = prefix_list_cons_prefix(pl, p);
                if(pl2 == NULL) {
                    destroy_prefix_list(pl);
                    return NULL;
                }
                pl = pl2;
            }
        }
    }
    return pl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl 0xc(%rdi), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
je 0x9044
movq %rsi, %rbx
movq %rdi, %r14
callq 0x8619
testq %rax, %rax
je 0x9044
movq %rbx, 0x20(%rsp)
leaq 0x83a5(%rip), %r15      # 0x112a8
leaq 0x8f86(%rip), %r13      # 0x11e90
xorl %r12d, %r12d
movq %rax, %rbx
movq %r14, 0x10(%rsp)
movslq (%r15), %rax
cmpq %rax, %r12
jge 0x9046
movq %r12, %rdi
shlq $0x6, %rdi
movq (%r13,%rdi), %rax
movl 0x8(%rax), %eax
cmpl 0x8(%r14), %eax
jne 0x8fd7
addq %r13, %rdi
addq $0x8, %rdi
xorl %esi, %esi
callq 0x3d24
testq %rax, %rax
je 0x8fd7
movq 0x40(%rax), %rbp
testq %rbp, %rbp
je 0x8fd7
movq %rbx, (%rsp)
movq 0x50(%rax), %rbx
testq %rbx, %rbx
je 0x8fa6
movq %rax, 0x18(%rsp)
movl 0x48(%rax), %eax
testl %eax, %eax
movl $0x0, %r15d
movl %eax, 0xc(%rsp)
cmovgl %eax, %r15d
xorl %r13d, %r13d
leaq 0x82f7(%rip), %r14      # 0x11280
cmpq %r13, %r15
je 0x8fac
movq %rbp, %rdi
movq %r14, %rsi
callq 0x8ac1
testl %eax, %eax
jne 0x8fb2
incq %r13
addq $0xc, %rbp
jmp 0x8f89
movq (%rsp), %rbx
jmp 0x8fd7
pushq $-0x1
popq %r14
jmp 0x8fb9
movl 0x8(%rbp), %r14d
movl %r13d, %r15d
cmpl 0xc(%rsp), %r15d
jne 0x8fdf
movq 0x10(%rsp), %r14
movq (%rsp), %rbx
leaq 0x82d8(%rip), %r15      # 0x112a8
leaq 0x8eb9(%rip), %r13      # 0x11e90
incq %r12
jmp 0x8f15
xorl %r15d, %r15d
xorl %r13d, %r13d
movswq 0x8(%rbx), %rax
cmpq %rax, %r13
jge 0x8fc0
movq (%rbx), %rbp
cmpl %r14d, 0x18(%rbp,%r15)
jne 0x9033
addq %r15, %rbp
movq 0x20(%rsp), %rsi
testq %rsi, %rsi
je 0x9012
movq %rbp, %rdi
callq 0x8904
testl %eax, %eax
je 0x9033
movq (%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x863f
testq %rax, %rax
je 0x903c
movq 0x18(%rsp), %rcx
movq 0x50(%rcx), %rbx
movq %rax, (%rsp)
incq %r13
addq $0x1c, %r15
jmp 0x8fe5
movq %rbx, %rdi
callq 0x8624
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq