// File: /workspace/github_c_makefile_star2_O1/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), %eax
andl $0xf, %eax
shll $0x8, %eax
movzbl 0xc(%rdi), %ecx
orq %rax, %rcx
cmpw $0x5, %cx
jae 0x11d1b
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 0x11d1a
cmpw $0x5, %cx
je 0x11d1a
movb 0x13(%rdi), %al
testb $0x40, %al
jne 0x11d66
cmpw $0x7, %cx
jb 0x11d18
movzbl 0x1(%rdi), %edx
andl $0xf, %edx
shll $0x8, %edx
movzbl 0x2(%rdi), %esi
addl %esi, %edx
decl %edx
movzwl %dx, %esi
cmpl $0x15, %esi
jae 0x11da4
xorl %edx, %edx
jmp 0x11df6
testb $0x10, %al
jne 0x11d97
cmpw $0x7, %cx
jb 0x11d18
movb 0x14(%rdi), %dl
shrb $0x5, %dl
andb $0x4, %dl
leal 0x7(%rdx), %esi
movzbl %sil, %esi
cmpw %si, %cx
jb 0x11d18
incb %dl
testb $0x20, %al
jne 0x11e21
orb $0xa, %dl
jmp 0x11e24
testb $0x20, %al
jne 0x11e10
cmpw $0xa, %cx
jmp 0x11e2a
movb 0x14(%rdi), %r9b
leaq 0x15(%rdi), %r8
incb %r9b
je 0x11de7
xorl %edx, %edx
leaq 0x1(%r8), %r10
movq %r10, %r11
subq %rdi, %r11
cmpq %rsi, %r11
jg 0x11df6
movl $0x1, %r11d
testb $0x10, %al
je 0x11ddf
movb (%r10), %r10b
shrb $0x7, %r10b
movzbl %r10b, %r10d
leaq 0x2(,%r10,4), %r11
addq %r11, %r8
decb %r9b
jne 0x11db3
movq %r8, %r9
subq %rdi, %r9
xorl %edx, %edx
cmpq %rsi, %r9
cmovlq %r8, %rdx
testq %rdx, %rdx
je 0x11d18
addq $0xe, %rdi
subq %rdi, %rdx
testb $0x20, %al
jne 0x11e16
addq $0x4, %rdx
jmp 0x11e1a
cmpw $0xf, %cx
jmp 0x11e2a
addq $0x9, %rdx
cmpq %rcx, %rdx
setbe %al
retq
addb $0xf, %dl
movzbl %dl, %eax
cmpw %ax, %cx
setae %al
retq