// File: /workspace/github_c_makefile_star2_O0/videolan[P]bitstream/examples/mpeg_print_pcr.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)) {
        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)
                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;
                }
                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;
                            free(pp_sids[i_pmt]->p_current_pmt);
                            pp_sids[i_pmt]->p_current_pmt = NULL;
                            break;
                        }
                }
            }
        }

        psi_table_free(pp_old_pat_sections);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x860, %rsp            # imm = 0x860
movq 0x3317e(%rip), %rdi     # 0x350b0
callq 0x2440
movb %al, -0x801(%rbp)
leaq 0x3396c(%rip), %rdi     # 0x358b0
callq 0x24a0
testb $0x1, %al
jne 0x1f4f
jmp 0x1f85
leaq 0x3395a(%rip), %rdi     # 0x358b0
leaq 0x33153(%rip), %rsi     # 0x350b0
callq 0x24c0
testb $0x1, %al
jne 0x1f68
jmp 0x1f85
leaq 0x33141(%rip), %rdi     # 0x350b0
callq 0x2570
leaq 0x33135(%rip), %rdi     # 0x350b0
callq 0x25b0
jmp 0x2409
leaq 0x33124(%rip), %rdi     # 0x350b0
callq 0x25f0
testb $0x1, %al
jne 0x1fb2
leaq 0x33114(%rip), %rdi     # 0x350b0
callq 0x2570
leaq 0x33108(%rip), %rdi     # 0x350b0
callq 0x25b0
jmp 0x2409
leaq -0x800(%rbp), %rdi
leaq 0x338f0(%rip), %rsi     # 0x358b0
callq 0x26e0
leaq 0x338e4(%rip), %rdi     # 0x358b0
leaq 0x330dd(%rip), %rsi     # 0x350b0
callq 0x26e0
leaq 0x330d1(%rip), %rdi     # 0x350b0
callq 0x25b0
movb $0x0, -0x802(%rbp)
movzbl -0x802(%rbp), %eax
movzbl -0x801(%rbp), %ecx
cmpl %ecx, %eax
jg 0x2266
leaq 0x338a8(%rip), %rdi     # 0x358b0
movzbl -0x802(%rbp), %esi
callq 0x2710
movq %rax, -0x810(%rbp)
movl $0x0, -0x81c(%rbp)
movq -0x810(%rbp), %rdi
movl -0x81c(%rbp), %eax
movzbl %al, %esi
callq 0x2730
movq %rax, -0x818(%rbp)
cmpq $0x0, %rax
je 0x2251
movq $0x0, -0x828(%rbp)
movq -0x818(%rbp), %rdi
callq 0x27b0
movw %ax, -0x82a(%rbp)
movq -0x818(%rbp), %rdi
callq 0x27d0
movw %ax, -0x82c(%rbp)
movl -0x81c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x81c(%rbp)
movzwl -0x82a(%rbp), %eax
cmpl $0x0, %eax
jne 0x2099
jmp 0x2025
leaq -0x800(%rbp), %rdi
callq 0x24a0
testb $0x1, %al
jne 0x20ab
jmp 0x20e9
leaq -0x800(%rbp), %rdi
movzwl -0x82a(%rbp), %esi
callq 0x2800
movq %rax, -0x828(%rbp)
cmpq $0x0, %rax
je 0x20e9
movq -0x828(%rbp), %rdi
callq 0x27d0
movzwl %ax, %eax
movzwl -0x82c(%rbp), %ecx
cmpl %ecx, %eax
je 0x224c
cmpq $0x0, -0x828(%rbp)
je 0x2119
movq -0x828(%rbp), %rdi
callq 0x27d0
movzwl %ax, %eax
movl %eax, %ecx
leaq 0x2fa5(%rip), %rax      # 0x50b0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movzwl -0x82c(%rbp), %eax
movl %eax, %ecx
leaq 0x2f87(%rip), %rax      # 0x50b0
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 0x33f63(%rip), %eax     # 0x360b0
jge 0x219e
movq 0x33f62(%rip), %rax     # 0x360b8
movslq -0x83c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movzwl (%rax), %eax
movzwl -0x82a(%rbp), %ecx
cmpl %ecx, %eax
je 0x2189
movq 0x33f42(%rip), %rax     # 0x360b8
movslq -0x83c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movzwl (%rax), %eax
cmpl $0x0, %eax
jne 0x218b
jmp 0x219e
jmp 0x218d
movl -0x83c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x83c(%rbp)
jmp 0x2141
movl -0x83c(%rbp), %eax
cmpl 0x33f06(%rip), %eax     # 0x360b0
jne 0x2210
movl $0x10, %edi
callq 0x10d0
movq %rax, -0x838(%rbp)
movq 0x33ef4(%rip), %rdi     # 0x360b8
movl 0x33ee6(%rip), %eax     # 0x360b0
addl $0x1, %eax
movl %eax, 0x33edd(%rip)     # 0x360b0
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x10e0
movq %rax, 0x33ed2(%rip)     # 0x360b8
movq -0x838(%rbp), %rdx
movq 0x33ec4(%rip), %rax     # 0x360b8
movslq -0x83c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x838(%rbp), %rax
movq $0x0, 0x8(%rax)
jmp 0x2229
movq 0x33ea1(%rip), %rax     # 0x360b8
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 0x2025
jmp 0x2253
movb -0x802(%rbp), %al
addb $0x1, %al
movb %al, -0x802(%rbp)
jmp 0x1feb
leaq -0x800(%rbp), %rdi
callq 0x24a0
testb $0x1, %al
jne 0x227b
jmp 0x2409
movq -0x800(%rbp), %rdi
callq 0x2440
movb %al, -0x801(%rbp)
movb $0x0, -0x802(%rbp)
movzbl -0x802(%rbp), %eax
movzbl -0x801(%rbp), %ecx
cmpl %ecx, %eax
jg 0x23fd
leaq -0x800(%rbp), %rdi
movzbl -0x802(%rbp), %esi
callq 0x2710
movq %rax, -0x848(%rbp)
movl $0x0, -0x854(%rbp)
movq -0x848(%rbp), %rdi
movl -0x854(%rbp), %eax
movzbl %al, %esi
callq 0x2730
movq %rax, -0x850(%rbp)
cmpq $0x0, %rax
je 0x23e8
movq -0x850(%rbp), %rdi
callq 0x27b0
movw %ax, -0x856(%rbp)
movl -0x854(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x854(%rbp)
movzwl -0x856(%rbp), %eax
cmpl $0x0, %eax
jne 0x2324
jmp 0x22ce
leaq 0x33585(%rip), %rdi     # 0x358b0
movzwl -0x856(%rbp), %esi
callq 0x2800
cmpq $0x0, %rax
jne 0x23e3
movl $0x0, -0x85c(%rbp)
movl -0x85c(%rbp), %eax
cmpl 0x33d59(%rip), %eax     # 0x360b0
jge 0x23e1
movq 0x33d54(%rip), %rax     # 0x360b8
movslq -0x85c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movzwl (%rax), %eax
movzwl -0x856(%rbp), %ecx
cmpl %ecx, %eax
jne 0x23cb
movq 0x33d34(%rip), %rax     # 0x360b8
movslq -0x85c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movw $0x0, (%rax)
movq 0x33d1d(%rip), %rax     # 0x360b8
movslq -0x85c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rdi
callq 0x1030
movq 0x33d02(%rip), %rax     # 0x360b8
movslq -0x85c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq $0x0, 0x8(%rax)
jmp 0x23e1
jmp 0x23cd
movl -0x85c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x85c(%rbp)
jmp 0x234b
jmp 0x23e3
jmp 0x22ce
jmp 0x23ea
movb -0x802(%rbp), %al
addb $0x1, %al
movb %al, -0x802(%rbp)
jmp 0x2294
leaq -0x800(%rbp), %rdi
callq 0x2570
addq $0x860, %rsp            # imm = 0x860
popq %rbp
retq
nopw %cs:(%rax,%rax)