#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 */

/* Variables and functions */
int _iconv(char *, char *, char *, char *, char *);
int main(int argc, char *argv[]) {
  int ret;
  (void)argc;
  ret = _iconv(argv[0], "ISO-8859-1", "ISO-8859-1", "", "");
  ret |= _iconv(argv[0], "ISO-8859-15", "iso-8859-15", "test", "test");
  ret |= _iconv(argv[0], "UTF-8", "UTF8", "test", "test");
  ret |= _iconv(argv[0], "UTF-8", "UTF-8", "test", "test");
  return (ret == 0) ? 0 : 2;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xecc(%rip),%rdx
lea    0xecf(%rip),%r8
mov    %rdx,%rsi
mov    %r8,%rcx
call   1030 <_iconv@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xeb4(%rip),%rsi
lea    0xeb9(%rip),%rdx
lea    0xebe(%rip),%r8
mov    %r8,%rcx
call   1030 <_iconv@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xea7(%rip),%rsi
lea    0xea6(%rip),%rdx
lea    0xe94(%rip),%r8
mov    %r8,%rcx
call   1030 <_iconv@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe7d(%rip),%rdx
lea    0xe71(%rip),%r8
mov    %rdx,%rsi
mov    %r8,%rcx
call   1030 <_iconv@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edx
mov    $0x2,%eax
xor    %ecx,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    (%rsi),%rdi
lea    0xedb(%rip),%rdx
lea    0xede(%rip),%rcx
mov    %rdx,%rsi
mov    %rcx,%r8
call   1030 <_iconv@plt>
mov    %eax,%r15d
mov    (%r12),%rdi
lea    0xec6(%rip),%rsi
lea    0xecb(%rip),%rdx
lea    0xed0(%rip),%r14
mov    %r14,%rcx
mov    %r14,%r8
call   1030 <_iconv@plt>
mov    %eax,%ebp
or     %r15d,%ebp
mov    (%r12),%rdi
lea    0xeba(%rip),%r15
lea    0xeb9(%rip),%rdx
mov    %r15,%rsi
mov    %r14,%rcx
mov    %r14,%r8
call   1030 <_iconv@plt>
mov    %eax,%ebx
or     %ebp,%ebx
mov    (%r12),%rdi
mov    %r15,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r14,%r8
call   1030 <_iconv@plt>
xor    %ecx,%ecx
or     %ebx,%eax
setne  %cl
add    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"ISO-8859-1\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [12 x i8] c"ISO-8859-15\00"
@.str.3 = [12 x i8] c"iso-8859-15\00"
@.str.4 = [5 x i8] c"test\00"
@.str.5 = [6 x i8] c"UTF-8\00"
@.str.6 = [5 x i8] c"UTF8\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
%11 = call i32 @_iconv(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
store i32 %11, i32* %6
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @_iconv(i8* %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32, i32* %6
%17 = or i32 %16, %15
store i32 %17, i32* %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 @_iconv(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* %6
%23 = or i32 %22, %21
store i32 %23, i32* %6
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @_iconv(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%28 = load i32, i32* %6
%29 = or i32 %28, %27
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, i32 0, i32 2
ret i32 %33
}

LLVM IR (-O2):
@.str = [11 x i8] c"ISO-8859-1\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [12 x i8] c"ISO-8859-15\00"
@.str.3 = [12 x i8] c"iso-8859-15\00"
@.str.4 = [5 x i8] c"test\00"
@.str.5 = [6 x i8] c"UTF-8\00"
@.str.6 = [5 x i8] c"UTF8\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = tail call i32 @_iconv(i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%5 = load i8*, i8** %1
%6 = tail call i32 @_iconv(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%7 = or i32 %6, %4
%8 = load i8*, i8** %1
%9 = tail call i32 @_iconv(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%10 = or i32 %7, %9
%11 = load i8*, i8** %1
%12 = tail call i32 @_iconv(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%13 = or i32 %10, %12
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i32 0, i32 2
ret i32 %15
}