// File: /workspace/github_c_makefile_star2_O3/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, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
testl %esi, %esi
jle 0x7071
movl %esi, %r15d
leaq 0x28(%rsp), %r12
xorl %ecx, %ecx
movq %rdi, 0x10(%rsp)
movl %esi, 0x8(%rsp)
movl %r15d, %eax
subl %ecx, %eax
cmpl $0x1, %eax
jle 0x7087
movslq %ecx, %rbx
leaq (%rdi,%rbx), %r14
movzbl (%r14), %r13d
movl $0x1, %edx
movl $0x1, %ebp
testl %r13d, %r13d
je 0x7023
movzbl 0x1(%r14), %ebp
cmpl $0x2a, %r13d
je 0x6f23
cmpl $0x6, %r13d
jne 0x7014
movl %ecx, 0xc(%rsp)
leaq 0xc32a(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x7032
cmpb $0x4, %bpl
jae 0x6f65
leaq 0xc314(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x703f
movl 0x8(%rsp), %r15d
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %ecx
movl $0x1, %edx
jmp 0x7020
movl %ebp, %r15d
shrl $0x2, %r15d
addq %r14, %rbx
addq $0x2, %rbx
xorl %r14d, %r14d
movl (%rbx,%r14,4), %eax
movl $0xffff0000, 0x30(%rsp) # imm = 0xFFFF0000
movq $0x0, 0x28(%rsp)
movl %eax, 0x34(%rsp)
movq %r12, %rdi
callq 0x905d
leaq 0xc2ba(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x700d
cmpl $0x6, %r13d
jne 0x6fd2
movq 0x18(%rsp), %rax
movq (%rax), %rdi
movq %r12, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x938c
testq %rax, %rax
je 0x6ffc
movq 0x18(%rsp), %rcx
jmp 0x6ff9
movq 0x20(%rsp), %rax
movq (%rax), %rdi
movq %r12, %rsi
movl $0x80, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x938c
testq %rax, %rax
je 0x6ffc
movq 0x20(%rsp), %rcx
movq %rax, (%rcx)
incq %r14
cmpq %r14, %r15
jne 0x6f76
jmp 0x6f3d
callq 0x2cbc
jmp 0x6fa3
leaq 0xc23d(%rip), %rax      # 0x13258
cmpl $0x3, (%rax)
jge 0x7049
addl $0x2, %ebp
addl %ecx, %ebp
movl %ebp, %ecx
cmpl %r15d, %ebp
jl 0x6ee2
jmp 0x7076
movl %r13d, %edi
callq 0x2c96
jmp 0x6f37
callq 0x2cd3
jmp 0x6f4d
movl $0x2, %edi
leaq 0x6c35(%rip), %rsi      # 0xdc8a
movl %r13d, %edx
movl %ecx, %ebx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30a8
movl $0x1, %edx
movl %ebx, %ecx
movq 0x10(%rsp), %rdi
jmp 0x7020
movl $0x1, %edx
movl %edx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2cea
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
jmp 0x7076