// File: /workspace/github_c_makefile_star2_O3/videolan[P]bitstream/examples/dvb_ecmg.c
// Function: send_channel_error
static void send_channel_error(uint16_t i_wanted_channelid, uint16_t i_error)
{
    uint8_t p_tlv_h[MAX_TLV_SIZE];
    uint8_t *p_tlv = tlvh_get_tlv(p_tlv_h);
    uint8_t *p_tlv_n;

    fprintf(stderr, "sending error on channel ID=0x%hx error=0x%hx\n",
            i_wanted_channelid, i_error);

    tlvh_set_version(p_tlv_h, i_version);
    ecmg_init(p_tlv);
    tlv_set_type(p_tlv, ECMG_TYPE_CHANNEL_ERROR);
    /* length will be written at the end */
    tlv_set_length(p_tlv, MAX_TLV_SIZE - TLV_HEADER_SIZE - TLVH_HEADER_SIZE);

    ecmg_append_channelid(p_tlv, i_wanted_channelid);
    ecmg_append_errorstatus(p_tlv, i_error);

    p_tlv_n = tlv_find_param(p_tlv, TLV_PARAM_EMPTY, 0);
    tlv_set_length(p_tlv, p_tlv_n - p_tlv - TLV_HEADER_SIZE);
    write_wrapper(p_tlv_h, p_tlv_n - p_tlv_h);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movl %esi, %ecx
movl %edi, %ebx
leaq 0x1(%rsp), %r14
movq 0x4efb(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x31d3(%rip), %rsi      # 0x42da
xorl %r15d, %r15d
movl %ebx, %edx
movl %ecx, %ebp
xorl %eax, %eax
callq 0x1070
movb 0x4f5d(%rip), %al       # 0x6078
movb %al, -0x1(%r14)
leaq 0x5(%rsp), %rax
andw $0x0, (%rax)
movl $0xf7030500, -0x4(%rax) # imm = 0xF7030500
movq %rax, %rdx
testb %r15b, %r15b
je 0x1164
movzbl %r15b, %ecx
movq %rax, %rdx
movq %rdx, %rsi
subq %r14, %rsi
cmpq $0x3f7, %rsi            # imm = 0x3F7
jg 0x1183
movzwl 0x2(%rdx), %esi
rolw $0x8, %si
movzwl %si, %esi
addq %rsi, %rdx
addq $0x4, %rdx
decw %cx
jne 0x113e
movq %rdx, %rcx
subq %r14, %rcx
addq $-0x4, %rcx
cmpq $0x3f6, %rcx            # imm = 0x3F6
jg 0x1183
incb %r15b
movb 0x1(%rdx), %cl
orb (%rdx), %cl
jne 0x112f
jmp 0x1185
xorl %edx, %edx
movq %rdx, %rsi
subq %r14, %rsi
addq $0x4, %rsi
movl $0x3f7, %ecx            # imm = 0x3F7
cmpq $0x3f7, %rsi            # imm = 0x3F7
jg 0x11ba
movl $0x2000e00, (%rdx)      # imm = 0x2000E00
movb %bh, 0x4(%rdx)
movb %bl, 0x5(%rdx)
andw $0x0, 0x6(%rdx)
movzwl 0x3(%rsp), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
xorl %esi, %esi
movq %rax, %rdx
testb %sil, %sil
je 0x11f0
movzbl %sil, %edi
movq %rax, %rdx
movq %rdx, %r8
subq %r14, %r8
cmpq %rcx, %r8
jg 0x120d
movzwl 0x2(%rdx), %r8d
rolw $0x8, %r8w
movzwl %r8w, %r8d
addq %r8, %rdx
addq $0x4, %rdx
decw %di
jne 0x11cb
movq %rdx, %rdi
subq %r14, %rdi
addq $-0x4, %rdi
cmpq %rcx, %rdi
jge 0x120d
incb %sil
movb 0x1(%rdx), %dil
orb (%rdx), %dil
jne 0x11bc
jmp 0x120f
xorl %edx, %edx
movq %rdx, %rsi
subq %r14, %rsi
addq $0x4, %rsi
cmpq %rcx, %rsi
jg 0x123d
movl $0x2000070, (%rdx)      # imm = 0x2000070
movl %ebp, %ecx
movb %ch, 0x4(%rdx)
movb %cl, 0x5(%rdx)
andw $0x0, 0x6(%rdx)
movzwl 0x3(%rsp), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
xorl %edx, %edx
movq %rax, %rsi
testb %dl, %dl
je 0x1271
movzbl %dl, %edi
movq %rax, %rsi
movq %rsi, %r8
subq %r14, %r8
cmpq %rcx, %r8
jg 0x128d
movzwl 0x2(%rsi), %r8d
rolw $0x8, %r8w
movzwl %r8w, %r8d
addq %r8, %rsi
addq $0x4, %rsi
decw %di
jne 0x124c
movq %rsi, %rdi
subq %r14, %rdi
addq $-0x4, %rdi
cmpq %rcx, %rdi
jge 0x128d
incb %dl
movb 0x1(%rsi), %dil
orb (%rsi), %dil
jne 0x123f
jmp 0x128f
xorl %esi, %esi
movl %esi, %eax
subl %r14d, %eax
addl $-0x4, %eax
rolw $0x8, %ax
movq %rsp, %rdi
movw %ax, 0x3(%rdi)
subq %rdi, %rsi
callq 0x195e
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r14
popq %r15
popq %rbp
retq