// File: /workspace/github_c_makefile_star2_O0/videolan[P]bitstream/examples/dvb_gen_si.c
// Function: generate_pat
static void generate_pat(void) {
    // Generate empty PAT
    uint8_t *pat = psi_allocate();
    uint8_t *pat_n;
    uint8_t j = 0;

    // Generate empty PAT
    pat_init(pat);
    pat_set_length(pat, 0);
    pat_set_tsid(pat, tsid);
    psi_set_version(pat, 0);
    psi_set_current(pat);
    psi_set_section(pat, 0);
    psi_set_lastsection(pat, 0);
    psi_set_crc(pat);
    output_psi_section(pat, PAT_PID, &cc);

    // Increase PAT version
    psi_set_version(pat, 1);
    psi_set_current(pat);
    psi_set_crc(pat);
    output_psi_section(pat, PAT_PID, &cc);

    // Add couple of programs to PAT
    psi_set_version(pat, 2);
    psi_set_current(pat);
    psi_set_length(pat, PSI_MAX_SIZE);

    pat_n = pat_get_program(pat, j++);
    patn_init(pat_n);
    patn_set_program(pat_n, 0);
    patn_set_pid(pat_n, NIT_PID);

    pat_n = pat_get_program(pat, j++);
    patn_init(pat_n);
    patn_set_program(pat_n, sid);
    patn_set_pid(pat_n, pmt_pid);

    pat_n = pat_get_program(pat, j++);
    patn_init(pat_n);
    patn_set_program(pat_n, sid + 100);
    patn_set_pid(pat_n, pmt_pid + 100);

    pat_n = pat_get_program(pat, j++);
    patn_init(pat_n);
    patn_set_program(pat_n, sid + 200);
    patn_set_pid(pat_n, pmt_pid + 200);

    pat_n = pat_get_program(pat, j++);
    patn_init(pat_n);
    patn_set_program(pat_n, sid + 300);
    patn_set_pid(pat_n, pmt_pid + 300);

    // Set correct PAT length
    pat_n = pat_get_program(pat, j); // Get offset of the end of last program
    pat_set_length(pat, pat_n - pat - PAT_HEADER_SIZE);
    psi_set_crc(pat);

    output_psi_section(pat, PAT_PID, &cc);

    free(pat);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
callq 0x4f30
movq %rax, -0x8(%rbp)
movb $0x0, -0x11(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4f40
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x4f80
movq -0x8(%rbp), %rdi
movzwl 0x1fe04(%rip), %esi     # 0x21088
callq 0x4fb0
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x4ff0
movq -0x8(%rbp), %rdi
callq 0x5020
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x5040
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x5060
movq -0x8(%rbp), %rdi
callq 0x5080
movq -0x8(%rbp), %rdi
xorl %esi, %esi
leaq 0x1fdf0(%rip), %rdx     # 0x210b9
callq 0x5170
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x4ff0
movq -0x8(%rbp), %rdi
callq 0x5020
movq -0x8(%rbp), %rdi
callq 0x5080
movq -0x8(%rbp), %rdi
xorl %esi, %esi
leaq 0x1fdbe(%rip), %rdx     # 0x210b9
callq 0x5170
movq -0x8(%rbp), %rdi
movl $0x2, %esi
callq 0x4ff0
movq -0x8(%rbp), %rdi
callq 0x5020
movq -0x8(%rbp), %rdi
movl $0x3fd, %esi            # imm = 0x3FD
callq 0x5290
movq -0x8(%rbp), %rdi
movb -0x11(%rbp), %al
movb %al, %cl
addb $0x1, %cl
movb %cl, -0x11(%rbp)
movzbl %al, %esi
callq 0x52e0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5360
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x5380
movq -0x10(%rbp), %rdi
movl $0x10, %esi
callq 0x53c0
movq -0x8(%rbp), %rdi
movb -0x11(%rbp), %al
movb %al, %cl
addb $0x1, %cl
movb %cl, -0x11(%rbp)
movzbl %al, %esi
callq 0x52e0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5360
movq -0x10(%rbp), %rdi
movzwl 0x1fcf9(%rip), %esi     # 0x2108a
callq 0x5380
movq -0x10(%rbp), %rdi
movzwl 0x1fcef(%rip), %esi     # 0x21090
callq 0x53c0
movq -0x8(%rbp), %rdi
movb -0x11(%rbp), %al
movb %al, %cl
addb $0x1, %cl
movb %cl, -0x11(%rbp)
movzbl %al, %esi
callq 0x52e0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5360
movq -0x10(%rbp), %rdi
movzwl 0x1fcb5(%rip), %eax     # 0x2108a
addl $0x64, %eax
movzwl %ax, %esi
callq 0x5380
movq -0x10(%rbp), %rdi
movzwl 0x1fca5(%rip), %eax     # 0x21090
addl $0x64, %eax
movzwl %ax, %esi
callq 0x53c0
movq -0x8(%rbp), %rdi
movb -0x11(%rbp), %al
movb %al, %cl
addb $0x1, %cl
movb %cl, -0x11(%rbp)
movzbl %al, %esi
callq 0x52e0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5360
movq -0x10(%rbp), %rdi
movzwl 0x1fc65(%rip), %eax     # 0x2108a
addl $0xc8, %eax
movzwl %ax, %esi
callq 0x5380
movq -0x10(%rbp), %rdi
movzwl 0x1fc53(%rip), %eax     # 0x21090
addl $0xc8, %eax
movzwl %ax, %esi
callq 0x53c0
movq -0x8(%rbp), %rdi
movb -0x11(%rbp), %al
movb %al, %cl
addb $0x1, %cl
movb %cl, -0x11(%rbp)
movzbl %al, %esi
callq 0x52e0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5360
movq -0x10(%rbp), %rdi
movzwl 0x1fc11(%rip), %eax     # 0x2108a
addl $0x12c, %eax            # imm = 0x12C
movzwl %ax, %esi
callq 0x5380
movq -0x10(%rbp), %rdi
movzwl 0x1fbff(%rip), %eax     # 0x21090
addl $0x12c, %eax            # imm = 0x12C
movzwl %ax, %esi
callq 0x53c0
movq -0x8(%rbp), %rdi
movzbl -0x11(%rbp), %esi
callq 0x52e0
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
subq $0x8, %rax
movzwl %ax, %esi
callq 0x4f80
movq -0x8(%rbp), %rdi
callq 0x5080
movq -0x8(%rbp), %rdi
xorl %esi, %esi
leaq 0x1fbd9(%rip), %rdx     # 0x210b9
callq 0x5170
movq -0x8(%rbp), %rdi
callq 0x1030
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)