// File: /workspace/github_c_makefile_star2_O3/videolan[P]bitstream/examples/./bitstream/scte/35.h
// Function: scte35_insert_validate
static inline bool scte35_insert_validate(const uint8_t *p_scte35)
{
    size_t i_length = scte35_get_command_length(p_scte35);
    if (i_length < SCTE35_INSERT_HEADER_SIZE)
        return false;

    if (scte35_insert_has_cancel(p_scte35))
        return i_length <= SCTE35_INSERT_HEADER_SIZE;
    if (i_length < SCTE35_INSERT_HEADER_SIZE + SCTE35_INSERT_HEADER2_SIZE)
        return false;

    if (scte35_insert_has_program_splice(p_scte35)) {
        if (scte35_insert_has_splice_immediate(p_scte35)) {
            if (scte35_insert_has_duration(p_scte35))
                return i_length >= SCTE35_INSERT_HEADER_SIZE +
                                   SCTE35_INSERT_HEADER2_SIZE +
                                   SCTE35_BREAK_DURATION_HEADER_SIZE +
                                   SCTE35_INSERT_FOOTER_SIZE;
            return i_length >= SCTE35_INSERT_HEADER_SIZE +
                               SCTE35_INSERT_HEADER2_SIZE +
                               SCTE35_INSERT_FOOTER_SIZE;
        }

        if (i_length < SCTE35_INSERT_HEADER_SIZE + SCTE35_INSERT_HEADER2_SIZE +
                       SCTE35_SPLICE_TIME_HEADER_SIZE ||
            i_length < SCTE35_INSERT_HEADER_SIZE + SCTE35_INSERT_HEADER2_SIZE +
                       scte35_splice_time_size(
                           scte35_insert_get_splice_time(p_scte35)))
            return false;

        if (scte35_insert_has_duration(p_scte35))
            return i_length >= SCTE35_INSERT_HEADER_SIZE +
                SCTE35_INSERT_HEADER2_SIZE +
                scte35_splice_time_size(scte35_insert_get_splice_time(p_scte35))
                + SCTE35_BREAK_DURATION_HEADER_SIZE +
                SCTE35_INSERT_FOOTER_SIZE;
        return i_length >= SCTE35_INSERT_HEADER_SIZE +
            SCTE35_INSERT_HEADER2_SIZE +
            scte35_splice_time_size(scte35_insert_get_splice_time(p_scte35))
            + SCTE35_INSERT_FOOTER_SIZE;
    }

    if (i_length < SCTE35_INSERT_HEADER_SIZE + SCTE35_INSERT_HEADER2_SIZE +
                   SCTE35_INSERT_COMPONENT_COUNT_SIZE)
        return false;

    const uint8_t *p_command = scte35_get_command(p_scte35);
    const uint8_t *p_end = scte35_insert_get_component(p_scte35,
            scte35_insert_get_component_count(p_scte35) + 1);
    if (p_end == NULL)
        return false;

    if (scte35_insert_has_duration(p_scte35))
        return i_length >= p_end + SCTE35_BREAK_DURATION_HEADER_SIZE +
                                   SCTE35_INSERT_FOOTER_SIZE - p_command;
    return i_length >= p_end + SCTE35_INSERT_FOOTER_SIZE - p_command;
}

// Assembly:
movzbl 0xb(%rdi), %ecx
movzbl 0xc(%rdi), %eax
andl $0xf, %ecx
shll $0x8, %ecx
orq %rax, %rcx
cmpw $0x5, %cx
jae 0x10cef
xorl %eax, %eax
retq
movb 0x12(%rdi), %dl
testb %dl, %dl
sets %sil
cmpw $0x5, %cx
sete %al
andb %sil, %al
testb %dl, %dl
js 0x10cee
cmpw $0x5, %cx
je 0x10cee
movb 0x13(%rdi), %al
testb $0x40, %al
jne 0x10d98
cmpw $0x7, %cx
jb 0x10cec
movzbl 0x1(%rdi), %edx
movzbl 0x2(%rdi), %esi
andl $0xf, %edx
shll $0x8, %edx
addl %esi, %edx
decl %edx
movzwl %dx, %esi
cmpl $0x15, %esi
jb 0x10cec
movb 0x14(%rdi), %r8b
leaq 0x15(%rdi), %rdx
incb %r8b
je 0x10d78
leaq 0x1(%rdx), %r9
movq %r9, %r10
subq %rdi, %r10
cmpq %rsi, %r10
jg 0x10cec
movl $0x1, %r10d
testb $0x10, %al
je 0x10d70
movb (%r9), %r9b
shrb $0x7, %r9b
movzbl %r9b, %r9d
leaq 0x2(,%r9,4), %r10
addq %r10, %rdx
decb %r8b
jne 0x10d44
movq %rdx, %r8
subq %rdi, %r8
cmpq %rsi, %r8
jge 0x10cec
addq $0xe, %rdi
subq %rdi, %rdx
testb $0x20, %al
jne 0x10de7
addq $0x4, %rdx
jmp 0x10deb
testb $0x10, %al
jne 0x10dca
cmpw $0x7, %cx
jb 0x10cec
movb 0x14(%rdi), %dl
shrb $0x5, %dl
andb $0x4, %dl
leal 0x7(%rdx), %esi
movzbl %sil, %esi
cmpw %si, %cx
jb 0x10cec
incb %dl
testb $0x20, %al
jne 0x10dda
orb $0xa, %dl
jmp 0x10ddd
testb $0x20, %al
jne 0x10dd4
cmpw $0xa, %cx
jmp 0x10de3
cmpw $0xf, %cx
jmp 0x10de3
addb $0xf, %dl
movzbl %dl, %eax
cmpw %ax, %cx
setae %al
retq
addq $0x9, %rdx
cmpq %rcx, %rdx
setbe %al
retq