// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movq %rcx, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq %rdi, 0x28(%rsp)
movl $0x1, %eax
testl %esi, %esi
jle 0x725b
leaq 0x30(%rsp), %r13
xorl %ebp, %ebp
movl %esi, 0x10(%rsp)
movl %esi, %eax
subl %ebp, %eax
cmpl $0x4, %eax
jl 0x726a
movslq %ebp, %r14
movq 0x28(%rsp), %rcx
leaq (%rcx,%r14), %r15
movzwl 0x2(%r15), %r12d
rolw $0x8, %r12w
movzwl %r12w, %ebx
leal 0x4(%rbx), %ecx
cmpl %ecx, %eax
jb 0x726a
movzwl (%r15), %edi
movl %edi, %eax
rolw $0x8, %ax
movzwl %ax, %edx
movl %edx, %eax
orl $0x8, %eax
cmpl $0x1f, %eax
jne 0x7146
movl %ecx, 0x14(%rsp)
leaq 0xc13c(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x7212
cmpw $0x10, %r12w
jae 0x716e
leaq 0xc125(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x7228
movl 0x10(%rsp), %esi
movl 0x14(%rsp), %ecx
jmp 0x7156
leaq 0xc10b(%rip), %rax      # 0x13258
cmpl $0x3, (%rax)
jge 0x7232
addl %ebp, %ecx
movl %ecx, %ebp
negl %ebp
andl $0x3, %ebp
addl %ecx, %ebp
cmpl %esi, %ebp
jl 0x70c8
jmp 0x7256
addq %r15, %r14
addq $0x2, %r14
andl $-0x10, %ebx
movzwl %di, %r15d
xorl %r12d, %r12d
movups (%r14,%r12), %xmm0
movaps %xmm0, 0x30(%rsp)
movq %r13, %rdi
callq 0x905d
leaq 0xc0c0(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x720b
cmpl $0x1700, %r15d          # imm = 0x1700
jne 0x71cf
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movq %r13, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x938c
testq %rax, %rax
je 0x71f9
movq 0x18(%rsp), %rcx
jmp 0x71f6
movq 0x20(%rsp), %rax
movq (%rax), %rdi
movq %r13, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x938c
testq %rax, %rax
je 0x71f9
movq 0x20(%rsp), %rcx
movq %rax, (%rcx)
addq $0x10, %r12
cmpq %r12, %rbx
jne 0x717f
jmp 0x712c
callq 0x2d33
jmp 0x719d
movl %edi, 0xc(%rsp)
movl 0xc(%rsp), %edi
callq 0x2d0c
movl 0xc(%rsp), %edi
jmp 0x7125
callq 0x2d4a
jmp 0x713c
movl $0x2, %edi
leaq 0x6a4c(%rip), %rsi      # 0xdc8a
movl %ecx, %r14d
movl %ebx, %ecx
xorl %eax, %eax
callq 0x30a8
movl %r14d, %ecx
movl 0x10(%rsp), %esi
jmp 0x7156
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2d61
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x725b
nop