// File: /workspace/github_c_makefile_star2_O1/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 0xa2bb
movq %rsi, %rbx
movq %rdi, %r14
movl $0x1, %edi
movl $0x10, %esi
callq 0x21b0
testq %rax, %rax
je 0xa2bb
movq %rax, %r15
leaq 0x918d(%rip), %r13      # 0x132a8
cmpl $0x0, (%r13)
jle 0xa2be
movq %rbx, 0x20(%rsp)
leaq 0x9d5e(%rip), %rbp      # 0x13e90
xorl %ebx, %ebx
movq %rbx, %rdi
shlq $0x6, %rdi
movq (%rbp,%rdi), %rax
movl 0x8(%rax), %eax
movl $0x4, %ecx
cmpl 0x8(%r14), %eax
jne 0xa1b0
addq %rbp, %rdi
addq $0x8, %rdi
xorl %esi, %esi
callq 0x4b4e
testq %rax, %rax
je 0xa1ab
movq %rax, %r12
movq 0x40(%rax), %rcx
testq %rcx, %rcx
je 0xa1ab
cmpq $0x0, 0x50(%r12)
je 0xa1ab
movl 0x48(%r12), %eax
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %edx, %edx
testl %eax, %eax
jle 0xa1a7
movl (%rcx), %esi
leaq 0x90f1(%rip), %rdi      # 0x13280
cmpl (%rdi), %esi
je 0xa1a3
incq %rdx
addq $0xc, %rcx
cmpq %rdx, %rax
jne 0xa186
movl %eax, %edx
jmp 0xa1a7
movl 0x8(%rcx), %r8d
cmpl %eax, %edx
jne 0xa1ce
movl $0x4, %ecx
testb $0xb, %cl
jne 0xa2bb
incq %rbx
movslq (%r13), %rax
cmpq %rax, %rbx
jl 0xa134
jmp 0xa2be
movq 0x50(%r12), %rax
cmpw $0x0, 0x8(%rax)
jle 0xa295
movq %r15, 0x10(%rsp)
movq %r14, 0x18(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
movl %r8d, 0xc(%rsp)
testq %rax, %rax
je 0xa255
movq (%rax), %r13
xorl %ebp, %ebp
cmpl %r8d, 0x18(%r13,%r15)
jne 0xa25a
addq %r15, %r13
movq 0x20(%rsp), %rsi
testq %rsi, %rsi
je 0xa21d
movq %r13, %rdi
callq 0x9aa4
testl %eax, %eax
je 0xa24e
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x97de
movq %rax, %r13
testq %rax, %rax
jne 0xa240
movq %rbp, %rdi
callq 0x97c3
movq %rbp, %rax
xorl %ebp, %ebp
testq %r13, %r13
sete %bpl
movq %rax, 0x10(%rsp)
movl 0xc(%rsp), %r8d
jmp 0xa25a
movl $0xa, %ebp
cmpl $0xa, %ebp
je 0xa263
testl %ebp, %ebp
jne 0xa29c
incq %r14
movq 0x50(%r12), %rax
movswq 0x8(%rax), %rcx
addq $0x1c, %r15
cmpq %rcx, %r14
jl 0xa1f3
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %r15
leaq 0x901a(%rip), %r13      # 0x132a8
leaq 0x9bfb(%rip), %rbp      # 0x13e90
xorl %ecx, %ecx
jmp 0xa1b0
movl %ebp, %ecx
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %r15
leaq 0x8ff9(%rip), %r13      # 0x132a8
leaq 0x9bda(%rip), %rbp      # 0x13e90
jmp 0xa1b0
xorl %r15d, %r15d
movq %r15, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq