// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movl %edi, -0x4(%rbp)
callq 0xd580
movq %rax, %rdi
callq 0xcbd0
movq %rax, -0x10(%rbp)
callq 0xd6f0
movq %rax, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0xe815
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
leaq 0x7bd9(%rip), %rcx      # 0x162b0
cmpl (%rcx), %eax
jge 0xe813
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movslq -0x1c(%rbp), %rdx
leaq 0x7bcc(%rip), %rcx      # 0x162c0
imulq $0x98, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x68(%rcx), %eax
jge 0xe7a2
movslq -0x1c(%rbp), %rcx
leaq 0x7bae(%rip), %rax      # 0x162c0
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
cmpl $0x0, 0x8(%rax)
je 0xe754
movslq -0x1c(%rbp), %rcx
leaq 0x7b93(%rip), %rax      # 0x162c0
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq 0x60(%rax), %rdi
movslq -0x20(%rbp), %rax
imulq $0x70, %rax, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0xc620
cmpl $0x0, %eax
jne 0xe794
movslq -0x1c(%rbp), %rax
leaq 0x7b61(%rip), %rdi      # 0x162c0
imulq $0x98, %rax, %rax
addq %rax, %rdi
movslq -0x1c(%rbp), %rcx
leaq 0x7b4c(%rip), %rax      # 0x162c0
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq 0x60(%rax), %rsi
movslq -0x20(%rbp), %rax
imulq $0x70, %rax, %rax
addq %rax, %rsi
callq 0xdf30
jmp 0xe79d
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xe6e6
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0xe803
movslq -0x1c(%rbp), %rax
leaq 0x7afd(%rip), %rdi      # 0x162c0
imulq $0x98, %rax, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movslq -0x20(%rbp), %rax
imulq $0x1c, %rax, %rax
addq %rax, %rsi
movl $0x1, %edx
callq 0xdde0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xe7f6
jmp 0xe7f8
jmp 0xe7f8
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xe7a9
jmp 0xe805
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe6cd
jmp 0xe815
leaq 0x7a64(%rip), %rax      # 0x16280
movq (%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
leaq 0x7a68(%rip), %rcx      # 0x162b0
cmpl (%rcx), %eax
jge 0xeb6f
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movslq -0x1c(%rbp), %rdx
leaq 0x7a5b(%rip), %rcx      # 0x162c0
imulq $0x98, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x68(%rcx), %eax
jge 0xeb5f
movslq -0x1c(%rbp), %rcx
leaq 0x7a3d(%rip), %rax      # 0x162c0
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq 0x60(%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movslq -0x1c(%rbp), %rax
leaq 0x7a15(%rip), %rdi      # 0x162c0
imulq $0x98, %rax, %rax
addq %rax, %rdi
movq -0x48(%rbp), %rsi
callq 0xd360
movq %rax, -0x50(%rbp)
callq 0xd250
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x40(%rcx)
movb %al, -0x61(%rbp)
jle 0xe8f8
movq -0x48(%rbp), %rsi
addq $0x40, %rsi
leaq 0x7996(%rip), %rdi      # 0x16280
callq 0xf900
cmpl $0x0, %eax
setg %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0xe913
cmpl $0x0, -0x5c(%rbp)
je 0xe99d
cmpl $0x0, -0x4(%rbp)
jne 0xe926
movq -0x48(%rbp), %rdi
addq $0x40, %rdi
callq 0xfc10
movslq -0x1c(%rbp), %rax
leaq 0x798f(%rip), %rdi      # 0x162c0
imulq $0x98, %rax, %rax
addq %rax, %rdi
movslq -0x1c(%rbp), %rcx
leaq 0x797a(%rip), %rax      # 0x162c0
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq 0x60(%rax), %rsi
movslq -0x20(%rbp), %rax
imulq $0x70, %rax, %rax
addq %rax, %rsi
cmpl $0x0, -0x4(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
movq -0x58(%rbp), %rcx
movq -0x50(%rbp), %r8
callq 0xe020
movl %eax, -0x60(%rbp)
movb $0x1, %al
cmpl $0x0, -0x24(%rbp)
movb %al, -0x62(%rbp)
jne 0xe992
cmpl $0x0, -0x60(%rbp)
setne %al
movb %al, -0x62(%rbp)
movb -0x62(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jle 0xeb1d
movq -0x48(%rbp), %rsi
addq $0x50, %rsi
leaq 0x78c5(%rip), %rdi      # 0x16280
callq 0xf900
cmpl $0x0, %eax
jle 0xeb1d
jmp 0xe9cb
leaq 0x7896(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0xe9ea
movl $0x2, %edi
leaq 0x4905(%rip), %rsi      # 0x132e8
movb $0x0, %al
callq 0xfda0
jmp 0xe9ec
movq -0x48(%rbp), %rdi
addq $0x1c, %rdi
callq 0xc010
leaq 0x7868(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0xea30
movslq -0x1c(%rbp), %rcx
leaq 0x78b0(%rip), %rax      # 0x162c0
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdx
movl $0x2, %edi
leaq 0x4894(%rip), %rsi      # 0x132bd
movb $0x0, %al
callq 0xfda0
jmp 0xea32
movslq -0x1c(%rbp), %rcx
leaq 0x7883(%rip), %rax      # 0x162c0
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %edi
movslq -0x1c(%rbp), %rcx
leaq 0x786b(%rip), %rax      # 0x162c0
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movq -0x48(%rbp), %rdx
addq $0x1c, %rdx
movq -0x48(%rbp), %rax
movzbl 0x2c(%rax), %ecx
xorl %eax, %eax
movl %eax, %r8d
xorl %r9d, %r9d
movl $0x1, (%rsp)
callq 0xf490
movl %eax, -0x60(%rbp)
cmpl $0x0, -0x60(%rbp)
jl 0xeaf8
movq -0x48(%rbp), %rax
movl $0x1, 0x3c(%rax)
movl $0x1, -0x24(%rbp)
xorl %eax, %eax
movl %eax, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x8b60
movslq -0x1c(%rbp), %rax
leaq 0x7804(%rip), %rdi      # 0x162c0
imulq $0x98, %rax, %rax
addq %rax, %rdi
movq -0x48(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0xe420
movl %eax, -0x60(%rbp)
movb $0x1, %al
cmpl $0x0, -0x24(%rbp)
movb %al, -0x63(%rbp)
jne 0xeaeb
cmpl $0x0, -0x60(%rbp)
setne %al
movb %al, -0x63(%rbp)
movb -0x63(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
jmp 0xeb10
movq 0x74f9(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0x47ee(%rip), %rsi      # 0x132f7
movb $0x0, %al
callq 0x21f0
movq -0x48(%rbp), %rdi
addq $0x50, %rdi
callq 0xfc10
movq -0x48(%rbp), %rsi
addq $0x40, %rsi
leaq -0x38(%rbp), %rdi
callq 0xf980
movq -0x48(%rbp), %rsi
addq $0x50, %rsi
leaq -0x38(%rbp), %rdi
callq 0xf980
movq -0x58(%rbp), %rdi
callq 0xc2d0
movq -0x50(%rbp), %rdi
callq 0xc2d0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xe857
jmp 0xeb61
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xe83e
movq -0x10(%rbp), %rdi
callq 0xc2d0
movq -0x18(%rbp), %rdi
callq 0xc2d0
leaq 0x76b0(%rip), %rax      # 0x16238
movq -0x38(%rbp), %rcx
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x24(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq