// File: /workspace/github_c_makefile_star2_O2/jech[P]shncpd/prefix.c
// Function: prefix_assignment
int
prefix_assignment(int changed)
{
    struct prefix_list *delegated =
        filter_included(all_delegated_prefixes());
    struct prefix_list *addresses = all_node_addresses();
    int i, j;
    int republish = 0;
    struct timespec again;

    if(changed) {
        for(i = 0; i < numinterfaces; i++) {
            /* Flush any delegated prefixes that have disappeared. */
            j = 0;
            while(j < interfaces[i].numassigned) {
                if(interfaces[i].ifindex == 0 ||
                   !prefix_list_member(&interfaces[i].assigned[j].delegated,
                                       delegated))
                    flush_assigned(&interfaces[i], &interfaces[i].assigned[j]);
                else
                    j++;
            }
            /* Add any delegated prefixes that have appeared. */
            for(j = 0; j < delegated->numprefixes; j++) {
                struct assigned_prefix *ap =
                    find_assigned(&interfaces[i],
                                  &delegated->prefixes[j], 1);
                if(ap == NULL)
                    continue;
            }
        }
    }

    again = now;
    again.tv_sec += 120;

    for(i = 0; i < numinterfaces; i++) {
        for(j = 0; j < interfaces[i].numassigned; j++) {
            struct assigned_prefix *ap = &interfaces[i].assigned[j];
            struct prefix_list *link_assigned =
                link_assigned_prefixes(&interfaces[i], &ap->delegated);
            struct prefix_list *all_assigned = all_assigned_prefixes();
            int bt =
                ap->backoff_timer.tv_sec > 0 &&
                ts_compare(&now, &ap->backoff_timer) > 0;
            int rc;
            if(changed || bt) {
                if(!changed)
                    ts_zero(&ap->backoff_timer);
                rc = prefix_assignment_1(&interfaces[i],
                                         &interfaces[i].assigned[j],
                                         !changed,
                                         all_assigned, link_assigned);
                republish = republish || rc;
            }

            if(ap->apply_timer.tv_sec > 0 &&
               ts_compare(&now, &ap->apply_timer) > 0) {
                debugf("Adding prefix ");
                debug_prefix(&ap->assigned);
                debugf(" to interface %s.\n", interfaces[i].ifname);
                rc = kernel_route(interfaces[i].ifindex, interfaces[i].ifname,
                                  &ap->assigned.p, ap->assigned.plen,
                                  NULL, 0, 1);
                if(rc >= 0) {
                    ap->applied = 1;
                    republish = 1;
                    schedule_ra(NULL, 1, 0);
                    rc = address_assignment_1(&interfaces[i], ap, addresses);
                    republish = republish || rc;
                } else {
                    fprintf(stderr, "Couldn't apply prefix.\n");
                }
                ts_zero(&ap->apply_timer);
            }

            ts_min(&again, &ap->backoff_timer);
            ts_min(&again, &ap->apply_timer);

            destroy_prefix_list(all_assigned);
            destroy_prefix_list(link_assigned);
        }
    }

    destroy_prefix_list(delegated);
    destroy_prefix_list(addresses);

    prefix_assignment_time = again;
    return republish;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %edi, %ebx
callq 0x9058
movq %rax, %rbp
movq %rax, %rdi
callq 0x8acb
callq 0x912d
movq %rax, 0x30(%rsp)
movl %ebx, 0x14(%rsp)
testl %ebx, %ebx
movq %rbp, 0x20(%rsp)
je 0x9cd1
xorl %r12d, %r12d
pushq $0x1
popq %rbx
leaq 0x765f(%rip), %rax      # 0x112a0
movslq (%rax), %rax
cmpq %rax, %r12
jge 0x9cd1
imulq $0x98, %r12, %r14
addq 0x7385(%rip), %r14      # 0x10fe0
xorl %ebp, %ebp
movl %ebp, %ebp
imulq $0x70, %rbp, %r13
cmpl 0x68(%r14), %ebp
jge 0x9c9a
cmpl $0x0, 0x8(%r14)
movq 0x60(%r14), %r15
je 0x9c86
leaq (%r15,%r13), %rdi
movq 0x20(%rsp), %rsi
callq 0x87dc
testl %eax, %eax
jne 0x9c96
addq %r13, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x96c6
jmp 0x9c63
incl %ebp
jmp 0x9c5d
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x20(%rsp), %rbp
movswq 0x8(%rbp), %rax
cmpq %rax, %r13
jge 0x9cc9
movq (%rbp), %rsi
addq %r15, %rsi
movq %r14, %rdi
movl %ebx, %edx
callq 0x95e7
incq %r13
addq $0x1c, %r15
jmp 0x9ca5
incq %r12
jmp 0x9c3a
xorl %eax, %eax
movl 0x14(%rsp), %r12d
testl %r12d, %r12d
sete %al
movl %eax, 0x28(%rsp)
leaq 0x7587(%rip), %rax      # 0x11270
movups (%rax), %xmm0
leaq 0x60(%rsp), %rax
movaps %xmm0, (%rax)
addq $0x78, (%rax)
xorl %ecx, %ecx
xorl %ebx, %ebx
leaq 0x759d(%rip), %rax      # 0x112a0
movslq (%rax), %rax
cmpq %rax, %rcx
jge 0x9f23
movq %rcx, 0x40(%rsp)
imulq $0x98, %rcx, %rbp
addq 0x72be(%rip), %rbp      # 0x10fe0
xorl %r13d, %r13d
xorl %ecx, %ecx
movslq 0x68(%rbp), %rax
cmpq %rax, %rcx
jge 0x9f11
movq %rcx, 0x58(%rsp)
movq 0x60(%rbp), %r14
leaq (%r14,%r13), %rsi
movq %rbp, %rdi
movq %rsi, 0x48(%rsp)
callq 0x8ec6
movq %rax, %r15
callq 0x8e24
movq %rax, 0x38(%rsp)
leaq (%r14,%r13), %rsi
addq $0x40, %rsi
cmpq $0x0, (%rsi)
movq %rsi, 0x18(%rsp)
jle 0x9d81
leaq 0x74fb(%rip), %rdi      # 0x11270
callq 0xa742
testl %eax, %eax
setg %al
jmp 0x9d83
xorl %eax, %eax
testl %r12d, %r12d
movq %r15, 0x50(%rsp)
jne 0x9d91
testb %al, %al
je 0x9dc4
testl %r12d, %r12d
jne 0x9da0
movq 0x18(%rsp), %rdi
callq 0xa866
movq 0x60(%rbp), %rsi
addq %r13, %rsi
movq %rbp, %rdi
movl 0x28(%rsp), %edx
movq 0x38(%rsp), %rcx
movq %r15, %r8
callq 0x975d
xorl %ecx, %ecx
orl %eax, %ebx
setne %cl
movl %ecx, %ebx
leaq (%r14,%r13), %r15
addq $0x50, %r15
cmpq $0x0, (%r15)
jle 0x9e7e
leaq 0x7493(%rip), %rdi      # 0x11270
movq %r15, %rsi
callq 0xa742
testl %eax, %eax
jle 0x9e7e
movl %ebx, 0x2c(%rsp)
leaq 0x7460(%rip), %rbx      # 0x11258
cmpl $0x2, (%rbx)
jge 0x9ec0
leaq (%r14,%r13), %r12
addq $0x1c, %r12
movq %r12, %rdi
callq 0x8448
cmpl $0x2, (%rbx)
jge 0x9ed6
movl 0x8(%rbp), %edi
movq (%rbp), %rsi
movzbl 0x2c(%r14,%r13), %ecx
movl $0x1, (%rsp)
movq %r12, %rdx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xa48f
testl %eax, %eax
movl 0x2c(%rsp), %ebx
js 0x9ef0
movl $0x1, 0x3c(%r14,%r13)
xorl %edi, %edi
pushq $0x1
popq %rbx
movl %ebx, %esi
xorl %edx, %edx
callq 0x6832
movq %rbp, %rdi
movq 0x48(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x9a3b
movl 0x14(%rsp), %r12d
movq %r15, %rdi
callq 0xa866
movq 0x18(%rsp), %rsi
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0xa765
movq %r14, %rdi
movq %r15, %rsi
callq 0xa765
movq 0x38(%rsp), %rdi
callq 0x8624
movq 0x50(%rsp), %rdi
callq 0x8624
movq 0x58(%rsp), %rcx
incq %rcx
addq $0x70, %r13
jmp 0x9d27
pushq $0x2
popq %rdi
leaq 0x3288(%rip), %rsi      # 0xd152
xorl %eax, %eax
callq 0x23c0
jmp 0x9e01
movq (%rbp), %rdx
pushq $0x2
popq %rdi
leaq 0x3243(%rip), %rsi      # 0xd127
xorl %eax, %eax
callq 0x23c0
jmp 0x9e1a
movq 0x7101(%rip), %rax      # 0x10ff8
movq (%rax), %rcx
leaq 0x3260(%rip), %rdi      # 0xd161
pushq $0x17
popq %rsi
pushq $0x1
popq %rdx
callq 0x2340
jmp 0x9e71
movq 0x40(%rsp), %rcx
incq %rcx
movq 0x20(%rsp), %rbp
jmp 0x9cfc
movq %rbp, %rdi
callq 0x8624
movq 0x30(%rsp), %rdi
callq 0x8624
leaq 0x72ec(%rip), %rax      # 0x11228
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rax)
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq