// File: /workspace/github_c_makefile_star2_O2/videolan[P]bitstream/examples/dvb_print_si.c
// Function: iconv_wrapper
static char *iconv_wrapper(void *_unused, const char *psz_encoding,
                           char *p_string, size_t i_length)
{
    char *psz_string, *p;
    size_t i_out_length;

    if (!strcmp(psz_encoding, psz_native_encoding))
        return iconv_append_null(p_string, i_length);

    if (iconv_handle != (iconv_t)-1 &&
        strcmp(psz_encoding, psz_current_encoding)) {
        iconv_close(iconv_handle);
        iconv_handle = (iconv_t)-1;
    }

    if (iconv_handle == (iconv_t)-1)
        iconv_handle = iconv_open(psz_native_encoding, psz_encoding);
    if (iconv_handle == (iconv_t)-1) {
        fprintf(stderr, "couldn't initiate conversion from %s to %s (%m)\n",
                psz_encoding, psz_native_encoding);
        return iconv_append_null(p_string, i_length);
    }
    psz_current_encoding = psz_encoding;

    /* converted strings can be up to six times larger */
    i_out_length = i_length * 6;
    p = psz_string = malloc(i_out_length);
    if (iconv(iconv_handle, &p_string, &i_length, &p, &i_out_length) == -1) {
        fprintf(stderr, "couldn't convert from %s to %s (%m)\n", psz_encoding,
                psz_native_encoding);
        free(psz_string);
        return iconv_append_null(p_string, i_length);
    }
    if (i_length)
        fprintf(stderr, "partial conversion from %s to %s\n", psz_encoding,
                psz_native_encoding);

    *p = '\0';
    return psz_string;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %rbx
movq %rdx, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
leaq 0x47fb(%rip), %rsi      # 0x11a3f
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xd388
movq 0xdec5(%rip), %r12      # 0x1b120
cmpq $-0x1, %r12
je 0xd284
movq 0xdec0(%rip), %rsi      # 0x1b128
movq %rbx, %rdi
callq 0x2120
testl %eax, %eax
je 0xd2a7
movq %r12, %rdi
callq 0x21a0
orq $-0x1, 0xde9c(%rip)     # 0x1b120
leaq 0x47b4(%rip), %rdi      # 0x11a3f
movq %rbx, %rsi
callq 0x2210
movq %rax, %r12
movq %rax, 0xde83(%rip)      # 0x1b120
cmpq $-0x1, %rax
je 0xd366
movq %rbx, 0xde7a(%rip)      # 0x1b128
imulq $0x6, %r14, %rdi
leaq 0x20(%rsp), %r15
movq %rdi, (%r15)
callq 0x2160
movq %rax, %r14
leaq 0x18(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x10(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movq %r15, %r8
callq 0x2060
cmpq $-0x1, %rax
je 0xd304
cmpq $0x0, 0x8(%rsp)
jne 0xd342
movq 0x18(%rsp), %rax
movb $0x0, (%rax)
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0xdced(%rip), %rax      # 0x1aff8
movq (%rax), %rdi
leaq 0x8b16(%rip), %rsi      # 0x15e2b
leaq 0x4723(%rip), %rcx      # 0x11a3f
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2130
movq %r14, %rdi
callq 0x2030
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0xd3da
movq %rax, %r14
jmp 0xd2f5
movq 0xdcaf(%rip), %rax      # 0x1aff8
movq (%rax), %rdi
leaq 0x8afd(%rip), %rsi      # 0x15e50
leaq 0x46e5(%rip), %rcx      # 0x11a3f
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2130
jmp 0xd2ed
movq 0xdc8b(%rip), %rax      # 0x1aff8
movq (%rax), %rdi
leaq 0x8a83(%rip), %rsi      # 0x15dfa
leaq 0x46c1(%rip), %rcx      # 0x11a3f
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2130
movq %r15, %rdi
movq %r14, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xd3da