#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;

/* Variables and functions */
int E2BIG;
int EILSEQ;
int EINVAL;
int ENOMEM;
int /*<<< orphan*/ abort();
int errno;
size_t iconv(scalar_t__, char const **, size_t *, char **, size_t *);
int /*<<< orphan*/ iconv_close(scalar_t__);
scalar_t__ iconv_open(char const *, char const *);
char *malloc(size_t);
char *realloc(char *, size_t);
int /*<<< orphan*/ strcmp(char const *, char *);
int iconv_string(const char *tocode, const char *fromcode, const char *start,
                 const char *end, char **resultp, size_t *lengthp) {
  iconv_t cd = iconv_open(tocode, fromcode);
  size_t length;
  char *result;
  if (cd == (iconv_t)(-1)) {
    if (errno != EINVAL)
      return -1;
    if (!strcmp(fromcode, "autodetect_utf8")) {
      int ret;
      ret = iconv_string(tocode, "UTF-8", start, end, resultp, lengthp);
      if (!(ret < 0 && errno == EILSEQ))
        return ret;
      ret = iconv_string(tocode, "ISO-8859-1", start, end, resultp, lengthp);
      return ret;
    }
    if (!strcmp(fromcode, "autodetect_jp")) {
      int ret;
      ret = iconv_string(tocode, "ISO-2022-JP-2", start, end, resultp, lengthp);
      if (!(ret < 0 && errno == EILSEQ))
        return ret;
      ret = iconv_string(tocode, "EUC-JP", start, end, resultp, lengthp);
      if (!(ret < 0 && errno == EILSEQ))
        return ret;
      ret = iconv_string(tocode, "SHIFT_JIS", start, end, resultp, lengthp);
      return ret;
    }
    if (!strcmp(fromcode, "autodetect_kr")) {
      int ret;
      ret = iconv_string(tocode, "ISO-2022-KR", start, end, resultp, lengthp);
      if (!(ret < 0 && errno == EILSEQ))
        return ret;
      ret = iconv_string(tocode, "EUC-KR", start, end, resultp, lengthp);
      return ret;
    }
    errno = EINVAL;
    return -1;
  }
  {
    size_t count = 0;
    char tmpbuf[4096];
    const char *inptr = start;
    size_t insize = end - start;
    while (insize > 0) {
      char *outptr = tmpbuf;
      size_t outsize = 4096;
      size_t res = iconv(cd, &inptr, &insize, &outptr, &outsize);
      if (res == (size_t)(-1) && errno != E2BIG) {
        int saved_errno = (errno == EINVAL ? EILSEQ : errno);
        iconv_close(cd);
        errno = saved_errno;
        return -1;
      }
      count += outptr - tmpbuf;
    }
    {
      char *outptr = tmpbuf;
      size_t outsize = 4096;
      size_t res = iconv(cd, NULL, NULL, &outptr, &outsize);
      if (res == (size_t)(-1)) {
        int saved_errno = errno;
        iconv_close(cd);
        errno = saved_errno;
        return -1;
      }
      count += outptr - tmpbuf;
    }
    length = count;
  }
  if (lengthp != NULL)
    *lengthp = length;
  if (resultp == NULL) {
    iconv_close(cd);
    return 0;
  }
  result = (*resultp == NULL ? malloc(length) : realloc(*resultp, length));
  *resultp = result;
  if (length == 0) {
    iconv_close(cd);
    return 0;
  }
  if (result == NULL) {
    iconv_close(cd);
    errno = ENOMEM;
    return -1;
  }
  iconv(cd, NULL, NULL, NULL, NULL);
  {
    const char *inptr = start;
    size_t insize = end - start;
    char *outptr = result;
    size_t outsize = length;
    while (insize > 0) {
      size_t res = iconv(cd, &inptr, &insize, &outptr, &outsize);
      if (res == (size_t)(-1)) {
        if (errno == EINVAL)
          break;
        else {
          int saved_errno = errno;
          iconv_close(cd);
          errno = saved_errno;
          return -1;
        }
      }
    }
    {
      size_t res = iconv(cd, NULL, NULL, &outptr, &outsize);
      if (res == (size_t)(-1)) {
        int saved_errno = errno;
        iconv_close(cd);
        errno = saved_errno;
        return -1;
      }
    }
    if (outsize != 0)
      abort();
  }
  iconv_close(cd);
  return 0;
}


