#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 scalar_t__ iconv_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int EILSEQ;
int errno;
scalar_t__ ferror(int /*<<< orphan*/);
scalar_t__ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t iconv(scalar_t__, char **, size_t *, char **, size_t *);
scalar_t__ iconv_close(scalar_t__);
scalar_t__ iconv_open(char const *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char const *, char *);
int main(int argc, char *argv[]) {
  const char *charset;
  iconv_t cd;
  int bmp_only;
  if (argc != 2) {
    fprintf(stderr, "Usage: tst-table-to charset\n");
    return 1;
  }
  charset = argv[1];
  cd = iconv_open(charset, "UTF-8");
  if (cd == (iconv_t)(-1)) {
    perror("iconv_open");
    return 1;
  }
  bmp_only = (strcmp(charset, "UTF-8") == 0 || strcmp(charset, "GB18030") == 0);
  {
    unsigned int i;
    unsigned char buf[10];
    for (i = 0; i < (bmp_only ? 0x10000 : 0x30000); i++) {
      unsigned char in[6];
      unsigned int incount =
          (i < 0x80    ? (in[0] = i, 1)
           : i < 0x800 ? (in[0] = 0xc0 | (i >> 6), in[1] = 0x80 | (i & 0x3f), 2)
           : i < 0x10000
               ? (in[0] = 0xe0 | (i >> 12), in[1] = 0x80 | ((i >> 6) & 0x3f),
                  in[2] = 0x80 | (i & 0x3f), 3)
               : (in[0] = 0xf0 | (i >> 18), in[1] = 0x80 | ((i >> 12) & 0x3f),
                  in[2] = 0x80 | ((i >> 6) & 0x3f), in[3] = 0x80 | (i & 0x3f),
                  4));
      const char *inbuf = (const char *)in;
      size_t inbytesleft = incount;
      char *outbuf = (char *)buf;
      size_t outbytesleft = sizeof(buf);
      size_t result;
      size_t result2 = 0;
      iconv(cd, NULL, NULL, NULL, NULL);
      result = iconv(cd, (char **)&inbuf, &inbytesleft, &outbuf, &outbytesleft);
      if (result != (size_t)(-1))
        result2 = iconv(cd, NULL, NULL, &outbuf, &outbytesleft);
      if (result == (size_t)(-1) || result2 == (size_t)(-1)) {
        if (errno != EILSEQ) {
          int saved_errno = errno;
          fprintf(stderr, "0x%02X: iconv error: ", i);
          errno = saved_errno;
          perror("");
          return 1;
        }
      } else if (result == 0) {
        unsigned int j, jmax;
        if (inbytesleft != 0 || outbytesleft == sizeof(buf)) {
          fprintf(stderr, "0x%02X: inbytes = %ld, outbytes = %ld\n", i,
                  (long)(incount - inbytesleft),
                  (long)(sizeof(buf) - outbytesleft));
          return 1;
        }
        jmax = sizeof(buf) - outbytesleft;
        printf("0x");
        for (j = 0; j < jmax; j++)
          printf("%02X", buf[j]);
        printf("\t0x%04X\n", i);
      }
    }
  }
  if (iconv_close(cd) < 0) {
    perror("iconv_close");
    return 1;
  }
  if (ferror(stdin) || fflush(stdout) || ferror(stdout)) {
    fprintf(stderr, "I/O error\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11d6 <main+0x46>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1605 <main+0x475>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   10b0 <iconv_open@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xffffffffffffffff,-0x20(%rbp)
jne    1219 <main+0x89>
lea    0xe1b(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1605 <main+0x475>
mov    -0x18(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1060 <strcmp@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x7d(%rbp)
je     1255 <main+0xc5>
mov    -0x18(%rbp),%rdi
lea    0xde8(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x7d(%rbp)
mov    -0x7d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%esi
mov    $0x30000,%ecx
mov    $0x10000,%edx
cmp    $0x0,%esi
cmovne %edx,%ecx
cmp    %ecx,%eax
jae    1568 <main+0x3d8>
cmpl   $0x80,-0x28(%rbp)
jae    12a8 <main+0x118>
mov    -0x28(%rbp),%eax
mov    %al,-0x38(%rbp)
mov    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    138c <main+0x1fc>
cmpl   $0x800,-0x28(%rbp)
jae    12e1 <main+0x151>
mov    -0x28(%rbp),%eax
shr    $0x6,%eax
or     $0xc0,%eax
mov    %al,-0x38(%rbp)
mov    -0x28(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x37(%rbp)
mov    $0x2,%eax
mov    %eax,-0x88(%rbp)
jmp    1380 <main+0x1f0>
cmpl   $0x10000,-0x28(%rbp)
jae    132b <main+0x19b>
mov    -0x28(%rbp),%eax
shr    $0xc,%eax
or     $0xe0,%eax
mov    %al,-0x38(%rbp)
mov    -0x28(%rbp),%eax
shr    $0x6,%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x37(%rbp)
mov    -0x28(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x36(%rbp)
mov    $0x3,%eax
mov    %eax,-0x8c(%rbp)
jmp    1374 <main+0x1e4>
mov    -0x28(%rbp),%eax
shr    $0x12,%eax
or     $0xf0,%eax
mov    %al,-0x38(%rbp)
mov    -0x28(%rbp),%eax
shr    $0xc,%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x37(%rbp)
mov    -0x28(%rbp),%eax
shr    $0x6,%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x36(%rbp)
mov    -0x28(%rbp),%eax
and    $0x3f,%eax
or     $0x80,%eax
mov    %al,-0x35(%rbp)
mov    $0x4,%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x3c(%rbp),%eax
mov    %rax,-0x50(%rbp)
lea    -0x32(%rbp),%rax
mov    %rax,-0x58(%rbp)
movq   $0xa,-0x60(%rbp)
movq   $0x0,-0x70(%rbp)
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rsi
mov    %r8,%rdx
mov    %r8,%rcx
call   1030 <iconv@plt>
mov    -0x20(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
lea    -0x60(%rbp),%r8
call   1030 <iconv@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0xffffffffffffffff,-0x68(%rbp)
je     1417 <main+0x287>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x58(%rbp),%rcx
lea    -0x60(%rbp),%r8
mov    %rdx,%rsi
call   1030 <iconv@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0xffffffffffffffff,-0x68(%rbp)
je     142d <main+0x29d>
cmpq   $0xffffffffffffffff,-0x70(%rbp)
jne    1494 <main+0x304>
mov    0x2b94(%rip),%rax
mov    (%rax),%eax
mov    0x2bb3(%rip),%rcx
cmp    (%rcx),%eax
je     148f <main+0x2ff>
mov    0x2b7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    0x2b78(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
lea    0xbd2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x74(%rbp),%ecx
mov    0x2b53(%rip),%rax
mov    %ecx,(%rax)
lea    0xc05(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1605 <main+0x475>
jmp    1555 <main+0x3c5>
cmpq   $0x0,-0x68(%rbp)
jne    1550 <main+0x3c0>
cmpq   $0x0,-0x50(%rbp)
jne    14b5 <main+0x325>
cmpq   $0xa,-0x60(%rbp)
jne    14ee <main+0x35e>
mov    0x2b14(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
mov    -0x3c(%rbp),%eax
mov    %eax,%ecx
sub    -0x50(%rbp),%rcx
mov    $0xa,%r8d
sub    -0x60(%rbp),%r8
lea    0xb71(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1605 <main+0x475>
mov    $0xa,%eax
sub    -0x60(%rbp),%rax
mov    %eax,-0x7c(%rbp)
lea    0xb72(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x7c(%rbp),%eax
jae    153f <main+0x3af>
mov    -0x78(%rbp),%eax
movzbl -0x32(%rbp,%rax,1),%esi
lea    0xb4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    150f <main+0x37f>
mov    -0x28(%rbp),%esi
lea    0xb32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1555 <main+0x3c5>
jmp    155a <main+0x3ca>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1267 <main+0xd7>
mov    -0x20(%rbp),%rdi
call   1090 <iconv_close@plt>
cmp    $0x0,%rax
jge    1593 <main+0x403>
lea    0xb02(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1605 <main+0x475>
mov    0x2a46(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
jne    15db <main+0x44b>
mov    0x2a0e(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
cmp    $0x0,%rax
jne    15db <main+0x44b>
mov    0x29f6(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     15fe <main+0x46e>
mov    0x29ee(%rip),%rax
mov    (%rax),%edi
lea    0xaa5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1605 <main+0x475>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
cmp    $0x2,%edi
jne    11fd <main+0x6d>
mov    0x8(%rsi),%rbp
lea    0xe6f(%rip),%rsi
mov    %rbp,%rdi
call   10b0 <iconv_open@plt>
cmp    $0xffffffffffffffff,%rax
je     14a7 <main+0x317>
mov    %rax,%r13
lea    0xe53(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1212 <main+0x82>
lea    0xe50(%rip),%rsi
mov    %rbp,%rdi
call   1060 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
shl    $0x11,%ecx
or     $0x10000,%ecx
mov    %ecx,0x14(%rsp)
jmp    121a <main+0x8a>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
jmp    1461 <main+0x2d1>
movl   $0x10000,0x14(%rsp)
lea    0x20(%rsp),%rbx
lea    0x18(%rsp),%rbp
xor    %r14d,%r14d
jmp    1261 <main+0xd1>
nopl   0x0(%rax)
mov    0x2d91(%rip),%rax
mov    (%rax),%ebx
mov    0x2db0(%rip),%rax
cmp    (%rax),%ebx
jne    14c7 <main+0x337>
add    $0x1,%r14d
cmp    0x14(%rsp),%r14d
lea    0x20(%rsp),%rbx
lea    0x18(%rsp),%rbp
je     140e <main+0x27e>
cmp    $0x7f,%r14d
ja     1280 <main+0xf0>
mov    %r14b,0xe(%rsp)
mov    $0x1,%r15d
jmp    1320 <main+0x190>
nopw   0x0(%rax,%rax,1)
cmp    $0x7ff,%r14d
ja     12b0 <main+0x120>
mov    %r14d,%eax
shr    $0x6,%eax
or     $0xc0,%al
mov    %al,0xe(%rsp)
mov    %r14d,%eax
and    $0x3f,%al
or     $0x80,%al
mov    %al,0xf(%rsp)
mov    $0x2,%r15d
jmp    1320 <main+0x190>
nopl   0x0(%rax,%rax,1)
cmp    $0xffff,%r14d
ja     12e6 <main+0x156>
mov    %r14d,%eax
shr    $0xc,%eax
or     $0xe0,%al
mov    %al,0xe(%rsp)
mov    %r14d,%eax
shr    $0x6,%eax
and    $0x3f,%al
or     $0x80,%al
mov    %al,0xf(%rsp)
mov    %r14d,%eax
and    $0x3f,%al
or     $0x80,%al
mov    %al,0x10(%rsp)
mov    $0x3,%r15d
jmp    1320 <main+0x190>
movb   $0xf0,0xe(%rsp)
mov    %r14d,%eax
shr    $0xc,%eax
and    $0x3f,%al
or     $0x80,%al
mov    %al,0xf(%rsp)
mov    %r14d,%eax
shr    $0x6,%eax
and    $0x3f,%al
or     $0x80,%al
mov    %al,0x10(%rsp)
mov    %r14d,%eax
and    $0x3f,%al
or     $0x80,%al
mov    %al,0x11(%rsp)
mov    $0x4,%r15d
nopl   0x0(%rax,%rax,1)
lea    0xe(%rsp),%rax
mov    %rax,0x30(%rsp)
mov    %r15,0x28(%rsp)
lea    0x3e(%rsp),%rax
mov    %rax,0x20(%rsp)
movq   $0xa,0x18(%rsp)
mov    %r13,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <iconv@plt>
mov    %r13,%rdi
lea    0x30(%rsp),%rsi
lea    0x28(%rsp),%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1030 <iconv@plt>
cmp    $0xffffffffffffffff,%rax
je     1230 <main+0xa0>
mov    %rax,%r12
mov    %r13,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1030 <iconv@plt>
cmp    $0xffffffffffffffff,%rax
je     1230 <main+0xa0>
test   %r12,%r12
jne    1248 <main+0xb8>
mov    0x28(%rsp),%rax
mov    0x18(%rsp),%r12
test   %rax,%rax
jne    147c <main+0x2ec>
cmp    $0xa,%r12
je     147c <main+0x2ec>
lea    0xcb2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xa,%r12d
lea    0xca3(%rip),%r15
je     13f8 <main+0x268>
mov    $0xa,%ebx
sub    %r12d,%ebx
xor    %ebp,%ebp
nop
movzbl 0x3e(%rsp,%rbp,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    13e0 <main+0x250>
lea    0xc7c(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1248 <main+0xb8>
mov    %r13,%rdi
call   1090 <iconv_close@plt>
test   %rax,%rax
js     14b5 <main+0x325>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
call   1040 <ferror@plt>
test   %rax,%rax
jne    1451 <main+0x2c1>
mov    0x2b87(%rip),%rbx
mov    (%rbx),%edi
call   1080 <fflush@plt>
test   %rax,%rax
jne    1451 <main+0x2c1>
mov    (%rbx),%edi
call   1040 <ferror@plt>
test   %rax,%rax
je     14c3 <main+0x333>
mov    0x2b78(%rip),%rax
mov    (%rax),%edi
lea    0xc2f(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b4d(%rip),%rcx
mov    (%rcx),%edi
sub    %rax,%r15
mov    $0xa,%r8d
sub    %r12,%r8
lea    0xbb4(%rip),%rsi
mov    %r14d,%edx
mov    %r15,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1468 <main+0x2d8>
lea    0xb75(%rip),%rdi
call   10a0 <perror@plt>
jmp    1468 <main+0x2d8>
lea    0xbc8(%rip),%rdi
call   10a0 <perror@plt>
jmp    1468 <main+0x2d8>
xor    %eax,%eax
jmp    146d <main+0x2dd>
mov    0x2b02(%rip),%rax
mov    (%rax),%edi
lea    0xb5f(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2ae0(%rip),%rax
mov    %ebx,(%rax)
lea    0xb92(%rip),%rdi
call   10a0 <perror@plt>
jmp    1468 <main+0x2d8>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: tst-table-to charset\0A\00"
@.str.1 = [6 x i8] c"UTF-8\00"
@.str.2 = [11 x i8] c"iconv_open\00"
@.str.3 = [8 x i8] c"GB18030\00"
@errno = global i32 0
@EILSEQ = global i32 0
@.str.4 = [22 x i8] c"0x%02X: iconv error: \00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [39 x i8] c"0x%02X: inbytes = %ld, outbytes = %ld\0A\00"
@.str.7 = [3 x i8] c"0x\00"
@.str.8 = [5 x i8] c"%02X\00"
@.str.9 = [9 x i8] c"\090x%04X\0A\00"
@.str.10 = [12 x i8] c"iconv_close\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.11 = [11 x i8] c"I/O error\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca [10 x i8]
%11 = alloca [6 x i8]
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i64
%18 = alloca i64
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 2
br i1 %23, label %24, label %27
24: ; preds = %2
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %224
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
store i8* %30, i8** %6
%31 = load i8*, i8** %6
%32 = call i64 @iconv_open(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i64 %32, i64* %7
%33 = load i64, i64* %7
%34 = icmp eq i64 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %27
%36 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %224
37: ; preds = %27
%38 = load i8*, i8** %6
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %37
%42 = load i8*, i8** %6
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br label %45
45: ; preds = %41, %37
%46 = phi i1 [ true, %37 ], [ %44, %41 ]
%47 = zext i1 %46 to i32
store i32 %47, i32* %8
store i32 0, i32* %9
br label %48
48: ; preds = %199, %45
%49 = load i32, i32* %9
%50 = load i32, i32* %8
%51 = icmp ne i32 %50, 0
%52 = zext i1 %51 to i64
%53 = select i1 %51, i32 65536, i32 196608
%54 = icmp ult i32 %49, %53
br i1 %54, label %55, label %202
55: ; preds = %48
%56 = load i32, i32* %9
%57 = icmp ult i32 %56, 128
br i1 %57, label %58, label %62
58: ; preds = %55
%59 = load i32, i32* %9
%60 = trunc i32 %59 to i8
%61 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 0
store i8 %60, i8* %61
br label %123
62: ; preds = %55
%63 = load i32, i32* %9
%64 = icmp ult i32 %63, 2048
br i1 %64, label %65, label %76
65: ; preds = %62
%66 = load i32, i32* %9
%67 = lshr i32 %66, 6
%68 = or i32 192, %67
%69 = trunc i32 %68 to i8
%70 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 0
store i8 %69, i8* %70
%71 = load i32, i32* %9
%72 = and i32 %71, 63
%73 = or i32 128, %72
%74 = trunc i32 %73 to i8
%75 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 1
store i8 %74, i8* %75
br label %121
76: ; preds = %62
%77 = load i32, i32* %9
%78 = icmp ult i32 %77, 65536
br i1 %78, label %79, label %96
79: ; preds = %76
%80 = load i32, i32* %9
%81 = lshr i32 %80, 12
%82 = or i32 224, %81
%83 = trunc i32 %82 to i8
%84 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 0
store i8 %83, i8* %84
%85 = load i32, i32* %9
%86 = lshr i32 %85, 6
%87 = and i32 %86, 63
%88 = or i32 128, %87
%89 = trunc i32 %88 to i8
%90 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 1
store i8 %89, i8* %90
%91 = load i32, i32* %9
%92 = and i32 %91, 63
%93 = or i32 128, %92
%94 = trunc i32 %93 to i8
%95 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 2
store i8 %94, i8* %95
br label %119
96: ; preds = %76
%97 = load i32, i32* %9
%98 = lshr i32 %97, 18
%99 = or i32 240, %98
%100 = trunc i32 %99 to i8
%101 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 0
store i8 %100, i8* %101
%102 = load i32, i32* %9
%103 = lshr i32 %102, 12
%104 = and i32 %103, 63
%105 = or i32 128, %104
%106 = trunc i32 %105 to i8
%107 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 1
store i8 %106, i8* %107
%108 = load i32, i32* %9
%109 = lshr i32 %108, 6
%110 = and i32 %109, 63
%111 = or i32 128, %110
%112 = trunc i32 %111 to i8
%113 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 2
store i8 %112, i8* %113
%114 = load i32, i32* %9
%115 = and i32 %114, 63
%116 = or i32 128, %115
%117 = trunc i32 %116 to i8
%118 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 3
store i8 %117, i8* %118
br label %119
119: ; preds = %96, %79
%120 = phi i32 [ 3, %79 ], [ 4, %96 ]
br label %121
121: ; preds = %119, %65
%122 = phi i32 [ 2, %65 ], [ %120, %119 ]
br label %123
123: ; preds = %121, %58
%124 = phi i32 [ 1, %58 ], [ %122, %121 ]
store i32 %124, i32* %12
%125 = getelementptr inbounds [6 x i8], [6 x i8]* %11, i64 0, i64 0
store i8* %125, i8** %13
%126 = load i32, i32* %12
%127 = zext i32 %126 to i64
store i64 %127, i64* %14
%128 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
store i8* %128, i8** %15
store i64 10, i64* %16
store i64 0, i64* %18
%129 = load i64, i64* %7
%130 = call i64 @iconv(i64 %129, i8** null, i64* null, i8** null, i64* null)
%131 = load i64, i64* %7
%132 = call i64 @iconv(i64 %131, i8** %13, i64* %14, i8** %15, i64* %16)
store i64 %132, i64* %17
%133 = load i64, i64* %17
%134 = icmp ne i64 %133, -1
br i1 %134, label %135, label %138
135: ; preds = %123
%136 = load i64, i64* %7
%137 = call i64 @iconv(i64 %136, i8** null, i64* null, i8** %15, i64* %16)
store i64 %137, i64* %18
br label %138
138: ; preds = %135, %123
%139 = load i64, i64* %17
%140 = icmp eq i64 %139, -1
br i1 %140, label %144, label %141
141: ; preds = %138
%142 = load i64, i64* %18
%143 = icmp eq i64 %142, -1
br i1 %143, label %144, label %156
144: ; preds = %141, %138
%145 = load i32, i32* @errno
%146 = load i32, i32* @EILSEQ
%147 = icmp ne i32 %145, %146
br i1 %147, label %148, label %155
148: ; preds = %144
%149 = load i32, i32* @errno
store i32 %149, i32* %19
%150 = load i32, i32* @stderr
%151 = load i32, i32* %9
%152 = call i32 (i32, i8*, ...) @fprintf(i32 %150, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %151)
%153 = load i32, i32* %19
store i32 %153, i32* @errno
%154 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %224
155: ; preds = %144
br label %198
156: ; preds = %141
%157 = load i64, i64* %17
%158 = icmp eq i64 %157, 0
br i1 %158, label %159, label %197
159: ; preds = %156
%160 = load i64, i64* %14
%161 = icmp ne i64 %160, 0
br i1 %161, label %165, label %162
162: ; preds = %159
%163 = load i64, i64* %16
%164 = icmp eq i64 %163, 10
br i1 %164, label %165, label %175
165: ; preds = %162, %159
%166 = load i32, i32* @stderr
%167 = load i32, i32* %9
%168 = load i32, i32* %12
%169 = zext i32 %168 to i64
%170 = load i64, i64* %14
%171 = sub i64 %169, %170
%172 = load i64, i64* %16
%173 = sub i64 10, %172
%174 = call i32 (i32, i8*, ...) @fprintf(i32 %166, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %167, i64 %171, i64 %173)
store i32 1, i32* %3
br label %224
175: ; preds = %162
%176 = load i64, i64* %16
%177 = sub i64 10, %176
%178 = trunc i64 %177 to i32
store i32 %178, i32* %21
%179 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %20
br label %180
180: ; preds = %191, %175
%181 = load i32, i32* %20
%182 = load i32, i32* %21
%183 = icmp ult i32 %181, %182
br i1 %183, label %184, label %194
184: ; preds = %180
%185 = load i32, i32* %20
%186 = zext i32 %185 to i64
%187 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 %186
%188 = load i8, i8* %187
%189 = zext i8 %188 to i32
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %189)
br label %191
191: ; preds = %184
%192 = load i32, i32* %20
%193 = add i32 %192, 1
store i32 %193, i32* %20
br label %180
194: ; preds = %180
%195 = load i32, i32* %9
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %195)
br label %197
197: ; preds = %194, %156
br label %198
198: ; preds = %197, %155
br label %199
199: ; preds = %198
%200 = load i32, i32* %9
%201 = add i32 %200, 1
store i32 %201, i32* %9
br label %48
202: ; preds = %48
%203 = load i64, i64* %7
%204 = call i64 @iconv_close(i64 %203)
%205 = icmp slt i64 %204, 0
br i1 %205, label %206, label %208
206: ; preds = %202
%207 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %224
208: ; preds = %202
%209 = load i32, i32* @stdin
%210 = call i64 @ferror(i32 %209)
%211 = icmp ne i64 %210, 0
br i1 %211, label %220, label %212
212: ; preds = %208
%213 = load i32, i32* @stdout
%214 = call i64 @fflush(i32 %213)
%215 = icmp ne i64 %214, 0
br i1 %215, label %220, label %216
216: ; preds = %212
%217 = load i32, i32* @stdout
%218 = call i64 @ferror(i32 %217)
%219 = icmp ne i64 %218, 0
br i1 %219, label %220, label %223
220: ; preds = %216, %212, %208
%221 = load i32, i32* @stderr
%222 = call i32 (i32, i8*, ...) @fprintf(i32 %221, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %3
br label %224
223: ; preds = %216
store i32 0, i32* %3
br label %224
224: ; preds = %223, %220, %206, %165, %148, %35, %24
%225 = load i32, i32* %3
ret i32 %225
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: tst-table-to charset\0A\00"
@.str.1 = [6 x i8] c"UTF-8\00"
@.str.2 = [11 x i8] c"iconv_open\00"
@.str.3 = [8 x i8] c"GB18030\00"
@errno = global i32 0
@EILSEQ = global i32 0
@.str.4 = [22 x i8] c"0x%02X: iconv error: \00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [39 x i8] c"0x%02X: inbytes = %ld, outbytes = %ld\0A\00"
@.str.7 = [3 x i8] c"0x\00"
@.str.8 = [5 x i8] c"%02X\00"
@.str.9 = [9 x i8] c"\090x%04X\0A\00"
@.str.10 = [12 x i8] c"iconv_close\00"
@stdin = global i32 0
@stdout = global i32 0
@.str.11 = [11 x i8] c"I/O error\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = alloca [6 x i8]
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = icmp eq i32 %0, 2
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %147
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i64 @iconv_open(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %147
20: ; preds = %13
%21 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
%26 = select i1 %25, i32 65536, i32 196608
br label %27
27: ; preds = %23, %20
%28 = phi i32 [ 65536, %20 ], [ %26, %23 ]
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%30 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%31 = bitcast i8** %5 to i8*
%32 = bitcast i64* %6 to i8*
%33 = bitcast i8** %7 to i8*
%34 = bitcast i64* %8 to i8*
%35 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 1
%36 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 2
%37 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 3
br label %38
38: ; preds = %27, %123
%39 = phi i32 [ 0, %27 ], [ %124, %123 ]
%40 = icmp ult i32 %39, 128
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = trunc i32 %39 to i8
store i8 %42, i8* %30
br label %77
43: ; preds = %38
%44 = icmp ult i32 %39, 2048
br i1 %44, label %45, label %52
45: ; preds = %43
%46 = lshr i32 %39, 6
%47 = trunc i32 %46 to i8
%48 = or i8 %47, -64
store i8 %48, i8* %30
%49 = trunc i32 %39 to i8
%50 = and i8 %49, 63
%51 = or i8 %50, -128
store i8 %51, i8* %35
br label %77
52: ; preds = %43
%53 = icmp ult i32 %39, 65536
br i1 %53, label %54, label %65
54: ; preds = %52
%55 = lshr i32 %39, 12
%56 = trunc i32 %55 to i8
%57 = or i8 %56, -32
store i8 %57, i8* %30
%58 = lshr i32 %39, 6
%59 = trunc i32 %58 to i8
%60 = and i8 %59, 63
%61 = or i8 %60, -128
store i8 %61, i8* %35
%62 = trunc i32 %39 to i8
%63 = and i8 %62, 63
%64 = or i8 %63, -128
store i8 %64, i8* %36
br label %77
65: ; preds = %52
store i8 -16, i8* %30
%66 = lshr i32 %39, 12
%67 = trunc i32 %66 to i8
%68 = and i8 %67, 63
%69 = or i8 %68, -128
store i8 %69, i8* %35
%70 = lshr i32 %39, 6
%71 = trunc i32 %70 to i8
%72 = and i8 %71, 63
%73 = or i8 %72, -128
store i8 %73, i8* %36
%74 = trunc i32 %39 to i8
%75 = and i8 %74, 63
%76 = or i8 %75, -128
store i8 %76, i8* %37
br label %77
77: ; preds = %45, %65, %54, %41
%78 = phi i64 [ 1, %41 ], [ 2, %45 ], [ 3, %54 ], [ 4, %65 ]
store i8* %30, i8** %5
store i64 %78, i64* %6
store i8* %29, i8** %7
store i64 10, i64* %8
%79 = call i64 @iconv(i64 %16, i8** null, i64* null, i8** null, i64* null)
%80 = call i64 @iconv(i64 %16, i8** %5, i64* %6, i8** %7, i64* %8)
%81 = icmp eq i64 %80, -1
br i1 %81, label %85, label %82
82: ; preds = %77
%83 = call i64 @iconv(i64 %16, i8** null, i64* null, i8** %7, i64* %8)
%84 = icmp eq i64 %83, -1
br i1 %84, label %85, label %93
85: ; preds = %77, %82
%86 = load i32, i32* @errno
%87 = load i32, i32* @EILSEQ
%88 = icmp eq i32 %86, %87
br i1 %88, label %123, label %89
89: ; preds = %85
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %39)
store i32 %86, i32* @errno
%92 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
br label %126
93: ; preds = %82
%94 = icmp eq i64 %80, 0
br i1 %94, label %95, label %123
95: ; preds = %93
%96 = load i64, i64* %6
%97 = icmp ne i64 %96, 0
%98 = load i64, i64* %8
%99 = icmp eq i64 %98, 10
%100 = select i1 %97, i1 true, i1 %99
br i1 %100, label %101, label %106
101: ; preds = %95
%102 = load i32, i32* @stderr
%103 = sub i64 %78, %96
%104 = sub i64 10, %98
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i32 %39, i64 %103, i64 %104)
br label %126
106: ; preds = %95
%107 = trunc i64 %98 to i32
%108 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%109 = icmp eq i32 %107, 10
br i1 %109, label %121, label %110
110: ; preds = %106
%111 = sub i64 10, %98
%112 = and i64 %111, 4294967295
br label %113
113: ; preds = %110, %113
%114 = phi i64 [ 0, %110 ], [ %119, %113 ]
%115 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %114
%116 = load i8, i8* %115
%117 = zext i8 %116 to i32
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 %117)
%119 = add nuw nsw i64 %114, 1
%120 = icmp eq i64 %119, %112
br i1 %120, label %121, label %113
121: ; preds = %113, %106
%122 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i32 %39)
br label %123
123: ; preds = %121, %93, %85
%124 = add nuw nsw i32 %39, 1
%125 = icmp eq i32 %124, %28
br i1 %125, label %127, label %38
126: ; preds = %89, %101
br label %147
127: ; preds = %123
%128 = call i64 @iconv_close(i64 %16)
%129 = icmp slt i64 %128, 0
br i1 %129, label %130, label %132
130: ; preds = %127
%131 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %147
132: ; preds = %127
%133 = load i32, i32* @stdin
%134 = call i64 @ferror(i32 %133)
%135 = icmp eq i64 %134, 0
br i1 %135, label %136, label %144
136: ; preds = %132
%137 = load i32, i32* @stdout
%138 = call i64 @fflush(i32 %137)
%139 = icmp eq i64 %138, 0
br i1 %139, label %140, label %144
140: ; preds = %136
%141 = load i32, i32* @stdout
%142 = call i64 @ferror(i32 %141)
%143 = icmp eq i64 %142, 0
br i1 %143, label %147, label %144
144: ; preds = %140, %136, %132
%145 = load i32, i32* @stderr
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %145, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0))
br label %147
147: ; preds = %126, %140, %144, %130, %18, %10
%148 = phi i32 [ 1, %10 ], [ 1, %18 ], [ 1, %130 ], [ 1, %144 ], [ 0, %140 ], [ 1, %126 ]
ret i32 %148
}