// File: /workspace/github_c_makefile_star2_O0/videolan[P]bitstream/examples/./bitstream/dvb/sim.h
// Function: ecmg_validate
static inline bool ecmg_validate(uint8_t *p_tlv)
{
    static const tlv_param_count_t p_ecmg_params_channel_setup[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {ECMG_PARAM_SUPERCASID, 1, 1}, {0, 0, 0}
    };
    static const tlv_param_count_t p_ecmg_params_channel_test[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {0, 0, 0}
    };
    static const tlv_param_count_t p_ecmg_params_channel_status[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {ECMG_PARAM_SECTIONTSPKT, 1, 1},
        {ECMG_PARAM_ACDELAYSTART, 0, 1}, {ECMG_PARAM_ACDELAYSTOP, 0, 1},
        {ECMG_PARAM_DELAYSTART, 1, 1}, {ECMG_PARAM_DELAYSTOP, 1, 1},
        {ECMG_PARAM_TRANSDELAYSTART, 0, 1}, {ECMG_PARAM_TRANSDELAYSTOP, 0, 1},
        {ECMG_PARAM_REPPERIOD, 1, 1}, {ECMG_PARAM_MAXSTREAMS, 1, 1},
        {ECMG_PARAM_MINCPDUR, 1, 1}, {ECMG_PARAM_LEADCW, 1, 1},
        {ECMG_PARAM_CWPERMSG, 1, 1}, {ECMG_PARAM_MAXCOMPTIME, 1, 1}, {0, 0, 0}
    };
    static const tlv_param_count_t p_ecmg_params_channel_close[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {0, 0, 0}
    };
    static const tlv_param_count_t p_ecmg_params_channel_error[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {ECMG_PARAM_ERRORSTATUS, 1, UINT16_MAX},
        {0, 0, 0}
    };

    static const tlv_param_count_t p_ecmg_params_stream_setup[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {ECMG_PARAM_STREAMID, 1, 1},
        {ECMG_PARAM_ECMID, 0, 1}, {ECMG_PARAM_NOMCPDUR, 1, 1}, {0, 0, 0}
    };
    static const tlv_param_count_t p_ecmg_params_stream_test[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {ECMG_PARAM_STREAMID, 1, 1}, {0, 0, 0}
    };
    static const tlv_param_count_t p_ecmg_params_stream_status[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {ECMG_PARAM_STREAMID, 1, 1},
        {ECMG_PARAM_ECMID, 0, 1}, {ECMG_PARAM_ACCESSCRITMODE, 1, 1}, {0, 0, 0}
    };
    static const tlv_param_count_t p_ecmg_params_stream_close[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {ECMG_PARAM_STREAMID, 1, 1}, {0, 0, 0}
    };
    static const tlv_param_count_t p_ecmg_params_stream_error[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {ECMG_PARAM_STREAMID, 1, 1},
        {ECMG_PARAM_ERRORSTATUS, 1, UINT16_MAX}, {0, 0, 0}
    };
    static const tlv_param_count_t p_ecmg_params_cw[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {ECMG_PARAM_STREAMID, 1, 1},
        {ECMG_PARAM_CPNUMBER, 1, 1}, {ECMG_PARAM_CWENCRYPT, 0, 1},
        {ECMG_PARAM_CPCWCOMB, 1, UINT16_MAX}, {ECMG_PARAM_CPDUR, 0, 1},
        {ECMG_PARAM_ACCESSCRIT, 0, 1}, {0, 0, 0}
    };
    static const tlv_param_count_t p_ecmg_params_ecm[] = {
        {ECMG_PARAM_CHANNELID, 1, 1}, {ECMG_PARAM_STREAMID, 1, 1},
        {ECMG_PARAM_CPNUMBER, 1, 1}, {ECMG_PARAM_ECM, 1, 1}, {0, 0, 0}
    };

    const tlv_param_count_t null_param = {0, 0, 0};
    const tlv_param_count_t *p_param = &null_param;
    uint8_t *p_tlv_n;
    int j = 0;

    switch (tlv_get_type(p_tlv)) {
        case ECMG_TYPE_CHANNEL_SETUP:
            p_param = p_ecmg_params_channel_setup; break;
        case ECMG_TYPE_CHANNEL_TEST:
            p_param = p_ecmg_params_channel_test; break;
        case ECMG_TYPE_CHANNEL_STATUS:
            p_param = p_ecmg_params_channel_status; break;
        case ECMG_TYPE_CHANNEL_CLOSE:
            p_param = p_ecmg_params_channel_close; break;
        case ECMG_TYPE_CHANNEL_ERROR:
            p_param = p_ecmg_params_channel_error; break;
        case ECMG_TYPE_STREAM_SETUP:
            p_param = p_ecmg_params_stream_setup; break;
        case ECMG_TYPE_STREAM_TEST:
            p_param = p_ecmg_params_stream_test; break;
        case ECMG_TYPE_STREAM_STATUS:
            p_param = p_ecmg_params_stream_status; break;
        case ECMG_TYPE_STREAM_CLOSEREQ:
        case ECMG_TYPE_STREAM_CLOSERESP:
            p_param = p_ecmg_params_stream_close; break;
        case ECMG_TYPE_STREAM_ERROR:
            p_param = p_ecmg_params_stream_error; break;
        case ECMG_TYPE_CW:
            p_param = p_ecmg_params_cw; break;
        case ECMG_TYPE_ECM:
            p_param = p_ecmg_params_ecm; break;
        default:
            break;
    }

    while (p_param->i_type)
        if (!tlv_validate_count_param(p_tlv, p_param++))
            return false;

    while ((p_tlv_n = tlv_get_param(p_tlv, j)) != NULL) {
        j++;
        if (!ecmg_validate_param(p_tlv_n)) return false;
    }

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movw $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
leaq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x19d0
movzwl %ax, %ecx
movl %ecx, -0x30(%rbp)
subw $0x1, %ax
je 0x1ba1
jmp 0x1af3
movl -0x30(%rbp), %eax
subl $0x2, %eax
je 0x1bb1
jmp 0x1b01
movl -0x30(%rbp), %eax
subl $0x3, %eax
je 0x1bc1
jmp 0x1b0f
movl -0x30(%rbp), %eax
subl $0x4, %eax
je 0x1bce
jmp 0x1b1d
movl -0x30(%rbp), %eax
subl $0x5, %eax
je 0x1bdb
jmp 0x1b2b
movl -0x30(%rbp), %eax
subl $0x101, %eax            # imm = 0x101
je 0x1be8
jmp 0x1b3b
movl -0x30(%rbp), %eax
subl $0x102, %eax            # imm = 0x102
je 0x1bf5
jmp 0x1b4b
movl -0x30(%rbp), %eax
subl $0x103, %eax            # imm = 0x103
je 0x1c02
jmp 0x1b5b
movl -0x30(%rbp), %eax
addl $0xfffffefc, %eax       # imm = 0xFFFFFEFC
subl $0x2, %eax
jb 0x1c0f
jmp 0x1b6e
movl -0x30(%rbp), %eax
subl $0x106, %eax            # imm = 0x106
je 0x1c1c
jmp 0x1b7e
movl -0x30(%rbp), %eax
subl $0x201, %eax            # imm = 0x201
je 0x1c29
jmp 0x1b8e
movl -0x30(%rbp), %eax
subl $0x202, %eax            # imm = 0x202
je 0x1c36
jmp 0x1c43
leaq 0x3668(%rip), %rax      # 0x5210
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x366a(%rip), %rax      # 0x5222
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x3668(%rip), %rax      # 0x5230
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x36b5(%rip), %rax      # 0x528a
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x36be(%rip), %rax      # 0x52a0
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x36d1(%rip), %rax      # 0x52c0
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x36e4(%rip), %rax      # 0x52e0
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x36f7(%rip), %rax      # 0x5300
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x370a(%rip), %rax      # 0x5320
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x371d(%rip), %rax      # 0x5340
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x3730(%rip), %rax      # 0x5360
movq %rax, -0x20(%rbp)
jmp 0x1c45
leaq 0x3753(%rip), %rax      # 0x5390
movq %rax, -0x20(%rbp)
jmp 0x1c45
jmp 0x1c45
jmp 0x1c47
movq -0x20(%rbp), %rax
cmpw $0x0, (%rax)
je 0x1c75
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq %rsi, %rax
addq $0x6, %rax
movq %rax, -0x20(%rbp)
callq 0x2920
testb $0x1, %al
jne 0x1c73
movb $0x0, -0x1(%rbp)
jmp 0x1cb2
jmp 0x1c47
jmp 0x1c77
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
movzwl %ax, %esi
callq 0x2770
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x1cae
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rdi
callq 0x2980
testb $0x1, %al
jne 0x1cac
movb $0x0, -0x1(%rbp)
jmp 0x1cb2
jmp 0x1c77
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)