// File: /workspace/github_c_makefile_star2_O1/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, 0x18(%rsp)
movq %rdx, 0x10(%rsp)
movl %esi, 0x8(%rsp)
movq %rdi, 0x28(%rsp)
leaq 0x30(%rsp), %r12
xorl %ebp, %ebp
movl 0x8(%rsp), %eax
subl %ebp, %eax
jle 0x75b8
cmpl $0x3, %eax
jle 0x7565
movslq %ebp, %rsi
movq 0x28(%rsp), %rcx
leaq (%rcx,%rsi), %r14
movzwl 0x2(%r14), %ebx
rolw $0x8, %bx
movzwl %bx, %r13d
leal 0x4(%r13), %ecx
cmpl %ecx, %eax
jl 0x756c
movzwl (%r14), %r15d
movl %r15d, %eax
rolw $0x8, %ax
movzwl %ax, %edx
movl %edx, %eax
orl $0x8, %eax
cmpl $0x1f, %eax
jne 0x7495
movl %ecx, 0xc(%rsp)
leaq 0xbde8(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x7578
cmpw $0x10, %bx
jae 0x74bf
leaq 0xbdd2(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x758f
movl 0xc(%rsp), %ecx
jmp 0x74a5
leaq 0xbdbc(%rip), %rax      # 0x13258
cmpl $0x3, (%rax)
jge 0x7599
addl %ebp, %ecx
movl %ecx, %ebp
negl %ebp
andl $0x3, %ebp
addl %ecx, %ebp
movb $0x1, %al
testb %al, %al
jne 0x7413
jmp 0x75bf
leaq (%r14,%rsi), %rbx
addq $0x2, %rbx
andl $-0x10, %r13d
movzwl %r15w, %r15d
xorl %r14d, %r14d
movups (%rbx,%r14), %xmm0
movaps %xmm0, 0x30(%rsp)
movq %r12, %rdi
callq 0x9562
leaq 0xbd6d(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x755e
cmpl $0x1700, %r15d          # imm = 0x1700
jne 0x7522
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movq %r12, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x9871
testq %rax, %rax
je 0x754c
movq 0x10(%rsp), %rcx
jmp 0x7549
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movq %r12, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x9871
testq %rax, %rax
je 0x754c
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
addq $0x10, %r14
cmpq %r14, %r13
jne 0x74d2
jmp 0x747f
callq 0x2d6f
jmp 0x74f0
callq 0x2dbf
jmp 0x7571
callq 0x2d9d
xorl %eax, %eax
jmp 0x74b2
movl %r15d, %edi
movq %rsi, 0x20(%rsp)
callq 0x2d48
movq 0x20(%rsp), %rsi
jmp 0x7479
callq 0x2d86
jmp 0x748f
movl $0x2, %edi
leaq 0x6705(%rip), %rsi      # 0xdcaa
movl %ecx, %ebx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x319e
movl %ebx, %ecx
jmp 0x74a5
movl $0x1, %eax
jmp 0x75c4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop