// File: /workspace/github_c_makefile_star2_O0/jech[P]shncpd/ra.c
// Function: send_ra
static int
send_ra(struct interface *interface, const struct sockaddr_in6 *to,
        int router)
{
    int buflen = 1024;
    unsigned char buf[buflen];
    int i = 0, j;
    struct prefix_list *d;

    MEM_UNDEFINED(buf, buflen);

    CHECK(16);
    BYTE(134);
    BYTE(0);
    SHORT(0);
    BYTE(0);
    BYTE(0);
    SHORT(router >= 2 ? 3600 : 0);
    LONG(0);
    LONG(0);

    if(interface) {
        if(interface->retractions) {
            for(j = 0; j < interface->retractions->numprefixes; j++) {
                struct prefix *p = &interface->retractions->prefixes[j];
                CHECK(32);
                BYTE(3);
                BYTE(4);
                BYTE(p->plen);
                BYTE(0x80);
                LONG(0);
                LONG(0);
                LONG(0);
                BYTES(&p->p, 16);
            }
        }

        destroy_prefix_list(interface->retractions);
        interface->retractions = NULL;

        if(router >= 1) {
            for(j = 0; j < interface->numassigned; j++) {
                struct assigned_prefix *ap = &interface->assigned[j];
                struct prefix *p = &ap->assigned;

                if(!ap->applied || prefix_v4(&ap->assigned) ||
                   p->plen >= 128)
                    continue;

                CHECK(32);
                BYTE(3);
                BYTE(4);
                BYTE(p->plen);
                BYTE(router <= 0 ? 0x80 : (0x80 | 0x40));
                LONG(router <= 0 ? 0 : 3600);
                LONG(router <= 0 ? 0 : 1800);
                LONG(0);
                BYTES(&p->p, 16);
            }
        }
    }

    d = all_delegated_prefixes();
    if(d && d->numprefixes > 0) {
        for(j = 0; j < d->numprefixes; j++) {
            struct prefix *p = &d->prefixes[j];
            if(prefix_v4(p)) {
                continue;
            }

            CHECK(32);
            BYTE(24);
            BYTE(p->plen > 64 ? 3 : 2);
            BYTE(p->plen);
            BYTE(0);
            LONG(router >= 1 ? 3600 : 0);
            BYTES(&p->p, p->plen > 64 ? 16 : 8);
        }
    }
    destroy_prefix_list(d);


    if(router >= 1) {
        struct prefix_list *dns = all_dhcp_data(0, 0, 1);

        if(dns && dns->numprefixes > 0) {
            CHECK(8 + dns->numprefixes * 16);
            BYTE(25);
            BYTE(1 + dns->numprefixes * 2);
            SHORT(0);
            LONG(MAX_RTR_ADV_INTERVAL * 3 / 2);
            for(j = 0; j < dns->numprefixes; j++) {
                BYTES(&dns->prefixes[j].p, 16);
            }
        }
        destroy_prefix_list(dns);
    }

 sendit:
    debugf("-> Router Advertisement\n");
    return sendto(ra_socket, buf, i, 0, (struct sockaddr*)to, sizeof(*to));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0x400, -0x18(%rbp)     # imm = 0x400
movl -0x18(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x20(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xa8(%rbp)
movq %rcx, %rsp
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
jmp 0x8fdf
jmp 0x8fe1
movl -0x18(%rbp), %eax
movl -0x2c(%rbp), %ecx
addl $0x10, %ecx
cmpl %ecx, %eax
jge 0x8ff3
jmp 0x974f
movq -0xa8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $-0x7a, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
xorl %edi, %edi
callq 0x2100
movw %ax, %cx
movq -0xa8(%rbp), %rax
movw %cx, -0x3a(%rbp)
movslq -0x2c(%rbp), %rcx
movw -0x3a(%rbp), %dx
movw %dx, (%rax,%rcx)
jmp 0x903f
movq -0xa8(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x2, %ecx
movl %ecx, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x14(%rbp), %edx
xorl %eax, %eax
movl $0xe10, %ecx            # imm = 0xE10
cmpl $0x2, %edx
cmovgel %ecx, %eax
movzwl %ax, %edi
callq 0x2100
movw %ax, %cx
movq -0xa8(%rbp), %rax
movw %cx, -0x3c(%rbp)
movslq -0x2c(%rbp), %rcx
movw -0x3c(%rbp), %dx
movw %dx, (%rax,%rcx)
jmp 0x90a5
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
xorl %edi, %edi
callq 0x2160
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0x40(%rbp)
movslq -0x2c(%rbp), %rcx
movl -0x40(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0x90cd
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
xorl %edi, %edi
callq 0x2160
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0x44(%rbp)
movslq -0x2c(%rbp), %rcx
movl -0x44(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0x90f5
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x9444
movq -0x8(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x926c
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x90(%rcx), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x926a
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movl -0x18(%rbp), %eax
movl -0x2c(%rbp), %ecx
addl $0x20, %ecx
cmpl %ecx, %eax
jge 0x916b
jmp 0x974f
movq -0xa8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $0x3, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
movb $0x4, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movq -0x50(%rbp), %rcx
movb 0x10(%rcx), %dl
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
movb $-0x80, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
xorl %edi, %edi
callq 0x2160
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0x54(%rbp)
movslq -0x2c(%rbp), %rcx
movl -0x54(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0x91db
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
xorl %edi, %edi
callq 0x2160
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0x58(%rbp)
movslq -0x2c(%rbp), %rcx
movl -0x58(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0x9203
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
xorl %edi, %edi
callq 0x2160
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0x5c(%rbp)
movslq -0x2c(%rbp), %rcx
movl -0x5c(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0x922b
movq -0xa8(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x4, %ecx
movl %ecx, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
movq -0x50(%rbp), %rdx
movq (%rdx), %rsi
movq %rsi, (%rax,%rcx)
movq 0x8(%rdx), %rdx
movq %rdx, 0x8(%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x9122
jmp 0x926c
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0xc2d0
movq -0x8(%rbp), %rax
movq $0x0, 0x90(%rax)
cmpl $0x1, -0x14(%rbp)
jl 0x9442
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x68(%rcx), %eax
jge 0x9440
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
addq $0x1c, %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
cmpl $0x0, 0x3c(%rax)
je 0x92fa
movq -0x68(%rbp), %rdi
addq $0x1c, %rdi
callq 0xcfe0
cmpl $0x0, %eax
jne 0x92fa
movq -0x70(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x80, %eax
jl 0x92ff
jmp 0x9432
movl -0x18(%rbp), %eax
movl -0x2c(%rbp), %ecx
addl $0x20, %ecx
cmpl %ecx, %eax
jge 0x9311
jmp 0x974f
movq -0xa8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $0x3, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
movb $0x4, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movq -0x70(%rbp), %rcx
movb 0x10(%rcx), %dl
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movl -0x14(%rbp), %esi
movl $0xc0, %ecx
movl $0x80, %edx
cmpl $0x0, %esi
cmovlel %edx, %ecx
movb %cl, %dl
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x14(%rbp), %ecx
movl $0xe10, %edi            # imm = 0xE10
xorl %eax, %eax
cmpl $0x0, %ecx
cmovlel %eax, %edi
callq 0x2160
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0x74(%rbp)
movslq -0x2c(%rbp), %rcx
movl -0x74(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0x93a3
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
movl -0x14(%rbp), %ecx
movl $0x708, %edi            # imm = 0x708
xorl %eax, %eax
cmpl $0x0, %ecx
cmovlel %eax, %edi
callq 0x2160
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0x78(%rbp)
movslq -0x2c(%rbp), %rcx
movl -0x78(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0x93d9
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
xorl %edi, %edi
callq 0x2160
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0x7c(%rbp)
movslq -0x2c(%rbp), %rcx
movl -0x7c(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0x9401
movq -0xa8(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x4, %ecx
movl %ecx, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
movq -0x70(%rbp), %rdx
movq (%rdx), %rsi
movq %rsi, (%rax,%rcx)
movq 0x8(%rdx), %rdx
movq %rdx, 0x8(%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x929c
jmp 0x9442
jmp 0x9444
callq 0xd580
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x95d9
movq -0x38(%rbp), %rax
movswl 0x8(%rax), %eax
cmpl $0x0, %eax
jle 0x95d9
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x38(%rbp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x95d7
movq -0x38(%rbp), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
callq 0xcfe0
cmpl $0x0, %eax
je 0x94b2
jmp 0x95c9
movl -0x18(%rbp), %eax
movl -0x2c(%rbp), %ecx
addl $0x20, %ecx
cmpl %ecx, %eax
jge 0x94c4
jmp 0x974f
movq -0xa8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $0x18, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movq -0x88(%rbp), %rcx
movzbl 0x10(%rcx), %esi
movl $0x2, %ecx
movl $0x3, %edx
cmpl $0x40, %esi
cmovgl %edx, %ecx
movb %cl, %dl
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movq -0x88(%rbp), %rcx
movb 0x10(%rcx), %dl
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movslq -0x2c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl -0x14(%rbp), %ecx
xorl %edi, %edi
movl $0xe10, %eax            # imm = 0xE10
cmpl $0x1, %ecx
cmovgel %eax, %edi
callq 0x2160
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0x8c(%rbp)
movslq -0x2c(%rbp), %rcx
movl -0x8c(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0x9567
movq -0xa8(%rbp), %rdi
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
addq %rax, %rdi
movq -0x88(%rbp), %rsi
movq -0x88(%rbp), %rax
movzbl 0x10(%rax), %edx
movl $0x8, %eax
movl $0x10, %ecx
cmpl $0x40, %edx
cmovgl %ecx, %eax
movslq %eax, %rdx
callq 0x2230
movq -0x88(%rbp), %rax
movzbl 0x10(%rax), %edx
movl $0x8, %eax
movl $0x10, %ecx
cmpl $0x40, %edx
cmovgl %ecx, %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x9470
jmp 0x95d9
movq -0x38(%rbp), %rdi
callq 0xc2d0
cmpl $0x1, -0x14(%rbp)
jl 0x974d
xorl %esi, %esi
movl $0x1, %edx
movl %esi, %edi
callq 0x54d0
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0x9741
movq -0x98(%rbp), %rax
movswl 0x8(%rax), %eax
cmpl $0x0, %eax
jle 0x9741
movl -0x18(%rbp), %eax
movl -0x2c(%rbp), %ecx
movq -0x98(%rbp), %rdx
movswl 0x8(%rdx), %edx
shll $0x4, %edx
addl $0x8, %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x9645
jmp 0x974f
movq -0xa8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $0x19, (%rax,%rcx)
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x2c(%rbp)
movq -0x98(%rbp), %rcx
movswl 0x8(%rcx), %ecx
shll %ecx
addl $0x1, %ecx
movb %cl, %dl
movslq -0x2c(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
xorl %edi, %edi
callq 0x2100
movw %ax, %cx
movq -0xa8(%rbp), %rax
movw %cx, -0x9a(%rbp)
movslq -0x2c(%rbp), %rcx
movw -0x9a(%rbp), %dx
movw %dx, (%rax,%rcx)
jmp 0x96a8
movl -0x2c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x2c(%rbp)
movl $0xdbba0, %edi          # imm = 0xDBBA0
callq 0x2160
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movl %ecx, -0xa0(%rbp)
movslq -0x2c(%rbp), %rcx
movl -0xa0(%rbp), %edx
movl %edx, (%rax,%rcx)
jmp 0x96d9
movl -0x2c(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x98(%rbp), %rcx
movswl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x973f
movq -0xa8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq -0x98(%rbp), %rdx
movq (%rdx), %rdx
movslq -0x30(%rbp), %rsi
imulq $0x1c, %rsi, %rsi
addq %rsi, %rdx
movq (%rdx), %rsi
movq %rsi, (%rax,%rcx)
movq 0x8(%rdx), %rdx
movq %rdx, 0x8(%rax,%rcx)
movl -0x2c(%rbp), %eax
addl $0x10, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x96e9
jmp 0x9741
movq -0x98(%rbp), %rdi
callq 0xc2d0
jmp 0x974f
jmp 0x9751
leaq 0xcb10(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x9770
movl $0x2, %edi
leaq 0x96a8(%rip), %rsi      # 0x12e11
movb $0x0, %al
callq 0xfda0
jmp 0x9772
jmp 0x9774
movq -0xa8(%rbp), %rsi
movl 0xca7b(%rip), %edi      # 0x161fc
movslq -0x2c(%rbp), %rdx
movq -0x10(%rbp), %r8
xorl %ecx, %ecx
movl $0x1c, %r9d
callq 0x2180
movq -0x20(%rbp), %rcx
movq %rcx, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)