// File: /workspace/github_c_makefile_star2_O3/videolan[P]bitstream/examples/dvb_ecmg.c
// Function: send_stream_error
static void send_stream_error(uint16_t i_wanted_streamid, 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 stream ID=0x%hx error=0x%hx\n",
            i_wanted_streamid, i_error);

    tlvh_set_version(p_tlv_h, i_version);
    ecmg_init(p_tlv);
    tlv_set_type(p_tlv, ECMG_TYPE_STREAM_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_channelid);
    ecmg_append_streamid(p_tlv, i_wanted_streamid);
    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 0x4d23(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x30e8(%rip), %rsi      # 0x43c7
xorl %r15d, %r15d
movl %ebx, %edx
movl %ecx, %ebp
xorl %eax, %eax
callq 0x1070
movb 0x4d85(%rip), %al       # 0x6078
movb %al, -0x1(%r14)
leaq 0x5(%rsp), %rax
andw $0x0, (%rax)
movl $0xf7030601, -0x4(%rax) # imm = 0xF7030601
movzwl 0x4d7c(%rip), %edx      # 0x608a
movq %rax, %rsi
testb %r15b, %r15b
je 0x1343
movzbl %r15b, %ecx
movq %rax, %rsi
movq %rsi, %rdi
subq %r14, %rdi
cmpq $0x3f7, %rdi            # imm = 0x3F7
jg 0x1362
movzwl 0x2(%rsi), %edi
rolw $0x8, %di
movzwl %di, %edi
addq %rdi, %rsi
addq $0x4, %rsi
decw %cx
jne 0x131d
movq %rsi, %rcx
subq %r14, %rcx
addq $-0x4, %rcx
cmpq $0x3f6, %rcx            # imm = 0x3F6
jg 0x1362
incb %r15b
movb 0x1(%rsi), %cl
orb (%rsi), %cl
jne 0x130e
jmp 0x1364
xorl %esi, %esi
movq %rsi, %rdi
subq %r14, %rdi
addq $0x4, %rdi
movl $0x3f7, %ecx            # imm = 0x3F7
cmpq $0x3f7, %rdi            # imm = 0x3F7
jg 0x1399
movl $0x2000e00, (%rsi)      # imm = 0x2000E00
movb %dh, 0x4(%rsi)
movb %dl, 0x5(%rsi)
andw $0x0, 0x6(%rsi)
movzwl 0x3(%rsp), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
xorl %esi, %esi
movq %rax, %rdx
testb %sil, %sil
je 0x13cf
movzbl %sil, %edi
movq %rax, %rdx
movq %rdx, %r8
subq %r14, %r8
cmpq %rcx, %r8
jg 0x13ec
movzwl 0x2(%rdx), %r8d
rolw $0x8, %r8w
movzwl %r8w, %r8d
addq %r8, %rdx
addq $0x4, %rdx
decw %di
jne 0x13aa
movq %rdx, %rdi
subq %r14, %rdi
addq $-0x4, %rdi
cmpq %rcx, %rdi
jge 0x13ec
incb %sil
movb 0x1(%rdx), %dil
orb (%rdx), %dil
jne 0x139b
jmp 0x13ee
xorl %edx, %edx
movq %rdx, %rsi
subq %r14, %rsi
addq $0x4, %rsi
cmpq %rcx, %rsi
jg 0x141a
movl $0x2000f00, (%rdx)      # imm = 0x2000F00
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 0x1450
movzbl %sil, %edi
movq %rax, %rdx
movq %rdx, %r8
subq %r14, %r8
cmpq %rcx, %r8
jg 0x146d
movzwl 0x2(%rdx), %r8d
rolw $0x8, %r8w
movzwl %r8w, %r8d
addq %r8, %rdx
addq $0x4, %rdx
decw %di
jne 0x142b
movq %rdx, %rdi
subq %r14, %rdi
addq $-0x4, %rdi
cmpq %rcx, %rdi
jge 0x146d
incb %sil
movb 0x1(%rdx), %dil
orb (%rdx), %dil
jne 0x141c
jmp 0x146f
xorl %edx, %edx
movq %rdx, %rsi
subq %r14, %rsi
addq $0x4, %rsi
cmpq %rcx, %rsi
jg 0x149d
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 0x14d1
movzbl %dl, %edi
movq %rax, %rsi
movq %rsi, %r8
subq %r14, %r8
cmpq %rcx, %r8
jg 0x14ed
movzwl 0x2(%rsi), %r8d
rolw $0x8, %r8w
movzwl %r8w, %r8d
addq %r8, %rsi
addq $0x4, %rsi
decw %di
jne 0x14ac
movq %rsi, %rdi
subq %r14, %rdi
addq $-0x4, %rdi
cmpq %rcx, %rdi
jge 0x14ed
incb %dl
movb 0x1(%rsi), %dil
orb (%rsi), %dil
jne 0x149f
jmp 0x14ef
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