// File: /workspace/github_c_makefile_star2_O2/jech[P]shncpd/receive.c
// Function: parse_dhcpv4
int
parse_dhcpv4(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 < 2) {
            fprintf(stderr, "Received truncated DHCPv4 TLV.\n");
            goto fail;
        }

        type = tlv[0];
        bodylen = tlv[1];

        switch(type) {
        case 0:
            i++;
            continue;
        case 6:
        case 42: {
            int j;
            struct in6_addr addr;
            struct prefix_list *pl;
            debugf(type == 6 ?
                   "         Name Server " :
                   "         NTP Server ");
            for(j = 0; j < bodylen / 4; j++) {
                unsigned char a[16] =
                    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
                memcpy(a + 12, tlv + i + 2 + j * 4, 4);
                memcpy(&addr, a, 16);
                debug_address(&addr);
                debugf(" ");
                if(type == 6) {
                    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 += 2 + bodylen;
    }
    return 1;

 fail:
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, 0x18(%rsp)
movq %rdx, %r15
movl %esi, 0x10(%rsp)
movq %rdi, 0x20(%rsp)
pushq $0x1
popq %r12
leaq 0x28(%rsp), %r13
xorl %ecx, %ecx
movl 0x10(%rsp), %eax
subl %ecx, %eax
jle 0x6412
cmpl $0x1, %eax
jle 0x63f2
movl %ecx, 0x14(%rsp)
movslq %ecx, %r14
movq 0x20(%rsp), %rax
leaq (%rax,%r14), %rbp
movzbl (%rbp), %ebx
movl %r12d, %eax
testl %ebx, %ebx
je 0x6396
movzbl 0x1(%rbp), %eax
movq %rax, 0x8(%rsp)
cmpl $0x2a, %ebx
je 0x62ad
cmpl $0x6, %ebx
jne 0x6382
leaq 0xafa4(%rip), %rax      # 0x11258
cmpl $0x2, (%rax)
jge 0x63a1
movq 0x8(%rsp), %r12
shrl $0x2, %r12d
addq %r14, %rbp
addq $0x2, %rbp
xorl %r14d, %r14d
cmpq %r14, %r12
je 0x6370
movl (%rbp,%r14,4), %eax
movl $0xffff0000, 0x30(%rsp) # imm = 0xFFFF0000
andq $0x0, 0x28(%rsp)
movl %eax, 0x34(%rsp)
movq %r13, %rdi
callq 0x83dc
leaq 0xaf59(%rip), %rax      # 0x11258
cmpl $0x2, (%rax)
jge 0x635d
cmpb $0x6, %bl
jne 0x632b
movq (%r15), %rdi
movq %r13, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x86c7
testq %rax, %rax
je 0x6355
movq %rax, (%r15)
jmp 0x6355
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movq %r13, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x86c7
testq %rax, %rax
je 0x6355
movq 0x18(%rsp), %rcx
movq %rax, (%rcx)
incq %r14
jmp 0x62d0
pushq $0x2
popq %rdi
leaq 0x6945(%rip), %rsi      # 0xccac
xorl %eax, %eax
callq 0x23c0
jmp 0x6304
leaq 0xaee1(%rip), %rax      # 0x11258
cmpl $0x2, (%rax)
jge 0x63c5
pushq $0x1
popq %r12
jmp 0x638e
leaq 0xaecf(%rip), %rax      # 0x11258
cmpl $0x3, (%rax)
jge 0x63d8
movq 0x8(%rsp), %rax
addl $0x2, %eax
addl 0x14(%rsp), %eax
movl %eax, %ecx
jmp 0x6262
cmpl $0x6, %ebx
leaq 0x68a2(%rip), %rsi      # 0xcc4d
leaq 0x6885(%rip), %rax      # 0xcc37
cmoveq %rax, %rsi
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x23c0
jmp 0x62bd
pushq $0x2
popq %rdi
leaq 0x651a(%rip), %rsi      # 0xc8e9
xorl %eax, %eax
callq 0x23c0
jmp 0x637c
pushq $0x2
popq %rdi
leaq 0x6880(%rip), %rsi      # 0xcc62
movl %ebx, %edx
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x23c0
jmp 0x638e
movq 0xabff(%rip), %rax      # 0x10ff8
movq (%rax), %rcx
leaq 0x6814(%rip), %rdi      # 0xcc17
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
callq 0x2340
pushq $-0x1
popq %r12
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq