// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x8811
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
subl -0x2c(%rbp), %eax
cmpl $0x4, %eax
jge 0x85f1
movq 0xda1d(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0xa323(%rip), %rsi      # 0x12908
movb $0x0, %al
callq 0x21f0
jmp 0x881a
jmp 0x85f3
movq -0x38(%rbp), %rax
movw (%rax), %ax
movw %ax, -0x42(%rbp)
movzwl -0x42(%rbp), %edi
callq 0x22b0
movzwl %ax, %eax
movl %eax, -0x3c(%rbp)
jmp 0x860f
movq -0x38(%rbp), %rax
movw 0x2(%rax), %ax
movw %ax, -0x44(%rbp)
movzwl -0x44(%rbp), %edi
callq 0x22b0
movzwl %ax, %eax
movl %eax, -0x40(%rbp)
movl -0x14(%rbp), %eax
subl -0x2c(%rbp), %eax
movl -0x40(%rbp), %ecx
addl $0x4, %ecx
cmpl %ecx, %eax
jge 0x8657
movq 0xd9b7(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0xa2bd(%rip), %rsi      # 0x12908
movb $0x0, %al
callq 0x21f0
jmp 0x881a
movl -0x3c(%rbp), %eax
orl $0x8, %eax
subl $0x1f, %eax
je 0x8667
jmp 0x87b9
jmp 0x8669
leaq 0xdbf8(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x8699
movl -0x3c(%rbp), %ecx
leaq 0xa70d(%rip), %rsi      # 0x12d8c
leaq 0xa6e9(%rip), %rax      # 0x12d6f
cmpl $0x17, %ecx
cmoveq %rax, %rsi
movl $0x2, %edi
movb $0x0, %al
callq 0xfda0
jmp 0x869b
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x40(%rbp), %eax
movl $0x10, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x64(%rbp), %eax
cmpl %ecx, %eax
jge 0x8794
movq -0x38(%rbp), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movl -0x48(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
movq 0x2(%rax,%rcx), %rdx
movq %rdx, -0x58(%rbp)
movq 0xa(%rax,%rcx), %rax
movq %rax, -0x50(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xbf70
leaq 0xdb72(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x870e
movl $0x2, %edi
leaq 0xa6a1(%rip), %rsi      # 0x12da8
movb $0x0, %al
callq 0xfda0
jmp 0x8710
cmpl $0x17, -0x3c(%rbp)
jne 0x874d
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x58(%rbp), %rsi
movl $0x80, %edx
xorl %eax, %eax
movl %eax, %ecx
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0xc400
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x874b
movq -0x60(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x8784
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq -0x58(%rbp), %rsi
movl $0x80, %edx
xorl %eax, %eax
movl %eax, %ecx
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0xc400
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x8782
movq -0x60(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
jmp 0x8784
jmp 0x8786
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x86a2
jmp 0x8796
leaq 0xdacb(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x87b5
movl $0x2, %edi
leaq 0xa237(%rip), %rsi      # 0x129e5
movb $0x0, %al
callq 0xfda0
jmp 0x87b7
jmp 0x87f2
leaq 0xdaa8(%rip), %rax      # 0x16268
cmpl $0x3, (%rax)
jl 0x87f0
jmp 0x87c7
leaq 0xda9a(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x87ec
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
movl $0x2, %edi
leaq 0xa579(%rip), %rsi      # 0x12d5e
movb $0x0, %al
callq 0xfda0
jmp 0x87ee
jmp 0x87f0
jmp 0x87f2
movl -0x40(%rbp), %eax
addl $0x4, %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
subl -0x2c(%rbp), %eax
andl $0x3, %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x85ae
movl $0x1, -0x4(%rbp)
jmp 0x8821
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)