x86 assembly (clang, -O0):
<iconv_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1110,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10a0 <iconv_open@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0xffffffffffffffff,-0x40(%rbp)
jne    1416 <iconv_string+0x296>
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    0x2df1(%rip),%rcx
cmp    (%rcx),%eax
je     11e3 <iconv_string+0x63>
movl   $0xffffffff,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x18(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    127a <iconv_string+0xfa>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    0xdf9(%rip),%rsi
call   1050 <iconv_string@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jge    1241 <iconv_string+0xc1>
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    0x2db7(%rip),%rcx
cmp    (%rcx),%eax
je     124c <iconv_string+0xcc>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    0xdaf(%rip),%rsi
call   1050 <iconv_string@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x18(%rbp),%rdi
lea    0xd9c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1361 <iconv_string+0x1e1>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    0xd81(%rip),%rsi
call   1050 <iconv_string@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    12d8 <iconv_string+0x158>
mov    0x2d01(%rip),%rax
mov    (%rax),%eax
mov    0x2d20(%rip),%rcx
cmp    (%rcx),%eax
je     12e3 <iconv_string+0x163>
mov    -0x58(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    0xd3f(%rip),%rsi
call   1050 <iconv_string@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jge    1328 <iconv_string+0x1a8>
mov    0x2cb1(%rip),%rax
mov    (%rax),%eax
mov    0x2cd0(%rip),%rcx
cmp    (%rcx),%eax
je     1333 <iconv_string+0x1b3>
mov    -0x58(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    0xcf6(%rip),%rsi
call   1050 <iconv_string@plt>
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x18(%rbp),%rdi
lea    0xce2(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    13f8 <iconv_string+0x278>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    0xcc7(%rip),%rsi
call   1050 <iconv_string@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jge    13bf <iconv_string+0x23f>
mov    0x2c1a(%rip),%rax
mov    (%rax),%eax
mov    0x2c39(%rip),%rcx
cmp    (%rcx),%eax
je     13ca <iconv_string+0x24a>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
lea    0xc83(%rip),%rsi
call   1050 <iconv_string@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    0x2bc1(%rip),%rax
mov    (%rax),%ecx
mov    0x2bc0(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
movq   $0x0,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x1078(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x1080(%rbp)
cmpq   $0x0,-0x1080(%rbp)
jbe    153d <iconv_string+0x3bd>
lea    -0x1070(%rbp),%rax
mov    %rax,-0x1088(%rbp)
movq   $0x1000,-0x1090(%rbp)
mov    -0x40(%rbp),%rdi
lea    -0x1078(%rbp),%rsi
lea    -0x1080(%rbp),%rdx
lea    -0x1088(%rbp),%rcx
lea    -0x1090(%rbp),%r8
call   1040 <iconv@plt>
mov    %rax,-0x1098(%rbp)
cmpq   $0xffffffffffffffff,-0x1098(%rbp)
ff
jne    151f <iconv_string+0x39f>
mov    0x2b25(%rip),%rax
mov    (%rax),%eax
mov    0x2b34(%rip),%rcx
cmp    (%rcx),%eax
je     151f <iconv_string+0x39f>
mov    0x2b0d(%rip),%rax
mov    (%rax),%eax
mov    0x2afc(%rip),%rcx
cmp    (%rcx),%eax
jne    14e0 <iconv_string+0x360>
mov    0x2b1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1100(%rbp)
jmp    14ef <iconv_string+0x36f>
mov    0x2ae1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1100(%rbp)
mov    -0x1100(%rbp),%eax
mov    %eax,-0x109c(%rbp)
mov    -0x40(%rbp),%rdi
call   1090 <iconv_close@plt>
mov    -0x109c(%rbp),%ecx
mov    0x2ab7(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x1088(%rbp),%rax
lea    -0x1070(%rbp),%rcx
sub    %rcx,%rax
add    -0x68(%rbp),%rax
mov    %rax,-0x68(%rbp)
jmp    143b <iconv_string+0x2bb>
lea    -0x1070(%rbp),%rax
mov    %rax,-0x10a8(%rbp)
movq   $0x1000,-0x10b0(%rbp)
mov    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x10a8(%rbp),%rcx
lea    -0x10b0(%rbp),%r8
mov    %rdx,%rsi
call   1040 <iconv@plt>
mov    %rax,-0x10b8(%rbp)
cmpq   $0xffffffffffffffff,-0x10b8(%rbp)
ff
jne    15bc <iconv_string+0x43c>
mov    0x2a38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10bc(%rbp)
mov    -0x40(%rbp),%rdi
call   1090 <iconv_close@plt>
mov    -0x10bc(%rbp),%ecx
mov    0x2a1a(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x10a8(%rbp),%rax
lea    -0x1070(%rbp),%rcx
sub    %rcx,%rax
add    -0x68(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     15f3 <iconv_string+0x473>
mov    -0x48(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x30(%rbp)
jne    1613 <iconv_string+0x493>
mov    -0x40(%rbp),%rdi
call   1090 <iconv_close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x30(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1636 <iconv_string+0x4b6>
mov    -0x48(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x1108(%rbp)
jmp    164d <iconv_string+0x4cd>
mov    -0x30(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rsi
call   1080 <realloc@plt>
mov    %rax,-0x1108(%rbp)
mov    -0x1108(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x48(%rbp)
jne    1683 <iconv_string+0x503>
mov    -0x40(%rbp),%rdi
call   1090 <iconv_close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
cmpq   $0x0,-0x50(%rbp)
jne    16b5 <iconv_string+0x535>
mov    -0x40(%rbp),%rdi
call   1090 <iconv_close@plt>
mov    0x2932(%rip),%rax
mov    (%rax),%ecx
mov    0x2921(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
mov    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rsi
mov    %r8,%rdx
mov    %r8,%rcx
call   1040 <iconv@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x10c8(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x10d0(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x10d8(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x10e0(%rbp)
cmpq   $0x0,-0x10d0(%rbp)
jbe    179c <iconv_string+0x61c>
mov    -0x40(%rbp),%rdi
lea    -0x10c8(%rbp),%rsi
lea    -0x10d0(%rbp),%rdx
lea    -0x10d8(%rbp),%rcx
lea    -0x10e0(%rbp),%r8
call   1040 <iconv@plt>
mov    %rax,-0x10e8(%rbp)
cmpq   $0xffffffffffffffff,-0x10e8(%rbp)
ff
jne    1797 <iconv_string+0x617>
mov    0x287a(%rip),%rax
mov    (%rax),%eax
mov    0x2869(%rip),%rcx
cmp    (%rcx),%eax
jne    1764 <iconv_string+0x5e4>
jmp    179c <iconv_string+0x61c>
mov    0x285d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10ec(%rbp)
mov    -0x40(%rbp),%rdi
call   1090 <iconv_close@plt>
mov    -0x10ec(%rbp),%ecx
mov    0x283f(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
jmp    16ff <iconv_string+0x57f>
mov    -0x40(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x10d8(%rbp),%rcx
lea    -0x10e0(%rbp),%r8
mov    %rdx,%rsi
call   1040 <iconv@plt>
mov    %rax,-0x10f8(%rbp)
cmpq   $0xffffffffffffffff,-0x10f8(%rbp)
ff
jne    1802 <iconv_string+0x682>
mov    0x27f2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10fc(%rbp)
mov    -0x40(%rbp),%rdi
call   1090 <iconv_close@plt>
mov    -0x10fc(%rbp),%ecx
mov    0x27d4(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1827 <iconv_string+0x6a7>
cmpq   $0x0,-0x10e0(%rbp)
je     1817 <iconv_string+0x697>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x40(%rbp),%rdi
call   1090 <iconv_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iconv_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1048,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,0x10(%rsp)
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbp
call   10a0 <iconv_open@plt>
mov    %rax,%rbx
cmp    $0xffffffffffffffff,%rax
je     125d <iconv_string+0xdd>
mov    %r12,0x20(%rsp)
mov    %r12,0x30(%rsp)
sub    %r12,%r13
mov    %r13,0x38(%rsp)
mov    %r13,0x18(%rsp)
je     13da <iconv_string+0x25a>
xor    %r13d,%r13d
lea    0x40(%rsp),%r15
mov    %rsp,%r12
lea    0x28(%rsp),%r14
jmp    1203 <iconv_string+0x83>
nopl   0x0(%rax,%rax,1)
sub    %r15,%r13
add    (%rsp),%r13
cmpq   $0x0,0x18(%rsp)
je     13dd <iconv_string+0x25d>
mov    %r15,(%rsp)
movq   $0x1000,0x28(%rsp)
mov    %rbx,%rdi
lea    0x20(%rsp),%rsi
lea    0x18(%rsp),%rdx
mov    %r12,%rcx
mov    %r14,%r8
call   1040 <iconv@plt>
cmp    $0xffffffffffffffff,%rax
jne    11f0 <iconv_string+0x70>
mov    0x2d93(%rip),%rax
mov    (%rax),%ebp
mov    0x2da2(%rip),%rax
cmp    (%rax),%ebp
je     11f0 <iconv_string+0x70>
mov    0x2d77(%rip),%rax
cmp    (%rax),%ebp
jne    154a <iconv_string+0x3ca>
mov    0x2d98(%rip),%rax
jmp    1548 <iconv_string+0x3c8>
mov    0x2d64(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%eax
mov    $0xffffffff,%ebx
mov    0x2d41(%rip),%rcx
cmp    (%rcx),%eax
jne    1560 <iconv_string+0x3e0>
mov    %r15,%rdi
lea    0xd6f(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1300 <iconv_string+0x180>
mov    %r15,%rdi
lea    0xd7d(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     1340 <iconv_string+0x1c0>
mov    %r15,%rdi
lea    0xd93(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1560 <iconv_string+0x3e0>
mov    %rbp,%rdi
lea    0xd8a(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%r9
call   1050 <iconv_string@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1560 <iconv_string+0x3e0>
mov    (%r14),%eax
lea    0xd6d(%rip),%r15
jmp    13ae <iconv_string+0x22e>
mov    %rbp,%rdi
lea    0xd06(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%r9
call   1050 <iconv_string@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1560 <iconv_string+0x3e0>
mov    (%r14),%eax
lea    0xce3(%rip),%r15
jmp    13ae <iconv_string+0x22e>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
lea    0xce5(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%r9
call   1050 <iconv_string@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1560 <iconv_string+0x3e0>
mov    (%r14),%eax
mov    0x2c7d(%rip),%rcx
cmp    (%rcx),%eax
jne    1560 <iconv_string+0x3e0>
mov    %rbp,%rdi
lea    0xcb8(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%r9
call   1050 <iconv_string@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1560 <iconv_string+0x3e0>
mov    (%r14),%eax
lea    0xc96(%rip),%r15
mov    0x2c3b(%rip),%rcx
cmp    (%rcx),%eax
jne    1560 <iconv_string+0x3e0>
mov    %rbp,%rdi
mov    %r15,%rsi
call   10a0 <iconv_open@plt>
cmp    $0xffffffffffffffff,%rax
je     1270 <iconv_string+0xf0>
mov    %rax,%rbx
jmp    11b9 <iconv_string+0x39>
xor    %r13d,%r13d
lea    0x40(%rsp),%r14
mov    %r14,(%rsp)
movq   $0x1000,0x28(%rsp)
mov    %rsp,%rcx
lea    0x28(%rsp),%r8
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <iconv@plt>
cmp    $0xffffffffffffffff,%rax
je     1446 <iconv_string+0x2c6>
mov    (%rsp),%rbp
sub    %r14,%rbp
add    %r13,%rbp
mov    0x8(%rsp),%rax
test   %rax,%rax
je     1420 <iconv_string+0x2a0>
mov    %rbp,(%rax)
mov    0x10(%rsp),%r12
test   %r12,%r12
mov    0x38(%rsp),%r15
je     1535 <iconv_string+0x3b5>
mov    (%r12),%rdi
test   %rdi,%rdi
je     1460 <iconv_string+0x2e0>
mov    %rbp,%rsi
call   1080 <realloc@plt>
jmp    1468 <iconv_string+0x2e8>
mov    0x2b7b(%rip),%r14
mov    (%r14),%ebp
mov    %rbx,%rdi
call   1090 <iconv_close@plt>
mov    %ebp,(%r14)
jmp    155b <iconv_string+0x3db>
mov    %rbp,%rdi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %rax,(%r12)
test   %rbp,%rbp
je     1535 <iconv_string+0x3b5>
test   %r14,%r14
je     14e4 <iconv_string+0x364>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <iconv@plt>
mov    0x30(%rsp),%rax
mov    %rax,0x40(%rsp)
mov    %r15,0x20(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbp,(%rsp)
test   %r15,%r15
je     1514 <iconv_string+0x394>
lea    0x40(%rsp),%r14
lea    0x20(%rsp),%r15
lea    0x18(%rsp),%r12
mov    %rsp,%rbp
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %rbp,%r8
call   1040 <iconv@plt>
cmp    $0xffffffffffffffff,%rax
je     1500 <iconv_string+0x380>
cmpq   $0x0,0x20(%rsp)
jne    14c0 <iconv_string+0x340>
jmp    1514 <iconv_string+0x394>
mov    %rbx,%rdi
call   1090 <iconv_close@plt>
mov    0x2add(%rip),%rax
mov    (%rax),%eax
mov    0x2acc(%rip),%rcx
mov    %eax,(%rcx)
jmp    155b <iconv_string+0x3db>
mov    0x2ac1(%rip),%rax
mov    (%rax),%ebp
mov    0x2ab0(%rip),%rax
cmp    (%rax),%ebp
jne    154a <iconv_string+0x3ca>
lea    0x18(%rsp),%rcx
mov    %rsp,%r8
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <iconv@plt>
cmp    $0xffffffffffffffff,%rax
je     1541 <iconv_string+0x3c1>
cmpq   $0x0,(%rsp)
jne    1574 <iconv_string+0x3f4>
mov    %rbx,%rdi
call   1090 <iconv_close@plt>
xor    %ebx,%ebx
jmp    1560 <iconv_string+0x3e0>
mov    0x2a80(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1090 <iconv_close@plt>
mov    0x2a6f(%rip),%rax
mov    %ebp,(%rax)
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x1048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@errno = global i32 0
@EINVAL = global i32 0
@.str = [16 x i8] c"autodetect_utf8\00"
@.str.1 = [6 x i8] c"UTF-8\00"
@EILSEQ = global i32 0
@.str.2 = [11 x i8] c"ISO-8859-1\00"
@.str.3 = [14 x i8] c"autodetect_jp\00"
@.str.4 = [14 x i8] c"ISO-2022-JP-2\00"
@.str.5 = [7 x i8] c"EUC-JP\00"
@.str.6 = [10 x i8] c"SHIFT_JIS\00"
@.str.7 = [14 x i8] c"autodetect_kr\00"
@.str.8 = [12 x i8] c"ISO-2022-KR\00"
@.str.9 = [7 x i8] c"EUC-KR\00"
@E2BIG = global i32 0
@ENOMEM = global i32 0
define i32 @iconv_string(i8* %0, i8* %1, i8* %2, i8* %3, i8** %4, i64* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8**
%13 = alloca i64*
%14 = alloca i64
%15 = alloca i64
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i64
%21 = alloca [4096 x i8]
%22 = alloca i8*
%23 = alloca i64
%24 = alloca i8*
%25 = alloca i64
%26 = alloca i64
%27 = alloca i32
%28 = alloca i8*
%29 = alloca i64
%30 = alloca i64
%31 = alloca i32
%32 = alloca i8*
%33 = alloca i64
%34 = alloca i8*
%35 = alloca i64
%36 = alloca i64
%37 = alloca i32
%38 = alloca i64
%39 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8** %4, i8*** %12
store i64* %5, i64** %13
%40 = load i8*, i8** %8
%41 = load i8*, i8** %9
%42 = call i64 @iconv_open(i8* %40, i8* %41)
store i64 %42, i64* %14
%43 = load i64, i64* %14
%44 = icmp eq i64 %43, -1
br i1 %44, label %45, label %148
45: ; preds = %6
%46 = load i32, i32* @errno
%47 = load i32, i32* @EINVAL
%48 = icmp ne i32 %46, %47
br i1 %48, label %49, label %50
49: ; preds = %45
store i32 -1, i32* %7
br label %296
50: ; preds = %45
%51 = load i8*, i8** %9
%52 = call i32 @strcmp(i8* %51, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%53 = icmp ne i32 %52, 0
br i1 %53, label %77, label %54
54: ; preds = %50
%55 = load i8*, i8** %8
%56 = load i8*, i8** %10
%57 = load i8*, i8** %11
%58 = load i8**, i8*** %12
%59 = load i64*, i64** %13
%60 = call i32 @iconv_string(i8* %55, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %56, i8* %57, i8** %58, i64* %59)
store i32 %60, i32* %17
%61 = load i32, i32* %17
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %54
%64 = load i32, i32* @errno
%65 = load i32, i32* @EILSEQ
%66 = icmp eq i32 %64, %65
br i1 %66, label %69, label %67
67: ; preds = %63, %54
%68 = load i32, i32* %17
store i32 %68, i32* %7
br label %296
69: ; preds = %63
%70 = load i8*, i8** %8
%71 = load i8*, i8** %10
%72 = load i8*, i8** %11
%73 = load i8**, i8*** %12
%74 = load i64*, i64** %13
%75 = call i32 @iconv_string(i8* %70, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %71, i8* %72, i8** %73, i64* %74)
store i32 %75, i32* %17
%76 = load i32, i32* %17
store i32 %76, i32* %7
br label %296
77: ; preds = %50
%78 = load i8*, i8** %9
%79 = call i32 @strcmp(i8* %78, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%80 = icmp ne i32 %79, 0
br i1 %80, label %119, label %81
81: ; preds = %77
%82 = load i8*, i8** %8
%83 = load i8*, i8** %10
%84 = load i8*, i8** %11
%85 = load i8**, i8*** %12
%86 = load i64*, i64** %13
%87 = call i32 @iconv_string(i8* %82, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %83, i8* %84, i8** %85, i64* %86)
store i32 %87, i32* %18
%88 = load i32, i32* %18
%89 = icmp slt i32 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %81
%91 = load i32, i32* @errno
%92 = load i32, i32* @EILSEQ
%93 = icmp eq i32 %91, %92
br i1 %93, label %96, label %94
94: ; preds = %90, %81
%95 = load i32, i32* %18
store i32 %95, i32* %7
br label %296
96: ; preds = %90
%97 = load i8*, i8** %8
%98 = load i8*, i8** %10
%99 = load i8*, i8** %11
%100 = load i8**, i8*** %12
%101 = load i64*, i64** %13
%102 = call i32 @iconv_string(i8* %97, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %98, i8* %99, i8** %100, i64* %101)
store i32 %102, i32* %18
%103 = load i32, i32* %18
%104 = icmp slt i32 %103, 0
br i1 %104, label %105, label %109
105: ; preds = %96
%106 = load i32, i32* @errno
%107 = load i32, i32* @EILSEQ
%108 = icmp eq i32 %106, %107
br i1 %108, label %111, label %109
109: ; preds = %105, %96
%110 = load i32, i32* %18
store i32 %110, i32* %7
br label %296
111: ; preds = %105
%112 = load i8*, i8** %8
%113 = load i8*, i8** %10
%114 = load i8*, i8** %11
%115 = load i8**, i8*** %12
%116 = load i64*, i64** %13
%117 = call i32 @iconv_string(i8* %112, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %113, i8* %114, i8** %115, i64* %116)
store i32 %117, i32* %18
%118 = load i32, i32* %18
store i32 %118, i32* %7
br label %296
119: ; preds = %77
%120 = load i8*, i8** %9
%121 = call i32 @strcmp(i8* %120, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%122 = icmp ne i32 %121, 0
br i1 %122, label %146, label %123
123: ; preds = %119
%124 = load i8*, i8** %8
%125 = load i8*, i8** %10
%126 = load i8*, i8** %11
%127 = load i8**, i8*** %12
%128 = load i64*, i64** %13
%129 = call i32 @iconv_string(i8* %124, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %125, i8* %126, i8** %127, i64* %128)
store i32 %129, i32* %19
%130 = load i32, i32* %19
%131 = icmp slt i32 %130, 0
br i1 %131, label %132, label %136
132: ; preds = %123
%133 = load i32, i32* @errno
%134 = load i32, i32* @EILSEQ
%135 = icmp eq i32 %133, %134
br i1 %135, label %138, label %136
136: ; preds = %132, %123
%137 = load i32, i32* %19
store i32 %137, i32* %7
br label %296
138: ; preds = %132
%139 = load i8*, i8** %8
%140 = load i8*, i8** %10
%141 = load i8*, i8** %11
%142 = load i8**, i8*** %12
%143 = load i64*, i64** %13
%144 = call i32 @iconv_string(i8* %139, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8* %140, i8* %141, i8** %142, i64* %143)
store i32 %144, i32* %19
%145 = load i32, i32* %19
store i32 %145, i32* %7
br label %296
146: ; preds = %119
%147 = load i32, i32* @EINVAL
store i32 %147, i32* @errno
store i32 -1, i32* %7
br label %296
148: ; preds = %6
store i64 0, i64* %20
%149 = load i8*, i8** %10
store i8* %149, i8** %22
%150 = load i8*, i8** %11
%151 = load i8*, i8** %10
%152 = ptrtoint i8* %150 to i64
%153 = ptrtoint i8* %151 to i64
%154 = sub i64 %152, %153
store i64 %154, i64* %23
br label %155
155: ; preds = %181, %148
%156 = load i64, i64* %23
%157 = icmp ugt i64 %156, 0
br i1 %157, label %158, label %189
158: ; preds = %155
%159 = getelementptr inbounds [4096 x i8], [4096 x i8]* %21, i64 0, i64 0
store i8* %159, i8** %24
store i64 4096, i64* %25
%160 = load i64, i64* %14
%161 = call i64 @iconv(i64 %160, i8** %22, i64* %23, i8** %24, i64* %25)
store i64 %161, i64* %26
%162 = load i64, i64* %26
%163 = icmp eq i64 %162, -1
br i1 %163, label %164, label %181
164: ; preds = %158
%165 = load i32, i32* @errno
%166 = load i32, i32* @E2BIG
%167 = icmp ne i32 %165, %166
br i1 %167, label %168, label %181
168: ; preds = %164
%169 = load i32, i32* @errno
%170 = load i32, i32* @EINVAL
%171 = icmp eq i32 %169, %170
br i1 %171, label %172, label %174
172: ; preds = %168
%173 = load i32, i32* @EILSEQ
br label %176
174: ; preds = %168
%175 = load i32, i32* @errno
br label %176
176: ; preds = %174, %172
%177 = phi i32 [ %173, %172 ], [ %175, %174 ]
store i32 %177, i32* %27
%178 = load i64, i64* %14
%179 = call i32 @iconv_close(i64 %178)
%180 = load i32, i32* %27
store i32 %180, i32* @errno
store i32 -1, i32* %7
br label %296
181: ; preds = %164, %158
%182 = load i8*, i8** %24
%183 = getelementptr inbounds [4096 x i8], [4096 x i8]* %21, i64 0, i64 0
%184 = ptrtoint i8* %182 to i64
%185 = ptrtoint i8* %183 to i64
%186 = sub i64 %184, %185
%187 = load i64, i64* %20
%188 = add i64 %187, %186
store i64 %188, i64* %20
br label %155
189: ; preds = %155
%190 = getelementptr inbounds [4096 x i8], [4096 x i8]* %21, i64 0, i64 0
store i8* %190, i8** %28
store i64 4096, i64* %29
%191 = load i64, i64* %14
%192 = call i64 @iconv(i64 %191, i8** null, i64* null, i8** %28, i64* %29)
store i64 %192, i64* %30
%193 = load i64, i64* %30
%194 = icmp eq i64 %193, -1
br i1 %194, label %195, label %200
195: ; preds = %189
%196 = load i32, i32* @errno
store i32 %196, i32* %31
%197 = load i64, i64* %14
%198 = call i32 @iconv_close(i64 %197)
%199 = load i32, i32* %31
store i32 %199, i32* @errno
store i32 -1, i32* %7
br label %296
200: ; preds = %189
%201 = load i8*, i8** %28
%202 = getelementptr inbounds [4096 x i8], [4096 x i8]* %21, i64 0, i64 0
%203 = ptrtoint i8* %201 to i64
%204 = ptrtoint i8* %202 to i64
%205 = sub i64 %203, %204
%206 = load i64, i64* %20
%207 = add i64 %206, %205
store i64 %207, i64* %20
%208 = load i64, i64* %20
store i64 %208, i64* %15
%209 = load i64*, i64** %13
%210 = icmp ne i64* %209, null
br i1 %210, label %211, label %214
211: ; preds = %200
%212 = load i64, i64* %15
%213 = load i64*, i64** %13
store i64 %212, i64* %213
br label %214
214: ; preds = %211, %200
%215 = load i8**, i8*** %12
%216 = icmp eq i8** %215, null
br i1 %216, label %217, label %220
217: ; preds = %214
%218 = load i64, i64* %14
%219 = call i32 @iconv_close(i64 %218)
store i32 0, i32* %7
br label %296
220: ; preds = %214
%221 = load i8**, i8*** %12
%222 = load i8*, i8** %221
%223 = icmp eq i8* %222, null
br i1 %223, label %224, label %227
224: ; preds = %220
%225 = load i64, i64* %15
%226 = call i8* @malloc(i64 %225)
br label %232
227: ; preds = %220
%228 = load i8**, i8*** %12
%229 = load i8*, i8** %228
%230 = load i64, i64* %15
%231 = call i8* @realloc(i8* %229, i64 %230)
br label %232
232: ; preds = %227, %224
%233 = phi i8* [ %226, %224 ], [ %231, %227 ]
store i8* %233, i8** %16
%234 = load i8*, i8** %16
%235 = load i8**, i8*** %12
store i8* %234, i8** %235
%236 = load i64, i64* %15
%237 = icmp eq i64 %236, 0
br i1 %237, label %238, label %241
238: ; preds = %232
%239 = load i64, i64* %14
%240 = call i32 @iconv_close(i64 %239)
store i32 0, i32* %7
br label %296
241: ; preds = %232
%242 = load i8*, i8** %16
%243 = icmp eq i8* %242, null
br i1 %243, label %244, label %248
244: ; preds = %241
%245 = load i64, i64* %14
%246 = call i32 @iconv_close(i64 %245)
%247 = load i32, i32* @ENOMEM
store i32 %247, i32* @errno
store i32 -1, i32* %7
br label %296
248: ; preds = %241
%249 = load i64, i64* %14
%250 = call i64 @iconv(i64 %249, i8** null, i64* null, i8** null, i64* null)
%251 = load i8*, i8** %10
store i8* %251, i8** %32
%252 = load i8*, i8** %11
%253 = load i8*, i8** %10
%254 = ptrtoint i8* %252 to i64
%255 = ptrtoint i8* %253 to i64
%256 = sub i64 %254, %255
store i64 %256, i64* %33
%257 = load i8*, i8** %16
store i8* %257, i8** %34
%258 = load i64, i64* %15
store i64 %258, i64* %35
br label %259
259: ; preds = %277, %248
%260 = load i64, i64* %33
%261 = icmp ugt i64 %260, 0
br i1 %261, label %262, label %278
262: ; preds = %259
%263 = load i64, i64* %14
%264 = call i64 @iconv(i64 %263, i8** %32, i64* %33, i8** %34, i64* %35)
store i64 %264, i64* %36
%265 = load i64, i64* %36
%266 = icmp eq i64 %265, -1
br i1 %266, label %267, label %277
267: ; preds = %262
%268 = load i32, i32* @errno
%269 = load i32, i32* @EINVAL
%270 = icmp eq i32 %268, %269
br i1 %270, label %271, label %272
271: ; preds = %267
br label %278
272: ; preds = %267
%273 = load i32, i32* @errno
store i32 %273, i32* %37
%274 = load i64, i64* %14
%275 = call i32 @iconv_close(i64 %274)
%276 = load i32, i32* %37
store i32 %276, i32* @errno
store i32 -1, i32* %7
br label %296
277: ; preds = %262
br label %259
278: ; preds = %271, %259
%279 = load i64, i64* %14
%280 = call i64 @iconv(i64 %279, i8** null, i64* null, i8** %34, i64* %35)
store i64 %280, i64* %38
%281 = load i64, i64* %38
%282 = icmp eq i64 %281, -1
br i1 %282, label %283, label %288
283: ; preds = %278
%284 = load i32, i32* @errno
store i32 %284, i32* %39
%285 = load i64, i64* %14
%286 = call i32 @iconv_close(i64 %285)
%287 = load i32, i32* %39
store i32 %287, i32* @errno
store i32 -1, i32* %7
br label %296
288: ; preds = %278
%289 = load i64, i64* %35
%290 = icmp ne i64 %289, 0
br i1 %290, label %291, label %293
291: ; preds = %288
%292 = call i32 (...) @abort()
unreachable
293: ; preds = %288
%294 = load i64, i64* %14
%295 = call i32 @iconv_close(i64 %294)
store i32 0, i32* %7
br label %296
296: ; preds = %293, %283, %272, %244, %238, %217, %195, %176, %146, %138, %136, %111, %109, %94, %69, %67, %49
%297 = load i32, i32* %7
ret i32 %297
}

LLVM IR (-O2):
@errno = global i32 0
@EINVAL = global i32 0
@.str = [16 x i8] c"autodetect_utf8\00"
@.str.1 = [6 x i8] c"UTF-8\00"
@EILSEQ = global i32 0
@.str.2 = [11 x i8] c"ISO-8859-1\00"
@.str.3 = [14 x i8] c"autodetect_jp\00"
@.str.4 = [14 x i8] c"ISO-2022-JP-2\00"
@.str.5 = [7 x i8] c"EUC-JP\00"
@.str.6 = [10 x i8] c"SHIFT_JIS\00"
@.str.7 = [14 x i8] c"autodetect_kr\00"
@.str.8 = [12 x i8] c"ISO-2022-KR\00"
@.str.9 = [7 x i8] c"EUC-KR\00"
@E2BIG = global i32 0
@ENOMEM = global i32 0
define i32 @iconv_string(i8* %0, i8* %1, i8* %2, i8* %3, i8** %4, i64* %5) {
%7 = alloca [4096 x i8]
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i8*
%17 = alloca i64
%18 = tail call i64 @iconv_open(i8* %0, i8* %1)
%19 = icmp eq i64 %18, -1
br i1 %19, label %20, label %66
20: ; preds = %6, %35
%21 = phi i8* [ %36, %35 ], [ %1, %6 ]
%22 = load i32, i32* @errno
%23 = load i32, i32* @EINVAL
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %170
25: ; preds = %20
%26 = tail call i32 @strcmp(i8* dereferenceable(1) %21, i8* dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = tail call i32 @iconv_string(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %3, i8** %4, i64* %5)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %170
31: ; preds = %28
%32 = load i32, i32* @errno
%33 = load i32, i32* @EILSEQ
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %170
35: ; preds = %31, %52, %62
%36 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %31 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), %52 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), %62 ]
%37 = tail call i64 @iconv_open(i8* %0, i8* %36)
%38 = icmp eq i64 %37, -1
br i1 %38, label %20, label %66
39: ; preds = %25
%40 = tail call i32 @strcmp(i8* dereferenceable(1) %21, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %56
42: ; preds = %39
%43 = tail call i32 @iconv_string(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %2, i8* %3, i8** %4, i64* %5)
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %170
45: ; preds = %42
%46 = load i32, i32* @errno
%47 = load i32, i32* @EILSEQ
%48 = icmp eq i32 %46, %47
br i1 %48, label %49, label %170
49: ; preds = %45
%50 = tail call i32 @iconv_string(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %2, i8* %3, i8** %4, i64* %5)
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %170
52: ; preds = %49
%53 = load i32, i32* @errno
%54 = load i32, i32* @EILSEQ
%55 = icmp eq i32 %53, %54
br i1 %55, label %35, label %170
56: ; preds = %39
%57 = tail call i32 @strcmp(i8* dereferenceable(1) %21, i8* dereferenceable(14) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %170
59: ; preds = %56
%60 = tail call i32 @iconv_string(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %2, i8* %3, i8** %4, i64* %5)
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %170
62: ; preds = %59
%63 = load i32, i32* @errno
%64 = load i32, i32* @EILSEQ
%65 = icmp eq i32 %63, %64
br i1 %65, label %35, label %170
66: ; preds = %35, %6
%67 = phi i64 [ %18, %6 ], [ %37, %35 ]
%68 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%69 = bitcast i8** %8 to i8*
store i8* %2, i8** %8
%70 = bitcast i64* %9 to i8*
%71 = ptrtoint i8* %3 to i64
%72 = ptrtoint i8* %2 to i64
%73 = sub i64 %71, %72
store i64 %73, i64* %9
%74 = icmp eq i64 %73, 0
br i1 %74, label %100, label %75
75: ; preds = %66
%76 = bitcast i8** %10 to i8*
%77 = bitcast i64* %11 to i8*
%78 = ptrtoint [4096 x i8]* %7 to i64
br label %86
79: ; preds = %86, %90
%80 = load i8*, i8** %10
%81 = ptrtoint i8* %80 to i64
%82 = sub i64 %87, %78
%83 = add i64 %82, %81
%84 = load i64, i64* %9
%85 = icmp eq i64 %84, 0
br i1 %85, label %100, label %86
86: ; preds = %75, %79
%87 = phi i64 [ 0, %75 ], [ %83, %79 ]
store i8* %68, i8** %10
store i64 4096, i64* %11
%88 = call i64 @iconv(i64 %67, i8** %8, i64* %9, i8** %10, i64* %11)
%89 = icmp eq i64 %88, -1
br i1 %89, label %90, label %79
90: ; preds = %86
%91 = load i32, i32* @errno
%92 = load i32, i32* @E2BIG
%93 = icmp eq i32 %91, %92
br i1 %93, label %79, label %94
94: ; preds = %90
%95 = load i32, i32* @EINVAL
%96 = icmp eq i32 %91, %95
%97 = load i32, i32* @EILSEQ
%98 = select i1 %96, i32 %97, i32 %91
%99 = call i32 @iconv_close(i64 %67)
store i32 %98, i32* @errno
br label %170
100: ; preds = %79, %66
%101 = phi i64 [ 0, %66 ], [ %83, %79 ]
%102 = bitcast i8** %12 to i8*
store i8* %68, i8** %12
%103 = bitcast i64* %13 to i8*
store i64 4096, i64* %13
%104 = call i64 @iconv(i64 %67, i8** null, i64* null, i8** %12, i64* %13)
%105 = icmp eq i64 %104, -1
br i1 %105, label %106, label %109
106: ; preds = %100
%107 = load i32, i32* @errno
%108 = call i32 @iconv_close(i64 %67)
store i32 %107, i32* @errno
br label %170
109: ; preds = %100
%110 = load i8*, i8** %12
%111 = ptrtoint i8* %110 to i64
%112 = ptrtoint [4096 x i8]* %7 to i64
%113 = sub i64 %111, %112
%114 = add i64 %113, %101
%115 = icmp eq i64* %5, null
br i1 %115, label %117, label %116
116: ; preds = %109
store i64 %114, i64* %5
br label %117
117: ; preds = %116, %109
%118 = icmp eq i8** %4, null
br i1 %118, label %119, label %121
119: ; preds = %117
%120 = call i32 @iconv_close(i64 %67)
br label %170
121: ; preds = %117
%122 = load i8*, i8** %4
%123 = icmp eq i8* %122, null
br i1 %123, label %124, label %126
124: ; preds = %121
%125 = call i8* @malloc(i64 %114)
br label %128
126: ; preds = %121
%127 = call i8* @realloc(i8* %122, i64 %114)
br label %128
128: ; preds = %126, %124
%129 = phi i8* [ %125, %124 ], [ %127, %126 ]
store i8* %129, i8** %4
%130 = icmp eq i64 %114, 0
br i1 %130, label %131, label %133
131: ; preds = %128
%132 = call i32 @iconv_close(i64 %67)
br label %170
133: ; preds = %128
%134 = icmp eq i8* %129, null
br i1 %134, label %135, label %138
135: ; preds = %133
%136 = call i32 @iconv_close(i64 %67)
%137 = load i32, i32* @ENOMEM
store i32 %137, i32* @errno
br label %170
138: ; preds = %133
%139 = call i64 @iconv(i64 %67, i8** null, i64* null, i8** null, i64* null)
%140 = bitcast i8** %14 to i8*
store i8* %2, i8** %14
%141 = bitcast i64* %15 to i8*
store i64 %73, i64* %15
%142 = bitcast i8** %16 to i8*
store i8* %129, i8** %16
%143 = bitcast i64* %17 to i8*
store i64 %114, i64* %17
%144 = icmp eq i64 %73, 0
br i1 %144, label %155, label %145
145: ; preds = %138, %148
%146 = call i64 @iconv(i64 %67, i8** %14, i64* %15, i8** %16, i64* %17)
%147 = icmp eq i64 %146, -1
br i1 %147, label %151, label %148
148: ; preds = %145
%149 = load i64, i64* %15
%150 = icmp eq i64 %149, 0
br i1 %150, label %155, label %145
151: ; preds = %145
%152 = load i32, i32* @errno
%153 = load i32, i32* @EINVAL
%154 = icmp eq i32 %152, %153
br i1 %154, label %155, label %165
155: ; preds = %148, %138, %151
%156 = call i64 @iconv(i64 %67, i8** null, i64* null, i8** %16, i64* %17)
%157 = icmp eq i64 %156, -1
br i1 %157, label %158, label %160
158: ; preds = %155
%159 = load i32, i32* @errno
br label %165
160: ; preds = %155
%161 = load i64, i64* %17
%162 = icmp eq i64 %161, 0
br i1 %162, label %168, label %163
163: ; preds = %160
%164 = call i32 (...) @abort()
unreachable
165: ; preds = %151, %158
%166 = phi i32 [ %159, %158 ], [ %152, %151 ]
%167 = call i32 @iconv_close(i64 %67)
store i32 %166, i32* @errno
br label %170
168: ; preds = %160
%169 = call i32 @iconv_close(i64 %67)
br label %170
170: ; preds = %62, %59, %45, %42, %52, %49, %31, %28, %20, %56, %165, %106, %94, %168, %135, %131, %119
%171 = phi i32 [ 0, %119 ], [ 0, %131 ], [ -1, %135 ], [ 0, %168 ], [ -1, %106 ], [ -1, %94 ], [ -1, %165 ], [ -1, %56 ], [ %60, %59 ], [ %60, %62 ], [ %50, %49 ], [ %50, %52 ], [ %43, %42 ], [ %43, %45 ], [ %29, %28 ], [ %29, %31 ], [ -1, %20 ]
ret i32 %171
}