// File: /workspace/github_c_makefile_star2_O1/jech[P]shncpd/prefix.c
// Function: prefix_assignment_1
int
prefix_assignment_1(struct interface *interface,
                    struct assigned_prefix *ap,
                    int backoff_triggered,
                    const struct prefix_list *all_assigned,
                    const struct prefix_list *link_assigned)
{
    struct prefix best;
    int have_best, have_assigned, rc;
    int republish = 0;

 again:

    have_assigned = ap->assigned.plen > 0;
    have_best =
        best_prefix(&ap->delegated, interface->ifindex,
                    have_assigned && ap->published ? &ap->assigned : NULL,
                    link_assigned, &best);

    if(backoff_triggered && have_assigned) {
        if(!ap->published) {
            ap->published = 1;
            republish = 1;
        }
        if(!ap->applied)
            ts_add_msec(&ap->apply_timer, &now, 2 * FLOODING_DELAY);
    } else if(!have_best && !have_assigned) {
        if(ap->backoff_timer.tv_sec == 0) {
            if(!backoff_triggered) {
                ts_add_random(&ap->backoff_timer, &now, BACKOFF_MAX_DELAY);
            } else {
                rc = random_prefix(&ap->assigned,
                                   select_plen(&ap->delegated,
                                               interface->type),
                                   0, 1,
                                   &ap->delegated, all_assigned);
                if(rc > 0) {
                    ap->assigned.prio = 2;
                    memcpy(ap->assigned.id, myid, 4);
                    ap->assigned.eid = interface->ifindex;
                    ts_add_msec(&ap->apply_timer, &now, 2 * FLOODING_DELAY);
                    rc = publish_prefix(interface, ap, 1);
                    if(rc < 0) {
                        fprintf(stderr, "Couldn't publish prefix.\n");
                        memset(&ap->assigned, 0, sizeof(ap->assigned));
                    }
                    republish = 1;
                } else {
                    fprintf(stderr, "Couldn't draw random prefix.\n");
                }
                ap->applied = 0;
            }
        }
    } else if(have_best && !have_assigned) {
        ts_zero(&ap->backoff_timer);
        ap->assigned = best;
        publish_prefix(interface, ap, 0);
        ts_add_msec(&ap->apply_timer, &now, 2 * FLOODING_DELAY);
    } else if(!have_best && have_assigned) {
        if(!prefix_valid(&ap->assigned, all_assigned, link_assigned)) {
            destroy_assigned(interface, ap);
            backoff_triggered = 0;
            goto again;
        }

        if(!ap->published) {
            /* Adopt. */
            ts_zero(&ap->apply_timer);
            ap->assigned.prio = 2;
            backoff_triggered = 1;
            goto again;
        }
    } else {
        ts_zero(&ap->backoff_timer);
        if(prefix_eq(&best, &ap->assigned)) {
            publish_prefix(interface, ap, 0);
            if(!ap->applied && ap->apply_timer.tv_sec == 0) {
                ts_add_msec(&ap->apply_timer, &now, 2 * FLOODING_DELAY);
            }
        } else {
            destroy_assigned(interface, ap);
            goto again;
        }
    }

    return republish;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r12
movq %rcx, 0x20(%rsp)
movq %rsi, %rbx
movq %rdi, 0x18(%rsp)
leaq 0x1c(%rsi), %rax
movq %rax, 0x10(%rsp)
leaq 0x40(%rsi), %rbp
leaq 0x50(%rsi), %rax
movq %rax, 0x8(%rsp)
testl %edx, %edx
setne %r14b
movb %r14b, 0x7(%rsp)
notb %r14b
movb 0x2c(%rbx), %r13b
testb %r13b, %r13b
je 0xaa62
cmpl $0x0, 0x38(%rbx)
je 0xaa62
movq 0x10(%rsp), %rdx
jmp 0xaa64
xorl %edx, %edx
testb %r13b, %r13b
sete %r15b
movq %rbx, %rdi
movq %r12, %rcx
leaq 0x2c(%rsp), %r8
callq 0xa4d1
orb %r14b, %r15b
testb $0x1, %r15b
je 0xab3b
testb %r13b, %r13b
jne 0xaa95
testl %eax, %eax
je 0xab76
testb %r13b, %r13b
jne 0xaaa2
testl %eax, %eax
jne 0xabee
testb %r13b, %r13b
je 0xaaab
testl %eax, %eax
je 0xaaf0
movq %rbp, %rdi
callq 0xbc1e
movb 0x3c(%rsp), %al
cmpb 0x2c(%rbx), %al
jne 0xaade
movdqu 0x2c(%rsp), %xmm0
movq 0x10(%rsp), %rax
movdqu (%rax), %xmm1
pcmpeqb %xmm0, %xmm1
pmovmskb %xmm1, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0xac31
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0xa7af
jmp 0xaa4c
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %r12, %rdx
callq 0x9d03
testl %eax, %eax
setne %r14b
je 0xab29
cmpl $0x0, 0x38(%rbx)
jne 0xac29
movq 0x8(%rsp), %rdi
callq 0xbc1e
movw $0x2, 0x2e(%rbx)
jmp 0xaa44
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0xa7af
jmp 0xaa44
xorl %r14d, %r14d
cmpl $0x0, 0x38(%rbx)
jne 0xab51
movl $0x1, 0x38(%rbx)
movl $0x1, %r14d
cmpl $0x0, 0x3c(%rbx)
jne 0xace4
leaq 0x870e(%rip), %rsi      # 0x13270
movq 0x8(%rsp), %rdi
movl $0x2710, %edx           # imm = 0x2710
callq 0xbae6
jmp 0xace4
xorl %r14d, %r14d
cmpq $0x0, 0x40(%rbx)
jne 0xace4
testb $0x1, 0x7(%rsp)
je 0xac55
movl $0x80, %esi
movq 0x18(%rsp), %rax
cmpl $0x3, 0xc(%rax)
je 0xac79
movzbl 0x10(%rbx), %eax
cmpl $0x60, %eax
jb 0xac6b
cmpl $0x0, (%rbx)
jne 0xac6b
cmpl $0x0, 0x4(%rbx)
jne 0xac6b
cmpl $0xffff0000, 0x8(%rbx)  # imm = 0xFFFF0000
jne 0xac6b
cmpl $0x75, %eax
movl $0x74, %ecx
cmovgel %eax, %ecx
cmpl $0x7a, %ecx
movl $0x7a, %esi
cmovll %ecx, %esi
addl $0x4, %esi
jmp 0xac79
movq %rbp, %rdi
callq 0xbc1e
movups 0x2c(%rsp), %xmm0
movups 0x38(%rsp), %xmm1
movq 0x10(%rsp), %rax
movups %xmm1, 0xc(%rax)
movups %xmm0, (%rax)
movl $0x0, 0x38(%rbx)
leaq 0x8656(%rip), %rsi      # 0x13270
movq 0x8(%rsp), %rdi
movl $0x2710, %edx           # imm = 0x2710
callq 0xbae6
xorl %r14d, %r14d
jmp 0xace4
movl $0x0, 0x38(%rbx)
xorl %r14d, %r14d
cmpl $0x0, 0x3c(%rbx)
jne 0xace4
cmpq $0x0, 0x50(%rbx)
jne 0xace4
jmp 0xab5b
leaq 0x8614(%rip), %rsi      # 0x13270
movq %rbp, %rdi
movl $0xfa0, %edx            # imm = 0xFA0
callq 0xbbb3
jmp 0xace4
xorl %esi, %esi
cmpb $0x3f, %al
setae %sil
shll $0x4, %esi
orl $0x40, %esi
movl $0x1, %r14d
movq 0x10(%rsp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
movq %rbx, %r8
movq 0x20(%rsp), %r9
callq 0x9e35
testl %eax, %eax
je 0xacf6
movw $0x2, 0x2e(%rbx)
leaq 0x85d7(%rip), %r15      # 0x13280
movl (%r15), %eax
movl %eax, 0x30(%rbx)
movq 0x18(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x34(%rbx)
leaq 0x85af(%rip), %rsi      # 0x13270
movq 0x8(%rsp), %rdi
movl $0x2710, %edx           # imm = 0x2710
callq 0xbae6
movl (%r15), %eax
movl %eax, 0x30(%rbx)
movl $0x1, 0x38(%rbx)
movl $0x0, 0x3c(%rbx)
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x300a
xorl %r14d, %r14d
jmp 0xacdd