// File: /workspace/github_c_makefile_star2_O0/videolan[P]bitstream/examples/dvb_gen_si.c
// Function: generate_tot
static void generate_tot(void) {
    uint8_t *tot = psi_allocate();
    uint8_t *desc_loop, *desc;
    uint8_t desc_counter;

    tot_init(tot);
    tot_set_length(tot, 0);
    tot_set_desclength(tot, 0);

    tot_set_utc(tot, dvb_time_encode_UTC(ts_0));
    if (dvb_time_decode_UTC(tot_get_utc(tot)) != ts_0)
        fprintf(stderr, "check tot_get_set_utc!!!\n");
    psi_set_crc(tot);
    output_psi_section(tot, TOT_PID, &cc);

    tot_set_utc(tot, dvb_time_encode_UTC(ts_1));
    if (dvb_time_decode_UTC(tot_get_utc(tot)) != ts_1)
        fprintf(stderr, "check tot_get_set_utc!!!\n");
    psi_set_crc(tot);
    output_psi_section(tot, TOT_PID, &cc);

    /* Change time */
    tot_set_utc(tot, dvb_time_encode_UTC(ts_2));

    /* Add some descriptors */
    desc_loop = tot_get_descs(tot); // First descriptor
    tot_set_desclength(tot, DESCS_MAX_SIZE);
    desc_counter = 0;

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

    // Finish descriptor generation
    desc = descs_get_desc(desc_loop, desc_counter); // Get next descriptor pos
    tot_set_desclength(tot, desc - desc_loop - DESCS_HEADER_SIZE);
    tot_set_length(tot, tot_get_desclength(tot) + DESCS_HEADER_SIZE);
    psi_set_crc(tot);

    output_psi_section(tot, TOT_PID, &cc);

    free(tot);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
callq 0x4f30
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xdac0
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0xdb00
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0xdb30
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq 0x1db49(%rip), %rdi     # 0x21098
callq 0xb620
movq -0x28(%rbp), %rdi
movq %rax, %rsi
callq 0xd7c0
movq -0x8(%rbp), %rdi
callq 0xd8d0
movq %rax, %rdi
callq 0xd840
cmpq 0x1db20(%rip), %rax     # 0x21098
je 0x3592
movq 0x1da77(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
leaq 0x14002(%rip), %rsi     # 0x1758d
movb $0x0, %al
callq 0x1080
movq -0x8(%rbp), %rdi
callq 0x5080
movq -0x8(%rbp), %rdi
movl $0x14, %esi
leaq 0x1db0e(%rip), %rdx     # 0x210b9
callq 0x5170
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq 0x1dae1(%rip), %rdi     # 0x210a0
callq 0xb620
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0xd7c0
movq -0x8(%rbp), %rdi
callq 0xd8d0
movq %rax, %rdi
callq 0xd840
cmpq 0x1dab8(%rip), %rax     # 0x210a0
je 0x3602
movq 0x1da07(%rip), %rax     # 0x20ff8
movq (%rax), %rdi
leaq 0x13f92(%rip), %rsi     # 0x1758d
movb $0x0, %al
callq 0x1080
movq -0x8(%rbp), %rdi
callq 0x5080
movq -0x8(%rbp), %rdi
movl $0x14, %esi
leaq 0x1da9e(%rip), %rdx     # 0x210b9
callq 0x5170
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq 0x1da79(%rip), %rdi     # 0x210a8
callq 0xb620
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0xd7c0
movq -0x8(%rbp), %rdi
callq 0xdb80
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movl $0xfff, %esi            # imm = 0xFFF
callq 0xdb30
movb $0x0, -0x19(%rbp)
movq -0x10(%rbp), %rdi
movb -0x19(%rbp), %al
movb %al, %cl
addb $0x1, %cl
movb %cl, -0x19(%rbp)
leaq 0x23bb(%rip), %rdx      # 0x5a30
movzbl %al, %esi
callq 0x59c0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0xdba0
movq -0x10(%rbp), %rdi
leaq 0x239b(%rip), %rdx      # 0x5a30
movzbl -0x19(%rbp), %esi
callq 0x59c0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
subq $0x2, %rax
movzwl %ax, %esi
callq 0xdb30
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0xdd20
movq -0x38(%rbp), %rdi
movzwl %ax, %eax
addl $0x2, %eax
movzwl %ax, %esi
callq 0xdb00
movq -0x8(%rbp), %rdi
callq 0x5080
movq -0x8(%rbp), %rdi
movl $0x14, %esi
leaq 0x1d9c0(%rip), %rdx     # 0x210b9
callq 0x5170
movq -0x8(%rbp), %rdi
callq 0x1030
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)