// File: /workspace/github_c_makefile_star2_O2/jech[P]shncpd/receive.c
// Function: parse_dhcpv6
int
parse_dhcpv6(const unsigned char *buf, int buflen,
             struct prefix_list **dns, struct prefix_list **ntp)
{
    int i = 0;

    while(i < buflen) {
        unsigned const char *tlv = buf + i;
        int type, bodylen;

        if(buflen - i < 4) {
            fprintf(stderr, "Received truncated TLV.\n");
            goto fail;
        }

        DO_NTOHS(type, tlv);
        DO_NTOHS(bodylen, tlv + 2);
        if(buflen - i < 4 + bodylen) {
            fprintf(stderr, "Received truncated TLV.\n");
            goto fail;
        }

        switch(type) {
        case 23:
        case 31: {
            int j;
            struct in6_addr addr;
            struct prefix_list *pl;
            debugf(type == 23 ?
                   "         OPTION_DNS_SERVERS " :
                   "         OPTION_SNTP_SERVERS ");
            for(j = 0; j < bodylen / 16; j++) {
                memcpy(&addr, tlv + i + 2 + j * 16, 16);
                debug_address(&addr);
                debugf(" ");
                if(type == 23) {
                    pl = prefix_list_cons(*dns, &addr, 128, NULL, 0, 0);
                    if(pl != NULL)
                        *dns = pl;
                } else {
                    pl = prefix_list_cons(*ntp, &addr, 128, NULL, 0, 0);
                    if(pl != NULL)
                        *ntp = pl;
                }
            }
            debugf("\n");
            break;
        }
        default:
            if(debug_level >= 3)
                debugf("         %d: %d\n", type, bodylen);
            break;
        }
        i += 4 + bodylen;
        i += -i & 3;
    }
    return 1;

 fail:
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, 0x10(%rsp)
movq %rdx, %r15
movl %esi, 0x8(%rsp)
movq %rdi, 0x18(%rsp)
leaq 0x20(%rsp), %rbx
xorl %edx, %edx
movl 0x8(%rsp), %eax
subl %edx, %eax
jle 0x65dd
cmpl $0x4, %eax
jl 0x65ef
movslq %edx, %r14
movq 0x18(%rsp), %rcx
leaq (%rcx,%r14), %r12
movzwl 0x2(%r12), %ecx
rolw $0x8, %cx
movzwl %cx, %r13d
leal 0x4(%r13), %ecx
cmpl %ecx, %eax
jb 0x65ef
movl %ecx, 0x4(%rsp)
movl %edx, 0xc(%rsp)
movzwl (%r12), %ebp
movl %ebp, %eax
rolw $0x8, %ax
movzwl %ax, %edx
movl %edx, %eax
orl $0x8, %eax
cmpl $0x1f, %eax
jne 0x656c
leaq 0xada8(%rip), %rax      # 0x11258
cmpl $0x2, (%rax)
jge 0x658e
addq %r14, %r12
addq $0x2, %r12
andl $-0x10, %r13d
xorl %r14d, %r14d
cmpq %r14, %r13
je 0x655a
movups (%r12,%r14), %xmm0
movaps %xmm0, 0x20(%rsp)
movq %rbx, %rdi
callq 0x83dc
leaq 0xad6f(%rip), %rax      # 0x11258
cmpl $0x2, (%rax)
jge 0x6547
cmpw $0x1700, %bp            # imm = 0x1700
jne 0x6517
movq (%r15), %rdi
movq %rbx, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x86c7
testq %rax, %rax
je 0x6541
movq %rax, (%r15)
jmp 0x6541
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movq %rbx, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x86c7
testq %rax, %rax
je 0x6541
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
addq $0x10, %r14
jmp 0x64c7
pushq $0x2
popq %rdi
leaq 0x675b(%rip), %rsi      # 0xccac
xorl %eax, %eax
callq 0x23c0
jmp 0x64ee
leaq 0xacf7(%rip), %rax      # 0x11258
cmpl $0x2, (%rax)
jge 0x65b4
movl 0x4(%rsp), %ebp
jmp 0x657c
leaq 0xace5(%rip), %rax      # 0x11258
cmpl $0x3, (%rax)
movl 0x4(%rsp), %ebp
jge 0x65c7
addl 0xc(%rsp), %ebp
movl %ebp, %edx
negl %edx
andl $0x3, %edx
addl %ebp, %edx
jmp 0x644a
cmpw $0x1700, %bp            # imm = 0x1700
leaq 0x66f6(%rip), %rsi      # 0xcc90
leaq 0x66d2(%rip), %rax      # 0xcc73
cmoveq %rax, %rsi
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x23c0
jmp 0x64b9
pushq $0x2
popq %rdi
leaq 0x632b(%rip), %rsi      # 0xc8e9
xorl %eax, %eax
callq 0x23c0
jmp 0x6566
pushq $0x2
popq %rdi
leaq 0x6691(%rip), %rsi      # 0xcc62
movl %r13d, %ecx
xorl %eax, %eax
callq 0x23c0
jmp 0x657c
pushq $0x1
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xaa02(%rip), %rax      # 0x10ff8
movq (%rax), %rcx
leaq 0x620c(%rip), %rdi      # 0xc80c
pushq $0x18
popq %rsi
pushq $0x1
popq %rdx
callq 0x2340
pushq $-0x1
jmp 0x65df
nop