// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movq %rcx, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movq %rdi, 0x40(%rsp)
testl %esi, %esi
jle 0x73d7
movl %esi, %ebp
xorl %eax, %eax
movl $0x4, %ecx
movl %ecx, %ecx
movq %rcx, 0x30(%rsp)
movl %eax, %eax
movq %rax, 0x10(%rsp)
leaq 0x48(%rsp), %r12
movl $0x2, %eax
movl %eax, %eax
movq %rax, 0x38(%rsp)
xorl %r13d, %r13d
movl %esi, 0xc(%rsp)
movl %ebp, %eax
subl %r13d, %eax
cmpl $0x1, %eax
jle 0x737a
movslq %r13d, %rbx
movq 0x40(%rsp), %rax
leaq (%rax,%rbx), %r14
movzbl (%r14), %r15d
movzbl 0x1(%r14), %ecx
cmpl $0x2a, %r15d
je 0x723e
cmpl $0x6, %r15d
je 0x723e
testl %r15d, %r15d
jne 0x7342
incl %r13d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x65c8(%rip), %rdx      # 0xd7f8
movq 0x38(%rsp), %rcx
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0xc013(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x7399
movq %rcx, 0x18(%rsp)
cmpb $0x4, %cl
jae 0x7292
leaq 0xbff9(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x73ac
movq 0x18(%rsp), %rax
addl %eax, %r13d
addl $0x2, %r13d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x6578(%rip), %rdx      # 0xd7f8
movq 0x10(%rsp), %rcx
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
movl 0xc(%rsp), %ebp
jmpq *%rcx
movq 0x18(%rsp), %rbp
shrl $0x2, %ebp
addq %r14, %rbx
addq $0x2, %rbx
xorl %r14d, %r14d
movl (%rbx,%r14,4), %eax
movl $0xffff0000, 0x50(%rsp) # imm = 0xFFFF0000
movq $0x0, 0x48(%rsp)
movl %eax, 0x54(%rsp)
movq %r12, %rdi
callq 0x9562
leaq 0xbf8c(%rip), %rax      # 0x13258
cmpl $0x2, (%rax)
jge 0x733b
cmpl $0x6, %r15d
jne 0x7300
movq 0x20(%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 0x732a
movq 0x20(%rsp), %rcx
jmp 0x7327
movq 0x28(%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 0x732a
movq 0x28(%rsp), %rcx
movq %rax, (%rcx)
incq %r14
cmpq %r14, %rbp
jne 0x72a4
jmp 0x7258
callq 0x2cf8
jmp 0x72d1
leaq 0xbf0f(%rip), %rax      # 0x13258
cmpl $0x3, (%rax)
jge 0x73b6
addl %ecx, %r13d
addl $0x2, %r13d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x6497(%rip), %rdx      # 0xd7f8
movq 0x10(%rsp), %rcx
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl %ebp, %r13d
jl 0x71e9
jmp 0x73d7
callq 0x2d26
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x30(%rsp), %rcx
leaq 0x6468(%rip), %rdx      # 0xd7f8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl %r15d, %edi
movq %rcx, %rbp
callq 0x2cd2
movq %rbp, %rcx
jmp 0x724e
callq 0x2d0f
jmp 0x7268
movl $0x2, %edi
leaq 0x68e8(%rip), %rsi      # 0xdcaa
movl %r15d, %edx
movq %rcx, %rbx
xorl %eax, %eax
callq 0x319e
movq %rbx, %rcx
jmp 0x734e
movl $0x1, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq