#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*/ szDstBuf;
typedef scalar_t__ iconv_t;

/* Variables and functions */
scalar_t__ E2BIG;
scalar_t__ EILSEQ;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t iconv(scalar_t__, char **, size_t *, char **, size_t *);
int /*<<< orphan*/ iconv_close(scalar_t__);
scalar_t__ iconv_open(char const *, char const *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
size_t strlen(char *);
int utf8decode(char *, char *, int *);
int main(int argc, char *argv[]) {
  iconv_t sConv;
  const char *pszSrcEncoding;
  const char *pszDstEncoding = "UTF-8";
  int i;
  int nLastIdentical = -1;
  if (argc != 2) {
    fprintf(stderr, "Usage: generate_encoding_table encoding_name\n");
    return 1;
  }
  pszSrcEncoding = argv[1];
  sConv = iconv_open(pszDstEncoding, pszSrcEncoding);
  if (sConv == (iconv_t)-1) {
    fprintf(stderr, "Recode from %s to %s failed with the error: \"%s\".",
            pszSrcEncoding, pszDstEncoding, strerror(errno));
    return 1;
  }
  for (i = 0; i < 256; i++) {
    char szSrcBuf[2] = {(char)i, 0};
    char szDstBuf[5] = {0, 0, 0, 0, 0};
    char *pszSrcBuf = szSrcBuf;
    char *pszDstBuf = szDstBuf;
    size_t nSrcLen = strlen(szSrcBuf);
    size_t nDstLen = sizeof(szDstBuf);
    size_t nConverted =
        iconv(sConv, &pszSrcBuf, &nSrcLen, &pszDstBuf, &nDstLen);
    int nUnicode = -1;
    if (nConverted == -1) {
      if (errno == EILSEQ) {
      } else if (errno == E2BIG) {
        fprintf(stderr, "E2BIG for %d\n", i);
        return 1;
      } else {
        fprintf(stderr, "other error for %d\n", i);
        return 1;
      }
    } else {
      int len;
      nUnicode = utf8decode(szDstBuf, szDstBuf + strlen(szDstBuf), &len);
      if (nUnicode == 0xfffd)
        nUnicode = -1;
    }
    if (nLastIdentical >= 0 && i != nUnicode) {
      if (nLastIdentical + 1 == i)
        printf("info->map[0x%02X] = 0x%02X;\n", nLastIdentical, nLastIdentical);
      else {
        printf("for(i = 0x%02X; i < 0x%02X; i++)\n", nLastIdentical, i);
        printf("    info->map[i] = i;\n");
      }
      nLastIdentical = -1;
    }
    if (nUnicode < 0)
      printf("info->map[0x%02X] = -1;\n", i);
    else if (nUnicode <= 0xFF) {
      if (i == nUnicode) {
        if (nLastIdentical < 0)
          nLastIdentical = i;
      } else
        printf("info->map[0x%02X] = 0x%02X;\n", i, nUnicode);
    } else if (nUnicode <= 0xFFFF)
      printf("info->map[0x%02X] = 0x%04X;\n", i, nUnicode);
    else if (nUnicode <= 0xFFFFFF)
      printf("info->map[0x%02X] = 0x%06X;\n", i, nUnicode);
    else
      printf("info->map[0x%02X] = 0x%08X;\n", i, nUnicode);
  }
  if (nLastIdentical >= 0) {
    if (nLastIdentical + 1 == i)
      printf("info->map[0x%02X] = 0x%02X;\n", nLastIdentical, nLastIdentical);
    else {
      printf("for(i = 0x%02X; i < 0x%02X; i++)\n", nLastIdentical, i);
      printf("    info->map[i] = i;\n");
    }
    nLastIdentical = -1;
  }
  iconv_close(sConv);
  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)
lea    0xe50(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0xffffffff,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11e8 <main+0x58>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    157f <main+0x3ef>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10b0 <iconv_open@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0xffffffffffffffff,-0x18(%rbp)
jne    1263 <main+0xd3>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    0x2d95(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rdx
mov    -0x70(%rbp),%rcx
mov    %rax,%r8
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    157f <main+0x3ef>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x100,-0x2c(%rbp)
jge    1514 <main+0x384>
mov    -0x2c(%rbp),%eax
mov    %al,-0x32(%rbp)
movb   $0x0,-0x31(%rbp)
lea    -0x37(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1070 <memset@plt>
lea    -0x32(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x37(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x32(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x50(%rbp)
movq   $0x5,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x48(%rbp),%rcx
lea    -0x58(%rbp),%r8
call   1040 <iconv@plt>
mov    %rax,-0x60(%rbp)
movl   $0xffffffff,-0x64(%rbp)
cmpq   $0xffffffffffffffff,-0x60(%rbp)
jne    136f <main+0x1df>
mov    0x2cdc(%rip),%rax
mov    (%rax),%rax
mov    0x2cfa(%rip),%rcx
cmp    (%rcx),%rax
jne    1304 <main+0x174>
jmp    136a <main+0x1da>
mov    0x2cbd(%rip),%rax
mov    (%rax),%rax
mov    0x2ccb(%rip),%rcx
cmp    (%rcx),%rax
jne    1344 <main+0x1b4>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xd35(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    157f <main+0x3ef>
mov    0x2c85(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xd1d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    157f <main+0x3ef>
jmp    13c4 <main+0x234>
lea    -0x37(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    -0x37(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x37(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x90(%rbp),%rsi
mov    -0x88(%rbp),%rdi
add    %rax,%rsi
lea    -0x68(%rbp),%rdx
call   1030 <utf8decode@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xfffd,-0x64(%rbp)
jne    13bf <main+0x22f>
movl   $0xffffffff,-0x64(%rbp)
jmp    13c4 <main+0x234>
cmpl   $0x0,-0x30(%rbp)
jl     142b <main+0x29b>
mov    -0x2c(%rbp),%eax
cmp    -0x64(%rbp),%eax
je     142b <main+0x29b>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
cmp    -0x2c(%rbp),%eax
jne    1402 <main+0x272>
mov    -0x30(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1424 <main+0x294>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xc96(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcaa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x30(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    144b <main+0x2bb>
mov    -0x2c(%rbp),%esi
lea    0xc9f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1501 <main+0x371>
cmpl   $0xff,-0x64(%rbp)
jg     1492 <main+0x302>
mov    -0x2c(%rbp),%eax
cmp    -0x64(%rbp),%eax
jne    1479 <main+0x2e9>
cmpl   $0x0,-0x30(%rbp)
jge    1474 <main+0x2e4>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    148d <main+0x2fd>
mov    -0x2c(%rbp),%esi
mov    -0x64(%rbp),%edx
lea    0xc02(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14fc <main+0x36c>
cmpl   $0xffff,-0x64(%rbp)
jg     14b8 <main+0x328>
mov    -0x2c(%rbp),%esi
mov    -0x64(%rbp),%edx
lea    0xc4b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f7 <main+0x367>
cmpl   $0xffffff,-0x64(%rbp)
jg     14de <main+0x34e>
mov    -0x2c(%rbp),%esi
mov    -0x64(%rbp),%edx
lea    0xc42(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f2 <main+0x362>
mov    -0x2c(%rbp),%esi
mov    -0x64(%rbp),%edx
lea    0xc46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14f7 <main+0x367>
jmp    14fc <main+0x36c>
jmp    1501 <main+0x371>
jmp    1506 <main+0x376>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    126a <main+0xda>
cmpl   $0x0,-0x30(%rbp)
jl     156f <main+0x3df>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
cmp    -0x2c(%rbp),%eax
jne    1546 <main+0x3b6>
mov    -0x30(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xb4e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1568 <main+0x3d8>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xb52(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xb66(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <iconv_close@plt>
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    $0x38,%rsp
cmp    $0x2,%edi
jne    1381 <main+0x1f1>
mov    0x8(%rsi),%rbx
lea    0xe4e(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <iconv_open@plt>
cmp    $0xffffffffffffffff,%rax
je     13d3 <main+0x243>
mov    %rax,%r14
mov    $0xffffffff,%ebx
lea    0x6(%rsp),%r15
lea    0x8(%rsp),%r12
xor    %ebp,%ebp
jmp    11ff <main+0x6f>
nopw   0x0(%rax,%rax,1)
lea    0xee0(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
je     13a2 <main+0x212>
mov    %bpl,0x6(%rsp)
movb   $0x0,0x7(%rsp)
movb   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    %r15,0x28(%rsp)
mov    %r12,0x20(%rsp)
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rax,0x18(%rsp)
movq   $0x5,0x10(%rsp)
mov    %r14,%rdi
lea    0x28(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x10(%rsp),%r8
call   1040 <iconv@plt>
cmp    $0xffffffffffffffff,%rax
je     1290 <main+0x100>
mov    %r12,%rdi
call   1060 <strlen@plt>
lea    (%rsp,%rax,1),%rsi
add    $0x8,%rsi
mov    %r12,%rdi
lea    0x34(%rsp),%rdx
call   1030 <utf8decode@plt>
mov    $0xffffffff,%r13d
cmp    $0xfffd,%eax
je     12b0 <main+0x120>
mov    %eax,%r13d
jmp    12b0 <main+0x120>
nopw   0x0(%rax,%rax,1)
mov    0x2d31(%rip),%rax
mov    (%rax),%rax
mov    $0xffffffff,%r13d
mov    0x2d49(%rip),%rcx
cmp    (%rcx),%rax
jne    140f <main+0x27f>
test   %ebx,%ebx
js     1303 <main+0x173>
cmp    %r13d,%ebp
je     1303 <main+0x173>
lea    0x1(%rbx),%eax
cmp    %eax,%ebp
jne    12e0 <main+0x150>
lea    0xdc1(%rip),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    12fe <main+0x16e>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xdbe(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe3e(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%ebx
test   %r13d,%r13d
js     11e0 <main+0x50>
cmp    $0xff,%r13d
ja     1330 <main+0x1a0>
cmp    %r13d,%ebp
jne    1342 <main+0x1b2>
test   %ebx,%ebx
cmovs  %ebp,%ebx
jmp    11f0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0xffff,%r13d
ja     134b <main+0x1bb>
lea    0xda0(%rip),%rdi
jmp    1370 <main+0x1e0>
lea    0xd3f(%rip),%rdi
jmp    1370 <main+0x1e0>
cmp    $0xffffff,%r13d
ja     135d <main+0x1cd>
lea    0xda2(%rip),%rdi
jmp    1370 <main+0x1e0>
lea    0xdb6(%rip),%rdi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    11f0 <main+0x60>
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
lea    0xc75(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    146f <main+0x2df>
test   %ebx,%ebx
js     1465 <main+0x2d5>
cmp    $0xff,%ebx
jne    1444 <main+0x2b4>
lea    0xccb(%rip),%rdi
mov    $0xff,%esi
mov    $0xff,%edx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1465 <main+0x2d5>
mov    0x2bf6(%rip),%rax
mov    (%rax),%ebp
mov    0x2be5(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
lea    0xc42(%rip),%rsi
lea    0xc07(%rip),%rcx
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    146f <main+0x2df>
mov    0x2bca(%rip),%rcx
cmp    (%rcx),%rax
mov    0x2bb0(%rip),%rax
mov    (%rax),%edi
lea    0xc3d(%rip),%rax
lea    0xc44(%rip),%rsi
cmove  %rax,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
jmp    146f <main+0x2df>
lea    0xc5a(%rip),%rdi
mov    %ebx,%esi
mov    $0x100,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xcd7(%rip),%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1090 <iconv_close@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"UTF-8\00"
@stderr = global i32 0
@.str.1 = [46 x i8] c"Usage: generate_encoding_table encoding_name\0A\00"
@.str.2 = [50 x i8] c"Recode from %s to %s failed with the error: \22%s\22.\00"
@errno = global i64 0
@EILSEQ = global i64 0
@E2BIG = global i64 0
@.str.3 = [14 x i8] c"E2BIG for %d\0A\00"
@.str.4 = [20 x i8] c"other error for %d\0A\00"
@.str.5 = [29 x i8] c"info->map[0x%02X] = 0x%02X;\0A\00"
@.str.6 = [34 x i8] c"for(i = 0x%02X; i < 0x%02X; i++)\0A\00"
@.str.7 = [23 x i8] c" info->map[i] = i;\0A\00"
@.str.8 = [25 x i8] c"info->map[0x%02X] = -1;\0A\00"
@.str.9 = [29 x i8] c"info->map[0x%02X] = 0x%04X;\0A\00"
@.str.10 = [29 x i8] c"info->map[0x%02X] = 0x%06X;\0A\00"
@.str.11 = [29 x i8] c"info->map[0x%02X] = 0x%08X;\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [2 x i8]
%12 = alloca [5 x i8]
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %8
store i32 -1, i32* %10
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 2
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %180
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
store i8* %28, i8** %7
%29 = load i8*, i8** %8
%30 = load i8*, i8** %7
%31 = call i64 @iconv_open(i8* %29, i8* %30)
store i64 %31, i64* %6
%32 = load i64, i64* %6
%33 = icmp eq i64 %32, -1
br i1 %33, label %34, label %41
34: ; preds = %25
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %7
%37 = load i8*, i8** %8
%38 = load i64, i64* @errno
%39 = call i8* @strerror(i64 %38)
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i8* %36, i8* %37, i8* %39)
store i32 1, i32* %3
br label %180
41: ; preds = %25
store i32 0, i32* %9
br label %42
42: ; preds = %156, %41
%43 = load i32, i32* %9
%44 = icmp slt i32 %43, 256
br i1 %44, label %45, label %159
45: ; preds = %42
%46 = getelementptr inbounds [2 x i8], [2 x i8]* %11, i64 0, i64 0
%47 = load i32, i32* %9
%48 = trunc i32 %47 to i8
store i8 %48, i8* %46
%49 = getelementptr inbounds i8, i8* %46, i64 1
store i8 0, i8* %49
%50 = bitcast [5 x i8]* %12 to i8*
%51 = getelementptr inbounds [2 x i8], [2 x i8]* %11, i64 0, i64 0
store i8* %51, i8** %13
%52 = getelementptr inbounds [5 x i8], [5 x i8]* %12, i64 0, i64 0
store i8* %52, i8** %14
%53 = getelementptr inbounds [2 x i8], [2 x i8]* %11, i64 0, i64 0
%54 = call i64 @strlen(i8* %53)
store i64 %54, i64* %15
store i64 5, i64* %16
%55 = load i64, i64* %6
%56 = call i64 @iconv(i64 %55, i8** %13, i64* %15, i8** %14, i64* %16)
store i64 %56, i64* %17
store i32 -1, i32* %18
%57 = load i64, i64* %17
%58 = icmp eq i64 %57, -1
br i1 %58, label %59, label %77
59: ; preds = %45
%60 = load i64, i64* @errno
%61 = load i64, i64* @EILSEQ
%62 = icmp eq i64 %60, %61
br i1 %62, label %63, label %64
63: ; preds = %59
br label %76
64: ; preds = %59
%65 = load i64, i64* @errno
%66 = load i64, i64* @E2BIG
%67 = icmp eq i64 %65, %66
br i1 %67, label %68, label %72
68: ; preds = %64
%69 = load i32, i32* @stderr
%70 = load i32, i32* %9
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %70)
store i32 1, i32* %3
br label %180
72: ; preds = %64
%73 = load i32, i32* @stderr
%74 = load i32, i32* %9
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %74)
store i32 1, i32* %3
br label %180
76: ; preds = %63
br label %88
77: ; preds = %45
%78 = getelementptr inbounds [5 x i8], [5 x i8]* %12, i64 0, i64 0
%79 = getelementptr inbounds [5 x i8], [5 x i8]* %12, i64 0, i64 0
%80 = getelementptr inbounds [5 x i8], [5 x i8]* %12, i64 0, i64 0
%81 = call i64 @strlen(i8* %80)
%82 = getelementptr inbounds i8, i8* %79, i64 %81
%83 = call i32 @utf8decode(i8* %78, i8* %82, i32* %19)
store i32 %83, i32* %18
%84 = load i32, i32* %18
%85 = icmp eq i32 %84, 65533
br i1 %85, label %86, label %87
86: ; preds = %77
store i32 -1, i32* %18
br label %87
87: ; preds = %86, %77
br label %88
88: ; preds = %87, %76
%89 = load i32, i32* %10
%90 = icmp sge i32 %89, 0
br i1 %90, label %91, label %110
91: ; preds = %88
%92 = load i32, i32* %9
%93 = load i32, i32* %18
%94 = icmp ne i32 %92, %93
br i1 %94, label %95, label %110
95: ; preds = %91
%96 = load i32, i32* %10
%97 = add nsw i32 %96, 1
%98 = load i32, i32* %9
%99 = icmp eq i32 %97, %98
br i1 %99, label %100, label %104
100: ; preds = %95
%101 = load i32, i32* %10
%102 = load i32, i32* %10
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %101, i32 %102)
br label %109
104: ; preds = %95
%105 = load i32, i32* %10
%106 = load i32, i32* %9
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 %105, i32 %106)
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %109
109: ; preds = %104, %100
store i32 -1, i32* %10
br label %110
110: ; preds = %109, %91, %88
%111 = load i32, i32* %18
%112 = icmp slt i32 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %110
%114 = load i32, i32* %9
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %114)
br label %155
116: ; preds = %110
%117 = load i32, i32* %18
%118 = icmp sle i32 %117, 255
br i1 %118, label %119, label %134
119: ; preds = %116
%120 = load i32, i32* %9
%121 = load i32, i32* %18
%122 = icmp eq i32 %120, %121
br i1 %122, label %123, label %129
123: ; preds = %119
%124 = load i32, i32* %10
%125 = icmp slt i32 %124, 0
br i1 %125, label %126, label %128
126: ; preds = %123
%127 = load i32, i32* %9
store i32 %127, i32* %10
br label %128
128: ; preds = %126, %123
br label %133
129: ; preds = %119
%130 = load i32, i32* %9
%131 = load i32, i32* %18
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %130, i32 %131)
br label %133
133: ; preds = %129, %128
br label %154
134: ; preds = %116
%135 = load i32, i32* %18
%136 = icmp sle i32 %135, 65535
br i1 %136, label %137, label %141
137: ; preds = %134
%138 = load i32, i32* %9
%139 = load i32, i32* %18
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 %138, i32 %139)
br label %153
141: ; preds = %134
%142 = load i32, i32* %18
%143 = icmp sle i32 %142, 16777215
br i1 %143, label %144, label %148
144: ; preds = %141
%145 = load i32, i32* %9
%146 = load i32, i32* %18
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %145, i32 %146)
br label %152
148: ; preds = %141
%149 = load i32, i32* %9
%150 = load i32, i32* %18
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i32 %149, i32 %150)
br label %152
152: ; preds = %148, %144
br label %153
153: ; preds = %152, %137
br label %154
154: ; preds = %153, %133
br label %155
155: ; preds = %154, %113
br label %156
156: ; preds = %155
%157 = load i32, i32* %9
%158 = add nsw i32 %157, 1
store i32 %158, i32* %9
br label %42
159: ; preds = %42
%160 = load i32, i32* %10
%161 = icmp sge i32 %160, 0
br i1 %161, label %162, label %177
162: ; preds = %159
%163 = load i32, i32* %10
%164 = add nsw i32 %163, 1
%165 = load i32, i32* %9
%166 = icmp eq i32 %164, %165
br i1 %166, label %167, label %171
167: ; preds = %162
%168 = load i32, i32* %10
%169 = load i32, i32* %10
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %168, i32 %169)
br label %176
171: ; preds = %162
%172 = load i32, i32* %10
%173 = load i32, i32* %9
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 %172, i32 %173)
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %176
176: ; preds = %171, %167
store i32 -1, i32* %10
br label %177
177: ; preds = %176, %159
%178 = load i64, i64* %6
%179 = call i32 @iconv_close(i64 %178)
store i32 0, i32* %3
br label %180
180: ; preds = %177, %72, %68, %34, %22
%181 = load i32, i32* %3
ret i32 %181
}

LLVM IR (-O2):
@.str = [6 x i8] c"UTF-8\00"
@stderr = global i32 0
@.str.1 = [46 x i8] c"Usage: generate_encoding_table encoding_name\0A\00"
@.str.2 = [50 x i8] c"Recode from %s to %s failed with the error: \22%s\22.\00"
@errno = global i64 0
@EILSEQ = global i64 0
@E2BIG = global i64 0
@.str.3 = [14 x i8] c"E2BIG for %d\0A\00"
@.str.4 = [20 x i8] c"other error for %d\0A\00"
@.str.5 = [29 x i8] c"info->map[0x%02X] = 0x%02X;\0A\00"
@.str.6 = [34 x i8] c"for(i = 0x%02X; i < 0x%02X; i++)\0A\00"
@.str.8 = [25 x i8] c"info->map[0x%02X] = -1;\0A\00"
@.str.9 = [29 x i8] c"info->map[0x%02X] = 0x%04X;\0A\00"
@.str.10 = [29 x i8] c"info->map[0x%02X] = 0x%06X;\0A\00"
@.str.11 = [29 x i8] c"info->map[0x%02X] = 0x%08X;\0A\00"
@str.12 = [22 x i8] c" info->map[i] = i;\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i8]
%4 = alloca [5 x i8]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = icmp eq i32 %0, 2
br i1 %10, label %14, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
br label %107
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i64 @iconv_open(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = icmp eq i64 %17, -1
br i1 %18, label %28, label %19
19: ; preds = %14
%20 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
%21 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%23 = bitcast i8** %5 to i8*
%24 = bitcast i8** %6 to i8*
%25 = bitcast i64* %7 to i8*
%26 = bitcast i64* %8 to i8*
%27 = bitcast i32* %9 to i8*
br label %33
28: ; preds = %14
%29 = load i32, i32* @stderr
%30 = load i64, i64* @errno
%31 = tail call i8* @strerror(i64 %30)
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %31)
br label %107
33: ; preds = %19, %92
%34 = phi i32 [ -1, %19 ], [ %93, %92 ]
%35 = phi i32 [ 0, %19 ], [ %94, %92 ]
%36 = trunc i32 %35 to i8
store i8 %36, i8* %20
store i8 0, i8* %21
store i8* %20, i8** %5
store i8* %22, i8** %6
%37 = call i64 @strlen(i8* %20)
store i64 %37, i64* %7
store i64 5, i64* %8
%38 = call i64 @iconv(i64 %17, i8** %5, i64* %7, i8** %6, i64* %8)
%39 = icmp eq i64 %38, -1
br i1 %39, label %40, label %50
40: ; preds = %33
%41 = load i64, i64* @errno
%42 = load i64, i64* @EILSEQ
%43 = icmp eq i64 %41, %42
br i1 %43, label %56, label %44
44: ; preds = %40
%45 = load i64, i64* @E2BIG
%46 = icmp eq i64 %41, %45
%47 = load i32, i32* @stderr
%48 = select i1 %46, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0)
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* %48, i32 %35)
br label %107
50: ; preds = %33
%51 = call i64 @strlen(i8* %22)
%52 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 %51
%53 = call i32 @utf8decode(i8* %22, i8* %52, i32* %9)
%54 = icmp eq i32 %53, 65533
%55 = select i1 %54, i32 -1, i32 %53
br label %56
56: ; preds = %40, %50
%57 = phi i32 [ -1, %40 ], [ %55, %50 ]
%58 = icmp slt i32 %34, 0
%59 = icmp eq i32 %35, %57
%60 = select i1 %58, i1 true, i1 %59
br i1 %60, label %69, label %61
61: ; preds = %56
%62 = add nuw nsw i32 %34, 1
%63 = icmp eq i32 %62, %35
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %34, i32 %34)
br label %69
66: ; preds = %61
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 %34, i32 %35)
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
br label %69
69: ; preds = %64, %66, %56
%70 = phi i32 [ %34, %56 ], [ -1, %66 ], [ -1, %64 ]
%71 = icmp slt i32 %57, 0
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i32 %35)
br label %92
74: ; preds = %69
%75 = icmp ult i32 %57, 256
br i1 %75, label %76, label %82
76: ; preds = %74
br i1 %59, label %77, label %80
77: ; preds = %76
%78 = icmp slt i32 %70, 0
%79 = select i1 %78, i32 %35, i32 %70
br label %92
80: ; preds = %76
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %35, i32 %57)
br label %92
82: ; preds = %74
%83 = icmp ult i32 %57, 65536
br i1 %83, label %84, label %86
84: ; preds = %82
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i32 %35, i32 %57)
br label %92
86: ; preds = %82
%87 = icmp ult i32 %57, 16777216
br i1 %87, label %88, label %90
88: ; preds = %86
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %35, i32 %57)
br label %92
90: ; preds = %86
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0), i32 %35, i32 %57)
br label %92
92: ; preds = %77, %80, %88, %90, %84, %72
%93 = phi i32 [ %79, %77 ], [ %70, %90 ], [ %70, %88 ], [ %70, %84 ], [ %70, %80 ], [ %70, %72 ]
%94 = add nuw nsw i32 %35, 1
%95 = icmp eq i32 %94, 256
br i1 %95, label %96, label %33
96: ; preds = %92
%97 = icmp sgt i32 %93, -1
br i1 %97, label %98, label %105
98: ; preds = %96
%99 = icmp eq i32 %93, 255
br i1 %99, label %100, label %102
100: ; preds = %98
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 255, i32 255)
br label %105
102: ; preds = %98
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 %93, i32 256)
%104 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
br label %105
105: ; preds = %100, %102, %96
%106 = call i32 @iconv_close(i64 %17)
br label %107
107: ; preds = %44, %105, %28, %11
%108 = phi i32 [ 1, %11 ], [ 1, %28 ], [ 1, %44 ], [ 0, %105 ]
ret i32 %108
}