// File: /workspace/github_c_makefile_star2_O0/videolan[P]bitstream/examples/./bitstream/dvb/si/bat.h
// Function: bat_validate
static inline bool bat_validate(const uint8_t *p_bat)
{
    uint16_t i_section_size = psi_get_length(p_bat) + PSI_HEADER_SIZE
                               - PSI_CRC_SIZE;
    const uint8_t *p_bat_n;

    if (!psi_get_syntax(p_bat) || psi_get_tableid(p_bat) != BAT_TABLE_ID)
        return false;

    if (i_section_size < BAT_HEADER_SIZE
         || i_section_size < BAT_HEADER_SIZE + bat_get_desclength(p_bat))
        return false;

    if (!descs_validate(p_bat + 8))
        return false;

    p_bat_n = p_bat + BAT_HEADER_SIZE + bat_get_desclength(p_bat);

    if (bath_get_tslength(p_bat_n) != p_bat + i_section_size - p_bat_n
         - BAT_HEADER2_SIZE)
        return false;
    p_bat_n += BAT_HEADER2_SIZE;

    while (p_bat_n + BAT_TS_SIZE - p_bat <= i_section_size
            && p_bat_n + BAT_TS_SIZE + batn_get_desclength(p_bat_n) - p_bat
                <= i_section_size) {
        if (!descs_validate(p_bat_n + 4))
            return false;

        p_bat_n += BAT_TS_SIZE + batn_get_desclength(p_bat_n);
    }

    return (p_bat_n - p_bat == i_section_size);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3500
movzwl %ax, %eax
addl $0x3, %eax
subl $0x4, %eax
movw %ax, -0x12(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4360
testb $0x1, %al
jne 0x1dc01
jmp 0x1dc12
movq -0x10(%rbp), %rdi
callq 0x3530
movzbl %al, %eax
cmpl $0x4a, %eax
je 0x1dc1b
movb $0x0, -0x1(%rbp)
jmp 0x1dd83
movzwl -0x12(%rbp), %eax
cmpl $0xa, %eax
jl 0x1dc44
movzwl -0x12(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1d4d0
movw %ax, %cx
movl -0x24(%rbp), %eax
movzwl %cx, %ecx
addl $0xa, %ecx
cmpl %ecx, %eax
jge 0x1dc4d
movb $0x0, -0x1(%rbp)
jmp 0x1dd83
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0x1ce60
testb $0x1, %al
jne 0x1dc67
movb $0x0, -0x1(%rbp)
jmp 0x1dd83
movq -0x10(%rbp), %rax
addq $0xa, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1d4d0
movw %ax, %cx
movq -0x30(%rbp), %rax
movzwl %cx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1d500
movzwl %ax, %eax
movq -0x10(%rbp), %rcx
movzwl -0x12(%rbp), %edx
movslq %edx, %rdx
addq %rdx, %rcx
movq -0x20(%rbp), %rdx
subq %rdx, %rcx
subq $0x2, %rcx
cmpq %rcx, %rax
je 0x1dcc3
movb $0x0, -0x1(%rbp)
jmp 0x1dd83
movq -0x20(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rcx
addq $0x6, %rcx
movq -0x10(%rbp), %rax
subq %rax, %rcx
movzwl -0x12(%rbp), %eax
movl %eax, %edx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x31(%rbp)
jg 0x1dd27
movq -0x20(%rbp), %rax
addq $0x6, %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rdi
callq 0x1d530
movw %ax, %cx
movq -0x40(%rbp), %rax
movzwl %cx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movzwl -0x12(%rbp), %ecx
cmpq %rcx, %rax
setle %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x1dd30
jmp 0x1dd69
movq -0x20(%rbp), %rdi
addq $0x4, %rdi
callq 0x1ce60
testb $0x1, %al
jne 0x1dd47
movb $0x0, -0x1(%rbp)
jmp 0x1dd83
movq -0x20(%rbp), %rdi
callq 0x1d530
movzwl %ax, %ecx
addl $0x6, %ecx
movq -0x20(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0x1dccf
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movzwl -0x12(%rbp), %ecx
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nop