// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x0, %eax
setg %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0xe088
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0xe088
movq -0x10(%rbp), %rax
addq $0x1c, %rax
movq %rax, -0x68(%rbp)
jmp 0xe090
xorl %eax, %eax
movq %rax, -0x68(%rbp)
jmp 0xe090
movl -0x58(%rbp), %esi
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0xd830
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xe0fb
cmpl $0x0, -0x4c(%rbp)
je 0xe0fb
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jne 0xe0d3
movq -0x10(%rbp), %rax
movl $0x1, 0x38(%rax)
movl $0x1, -0x54(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
jne 0xe0f6
movq -0x10(%rbp), %rdi
addq $0x50, %rdi
leaq 0x8194(%rip), %rsi      # 0x16280
movl $0x2710, %edx           # imm = 0x2710
callq 0xfac0
jmp 0xe392
cmpl $0x0, -0x48(%rbp)
jne 0xe240
cmpl $0x0, -0x4c(%rbp)
jne 0xe240
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0xe23b
cmpl $0x0, -0x14(%rbp)
jne 0xe142
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
leaq 0x814d(%rip), %rsi      # 0x16280
movl $0xfa0, %edx            # imm = 0xFA0
callq 0xfba0
jmp 0xe239
movq -0x10(%rbp), %rax
addq $0x1c, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xe3a0
movq -0x70(%rbp), %rdi
movl %eax, %esi
movq -0x10(%rbp), %r8
movq -0x20(%rbp), %r9
xorl %edx, %edx
movl $0x1, %ecx
callq 0xcea0
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
jle 0xe216
movq -0x10(%rbp), %rax
movw $0x2, 0x2e(%rax)
movq -0x10(%rbp), %rax
leaq 0x80f6(%rip), %rcx      # 0x16290
movl (%rcx), %ecx
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x34(%rax)
movq -0x10(%rbp), %rdi
addq $0x50, %rdi
leaq 0x80c4(%rip), %rsi      # 0x16280
movl $0x2710, %edx           # imm = 0x2710
callq 0xfac0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x1, %edx
callq 0xd950
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x50(%rbp)
jge 0xe20d
movq 0x7e10(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0x5060(%rip), %rsi      # 0x13252
movb $0x0, %al
callq 0x21f0
movq -0x10(%rbp), %rdi
addq $0x1c, %rdi
xorl %esi, %esi
movl $0x1c, %edx
callq 0x2170
movl $0x1, -0x54(%rbp)
jmp 0xe22e
movq 0x7ddb(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0x5045(%rip), %rsi      # 0x1326c
movb $0x0, %al
callq 0x21f0
movq -0x10(%rbp), %rax
movl $0x0, 0x3c(%rax)
jmp 0xe23b
jmp 0xe390
cmpl $0x0, -0x48(%rbp)
je 0xe2a8
cmpl $0x0, -0x4c(%rbp)
jne 0xe2a8
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
callq 0xfc10
movq -0x10(%rbp), %rax
movq -0x44(%rbp), %rcx
movq %rcx, 0x1c(%rax)
movq -0x3c(%rbp), %rcx
movq %rcx, 0x24(%rax)
movq -0x34(%rbp), %rcx
movq %rcx, 0x2c(%rax)
movl -0x2c(%rbp), %ecx
movl %ecx, 0x34(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0xd950
movq -0x10(%rbp), %rdi
addq $0x50, %rdi
leaq 0x7fe7(%rip), %rsi      # 0x16280
movl $0x2710, %edx           # imm = 0x2710
callq 0xfac0
jmp 0xe38e
cmpl $0x0, -0x48(%rbp)
jne 0xe316
cmpl $0x0, -0x4c(%rbp)
je 0xe316
movq -0x10(%rbp), %rdi
addq $0x1c, %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xcc80
cmpl $0x0, %eax
jne 0xe2e7
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xdc90
movl $0x0, -0x14(%rbp)
jmp 0xe042
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jne 0xe314
movq -0x10(%rbp), %rdi
addq $0x50, %rdi
callq 0xfc10
movq -0x10(%rbp), %rax
movw $0x2, 0x2e(%rax)
movl $0x1, -0x14(%rbp)
jmp 0xe042
jmp 0xe38c
movq -0x10(%rbp), %rdi
addq $0x40, %rdi
callq 0xfc10
movq -0x10(%rbp), %rsi
addq $0x1c, %rsi
leaq -0x44(%rbp), %rdi
callq 0xc5c0
cmpl $0x0, %eax
je 0xe378
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0xd950
movq -0x10(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
jne 0xe376
movq -0x10(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0xe376
movq -0x10(%rbp), %rdi
addq $0x50, %rdi
leaq 0x7f14(%rip), %rsi      # 0x16280
movl $0x2710, %edx           # imm = 0x2710
callq 0xfac0
jmp 0xe38a
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xdc90
jmp 0xe042
jmp 0xe38c
jmp 0xe38e
jmp 0xe390
jmp 0xe392
movl -0x54(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)