// File: /workspace/github_c_makefile_star2_O0/videolan[P]bitstream/examples/dvb_print_si.c
// Function: handle_pat
static void handle_pat(void)
{
    PSI_TABLE_DECLARE(pp_old_pat_sections);
    uint8_t i_last_section = psi_table_get_lastsection(pp_next_pat_sections);
    uint8_t i;

    if (psi_table_validate(pp_current_pat_sections) &&
        psi_table_compare(pp_current_pat_sections, pp_next_pat_sections)) {
        /* Identical PAT. Shortcut. */
        psi_table_free(pp_next_pat_sections);
        psi_table_init(pp_next_pat_sections);
        return;
    }

    if (!pat_table_validate(pp_next_pat_sections)) {
        switch (i_print_type) {
        case PRINT_XML:
            printf("<ERROR type=\"invalid_pat\"/>\n");
            break;
        default:
            printf("invalid PAT received\n");
        }
        psi_table_free(pp_next_pat_sections);
        psi_table_init(pp_next_pat_sections);
        return;
    }

    /* Switch tables. */
    psi_table_copy(pp_old_pat_sections, pp_current_pat_sections);
    psi_table_copy(pp_current_pat_sections, pp_next_pat_sections);
    psi_table_init(pp_next_pat_sections);

    for (i = 0; i <= i_last_section; i++) {
        uint8_t *p_section = psi_table_get_section(pp_current_pat_sections, i);
        const uint8_t *p_program;
        int j = 0;

        while ((p_program = pat_get_program(p_section, j)) != NULL) {
            const uint8_t *p_old_program = NULL;
            uint16_t i_sid = patn_get_program(p_program);
            uint16_t i_pid = patn_get_pid(p_program);
            j++;

            if (i_sid == 0) {
                if (i_pid != NIT_PID)
                    fprintf(stderr,
                        "NIT is carried on PID %hu which isn't DVB compliant\n",
                        i_pid);
                continue; /* NIT */
            }

            if (!psi_table_validate(pp_old_pat_sections)
                  || (p_old_program =
                      pat_table_find_program(pp_old_pat_sections, i_sid))
                       == NULL
                  || patn_get_pid(p_old_program) != i_pid) {
                sid_t *p_sid;
                int i_pmt;
                if (p_old_program != NULL)
                    p_pids[patn_get_pid(p_old_program)].i_psi_refcount--;
                p_pids[i_pid].i_psi_refcount++;

                for (i_pmt = 0; i_pmt < i_nb_sids; i_pmt++)
                    if (pp_sids[i_pmt]->i_sid == i_sid ||
                        pp_sids[i_pmt]->i_sid == 0)
                        break;

                if (i_pmt == i_nb_sids) {
                    p_sid = malloc(sizeof(sid_t));
                    pp_sids = realloc(pp_sids, ++i_nb_sids * sizeof(sid_t *));
                    pp_sids[i_pmt] = p_sid;
                    p_sid->p_current_pmt = NULL;
                    psi_table_init(p_sid->pp_eit_sections);
                }
                else
                    p_sid = pp_sids[i_pmt];

                p_sid->i_sid = i_sid;
                p_sid->i_pmt_pid = i_pid;
            }
        }
    }

    if (psi_table_validate(pp_old_pat_sections)) {
        i_last_section = psi_table_get_lastsection( pp_old_pat_sections );
        for (i = 0; i <= i_last_section; i++) {
            uint8_t *p_section = psi_table_get_section(pp_old_pat_sections, i);
            const uint8_t *p_program;
            int j = 0;

            while ((p_program = pat_get_program(p_section, j)) != NULL) {
                uint16_t i_sid = patn_get_program(p_program);
                j++;

                if (i_sid == 0)
                    continue; /* NIT */

                if (pat_table_find_program(pp_current_pat_sections, i_sid)
                      == NULL) {
                    int i_pmt;
                    for (i_pmt = 0; i_pmt < i_nb_sids; i_pmt++)
                        if (pp_sids[i_pmt]->i_sid == i_sid) {
                            pp_sids[i_pmt]->i_sid = 0;
                            if (pp_sids[i_pmt]->p_current_pmt != NULL)
                                handle_pmt_es(pp_sids[i_pmt]->p_current_pmt,
                                              false);
                            free(pp_sids[i_pmt]->p_current_pmt);
                            pp_sids[i_pmt]->p_current_pmt = NULL;
                            psi_table_free(pp_sids[i]->pp_eit_sections);
                            psi_table_init(pp_sids[i]->pp_eit_sections);
                            break;
                        }
                }
            }
        }

        psi_table_free(pp_old_pat_sections);
    }

    if (pb_print_table[TABLE_PAT])
        pat_table_print(pp_current_pat_sections, print_wrapper, NULL,
                        i_print_type);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x860, %rsp            # imm = 0x860
movq 0x645be(%rip), %rdi     # 0x68b00
callq 0x4b50
movb %al, -0x801(%rbp)
leaq 0x63dac(%rip), %rdi     # 0x68300
callq 0x4bb0
testb $0x1, %al
jne 0x455f
jmp 0x4595
leaq 0x63d9a(%rip), %rdi     # 0x68300
leaq 0x64593(%rip), %rsi     # 0x68b00
callq 0x4bd0
testb $0x1, %al
jne 0x4578
jmp 0x4595
leaq 0x64581(%rip), %rdi     # 0x68b00
callq 0x2de0
leaq 0x64575(%rip), %rdi     # 0x68b00
callq 0x2bb0
jmp 0x4b18
leaq 0x64564(%rip), %rdi     # 0x68b00
callq 0x4c80
testb $0x1, %al
jne 0x45ed
movl 0x33d45(%rip), %eax     # 0x382f0
subl $0x1, %eax
jne 0x45c2
jmp 0x45b2
leaq 0x1f8ed(%rip), %rdi     # 0x23ea6
movb $0x0, %al
callq 0x20b0
jmp 0x45d0
leaq 0x1f8fa(%rip), %rdi     # 0x23ec3
movb $0x0, %al
callq 0x20b0
leaq 0x64529(%rip), %rdi     # 0x68b00
callq 0x2de0
leaq 0x6451d(%rip), %rdi     # 0x68b00
callq 0x2bb0
jmp 0x4b18
leaq -0x800(%rbp), %rdi
leaq 0x63d05(%rip), %rsi     # 0x68300
callq 0x4d70
leaq 0x63cf9(%rip), %rdi     # 0x68300
leaq 0x644f2(%rip), %rsi     # 0x68b00
callq 0x4d70
leaq 0x644e6(%rip), %rdi     # 0x68b00
callq 0x2bb0
movb $0x0, -0x802(%rbp)
movzbl -0x802(%rbp), %eax
movzbl -0x801(%rbp), %ecx
cmpl %ecx, %eax
jg 0x48df
leaq 0x63cbd(%rip), %rdi     # 0x68300
movzbl -0x802(%rbp), %esi
callq 0x4da0
movq %rax, -0x810(%rbp)
movl $0x0, -0x81c(%rbp)
movq -0x810(%rbp), %rdi
movl -0x81c(%rbp), %eax
movzbl %al, %esi
callq 0x4dc0
movq %rax, -0x818(%rbp)
cmpq $0x0, %rax
je 0x48ca
movq $0x0, -0x828(%rbp)
movq -0x818(%rbp), %rdi
callq 0x4e40
movw %ax, -0x82a(%rbp)
movq -0x818(%rbp), %rdi
callq 0x4e60
movw %ax, -0x82c(%rbp)
movl -0x81c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x81c(%rbp)
movzwl -0x82a(%rbp), %eax
cmpl $0x0, %eax
jne 0x4702
movzwl -0x82c(%rbp), %eax
cmpl $0x10, %eax
je 0x46fd
movq 0x3390b(%rip), %rax     # 0x37ff0
movq (%rax), %rdi
movzwl -0x82c(%rbp), %edx
leaq 0x1f7e3(%rip), %rsi     # 0x23ed9
movb $0x0, %al
callq 0x2120
jmp 0x4660
leaq -0x800(%rbp), %rdi
callq 0x4bb0
testb $0x1, %al
jne 0x4714
jmp 0x4752
leaq -0x800(%rbp), %rdi
movzwl -0x82a(%rbp), %esi
callq 0x4e90
movq %rax, -0x828(%rbp)
cmpq $0x0, %rax
je 0x4752
movq -0x828(%rbp), %rdi
callq 0x4e60
movzwl %ax, %eax
movzwl -0x82c(%rbp), %ecx
cmpl %ecx, %eax
je 0x48c5
cmpq $0x0, -0x828(%rbp)
je 0x4782
movq -0x828(%rbp), %rdi
callq 0x4e60
movzwl %ax, %eax
movl %eax, %ecx
leaq 0x33b8c(%rip), %rax     # 0x38300
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movzwl -0x82c(%rbp), %eax
movl %eax, %ecx
leaq 0x33b6e(%rip), %rax     # 0x38300
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl $0x0, -0x83c(%rbp)
movl -0x83c(%rbp), %eax
cmpl 0x68b6a(%rip), %eax     # 0x6d320
jge 0x4807
movq 0x68b69(%rip), %rax     # 0x6d328
movslq -0x83c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movzwl (%rax), %eax
movzwl -0x82a(%rbp), %ecx
cmpl %ecx, %eax
je 0x47f2
movq 0x68b49(%rip), %rax     # 0x6d328
movslq -0x83c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0x47f4
jmp 0x4807
jmp 0x47f6
movl -0x83c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x83c(%rbp)
jmp 0x47aa
movl -0x83c(%rbp), %eax
cmpl 0x68b0d(%rip), %eax     # 0x6d320
jne 0x4889
movl $0x810, %edi            # imm = 0x810
callq 0x2150
movq %rax, -0x838(%rbp)
movq 0x68afb(%rip), %rdi     # 0x6d328
movl 0x68aed(%rip), %eax     # 0x6d320
addl $0x1, %eax
movl %eax, 0x68ae4(%rip)     # 0x6d320
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x2180
movq %rax, 0x68ad9(%rip)     # 0x6d328
movq -0x838(%rbp), %rdx
movq 0x68acb(%rip), %rax     # 0x6d328
movslq -0x83c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x838(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x838(%rbp), %rdi
addq $0x10, %rdi
callq 0x2bb0
jmp 0x48a2
movq 0x68a98(%rip), %rax     # 0x6d328
movslq -0x83c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x838(%rbp)
movw -0x82a(%rbp), %cx
movq -0x838(%rbp), %rax
movw %cx, (%rax)
movw -0x82c(%rbp), %cx
movq -0x838(%rbp), %rax
movw %cx, 0x2(%rax)
jmp 0x4660
jmp 0x48cc
movb -0x802(%rbp), %al
addb $0x1, %al
movb %al, -0x802(%rbp)
jmp 0x4626
leaq -0x800(%rbp), %rdi
callq 0x4bb0
testb $0x1, %al
jne 0x48f4
jmp 0x4af2
movq -0x800(%rbp), %rdi
callq 0x4b50
movb %al, -0x801(%rbp)
movb $0x0, -0x802(%rbp)
movzbl -0x802(%rbp), %eax
movzbl -0x801(%rbp), %ecx
cmpl %ecx, %eax
jg 0x4ae6
leaq -0x800(%rbp), %rdi
movzbl -0x802(%rbp), %esi
callq 0x4da0
movq %rax, -0x848(%rbp)
movl $0x0, -0x854(%rbp)
movq -0x848(%rbp), %rdi
movl -0x854(%rbp), %eax
movzbl %al, %esi
callq 0x4dc0
movq %rax, -0x850(%rbp)
cmpq $0x0, %rax
je 0x4ad1
movq -0x850(%rbp), %rdi
callq 0x4e40
movw %ax, -0x856(%rbp)
movl -0x854(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x854(%rbp)
movzwl -0x856(%rbp), %eax
cmpl $0x0, %eax
jne 0x499d
jmp 0x4947
leaq 0x6395c(%rip), %rdi     # 0x68300
movzwl -0x856(%rbp), %esi
callq 0x4e90
cmpq $0x0, %rax
jne 0x4acc
movl $0x0, -0x85c(%rbp)
movl -0x85c(%rbp), %eax
cmpl 0x68950(%rip), %eax     # 0x6d320
jge 0x4aca
movq 0x6894b(%rip), %rax     # 0x6d328
movslq -0x85c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movzwl (%rax), %eax
movzwl -0x856(%rbp), %ecx
cmpl %ecx, %eax
jne 0x4ab4
movq 0x68927(%rip), %rax     # 0x6d328
movslq -0x85c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movw $0x0, (%rax)
movq 0x68910(%rip), %rax     # 0x6d328
movslq -0x85c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq $0x0, 0x8(%rax)
je 0x4a47
movq 0x688f7(%rip), %rax     # 0x6d328
movslq -0x85c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
xorl %esi, %esi
callq 0x4f40
movq 0x688da(%rip), %rax     # 0x6d328
movslq -0x85c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
callq 0x2030
movq 0x688bf(%rip), %rax     # 0x6d328
movslq -0x85c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x8(%rax)
movq 0x688a5(%rip), %rax     # 0x6d328
movzbl -0x802(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
addq $0x10, %rdi
callq 0x2de0
movq 0x6888a(%rip), %rax     # 0x6d328
movzbl -0x802(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
addq $0x10, %rdi
callq 0x2bb0
jmp 0x4aca
jmp 0x4ab6
movl -0x85c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x85c(%rbp)
jmp 0x49c4
jmp 0x4acc
jmp 0x4947
jmp 0x4ad3
movb -0x802(%rbp), %al
addb $0x1, %al
movb %al, -0x802(%rbp)
jmp 0x490d
leaq -0x800(%rbp), %rdi
callq 0x2de0
testb $0x1, 0x68807(%rip)     # 0x6d300
je 0x4b18
movl 0x337ef(%rip), %ecx     # 0x382f0
leaq 0x637f8(%rip), %rdi     # 0x68300
leaq 0x7d1(%rip), %rsi       # 0x52e0
xorl %eax, %eax
movl %eax, %edx
callq 0x50a0
addq $0x860, %rsp            # imm = 0x860
popq %rbp
retq
nopw %cs:(%rax,%rax)