// File: /workspace/github_c_makefile_star2_O0/videolan[P]bitstream/examples/dvb_gen_si.c
// Function: generate_tsdt
static void generate_tsdt(void) {
    // Generate empty tsdt
    uint8_t *tsdt = psi_allocate();
    uint8_t *desc;
    uint8_t desc_loop[DESCS_HEADER_SIZE + DESCS_MAX_SIZE];
    uint8_t desc_counter;

    tsdt_init(tsdt);
    tsdt_set_length(tsdt, 0);
    psi_set_version(tsdt, 0);
    psi_set_current(tsdt);
    psi_set_crc(tsdt);
    output_psi_section(tsdt, TSDT_PID, &cc);

    // Add couple of descriptors to TSDT
    psi_set_version(tsdt, 1);
    psi_set_current(tsdt);
    psi_set_length(tsdt, PSI_MAX_SIZE);

    descs_set_length(desc_loop, DESCS_MAX_SIZE);
    desc_counter = 0;

    desc = descs_get_desc(desc_loop, desc_counter++);
    build_desc67(desc, "DVB");

    desc = descs_get_desc(desc_loop, desc_counter++);
    build_desc67(desc, "CONT");

    desc = descs_get_desc(desc_loop, desc_counter++);
    build_desc68(desc);

    // Finish descriptor generation
    desc = descs_get_desc(desc_loop, desc_counter); // Get next descriptor pos
    descs_set_length(desc_loop, desc - desc_loop - DESCS_HEADER_SIZE);
    tsdt_set_desclength(tsdt, descs_get_length(desc_loop));
    // Put descriptor loop into TSDT
    memcpy(tsdt_get_descl(tsdt), desc_loop + DESCS_HEADER_SIZE,
        descs_get_length(desc_loop));

    psi_set_crc(tsdt);
    output_psi_section(tsdt, TSDT_PID, &cc);

    free(tsdt);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1040, %rsp           # imm = 0x1040
callq 0x4f30
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x5cc0
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x5940
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x4ff0
movq -0x8(%rbp), %rdi
callq 0x5020
movq -0x8(%rbp), %rdi
callq 0x5080
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x1f914(%rip), %rdx     # 0x210b9
callq 0x5170
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x4ff0
movq -0x8(%rbp), %rdi
callq 0x5020
movq -0x8(%rbp), %rdi
movl $0x3fd, %esi            # imm = 0x3FD
callq 0x5290
leaq -0x1020(%rbp), %rdi
movl $0xfff, %esi            # imm = 0xFFF
callq 0x5970
movb $0x0, -0x1021(%rbp)
leaq -0x1020(%rbp), %rdi
movb -0x1021(%rbp), %al
movb %al, %cl
addb $0x1, %cl
movb %cl, -0x1021(%rbp)
leaq 0x422a(%rip), %rdx      # 0x5a30
movzbl %al, %esi
callq 0x59c0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x15c09(%rip), %rsi     # 0x17426
callq 0x5d20
leaq -0x1020(%rbp), %rdi
movb -0x1021(%rbp), %al
movb %al, %cl
addb $0x1, %cl
movb %cl, -0x1021(%rbp)
leaq 0x41ef(%rip), %rdx      # 0x5a30
movzbl %al, %esi
callq 0x59c0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x15bd2(%rip), %rsi     # 0x1742a
callq 0x5d20
leaq -0x1020(%rbp), %rdi
movb -0x1021(%rbp), %al
movb %al, %cl
addb $0x1, %cl
movb %cl, -0x1021(%rbp)
leaq 0x41b4(%rip), %rdx      # 0x5a30
movzbl %al, %esi
callq 0x59c0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5d70
leaq -0x1020(%rbp), %rdi
leaq 0x4191(%rip), %rdx      # 0x5a30
movzbl -0x1021(%rbp), %esi
callq 0x59c0
movq %rax, -0x10(%rbp)
leaq -0x1020(%rbp), %rdi
movq -0x10(%rbp), %rax
leaq -0x1020(%rbp), %rcx
subq %rcx, %rax
subq $0x2, %rax
movzwl %ax, %esi
callq 0x5970
movq -0x8(%rbp), %rax
movq %rax, -0x1040(%rbp)
leaq -0x1020(%rbp), %rdi
callq 0x5ae0
movq -0x1040(%rbp), %rdi
movzwl %ax, %esi
callq 0x5ab0
movq -0x8(%rbp), %rdi
callq 0x5b10
movq %rax, -0x1038(%rbp)
leaq -0x1020(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x1030(%rbp)
leaq -0x1020(%rbp), %rdi
callq 0x5ae0
movq -0x1038(%rbp), %rdi
movq -0x1030(%rbp), %rsi
movzwl %ax, %eax
movl %eax, %edx
callq 0x1090
movq -0x8(%rbp), %rdi
callq 0x5080
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x1f764(%rip), %rdx     # 0x210b9
callq 0x5170
movq -0x8(%rbp), %rdi
callq 0x1030
addq $0x1040, %rsp           # imm = 0x1040
popq %rbp
retq
nopl (%rax)