#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 uint16_t;
typedef scalar_t__ iconv_t;

/* Variables and functions */
scalar_t__ EILSEQ;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, size_t, size_t,
                           size_t);
size_t iconv(scalar_t__, char **, size_t *, char **, size_t *);
int /*<<< orphan*/ iconv_close(scalar_t__);
scalar_t__ iconv_open(char *, char const *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  uint16_t table[0x100];
  iconv_t conv;
  const char *charset;
  int i, j;
  int ascii_based = 1;
  int iso_based = 1;
  if (argc != 2) {
    printf("usage: %s <charset>\n", argv[0]);
    return 1;
  }
  charset = argv[1];
  conv = iconv_open("UCS-2", charset);
  if (conv == (iconv_t)-1) {
    perror("iconv_open");
    return 2;
  }
  iconv_close(conv);
  for (i = 0x00; i < 0x100; i++) {
    unsigned char in[1], out[2];
    size_t inlen = 1, outlen = 2;
    char *inbuf = (char *)in;
    char *outbuf = (char *)out;
    size_t ret;
    in[0] = i;
    conv = iconv_open("UCS-2BE", charset);
    if (conv == (iconv_t)-1) {
      perror("iconv_open");
      return 2;
    }
    ret = iconv(conv, &inbuf, &inlen, &outbuf, &outlen);
    if (ret == (size_t)-1 && errno == EILSEQ) {
      table[i] = 0xFFFD;
      iconv_close(conv);
      continue;
    }
    if (ret == (size_t)-1) {
      perror("iconv");
      iconv_close(conv);
      return 4;
    }
    iconv_close(conv);
    if (ret != 0 || inlen != 0 || outlen != 0) {
      fprintf(stderr, "%d: smth went wrong: %zd %zd %zd\n", i, ret, inlen,
              outlen);
      return 3;
    }
    if (i < 0x80 && (out[0] != 0 || out[1] != i))
      ascii_based = 0;
    if (i < 0xA0 && (out[0] != 0 || out[1] != i))
      iso_based = 0;
    table[i] = (out[0] << 8) | out[1];
  }
  iso_based = 0;
  printf("/* generated by %s %s */\n", argv[0], charset);
  if (iso_based)
    i = 0xA0;
  else if (ascii_based)
    i = 0x80;
  else
    i = 0;
  printf("const gunichar2 charset_table_%s[0x%x] = {\n", charset, 0x100 - i);
  while (i < 0x100) {
    int start = i;
    printf("    ");
    for (j = 0; j < 8; j++, i++) {
      if (table[i] == 0xFFFD)
        printf("UNREPL, ");
      else
        printf("0x%.4x, ", table[i]);
    }
    if ((start & 0xf) == 0)
      printf("       /* 0x%.2X -      */", start);
    else
      printf("       /*      - 0x%.2X */", i - 1);
    printf("\n");
  }
  printf("};\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x42c(%rbp)
movl   $0x1,-0x430(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b8 <main+0x58>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    161f <main+0x4bf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1080 <iconv_open@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0xffffffffffffffff,-0x418(%rbp)
ff
jne    1207 <main+0xa7>
lea    0xe25(%rip),%rdi
call   1070 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    161f <main+0x4bf>
mov    -0x418(%rbp),%rdi
call   1060 <iconv_close@plt>
movl   $0x0,-0x424(%rbp)
cmpl   $0x100,-0x424(%rbp)
jge    1478 <main+0x318>
movq   $0x1,-0x440(%rbp)
movq   $0x2,-0x448(%rbp)
lea    -0x431(%rbp),%rax
mov    %rax,-0x450(%rbp)
lea    -0x433(%rbp),%rax
mov    %rax,-0x458(%rbp)
mov    -0x424(%rbp),%eax
mov    %al,-0x431(%rbp)
mov    -0x420(%rbp),%rsi
lea    0xdad(%rip),%rdi
call   1080 <iconv_open@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0xffffffffffffffff,-0x418(%rbp)
ff
jne    12ab <main+0x14b>
lea    0xd81(%rip),%rdi
call   1070 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    161f <main+0x4bf>
mov    -0x418(%rbp),%rdi
lea    -0x450(%rbp),%rsi
lea    -0x440(%rbp),%rdx
lea    -0x458(%rbp),%rcx
lea    -0x448(%rbp),%r8
call   1030 <iconv@plt>
mov    %rax,-0x460(%rbp)
cmpq   $0xffffffffffffffff,-0x460(%rbp)
ff
jne    1325 <main+0x1c5>
mov    0x2ce1(%rip),%rax
mov    (%rax),%rax
mov    0x2cf7(%rip),%rcx
cmp    (%rcx),%rax
jne    1325 <main+0x1c5>
movslq -0x424(%rbp),%rax
movl   $0xfffd,-0x410(%rbp,%rax,4)
mov    -0x418(%rbp),%rdi
call   1060 <iconv_close@plt>
jmp    1464 <main+0x304>
cmpq   $0xffffffffffffffff,-0x460(%rbp)
ff
jne    1357 <main+0x1f7>
lea    0xcf4(%rip),%rdi
call   1070 <perror@plt>
mov    -0x418(%rbp),%rdi
call   1060 <iconv_close@plt>
movl   $0x4,-0x4(%rbp)
jmp    161f <main+0x4bf>
mov    -0x418(%rbp),%rdi
call   1060 <iconv_close@plt>
cmpq   $0x0,-0x460(%rbp)
jne    138d <main+0x22d>
cmpq   $0x0,-0x440(%rbp)
jne    138d <main+0x22d>
cmpq   $0x0,-0x448(%rbp)
je     13c9 <main+0x269>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
mov    -0x424(%rbp),%edx
mov    -0x460(%rbp),%rcx
mov    -0x440(%rbp),%r8
mov    -0x448(%rbp),%r9
lea    0xc7c(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    161f <main+0x4bf>
cmpl   $0x80,-0x424(%rbp)
jge    1406 <main+0x2a6>
movzbl -0x433(%rbp),%eax
cmp    $0x0,%eax
jne    13fc <main+0x29c>
movzbl -0x432(%rbp),%eax
cmp    -0x424(%rbp),%eax
je     1406 <main+0x2a6>
movl   $0x0,-0x42c(%rbp)
cmpl   $0xa0,-0x424(%rbp)
jge    1443 <main+0x2e3>
movzbl -0x433(%rbp),%eax
cmp    $0x0,%eax
jne    1439 <main+0x2d9>
movzbl -0x432(%rbp),%eax
cmp    -0x424(%rbp),%eax
je     1443 <main+0x2e3>
movl   $0x0,-0x430(%rbp)
movzbl -0x433(%rbp),%ecx
shl    $0x8,%ecx
movzbl -0x432(%rbp),%eax
or     %eax,%ecx
movslq -0x424(%rbp),%rax
mov    %ecx,-0x410(%rbp,%rax,4)
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    121d <main+0xbd>
movl   $0x0,-0x430(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x420(%rbp),%rdx
lea    0xbbf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x430(%rbp)
je     14ba <main+0x35a>
movl   $0xa0,-0x424(%rbp)
jmp    14e5 <main+0x385>
cmpl   $0x0,-0x42c(%rbp)
je     14d6 <main+0x376>
movl   $0x80,-0x424(%rbp)
jmp    14e0 <main+0x380>
movl   $0x0,-0x424(%rbp)
jmp    14e5 <main+0x385>
mov    -0x420(%rbp),%rsi
mov    $0x100,%edx
sub    -0x424(%rbp),%edx
lea    0xb72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x100,-0x424(%rbp)
jge    160a <main+0x4aa>
mov    -0x424(%rbp),%eax
mov    %eax,-0x464(%rbp)
lea    0xb74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x428(%rbp)
cmpl   $0x8,-0x428(%rbp)
jge    15b5 <main+0x455>
movslq -0x424(%rbp),%rax
cmpl   $0xfffd,-0x410(%rbp,%rax,4)
jne    1571 <main+0x411>
lea    0xb3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    158d <main+0x42d>
movslq -0x424(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%esi
lea    0xb24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1592 <main+0x432>
mov    -0x428(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x428(%rbp)
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    1539 <main+0x3d9>
mov    -0x464(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    15e0 <main+0x480>
mov    -0x464(%rbp),%esi
lea    0xadf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15f7 <main+0x497>
mov    -0x424(%rbp),%esi
sub    $0x1,%esi
lea    0xade(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xa70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1505 <main+0x3a5>
lea    0xad8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    12ff <main+0x17f>
mov    0x8(%rbx),%rbp
lea    0xe6d(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <iconv_open@plt>
cmp    $0xffffffffffffffff,%rax
je     1582 <main+0x402>
mov    %rbx,0x18(%rsp)
mov    %rax,%rdi
call   1080 <iconv_close@plt>
mov    $0x1,%r14d
lea    0x8(%rsp),%r15
xor    %ebx,%ebx
jmp    1214 <main+0x94>
cs nopw 0x0(%rax,%rax,1)
movzbl 0x6(%rsp),%ecx
cmp    %rcx,%rbx
mov    $0x0,%edx
cmovne %edx,%r14d
test   %eax,%eax
cmovne %edx,%r14d
movzbl %cl,%ecx
shl    $0x8,%eax
or     %ecx,%eax
mov    %eax,0x30(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x100,%rbx
je     131a <main+0x19a>
movq   $0x1,0x10(%rsp)
movq   $0x2,0x8(%rsp)
lea    0x7(%rsp),%rax
mov    %rax,0x28(%rsp)
lea    0x5(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    %bl,0x7(%rsp)
lea    0xde1(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <iconv_open@plt>
cmp    $0xffffffffffffffff,%rax
je     1582 <main+0x402>
mov    %rax,%r12
mov    %rax,%rdi
lea    0x28(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x20(%rsp),%rcx
mov    %r15,%r8
call   1040 <iconv@plt>
cmp    $0xffffffffffffffff,%rax
je     12d0 <main+0x150>
mov    %rax,%r13
mov    %r12,%rdi
call   1080 <iconv_close@plt>
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%r9
test   %r13,%r13
jne    1561 <main+0x3e1>
test   %r8,%r8
jne    1561 <main+0x3e1>
test   %r9,%r9
jne    1561 <main+0x3e1>
movzbl 0x5(%rsp),%eax
cmp    $0x80,%rbx
jb     11e0 <main+0x60>
movzbl 0x6(%rsp),%ecx
jmp    11f7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
mov    0x2cf9(%rip),%rax
mov    (%rax),%rax
mov    0x2d0f(%rip),%rcx
cmp    (%rcx),%rax
jne    15a5 <main+0x425>
movl   $0xfffd,0x30(%rsp,%rbx,4)
mov    %r12,%rdi
call   1080 <iconv_close@plt>
jmp    1203 <main+0x83>
mov    (%rbx),%rsi
lea    0xcf7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%eax
jmp    1593 <main+0x413>
mov    0x18(%rsp),%rax
mov    (%rax),%rsi
lea    0xd2d(%rip),%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %ebx,%ebx
test   %r14d,%r14d
setne  %bl
shl    $0x7,%ebx
mov    $0x100,%edx
sub    %ebx,%edx
lea    0xd24(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd3f(%rip),%r14
lea    0xd3d(%rip),%r15
lea    0xd3f(%rip),%rbp
jmp    139b <main+0x21b>
nopl   (%rax)
lea    0xd57(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x8,%ebx
cmp    $0xff,%r12d
jge    1551 <main+0x3d1>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movslq %ebx,%r12
mov    0x30(%rsp,%r12,4),%esi
cmp    $0xfffd,%esi
jne    13d0 <main+0x250>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13da <main+0x25a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x0(,%r12,4),%r13
mov    %r13,%rax
or     $0x4,%rax
mov    0x30(%rsp,%rax,1),%esi
cmp    $0xfffd,%esi
jne    1410 <main+0x290>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    141a <main+0x29a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rax
or     $0x8,%rax
mov    0x30(%rsp,%rax,1),%esi
cmp    $0xfffd,%esi
jne    1440 <main+0x2c0>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    144a <main+0x2ca>
nopl   0x0(%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rax
or     $0xc,%rax
mov    0x30(%rsp,%rax,1),%esi
cmp    $0xfffd,%esi
jne    1470 <main+0x2f0>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    147a <main+0x2fa>
nopl   0x0(%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rax
or     $0x10,%rax
mov    0x30(%rsp,%rax,1),%esi
cmp    $0xfffd,%esi
jne    14a0 <main+0x320>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    14aa <main+0x32a>
nopl   0x0(%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rax
or     $0x14,%rax
mov    0x30(%rsp,%rax,1),%esi
cmp    $0xfffd,%esi
jne    14d0 <main+0x350>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    14da <main+0x35a>
nopl   0x0(%rax)
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
or     $0x18,%r13
mov    0x30(%rsp,%r13,1),%esi
cmp    $0xfffd,%esi
jne    1500 <main+0x380>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    150a <main+0x38a>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
or     $0x7,%r12
mov    0x30(%rsp,%r12,4),%esi
cmp    $0xfffd,%esi
jne    1530 <main+0x3b0>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   $0x8,%bl
jne    1370 <main+0x1f0>
jmp    1543 <main+0x3c3>
mov    %rbp,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   $0x8,%bl
jne    1370 <main+0x1f0>
lea    0xb69(%rip),%rdi
mov    %ebx,%esi
jmp    137a <main+0x1fa>
lea    0xb91(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
jmp    1593 <main+0x413>
mov    0x2a70(%rip),%rax
mov    (%rax),%edi
lea    0xac3(%rip),%rsi
mov    %ebx,%edx
mov    %r13,%rcx
call   1070 <fprintf@plt>
mov    $0x3,%eax
jmp    1593 <main+0x413>
lea    0xa92(%rip),%rdi
call   1090 <perror@plt>
mov    $0x2,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xa82(%rip),%rdi
call   1090 <perror@plt>
mov    %r12,%rdi
call   1080 <iconv_close@plt>
mov    $0x4,%eax
jmp    1593 <main+0x413>

LLVM IR (-O0):
@.str = [21 x i8] c"usage: %s <charset>\0A\00"
@.str.1 = [6 x i8] c"UCS-2\00"
@.str.2 = [11 x i8] c"iconv_open\00"
@.str.3 = [8 x i8] c"UCS-2BE\00"
@errno = global i64 0
@EILSEQ = global i64 0
@.str.4 = [6 x i8] c"iconv\00"
@stderr = global i32 0
@.str.5 = [34 x i8] c"%d: smth went wrong: %zd %zd %zd\0A\00"
@.str.6 = [26 x i8] c"/* generated by %s %s */\0A\00"
@.str.7 = [44 x i8] c"const gunichar2 charset_table_%s[0x%x] = {\0A\00"
@.str.8 = [5 x i8] c" \00"
@.str.9 = [9 x i8] c"UNREPL, \00"
@.str.10 = [9 x i8] c"0x%.4x, \00"
@.str.11 = [27 x i8] c" /* 0x%.2X - */\00"
@.str.12 = [27 x i8] c" /* - 0x%.2X */\00"
@.str.13 = [2 x i8] c"\0A\00"
@.str.14 = [4 x i8] c"};\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i32]
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [1 x i8]
%14 = alloca [2 x i8]
%15 = alloca i64
%16 = alloca i64
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i64
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %11
store i32 1, i32* %12
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 2
br i1 %22, label %23, label %28
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %26)
store i32 1, i32* %3
br label %205
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
store i8* %31, i8** %8
%32 = load i8*, i8** %8
%33 = call i64 @iconv_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %32)
store i64 %33, i64* %7
%34 = load i64, i64* %7
%35 = icmp eq i64 %34, -1
br i1 %35, label %36, label %38
36: ; preds = %28
%37 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %205
38: ; preds = %28
%39 = load i64, i64* %7
%40 = call i32 @iconv_close(i64 %39)
store i32 0, i32* %9
br label %41
41: ; preds = %138, %38
%42 = load i32, i32* %9
%43 = icmp slt i32 %42, 256
br i1 %43, label %44, label %141
44: ; preds = %41
store i64 1, i64* %15
store i64 2, i64* %16
%45 = getelementptr inbounds [1 x i8], [1 x i8]* %13, i64 0, i64 0
store i8* %45, i8** %17
%46 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
store i8* %46, i8** %18
%47 = load i32, i32* %9
%48 = trunc i32 %47 to i8
%49 = getelementptr inbounds [1 x i8], [1 x i8]* %13, i64 0, i64 0
store i8 %48, i8* %49
%50 = load i8*, i8** %8
%51 = call i64 @iconv_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %50)
store i64 %51, i64* %7
%52 = load i64, i64* %7
%53 = icmp eq i64 %52, -1
br i1 %53, label %54, label %56
54: ; preds = %44
%55 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %3
br label %205
56: ; preds = %44
%57 = load i64, i64* %7
%58 = call i64 @iconv(i64 %57, i8** %17, i64* %15, i8** %18, i64* %16)
store i64 %58, i64* %19
%59 = load i64, i64* %19
%60 = icmp eq i64 %59, -1
br i1 %60, label %61, label %71
61: ; preds = %56
%62 = load i64, i64* @errno
%63 = load i64, i64* @EILSEQ
%64 = icmp eq i64 %62, %63
br i1 %64, label %65, label %71
65: ; preds = %61
%66 = load i32, i32* %9
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %67
store i32 65533, i32* %68
%69 = load i64, i64* %7
%70 = call i32 @iconv_close(i64 %69)
br label %138
71: ; preds = %61, %56
%72 = load i64, i64* %19
%73 = icmp eq i64 %72, -1
br i1 %73, label %74, label %78
74: ; preds = %71
%75 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%76 = load i64, i64* %7
%77 = call i32 @iconv_close(i64 %76)
store i32 4, i32* %3
br label %205
78: ; preds = %71
%79 = load i64, i64* %7
%80 = call i32 @iconv_close(i64 %79)
%81 = load i64, i64* %19
%82 = icmp ne i64 %81, 0
br i1 %82, label %89, label %83
83: ; preds = %78
%84 = load i64, i64* %15
%85 = icmp ne i64 %84, 0
br i1 %85, label %89, label %86
86: ; preds = %83
%87 = load i64, i64* %16
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %96
89: ; preds = %86, %83, %78
%90 = load i32, i32* @stderr
%91 = load i32, i32* %9
%92 = load i64, i64* %19
%93 = load i64, i64* %15
%94 = load i64, i64* %16
%95 = call i32 @fprintf(i32 %90, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %91, i64 %92, i64 %93, i64 %94)
store i32 3, i32* %3
br label %205
96: ; preds = %86
%97 = load i32, i32* %9
%98 = icmp slt i32 %97, 128
br i1 %98, label %99, label %111
99: ; preds = %96
%100 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%101 = load i8, i8* %100
%102 = zext i8 %101 to i32
%103 = icmp ne i32 %102, 0
br i1 %103, label %110, label %104
104: ; preds = %99
%105 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 1
%106 = load i8, i8* %105
%107 = zext i8 %106 to i32
%108 = load i32, i32* %9
%109 = icmp ne i32 %107, %108
br i1 %109, label %110, label %111
110: ; preds = %104, %99
store i32 0, i32* %11
br label %111
111: ; preds = %110, %104, %96
%112 = load i32, i32* %9
%113 = icmp slt i32 %112, 160
br i1 %113, label %114, label %126
114: ; preds = %111
%115 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%116 = load i8, i8* %115
%117 = zext i8 %116 to i32
%118 = icmp ne i32 %117, 0
br i1 %118, label %125, label %119
119: ; preds = %114
%120 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 1
%121 = load i8, i8* %120
%122 = zext i8 %121 to i32
%123 = load i32, i32* %9
%124 = icmp ne i32 %122, %123
br i1 %124, label %125, label %126
125: ; preds = %119, %114
store i32 0, i32* %12
br label %126
126: ; preds = %125, %119, %111
%127 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%128 = load i8, i8* %127
%129 = zext i8 %128 to i32
%130 = shl i32 %129, 8
%131 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 1
%132 = load i8, i8* %131
%133 = zext i8 %132 to i32
%134 = or i32 %130, %133
%135 = load i32, i32* %9
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %136
store i32 %134, i32* %137
br label %138
138: ; preds = %126, %65
%139 = load i32, i32* %9
%140 = add nsw i32 %139, 1
store i32 %140, i32* %9
br label %41
141: ; preds = %41
store i32 0, i32* %12
%142 = load i8**, i8*** %5
%143 = getelementptr inbounds i8*, i8** %142, i64 0
%144 = load i8*, i8** %143
%145 = load i8*, i8** %8
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %144, i8* %145)
%147 = load i32, i32* %12
%148 = icmp ne i32 %147, 0
br i1 %148, label %149, label %150
149: ; preds = %141
store i32 160, i32* %9
br label %156
150: ; preds = %141
%151 = load i32, i32* %11
%152 = icmp ne i32 %151, 0
br i1 %152, label %153, label %154
153: ; preds = %150
store i32 128, i32* %9
br label %155
154: ; preds = %150
store i32 0, i32* %9
br label %155
155: ; preds = %154, %153
br label %156
156: ; preds = %155, %149
%157 = load i8*, i8** %8
%158 = load i32, i32* %9
%159 = sub nsw i32 256, %158
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i8* %157, i32 %159)
br label %161
161: ; preds = %201, %156
%162 = load i32, i32* %9
%163 = icmp slt i32 %162, 256
br i1 %163, label %164, label %203
164: ; preds = %161
%165 = load i32, i32* %9
store i32 %165, i32* %20
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %10
br label %167
167: ; preds = %185, %164
%168 = load i32, i32* %10
%169 = icmp slt i32 %168, 8
br i1 %169, label %170, label %190
170: ; preds = %167
%171 = load i32, i32* %9
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %172
%174 = load i32, i32* %173
%175 = icmp eq i32 %174, 65533
br i1 %175, label %176, label %178
176: ; preds = %170
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %184
178: ; preds = %170
%179 = load i32, i32* %9
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds [256 x i32], [256 x i32]* %6, i64 0, i64 %180
%182 = load i32, i32* %181
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %182)
br label %184
184: ; preds = %178, %176
br label %185
185: ; preds = %184
%186 = load i32, i32* %10
%187 = add nsw i32 %186, 1
store i32 %187, i32* %10
%188 = load i32, i32* %9
%189 = add nsw i32 %188, 1
store i32 %189, i32* %9
br label %167
190: ; preds = %167
%191 = load i32, i32* %20
%192 = and i32 %191, 15
%193 = icmp eq i32 %192, 0
br i1 %193, label %194, label %197
194: ; preds = %190
%195 = load i32, i32* %20
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i32 %195)
br label %201
197: ; preds = %190
%198 = load i32, i32* %9
%199 = sub nsw i32 %198, 1
%200 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i32 %199)
br label %201
201: ; preds = %197, %194
%202 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %161
203: ; preds = %161
%204 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %3
br label %205
205: ; preds = %203, %89, %74, %54, %36, %23
%206 = load i32, i32* %3
ret i32 %206
}

LLVM IR (-O2):
@.str = [21 x i8] c"usage: %s <charset>\0A\00"
@.str.1 = [6 x i8] c"UCS-2\00"
@.str.2 = [11 x i8] c"iconv_open\00"
@.str.3 = [8 x i8] c"UCS-2BE\00"
@errno = global i64 0
@EILSEQ = global i64 0
@.str.4 = [6 x i8] c"iconv\00"
@stderr = global i32 0
@.str.5 = [34 x i8] c"%d: smth went wrong: %zd %zd %zd\0A\00"
@.str.6 = [26 x i8] c"/* generated by %s %s */\0A\00"
@.str.7 = [44 x i8] c"const gunichar2 charset_table_%s[0x%x] = {\0A\00"
@.str.8 = [5 x i8] c" \00"
@.str.9 = [9 x i8] c"UNREPL, \00"
@.str.10 = [9 x i8] c"0x%.4x, \00"
@.str.11 = [27 x i8] c" /* 0x%.2X - */\00"
@.str.12 = [27 x i8] c" /* - 0x%.2X */\00"
@str = [3 x i8] c"};\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i32]
%4 = alloca [1 x i8]
%5 = alloca [2 x i8]
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = bitcast [256 x i32]* %3 to i8*
%11 = icmp eq i32 %0, 2
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i8*, i8** %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %186
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i64 @iconv_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = icmp eq i64 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %186
22: ; preds = %15
%23 = tail call i32 @iconv_close(i64 %18)
%24 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%25 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%26 = bitcast i64* %6 to i8*
%27 = bitcast i64* %7 to i8*
%28 = bitcast i8** %8 to i8*
%29 = bitcast i8** %9 to i8*
%30 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 1
br label %31
31: ; preds = %22, %87
%32 = phi i64 [ 0, %22 ], [ %89, %87 ]
%33 = phi i32 [ 1, %22 ], [ %88, %87 ]
store i64 1, i64* %6
store i64 2, i64* %7
store i8* %24, i8** %8
store i8* %25, i8** %9
%34 = trunc i64 %32 to i8
store i8 %34, i8* %24
%35 = call i64 @iconv_open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%36 = icmp eq i64 %35, -1
br i1 %36, label %37, label %39
37: ; preds = %31
%38 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %85
39: ; preds = %31
%40 = call i64 @iconv(i64 %35, i8** %8, i64* %6, i8** %9, i64* %7)
%41 = icmp eq i64 %40, -1
br i1 %41, label %42, label %52
42: ; preds = %39
%43 = load i64, i64* @errno
%44 = load i64, i64* @EILSEQ
%45 = icmp eq i64 %43, %44
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %32
store i32 65533, i32* %47
%48 = call i32 @iconv_close(i64 %35)
br label %87
49: ; preds = %42
%50 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%51 = call i32 @iconv_close(i64 %35)
br label %85
52: ; preds = %39
%53 = call i32 @iconv_close(i64 %35)
%54 = icmp ne i64 %40, 0
%55 = load i64, i64* %6
%56 = icmp ne i64 %55, 0
%57 = select i1 %54, i1 true, i1 %56
%58 = load i64, i64* %7
%59 = icmp ne i64 %58, 0
%60 = select i1 %57, i1 true, i1 %59
br i1 %60, label %61, label %65
61: ; preds = %52
%62 = trunc i64 %32 to i32
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %62, i64 %40, i64 %55, i64 %58)
br label %85
65: ; preds = %52
%66 = icmp ult i64 %32, 128
%67 = load i8, i8* %25
br i1 %66, label %70, label %68
68: ; preds = %65
%69 = load i8, i8* %30
br label %77
70: ; preds = %65
%71 = icmp eq i8 %67, 0
%72 = load i8, i8* %30
%73 = zext i8 %72 to i64
%74 = icmp eq i64 %32, %73
%75 = select i1 %71, i1 %74, i1 false
%76 = select i1 %75, i32 %33, i32 0
br label %77
77: ; preds = %68, %70
%78 = phi i8 [ %69, %68 ], [ %72, %70 ]
%79 = phi i32 [ %33, %68 ], [ %76, %70 ]
%80 = zext i8 %78 to i32
%81 = zext i8 %67 to i32
%82 = shl nuw nsw i32 %81, 8
%83 = or i32 %82, %80
%84 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %32
store i32 %83, i32* %84
br label %87
85: ; preds = %37, %49, %61
%86 = phi i32 [ 3, %61 ], [ 4, %49 ], [ 2, %37 ]
br label %186
87: ; preds = %46, %77
%88 = phi i32 [ %33, %46 ], [ %79, %77 ]
%89 = add nuw nsw i64 %32, 1
%90 = icmp eq i64 %89, 256
br i1 %90, label %91, label %31
91: ; preds = %87
%92 = load i8*, i8** %1
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %92, i8* %17)
%94 = icmp eq i32 %88, 0
%95 = select i1 %94, i32 0, i32 128
%96 = sub nuw nsw i32 256, %95
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0), i8* %17, i32 %96)
br label %98
98: ; preds = %91, %181
%99 = phi i32 [ %95, %91 ], [ %173, %181 ]
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%101 = sext i32 %99 to i64
%102 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %101
%103 = load i32, i32* %102
%104 = icmp eq i32 %103, 65533
br i1 %104, label %105, label %107
105: ; preds = %98
%106 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %109
107: ; preds = %98
%108 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %103)
br label %109
109: ; preds = %105, %107
%110 = or i64 %101, 1
%111 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %110
%112 = load i32, i32* %111
%113 = icmp eq i32 %112, 65533
br i1 %113, label %116, label %114
114: ; preds = %109
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %112)
br label %118
116: ; preds = %109
%117 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %118
118: ; preds = %116, %114
%119 = or i64 %101, 2
%120 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %119
%121 = load i32, i32* %120
%122 = icmp eq i32 %121, 65533
br i1 %122, label %125, label %123
123: ; preds = %118
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %121)
br label %127
125: ; preds = %118
%126 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %127
127: ; preds = %125, %123
%128 = or i64 %101, 3
%129 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %128
%130 = load i32, i32* %129
%131 = icmp eq i32 %130, 65533
br i1 %131, label %134, label %132
132: ; preds = %127
%133 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %130)
br label %136
134: ; preds = %127
%135 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %136
136: ; preds = %134, %132
%137 = or i64 %101, 4
%138 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %137
%139 = load i32, i32* %138
%140 = icmp eq i32 %139, 65533
br i1 %140, label %143, label %141
141: ; preds = %136
%142 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %139)
br label %145
143: ; preds = %136
%144 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %145
145: ; preds = %143, %141
%146 = or i64 %101, 5
%147 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %146
%148 = load i32, i32* %147
%149 = icmp eq i32 %148, 65533
br i1 %149, label %152, label %150
150: ; preds = %145
%151 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %148)
br label %154
152: ; preds = %145
%153 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %154
154: ; preds = %152, %150
%155 = or i64 %101, 6
%156 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %155
%157 = load i32, i32* %156
%158 = icmp eq i32 %157, 65533
br i1 %158, label %161, label %159
159: ; preds = %154
%160 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %157)
br label %163
161: ; preds = %154
%162 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %163
163: ; preds = %161, %159
%164 = or i64 %101, 7
%165 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %164
%166 = load i32, i32* %165
%167 = icmp eq i32 %166, 65533
br i1 %167, label %170, label %168
168: ; preds = %163
%169 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %166)
br label %172
170: ; preds = %163
%171 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %172
172: ; preds = %170, %168
%173 = add i32 %99, 8
%174 = trunc i64 %164 to i32
%175 = and i32 %99, 8
%176 = icmp eq i32 %175, 0
br i1 %176, label %177, label %179
177: ; preds = %172
%178 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i32 %99)
br label %181
179: ; preds = %172
%180 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0), i32 %174)
br label %181
181: ; preds = %179, %177
%182 = call i32 @putchar(i32 10)
%183 = icmp slt i32 %174, 255
br i1 %183, label %98, label %184
184: ; preds = %181
%185 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %186
186: ; preds = %85, %184, %20, %12
%187 = phi i32 [ 1, %12 ], [ 2, %20 ], [ 0, %184 ], [ %86, %85 ]
ret i32 %187
}