#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ iconv_t;

/* Variables and functions */
int iconv(int /*<<< orphan*/, char **, size_t *, char **, size_t *);
int /*<<< orphan*/ iconv_close(int /*<<< orphan*/);
int /*<<< orphan*/ iconv_open(char *, char *);
int strlen(char const *);
char *Output_ConvertEnc(char *encFrom, char *encTo, const char *in) {
  static char bufout[1024], *sin, *sout;
  int lenin, lenout, ret;
  iconv_t c_pt;
  if ((c_pt = iconv_open(encTo, encFrom)) == (iconv_t)-1) {
    return 0;
  }
  iconv(c_pt, 0, 0, 0, 0);
  lenin = strlen(in) + 1;
  lenout = 1024;
  sin = (char *)in;
  sout = bufout;
  ret = iconv(c_pt, &sin, (size_t *)&lenin, &sout, (size_t *)&lenout);
  if (ret == -1) {
    return 0;
  }
  iconv_close(c_pt);
  return bufout;
}


x86 assembly (clang, -O0):
<Output_ConvertEnc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <iconv_open@plt>
mov    %eax,-0x30(%rbp)
cmp    $0xffffffff,%eax
jne    117a <Output_ConvertEnc+0x3a>
movq   $0x0,-0x8(%rbp)
jmp    120a <Output_ConvertEnc+0xca>
mov    -0x30(%rbp),%edi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rsi
mov    %r8,%rdx
mov    %r8,%rcx
call   1030 <iconv@plt>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x400,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,0x329f(%rip)
lea    0x2e98(%rip),%rax
mov    %rax,0x3299(%rip)
mov    -0x30(%rbp),%edi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%r8
lea    0x327f(%rip),%rsi
lea    0x3280(%rip),%rcx
call   1030 <iconv@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    11f7 <Output_ConvertEnc+0xb7>
movq   $0x0,-0x8(%rbp)
jmp    120a <Output_ConvertEnc+0xca>
mov    -0x30(%rbp),%edi
call   1050 <iconv_close@plt>
lea    0x2e4a(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Output_ConvertEnc>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rdi,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
call   1060 <iconv_open@plt>
cmp    $0xffffffff,%eax
je     11d0 <Output_ConvertEnc+0x90>
mov    %eax,%ebx
xor    %r14d,%r14d
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <iconv@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,0xc(%rsp)
movl   $0x400,0x8(%rsp)
mov    %r15,0x32be(%rip)
lea    0x32b7(%rip),%rsi
lea    0x2eb0(%rip),%r15
mov    %r15,0x32b1(%rip)
lea    0x32aa(%rip),%rcx
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%r8
mov    %ebx,%edi
call   1030 <iconv@plt>
cmp    $0xffffffff,%eax
je     11d3 <Output_ConvertEnc+0x93>
mov    %ebx,%edi
call   1050 <iconv_close@plt>
mov    %r15,%r14
jmp    11d3 <Output_ConvertEnc+0x93>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@Output_ConvertEnc.bufout = internal global [1024 x i8] zeroinitializer
@Output_ConvertEnc.sin = internal global i8* null
@Output_ConvertEnc.sout = internal global i8* null
define i8* @Output_ConvertEnc(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%12 = load i8*, i8** %6
%13 = load i8*, i8** %5
%14 = call i32 @iconv_open(i8* %12, i8* %13)
store i32 %14, i32* %11
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %17
16: ; preds = %3
store i8* null, i8** %4
br label %34
17: ; preds = %3
%18 = load i32, i32* %11
%19 = call i32 @iconv(i32 %18, i8** null, i64* null, i8** null, i64* null)
%20 = load i8*, i8** %7
%21 = call i32 @strlen(i8* %20)
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
store i32 1024, i32* %9
%23 = load i8*, i8** %7
store i8* %23, i8** @Output_ConvertEnc.sin
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @Output_ConvertEnc.bufout, i64 0, i64 0), i8** @Output_ConvertEnc.sout
%24 = load i32, i32* %11
%25 = bitcast i32* %8 to i64*
%26 = bitcast i32* %9 to i64*
%27 = call i32 @iconv(i32 %24, i8** @Output_ConvertEnc.sin, i64* %25, i8** @Output_ConvertEnc.sout, i64* %26)
store i32 %27, i32* %10
%28 = load i32, i32* %10
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %31
30: ; preds = %17
store i8* null, i8** %4
br label %34
31: ; preds = %17
%32 = load i32, i32* %11
%33 = call i32 @iconv_close(i32 %32)
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @Output_ConvertEnc.bufout, i64 0, i64 0), i8** %4
br label %34
34: ; preds = %31, %30, %16
%35 = load i8*, i8** %4
ret i8* %35
}

LLVM IR (-O2):
@Output_ConvertEnc.bufout = internal global [1024 x i8] zeroinitializer
@Output_ConvertEnc.sin = internal global i8* null
@Output_ConvertEnc.sout = internal global i8* null
define i8* @Output_ConvertEnc(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = tail call i32 @iconv_open(i8* %1, i8* %0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %20, label %10
10: ; preds = %3
%11 = tail call i32 @iconv(i32 %8, i8** null, i64* null, i8** null, i64* null)
%12 = tail call i32 @strlen(i8* %2)
%13 = add nsw i32 %12, 1
store i32 %13, i32* %4
store i32 1024, i32* %5
store i8* %2, i8** @Output_ConvertEnc.sin
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @Output_ConvertEnc.bufout, i64 0, i64 0), i8** @Output_ConvertEnc.sout
%14 = bitcast i32* %4 to i64*
%15 = bitcast i32* %5 to i64*
%16 = call i32 @iconv(i32 %8, i8** @Output_ConvertEnc.sin, i64* %14, i8** @Output_ConvertEnc.sout, i64* %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %20, label %18
18: ; preds = %10
%19 = call i32 @iconv_close(i32 %8)
br label %20
20: ; preds = %10, %3, %18
%21 = phi i8* [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @Output_ConvertEnc.bufout, i64 0, i64 0), %18 ], [ null, %3 ], [ null, %10 ]
ret i8* %21
}