// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %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 0x8571
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
subl -0x2c(%rbp), %eax
cmpl $0x2, %eax
jge 0x8374
movq 0xdc9a(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0xa9ab(%rip), %rsi      # 0x12d13
movb $0x0, %al
callq 0x21f0
jmp 0x857a
movq -0x38(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x74(%rbp)
testl %eax, %eax
je 0x83ac
jmp 0x8395
movl -0x74(%rbp), %eax
subl $0x6, %eax
je 0x83ba
jmp 0x839f
movl -0x74(%rbp), %eax
subl $0x2a, %eax
je 0x83ba
jmp 0x8527
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8331
jmp 0x83bc
leaq 0xdea5(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x83ec
movl -0x3c(%rbp), %ecx
leaq 0xa977(%rip), %rsi      # 0x12d49
leaq 0xa95a(%rip), %rax      # 0x12d33
cmpl $0x6, %ecx
cmoveq %rax, %rsi
movl $0x2, %edi
movb $0x0, %al
callq 0xfda0
jmp 0x83ee
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x78(%rbp)
movl -0x40(%rbp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x78(%rbp), %eax
cmpl %ecx, %eax
jge 0x8502
movq 0xa996(%rip), %rax      # 0x12db0
movq %rax, -0x70(%rbp)
movq 0xa993(%rip), %rax      # 0x12db8
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movl -0x44(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movl 0x2(%rax,%rcx), %eax
movl %eax, -0x64(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x54(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x4c(%rbp)
leaq -0x54(%rbp), %rdi
callq 0xbf70
leaq 0xde04(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x847c
movl $0x2, %edi
leaq 0xa933(%rip), %rsi      # 0x12da8
movb $0x0, %al
callq 0xfda0
jmp 0x847e
cmpl $0x6, -0x3c(%rbp)
jne 0x84bb
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq -0x54(%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 0x84b9
movq -0x60(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
jmp 0x84f2
movq -0x28(%rbp), %rax
movq (%rax), %rdi
leaq -0x54(%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 0x84f0
movq -0x60(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
jmp 0x84f2
jmp 0x84f4
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x83f5
jmp 0x8504
leaq 0xdd5d(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x8523
movl $0x2, %edi
leaq 0xa4c9(%rip), %rsi      # 0x129e5
movb $0x0, %al
callq 0xfda0
jmp 0x8525
jmp 0x8560
leaq 0xdd3a(%rip), %rax      # 0x16268
cmpl $0x3, (%rax)
jl 0x855e
jmp 0x8535
leaq 0xdd2c(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x855a
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
movl $0x2, %edi
leaq 0xa80b(%rip), %rsi      # 0x12d5e
movb $0x0, %al
callq 0xfda0
jmp 0x855c
jmp 0x855e
jmp 0x8560
movl -0x40(%rbp), %eax
addl $0x2, %eax
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x8331
movl $0x1, -0x4(%rbp)
jmp 0x8581
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)