// File: /workspace/github_c_makefile_star2_O0/jech[P]shncpd/receive.c
// Function: parse_external
struct external *
parse_external(struct node *node, const unsigned char *buf, int buflen)
{
    int i = 0;
    struct external *ext = calloc(1, sizeof(struct external));
    if(ext == NULL)
        return NULL;

    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 34: {
            unsigned char plen;
            struct in6_addr addr;
            struct prefix_list *pl;
            if(bodylen < 9) {
                fprintf(stderr, "Truncated DELEGATED-PREFIX.\n");
                break;
            }
            plen = *(tlv + 12);
            if(bodylen < 9 + (plen + 7) / 8) {
                fprintf(stderr, "Truncated DELEGATED-PREFIX.\n");
                break;
            }
            parse_pref(&addr, tlv + 13, plen);
            debugf("       DELEGATED-PREFIX ");
            debug_prefix_raw(&addr, plen);
            debugf("\n");
            /* XXX parse embedded TLVs. */
            pl = prefix_list_cons(ext->delegated, &addr, plen, node->id, 0, 0);
            if(pl != NULL)
                ext->delegated = pl;
            break;
        }
        case 37: {
            debugf("       DHCPV4-DATA\n");
            parse_dhcpv4(tlv + 4, bodylen, &ext->dns, &ext->ntp);
            data_change_time = now;
            break;
        }
        case 38: {
            debugf("       DHCPV6-DATA\n");
            parse_dhcpv6(tlv + 4, bodylen, &ext->dns, &ext->ntp);
            data_change_time = now;
            break;
        }
        default:
            if(debug_level >= 3)
                debugf("       %d: %d\n", type, bodylen);
            break;
        }
        i += 4 + bodylen;
        i += -i & 3;
    }

    return ext;

 fail:
    destroy_external(ext);
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x1, %edi
movl $0x18, %esi
callq 0x21d0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x7f11
movq $0x0, -0x8(%rbp)
jmp 0x822c
jmp 0x7f13
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x8211
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl -0x1c(%rbp), %eax
subl -0x20(%rbp), %eax
cmpl $0x4, %eax
jge 0x7f56
movq 0xe0b8(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0xa9be(%rip), %rsi      # 0x12908
movb $0x0, %al
callq 0x21f0
jmp 0x821b
jmp 0x7f58
movq -0x30(%rbp), %rax
movw (%rax), %ax
movw %ax, -0x3a(%rbp)
movzwl -0x3a(%rbp), %edi
callq 0x22b0
movzwl %ax, %eax
movl %eax, -0x34(%rbp)
jmp 0x7f74
movq -0x30(%rbp), %rax
movw 0x2(%rax), %ax
movw %ax, -0x3c(%rbp)
movzwl -0x3c(%rbp), %edi
callq 0x22b0
movzwl %ax, %eax
movl %eax, -0x38(%rbp)
movl -0x1c(%rbp), %eax
subl -0x20(%rbp), %eax
movl -0x38(%rbp), %ecx
addl $0x4, %ecx
cmpl %ecx, %eax
jge 0x7fbc
movq 0xe052(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0xa958(%rip), %rsi      # 0x12908
movb $0x0, %al
callq 0x21f0
jmp 0x821b
movl -0x34(%rbp), %eax
movl %eax, -0x5c(%rbp)
subl $0x22, %eax
je 0x7fe8
jmp 0x7fc9
movl -0x5c(%rbp), %eax
subl $0x25, %eax
je 0x80f4
jmp 0x7fd7
movl -0x5c(%rbp), %eax
subl $0x26, %eax
je 0x8158
jmp 0x81b9
cmpl $0x9, -0x38(%rbp)
jge 0x800b
movq 0xe003(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0xacb6(%rip), %rsi      # 0x12cb5
movb $0x0, %al
callq 0x21f0
jmp 0x81f2
movq -0x30(%rbp), %rax
movb 0xc(%rax), %al
movb %al, -0x3d(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x60(%rbp)
movzbl -0x3d(%rbp), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x60(%rbp), %eax
addl $0x9, %ecx
cmpl %ecx, %eax
jge 0x8053
movq 0xdfbb(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0xac6e(%rip), %rsi      # 0x12cb5
movb $0x0, %al
callq 0x21f0
jmp 0x81f2
movq -0x30(%rbp), %rsi
addq $0xd, %rsi
movzbl -0x3d(%rbp), %edx
leaq -0x50(%rbp), %rdi
callq 0x8240
leaq 0xe1f9(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x8087
movl $0x2, %edi
leaq 0xac52(%rip), %rsi      # 0x12cd2
movb $0x0, %al
callq 0xfda0
jmp 0x8089
movzbl -0x3d(%rbp), %esi
leaq -0x50(%rbp), %rdi
callq 0xbfc0
leaq 0xe1cb(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x80b5
movl $0x2, %edi
leaq 0xa937(%rip), %rsi      # 0x129e5
movb $0x0, %al
callq 0xfda0
jmp 0x80b7
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movzbl -0x3d(%rbp), %edx
movq -0x10(%rbp), %rcx
addq $0x8, %rcx
leaq -0x50(%rbp), %rsi
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0xc400
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x80ef
movq -0x58(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
jmp 0x81f2
jmp 0x80f6
leaq 0xe16b(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x8115
movl $0x2, %edi
leaq 0xabdd(%rip), %rsi      # 0x12ceb
movb $0x0, %al
callq 0xfda0
jmp 0x8117
movq -0x30(%rbp), %rdi
addq $0x4, %rdi
movl -0x38(%rbp), %esi
movq -0x28(%rbp), %rdx
addq $0x8, %rdx
movq -0x28(%rbp), %rcx
addq $0x10, %rcx
callq 0x8310
leaq 0xe10a(%rip), %rax      # 0x16248
leaq 0xe13b(%rip), %rcx      # 0x16280
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x81f2
jmp 0x815a
leaq 0xe107(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x8179
movl $0x2, %edi
leaq 0xab8d(%rip), %rsi      # 0x12cff
movb $0x0, %al
callq 0xfda0
jmp 0x817b
movq -0x30(%rbp), %rdi
addq $0x4, %rdi
movl -0x38(%rbp), %esi
movq -0x28(%rbp), %rdx
addq $0x8, %rdx
movq -0x28(%rbp), %rcx
addq $0x10, %rcx
callq 0x8590
leaq 0xe0a6(%rip), %rax      # 0x16248
leaq 0xe0d7(%rip), %rcx      # 0x16280
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
jmp 0x81f2
leaq 0xe0a8(%rip), %rax      # 0x16268
cmpl $0x3, (%rax)
jl 0x81f0
jmp 0x81c7
leaq 0xe09a(%rip), %rax      # 0x16268
cmpl $0x2, (%rax)
jl 0x81ec
movl -0x34(%rbp), %edx
movl -0x38(%rbp), %ecx
movl $0x2, %edi
leaq 0xab7b(%rip), %rsi      # 0x12d60
movb $0x0, %al
callq 0xfda0
jmp 0x81ee
jmp 0x81f0
jmp 0x81f2
movl -0x38(%rbp), %eax
addl $0x4, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
xorl %eax, %eax
subl -0x20(%rbp), %eax
andl $0x3, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x7f13
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x822c
movq -0x28(%rbp), %rdi
callq 0x4f40
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)