#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ __ref_alloc(scalar_t__, char *, char *, int /*<<< orphan*/);
scalar_t__ strlen(char *);
char *cmyth_utf8tolatin1(char *s) {
  unsigned long ucs4;
  int c, state, octets;
  char *out, *t;
  ucs4 = 0;
  state = 0;
  octets = 0;
  out = (char *)(__ref_alloc((strlen(s) + 1), (char *)0, (char *)0, 0));
  t = out;
  *t = 0;
  while ((c = *(s++)) != 0) {
    switch (state) {
    case 0:
      ucs4 = 0;
      if ((c & 0xfe) == 0xfc) {
        ucs4 = (c & 0x01) << 30;
        octets = 6;
        state = 5;
      } else if ((c & 0xfc) == 0xf8) {
        ucs4 = (c & 0x03) << 24;
        octets = 5;
        state = 4;
      } else if ((c & 0xf8) == 0xf0) {
        ucs4 = (c & 0x07) << 18;
        octets = 4;
        state = 3;
      } else if ((c & 0xf0) == 0xe0) {
        ucs4 = (c & 0x0f) << 12;
        octets = 3;
        state = 2;
      } else if ((c & 0xe0) == 0xc0) {
        ucs4 = (c & 0x1f) << 6;
        octets = 2;
        state = 1;
      } else if ((c & 0x80) == 0x00) {
        ucs4 = (c & 0x7f);
        octets = 1;
        state = 0;
      } else {
        ;
      }
      break;
    case 1:
      if ((c & 0xc0) == 0x80) {
        ucs4 = ucs4 | (c & 0x3f);
        if (ucs4 < 0x80 || ucs4 > 0x7ff) {
          ucs4 = 0xffffffff;
        }
      } else {
        ucs4 = 0xffffffff;
      }
      state = 0;
      break;
    case 2:
      if ((c & 0xc0) == 0x80) {
        ucs4 = ucs4 | ((c & 0x3f) << 6);
        state = 1;
      } else {
        ucs4 = 0xffffffff;
        state = 0;
      }
      break;
    case 3:
      if ((c & 0xc0) == 0x80) {
        ucs4 = ucs4 | ((c & 0x3f) << 12);
        state = 2;
      } else {
        ucs4 = 0xffffffff;
        state = 0;
      }
      break;
    case 4:
      if ((c & 0xc0) == 0x80) {
        ucs4 = ucs4 | ((c & 0x3f) << 18);
        state = 3;
      } else {
        ucs4 = 0xffffffff;
        state = 0;
      }
      break;
    case 5:
      if ((c & 0xc0) == 0x80) {
        ucs4 = ucs4 | ((c & 0x3f) << 24);
        state = 4;
      } else {
        ucs4 = 0xffffffff;
        state = 0;
      }
      break;
    default:
      ucs4 = 0xffffffff;
      state = 0;
      break;
    }
    if (state == 0) {
      switch (octets) {
      case 1:
        if (ucs4 > 0x7f)
          ucs4 = 0xffffffff;
        break;
      case 2:
        if (ucs4 < 0x80 || ucs4 > 0x7ff)
          ucs4 = 0xffffffff;
        break;
      case 3:
        if (ucs4 < 0x800 || ucs4 > 0xffff)
          ucs4 = 0xffffffff;
        break;
      case 4:
        if (ucs4 < 0x10000 || ucs4 > 0x1fffff)
          ucs4 = 0xffffffff;
        break;
      case 5:
        if (ucs4 < 0x200000 || ucs4 > 0x3ffffff)
          ucs4 = 0xffffffff;
        break;
      case 6:
        if (ucs4 < 0x4000000 || ucs4 > 0x7fffffff)
          ucs4 = 0xffffffff;
        break;
      default:
        ucs4 = 0xffffffff;
        break;
      }
      if (ucs4 != 0xffffffff) {
        *(t++) = (char)ucs4;
      }
    }
  }
  *t = 0;
  return out;
}


x86 assembly (clang, -O0):
<cmyth_utf8tolatin1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
mov    %rdx,%rsi
call   1040 <__ref_alloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1613 <cmyth_utf8tolatin1+0x4f3>
mov    -0x18(%rbp),%eax
mov    %rax,-0x38(%rbp)
sub    $0x5,%rax
ja     14ac <cmyth_utf8tolatin1+0x38c>
mov    -0x38(%rbp),%rax
lea    0xe53(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movq   $0x0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
and    $0xfe,%eax
cmp    $0xfc,%eax
jne    11f3 <cmyth_utf8tolatin1+0xd3>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
shl    $0x1e,%eax
cltq
mov    %rax,-0x10(%rbp)
movl   $0x6,-0x1c(%rbp)
movl   $0x5,-0x18(%rbp)
jmp    1315 <cmyth_utf8tolatin1+0x1f5>
mov    -0x14(%rbp),%eax
and    $0xfc,%eax
cmp    $0xf8,%eax
jne    1228 <cmyth_utf8tolatin1+0x108>
mov    -0x14(%rbp),%eax
and    $0x3,%eax
shl    $0x18,%eax
cltq
mov    %rax,-0x10(%rbp)
movl   $0x5,-0x1c(%rbp)
movl   $0x4,-0x18(%rbp)
jmp    1310 <cmyth_utf8tolatin1+0x1f0>
mov    -0x14(%rbp),%eax
and    $0xf8,%eax
cmp    $0xf0,%eax
jne    125d <cmyth_utf8tolatin1+0x13d>
mov    -0x14(%rbp),%eax
and    $0x7,%eax
shl    $0x12,%eax
cltq
mov    %rax,-0x10(%rbp)
movl   $0x4,-0x1c(%rbp)
movl   $0x3,-0x18(%rbp)
jmp    130b <cmyth_utf8tolatin1+0x1eb>
mov    -0x14(%rbp),%eax
and    $0xf0,%eax
cmp    $0xe0,%eax
jne    1292 <cmyth_utf8tolatin1+0x172>
mov    -0x14(%rbp),%eax
and    $0xf,%eax
shl    $0xc,%eax
cltq
mov    %rax,-0x10(%rbp)
movl   $0x3,-0x1c(%rbp)
movl   $0x2,-0x18(%rbp)
jmp    1306 <cmyth_utf8tolatin1+0x1e6>
mov    -0x14(%rbp),%eax
and    $0xe0,%eax
cmp    $0xc0,%eax
jne    12c7 <cmyth_utf8tolatin1+0x1a7>
mov    -0x14(%rbp),%eax
and    $0x1f,%eax
shl    $0x6,%eax
cltq
mov    %rax,-0x10(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    1301 <cmyth_utf8tolatin1+0x1e1>
mov    -0x14(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    12f7 <cmyth_utf8tolatin1+0x1d7>
mov    -0x14(%rbp),%eax
and    $0x7f,%eax
cltq
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    12fc <cmyth_utf8tolatin1+0x1dc>
jmp    12fc <cmyth_utf8tolatin1+0x1dc>
jmp    1301 <cmyth_utf8tolatin1+0x1e1>
jmp    1306 <cmyth_utf8tolatin1+0x1e6>
jmp    130b <cmyth_utf8tolatin1+0x1eb>
jmp    1310 <cmyth_utf8tolatin1+0x1f0>
jmp    1315 <cmyth_utf8tolatin1+0x1f5>
jmp    14bc <cmyth_utf8tolatin1+0x39c>
mov    -0x14(%rbp),%eax
and    $0xc0,%eax
cmp    $0x80,%eax
jne    136b <cmyth_utf8tolatin1+0x24b>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
and    $0x3f,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x80,-0x10(%rbp)
jb     135d <cmyth_utf8tolatin1+0x23d>
cmpq   $0x7ff,-0x10(%rbp)
jbe    1366 <cmyth_utf8tolatin1+0x246>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
jmp    1374 <cmyth_utf8tolatin1+0x254>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    14bc <cmyth_utf8tolatin1+0x39c>
mov    -0x14(%rbp),%eax
and    $0xc0,%eax
cmp    $0x80,%eax
jne    13b6 <cmyth_utf8tolatin1+0x296>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
and    $0x3f,%ecx
shl    $0x6,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    13c6 <cmyth_utf8tolatin1+0x2a6>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    14bc <cmyth_utf8tolatin1+0x39c>
mov    -0x14(%rbp),%eax
and    $0xc0,%eax
cmp    $0x80,%eax
jne    1401 <cmyth_utf8tolatin1+0x2e1>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
and    $0x3f,%ecx
shl    $0xc,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
movl   $0x2,-0x18(%rbp)
jmp    1411 <cmyth_utf8tolatin1+0x2f1>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    14bc <cmyth_utf8tolatin1+0x39c>
mov    -0x14(%rbp),%eax
and    $0xc0,%eax
cmp    $0x80,%eax
jne    144c <cmyth_utf8tolatin1+0x32c>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
and    $0x3f,%ecx
shl    $0x12,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
movl   $0x3,-0x18(%rbp)
jmp    145c <cmyth_utf8tolatin1+0x33c>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    14bc <cmyth_utf8tolatin1+0x39c>
mov    -0x14(%rbp),%eax
and    $0xc0,%eax
cmp    $0x80,%eax
jne    1497 <cmyth_utf8tolatin1+0x377>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
and    $0x3f,%ecx
shl    $0x18,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
movl   $0x4,-0x18(%rbp)
jmp    14a7 <cmyth_utf8tolatin1+0x387>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    14bc <cmyth_utf8tolatin1+0x39c>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    160e <cmyth_utf8tolatin1+0x4ee>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x5,%eax
ja     15da <cmyth_utf8tolatin1+0x4ba>
mov    -0x40(%rbp),%rax
lea    0xb32(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpq   $0x7f,-0x10(%rbp)
jbe    1503 <cmyth_utf8tolatin1+0x3e3>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
jmp    15e3 <cmyth_utf8tolatin1+0x4c3>
cmpq   $0x80,-0x10(%rbp)
jb     1524 <cmyth_utf8tolatin1+0x404>
cmpq   $0x7ff,-0x10(%rbp)
jbe    152d <cmyth_utf8tolatin1+0x40d>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
jmp    15e3 <cmyth_utf8tolatin1+0x4c3>
cmpq   $0x800,-0x10(%rbp)
jb     154e <cmyth_utf8tolatin1+0x42e>
cmpq   $0xffff,-0x10(%rbp)
jbe    1557 <cmyth_utf8tolatin1+0x437>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
jmp    15e3 <cmyth_utf8tolatin1+0x4c3>
cmpq   $0x10000,-0x10(%rbp)
jb     1578 <cmyth_utf8tolatin1+0x458>
cmpq   $0x1fffff,-0x10(%rbp)
jbe    1581 <cmyth_utf8tolatin1+0x461>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
jmp    15e3 <cmyth_utf8tolatin1+0x4c3>
cmpq   $0x200000,-0x10(%rbp)
jb     15a2 <cmyth_utf8tolatin1+0x482>
cmpq   $0x3ffffff,-0x10(%rbp)
03
jbe    15ab <cmyth_utf8tolatin1+0x48b>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
jmp    15e3 <cmyth_utf8tolatin1+0x4c3>
cmpq   $0x4000000,-0x10(%rbp)
04
jb     15cc <cmyth_utf8tolatin1+0x4ac>
cmpq   $0x7fffffff,-0x10(%rbp)
7f
jbe    15d5 <cmyth_utf8tolatin1+0x4b5>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
jmp    15e3 <cmyth_utf8tolatin1+0x4c3>
mov    $0xffffffff,%eax
mov    %rax,-0x10(%rbp)
mov    $0xffffffff,%eax
cmp    %rax,-0x10(%rbp)
je     1609 <cmyth_utf8tolatin1+0x4e9>
mov    -0x10(%rbp),%rax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
jmp    160e <cmyth_utf8tolatin1+0x4ee>
jmp    1173 <cmyth_utf8tolatin1+0x53>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmyth_utf8tolatin1>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0x1(%rax),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <__ref_alloc@plt>
movb   $0x0,(%rax)
mov    (%rbx),%cl
test   %cl,%cl
je     1441 <cmyth_utf8tolatin1+0x321>
mov    $0xffffffff,%r8d
add    $0x1,%rbx
lea    0xebc(%rip),%r9
lea    0xe9d(%rip),%r11
mov    %rax,%r10
xor    %ebp,%ebp
xor    %edi,%edi
jmp    1184 <cmyth_utf8tolatin1+0x64>
nopl   0x0(%rax)
mov    $0xffffffff,%edi
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
je     1444 <cmyth_utf8tolatin1+0x324>
mov    $0xffffffff,%edx
cmp    $0x5,%ebp
ja     1370 <cmyth_utf8tolatin1+0x250>
movsbl %cl,%esi
mov    %ebp,%edx
movslq (%r11,%rdx,4),%rdx
add    %r11,%rdx
jmp    *%rdx
mov    %esi,%edx
and    $0xfe,%edx
cmp    $0xfc,%edx
jne    12b3 <cmyth_utf8tolatin1+0x193>
and    $0x1,%esi
shl    $0x1e,%esi
mov    $0x5,%ebp
mov    $0x6,%r14d
mov    %rsi,%rdi
jmp    1175 <cmyth_utf8tolatin1+0x55>
mov    %esi,%ecx
and    $0xc0,%ecx
mov    $0xffffffff,%edx
cmp    $0x80,%ecx
jne    1370 <cmyth_utf8tolatin1+0x250>
and    $0x3f,%esi
or     %rsi,%rdi
lea    -0x800(%rdi),%rcx
cmp    $0xfffffffffffff880,%rcx
cmovb  %r8,%rdi
mov    %rdi,%rdx
jmp    1370 <cmyth_utf8tolatin1+0x250>
mov    %esi,%ecx
and    $0xc0,%ecx
mov    $0xffffffff,%edx
cmp    $0x80,%ecx
jne    1370 <cmyth_utf8tolatin1+0x250>
and    $0x3f,%esi
shl    $0x6,%esi
or     %rsi,%rdi
mov    $0x1,%ebp
jmp    1175 <cmyth_utf8tolatin1+0x55>
mov    %esi,%ecx
and    $0xc0,%ecx
mov    $0xffffffff,%edx
cmp    $0x80,%ecx
jne    1370 <cmyth_utf8tolatin1+0x250>
and    $0x3f,%esi
shl    $0xc,%esi
or     %rsi,%rdi
mov    $0x2,%ebp
jmp    1175 <cmyth_utf8tolatin1+0x55>
mov    %esi,%ecx
and    $0xc0,%ecx
mov    $0xffffffff,%edx
cmp    $0x80,%ecx
jne    1370 <cmyth_utf8tolatin1+0x250>
and    $0x3f,%esi
shl    $0x12,%esi
or     %rsi,%rdi
mov    $0x3,%ebp
jmp    1175 <cmyth_utf8tolatin1+0x55>
mov    %esi,%ecx
and    $0xc0,%ecx
mov    $0xffffffff,%edx
cmp    $0x80,%ecx
jne    1370 <cmyth_utf8tolatin1+0x250>
and    $0x3f,%esi
shl    $0x18,%esi
or     %rsi,%rdi
mov    $0x4,%ebp
jmp    1175 <cmyth_utf8tolatin1+0x55>
mov    %esi,%edx
and    $0xfc,%edx
cmp    $0xf8,%edx
jne    12dc <cmyth_utf8tolatin1+0x1bc>
and    $0x3,%esi
shl    $0x18,%esi
mov    $0x4,%ebp
mov    $0x5,%r14d
mov    %rsi,%rdi
jmp    1175 <cmyth_utf8tolatin1+0x55>
mov    %esi,%edx
and    $0xf8,%edx
cmp    $0xf0,%edx
jne    1305 <cmyth_utf8tolatin1+0x1e5>
and    $0x7,%esi
shl    $0x12,%esi
mov    $0x3,%ebp
mov    $0x4,%r14d
mov    %rsi,%rdi
jmp    1175 <cmyth_utf8tolatin1+0x55>
mov    %esi,%edx
and    $0xf0,%edx
cmp    $0xe0,%edx
jne    132b <cmyth_utf8tolatin1+0x20b>
shl    $0xc,%esi
movzwl %si,%edi
mov    $0x2,%ebp
mov    $0x3,%r14d
jmp    1175 <cmyth_utf8tolatin1+0x55>
mov    %esi,%edx
and    $0xe0,%edx
cmp    $0xc0,%edx
jne    1354 <cmyth_utf8tolatin1+0x234>
and    $0x1f,%esi
shl    $0x6,%esi
mov    $0x1,%ebp
mov    $0x2,%r14d
mov    %rsi,%rdi
jmp    1175 <cmyth_utf8tolatin1+0x55>
test   $0x80,%cl
jne    1366 <cmyth_utf8tolatin1+0x246>
mov    %esi,%edx
mov    $0x1,%r14d
jmp    1430 <cmyth_utf8tolatin1+0x310>
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
lea    -0x1(%r14),%ecx
cmp    $0x5,%ecx
ja     1170 <cmyth_utf8tolatin1+0x50>
movslq (%r9,%rcx,4),%rcx
add    %r9,%rcx
jmp    *%rcx
mov    $0x1,%r14d
cmp    $0x7f,%rdx
jbe    1430 <cmyth_utf8tolatin1+0x310>
jmp    1170 <cmyth_utf8tolatin1+0x50>
lea    -0x800(%rdx),%rcx
mov    $0x2,%r14d
cmp    $0xfffffffffffff880,%rcx
jae    1430 <cmyth_utf8tolatin1+0x310>
jmp    1170 <cmyth_utf8tolatin1+0x50>
lea    -0x10000(%rdx),%rcx
mov    $0x3,%r14d
cmp    $0xffffffffffff0800,%rcx
jae    1430 <cmyth_utf8tolatin1+0x310>
jmp    1170 <cmyth_utf8tolatin1+0x50>
lea    -0x200000(%rdx),%rcx
mov    $0x4,%r14d
cmp    $0xffffffffffe10000,%rcx
jae    1430 <cmyth_utf8tolatin1+0x310>
jmp    1170 <cmyth_utf8tolatin1+0x50>
lea    -0x4000000(%rdx),%rcx
mov    $0x5,%r14d
cmp    $0xfffffffffc200000,%rcx
jae    1430 <cmyth_utf8tolatin1+0x310>
jmp    1170 <cmyth_utf8tolatin1+0x50>
lea    -0x80000000(%rdx),%rcx
mov    $0x6,%r14d
cmp    $0xffffffff84000000,%rcx
jb     1170 <cmyth_utf8tolatin1+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %dl,(%r10)
add    $0x1,%r10
xor    %ebp,%ebp
mov    %rdx,%rdi
jmp    1175 <cmyth_utf8tolatin1+0x55>
mov    %rax,%r10
movb   $0x0,(%r10)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @cmyth_utf8tolatin1(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %2
store i64 0, i64* %3
store i32 0, i32* %5
store i32 0, i32* %6
%9 = load i8*, i8** %2
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %10, 1
%12 = call i64 @__ref_alloc(i64 %11, i8* null, i8* null, i32 0)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %7
%14 = load i8*, i8** %7
store i8* %14, i8** %8
%15 = load i8*, i8** %8
store i8 0, i8* %15
br label %16
16: ; preds = %216, %1
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %2
%19 = load i8, i8* %17
%20 = sext i8 %19 to i32
store i32 %20, i32* %4
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %217
22: ; preds = %16
%23 = load i32, i32* %5
switch i32 %23, label %155 [
i32 0, label %24
i32 1, label %84
i32 2, label %103
i32 3, label %116
i32 4, label %129
i32 5, label %142
]
24: ; preds = %22
store i64 0, i64* %3
%25 = load i32, i32* %4
%26 = and i32 %25, 254
%27 = icmp eq i32 %26, 252
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i32, i32* %4
%30 = and i32 %29, 1
%31 = shl i32 %30, 30
%32 = sext i32 %31 to i64
store i64 %32, i64* %3
store i32 6, i32* %6
store i32 5, i32* %5
br label %83
33: ; preds = %24
%34 = load i32, i32* %4
%35 = and i32 %34, 252
%36 = icmp eq i32 %35, 248
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i32, i32* %4
%39 = and i32 %38, 3
%40 = shl i32 %39, 24
%41 = sext i32 %40 to i64
store i64 %41, i64* %3
store i32 5, i32* %6
store i32 4, i32* %5
br label %82
42: ; preds = %33
%43 = load i32, i32* %4
%44 = and i32 %43, 248
%45 = icmp eq i32 %44, 240
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = load i32, i32* %4
%48 = and i32 %47, 7
%49 = shl i32 %48, 18
%50 = sext i32 %49 to i64
store i64 %50, i64* %3
store i32 4, i32* %6
store i32 3, i32* %5
br label %81
51: ; preds = %42
%52 = load i32, i32* %4
%53 = and i32 %52, 240
%54 = icmp eq i32 %53, 224
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = load i32, i32* %4
%57 = and i32 %56, 15
%58 = shl i32 %57, 12
%59 = sext i32 %58 to i64
store i64 %59, i64* %3
store i32 3, i32* %6
store i32 2, i32* %5
br label %80
60: ; preds = %51
%61 = load i32, i32* %4
%62 = and i32 %61, 224
%63 = icmp eq i32 %62, 192
br i1 %63, label %64, label %69
64: ; preds = %60
%65 = load i32, i32* %4
%66 = and i32 %65, 31
%67 = shl i32 %66, 6
%68 = sext i32 %67 to i64
store i64 %68, i64* %3
store i32 2, i32* %6
store i32 1, i32* %5
br label %79
69: ; preds = %60
%70 = load i32, i32* %4
%71 = and i32 %70, 128
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %69
%74 = load i32, i32* %4
%75 = and i32 %74, 127
%76 = sext i32 %75 to i64
store i64 %76, i64* %3
store i32 1, i32* %6
store i32 0, i32* %5
br label %78
77: ; preds = %69
br label %78
78: ; preds = %77, %73
br label %79
79: ; preds = %78, %64
br label %80
80: ; preds = %79, %55
br label %81
81: ; preds = %80, %46
br label %82
82: ; preds = %81, %37
br label %83
83: ; preds = %82, %28
br label %156
84: ; preds = %22
%85 = load i32, i32* %4
%86 = and i32 %85, 192
%87 = icmp eq i32 %86, 128
br i1 %87, label %88, label %101
88: ; preds = %84
%89 = load i64, i64* %3
%90 = load i32, i32* %4
%91 = and i32 %90, 63
%92 = sext i32 %91 to i64
%93 = or i64 %89, %92
store i64 %93, i64* %3
%94 = load i64, i64* %3
%95 = icmp ult i64 %94, 128
br i1 %95, label %99, label %96
96: ; preds = %88
%97 = load i64, i64* %3
%98 = icmp ugt i64 %97, 2047
br i1 %98, label %99, label %100
99: ; preds = %96, %88
store i64 4294967295, i64* %3
br label %100
100: ; preds = %99, %96
br label %102
101: ; preds = %84
store i64 4294967295, i64* %3
br label %102
102: ; preds = %101, %100
store i32 0, i32* %5
br label %156
103: ; preds = %22
%104 = load i32, i32* %4
%105 = and i32 %104, 192
%106 = icmp eq i32 %105, 128
br i1 %106, label %107, label %114
107: ; preds = %103
%108 = load i64, i64* %3
%109 = load i32, i32* %4
%110 = and i32 %109, 63
%111 = shl i32 %110, 6
%112 = sext i32 %111 to i64
%113 = or i64 %108, %112
store i64 %113, i64* %3
store i32 1, i32* %5
br label %115
114: ; preds = %103
store i64 4294967295, i64* %3
store i32 0, i32* %5
br label %115
115: ; preds = %114, %107
br label %156
116: ; preds = %22
%117 = load i32, i32* %4
%118 = and i32 %117, 192
%119 = icmp eq i32 %118, 128
br i1 %119, label %120, label %127
120: ; preds = %116
%121 = load i64, i64* %3
%122 = load i32, i32* %4
%123 = and i32 %122, 63
%124 = shl i32 %123, 12
%125 = sext i32 %124 to i64
%126 = or i64 %121, %125
store i64 %126, i64* %3
store i32 2, i32* %5
br label %128
127: ; preds = %116
store i64 4294967295, i64* %3
store i32 0, i32* %5
br label %128
128: ; preds = %127, %120
br label %156
129: ; preds = %22
%130 = load i32, i32* %4
%131 = and i32 %130, 192
%132 = icmp eq i32 %131, 128
br i1 %132, label %133, label %140
133: ; preds = %129
%134 = load i64, i64* %3
%135 = load i32, i32* %4
%136 = and i32 %135, 63
%137 = shl i32 %136, 18
%138 = sext i32 %137 to i64
%139 = or i64 %134, %138
store i64 %139, i64* %3
store i32 3, i32* %5
br label %141
140: ; preds = %129
store i64 4294967295, i64* %3
store i32 0, i32* %5
br label %141
141: ; preds = %140, %133
br label %156
142: ; preds = %22
%143 = load i32, i32* %4
%144 = and i32 %143, 192
%145 = icmp eq i32 %144, 128
br i1 %145, label %146, label %153
146: ; preds = %142
%147 = load i64, i64* %3
%148 = load i32, i32* %4
%149 = and i32 %148, 63
%150 = shl i32 %149, 24
%151 = sext i32 %150 to i64
%152 = or i64 %147, %151
store i64 %152, i64* %3
store i32 4, i32* %5
br label %154
153: ; preds = %142
store i64 4294967295, i64* %3
store i32 0, i32* %5
br label %154
154: ; preds = %153, %146
br label %156
155: ; preds = %22
store i64 4294967295, i64* %3
store i32 0, i32* %5
br label %156
156: ; preds = %155, %154, %141, %128, %115, %102, %83
%157 = load i32, i32* %5
%158 = icmp eq i32 %157, 0
br i1 %158, label %159, label %216
159: ; preds = %156
%160 = load i32, i32* %6
switch i32 %160, label %206 [
i32 1, label %161
i32 2, label %166
i32 3, label %174
i32 4, label %182
i32 5, label %190
i32 6, label %198
]
161: ; preds = %159
%162 = load i64, i64* %3
%163 = icmp ugt i64 %162, 127
br i1 %163, label %164, label %165
164: ; preds = %161
store i64 4294967295, i64* %3
br label %165
165: ; preds = %164, %161
br label %207
166: ; preds = %159
%167 = load i64, i64* %3
%168 = icmp ult i64 %167, 128
br i1 %168, label %172, label %169
169: ; preds = %166
%170 = load i64, i64* %3
%171 = icmp ugt i64 %170, 2047
br i1 %171, label %172, label %173
172: ; preds = %169, %166
store i64 4294967295, i64* %3
br label %173
173: ; preds = %172, %169
br label %207
174: ; preds = %159
%175 = load i64, i64* %3
%176 = icmp ult i64 %175, 2048
br i1 %176, label %180, label %177
177: ; preds = %174
%178 = load i64, i64* %3
%179 = icmp ugt i64 %178, 65535
br i1 %179, label %180, label %181
180: ; preds = %177, %174
store i64 4294967295, i64* %3
br label %181
181: ; preds = %180, %177
br label %207
182: ; preds = %159
%183 = load i64, i64* %3
%184 = icmp ult i64 %183, 65536
br i1 %184, label %188, label %185
185: ; preds = %182
%186 = load i64, i64* %3
%187 = icmp ugt i64 %186, 2097151
br i1 %187, label %188, label %189
188: ; preds = %185, %182
store i64 4294967295, i64* %3
br label %189
189: ; preds = %188, %185
br label %207
190: ; preds = %159
%191 = load i64, i64* %3
%192 = icmp ult i64 %191, 2097152
br i1 %192, label %196, label %193
193: ; preds = %190
%194 = load i64, i64* %3
%195 = icmp ugt i64 %194, 67108863
br i1 %195, label %196, label %197
196: ; preds = %193, %190
store i64 4294967295, i64* %3
br label %197
197: ; preds = %196, %193
br label %207
198: ; preds = %159
%199 = load i64, i64* %3
%200 = icmp ult i64 %199, 67108864
br i1 %200, label %204, label %201
201: ; preds = %198
%202 = load i64, i64* %3
%203 = icmp ugt i64 %202, 2147483647
br i1 %203, label %204, label %205
204: ; preds = %201, %198
store i64 4294967295, i64* %3
br label %205
205: ; preds = %204, %201
br label %207
206: ; preds = %159
store i64 4294967295, i64* %3
br label %207
207: ; preds = %206, %205, %197, %189, %181, %173, %165
%208 = load i64, i64* %3
%209 = icmp ne i64 %208, 4294967295
br i1 %209, label %210, label %215
210: ; preds = %207
%211 = load i64, i64* %3
%212 = trunc i64 %211 to i8
%213 = load i8*, i8** %8
%214 = getelementptr inbounds i8, i8* %213, i32 1
store i8* %214, i8** %8
store i8 %212, i8* %213
br label %215
215: ; preds = %210, %207
br label %216
216: ; preds = %215, %156
br label %16
217: ; preds = %16
%218 = load i8*, i8** %8
store i8 0, i8* %218
%219 = load i8*, i8** %7
ret i8* %219
}

LLVM IR (-O2):
define i8* @cmyth_utf8tolatin1(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 1
%4 = tail call i64 @__ref_alloc(i64 %3, i8* null, i8* null, i32 0)
%5 = inttoptr i64 %4 to i8*
store i8 0, i8* %5
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %130, label %8
8: ; preds = %1, %123
%9 = phi i8 [ %128, %123 ], [ %6, %1 ]
%10 = phi i8* [ %15, %123 ], [ %0, %1 ]
%11 = phi i8* [ %127, %123 ], [ %5, %1 ]
%12 = phi i32 [ %124, %123 ], [ 0, %1 ]
%13 = phi i32 [ %125, %123 ], [ 0, %1 ]
%14 = phi i64 [ %126, %123 ], [ 0, %1 ]
%15 = getelementptr inbounds i8, i8* %10, i64 1
%16 = sext i8 %9 to i32
switch i32 %13, label %99 [
i32 0, label %17
i32 1, label %57
i32 2, label %67
i32 3, label %75
i32 4, label %83
i32 5, label %91
]
17: ; preds = %8
%18 = and i32 %16, 254
%19 = icmp eq i32 %18, 252
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = shl i32 %16, 30
%22 = and i32 %21, 1073741824
%23 = zext i32 %22 to i64
br label %123
24: ; preds = %17
%25 = and i32 %16, 252
%26 = icmp eq i32 %25, 248
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = shl nsw i32 %16, 24
%29 = and i32 %28, 50331648
%30 = zext i32 %29 to i64
br label %123
31: ; preds = %24
%32 = and i32 %16, 248
%33 = icmp eq i32 %32, 240
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = shl nsw i32 %16, 18
%36 = and i32 %35, 1835008
%37 = zext i32 %36 to i64
br label %123
38: ; preds = %31
%39 = and i32 %16, 240
%40 = icmp eq i32 %39, 224
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = shl nsw i32 %16, 12
%43 = and i32 %42, 61440
%44 = zext i32 %43 to i64
br label %123
45: ; preds = %38
%46 = and i32 %16, 224
%47 = icmp eq i32 %46, 192
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = shl nsw i32 %16, 6
%50 = and i32 %49, 1984
%51 = zext i32 %50 to i64
br label %123
52: ; preds = %45
%53 = and i32 %16, 128
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %99
55: ; preds = %52
%56 = zext i32 %16 to i64
br label %118
57: ; preds = %8
%58 = and i32 %16, 192
%59 = icmp eq i32 %58, 128
br i1 %59, label %60, label %99
60: ; preds = %57
%61 = and i32 %16, 63
%62 = zext i32 %61 to i64
%63 = or i64 %14, %62
%64 = add i64 %63, -2048
%65 = icmp ult i64 %64, -1920
%66 = select i1 %65, i64 4294967295, i64 %63
br label %99
67: ; preds = %8
%68 = and i32 %16, 192
%69 = icmp eq i32 %68, 128
br i1 %69, label %70, label %99
70: ; preds = %67
%71 = shl nsw i32 %16, 6
%72 = and i32 %71, 4032
%73 = zext i32 %72 to i64
%74 = or i64 %14, %73
br label %123
75: ; preds = %8
%76 = and i32 %16, 192
%77 = icmp eq i32 %76, 128
br i1 %77, label %78, label %99
78: ; preds = %75
%79 = shl nsw i32 %16, 12
%80 = and i32 %79, 258048
%81 = zext i32 %80 to i64
%82 = or i64 %14, %81
br label %123
83: ; preds = %8
%84 = and i32 %16, 192
%85 = icmp eq i32 %84, 128
br i1 %85, label %86, label %99
86: ; preds = %83
%87 = shl nsw i32 %16, 18
%88 = and i32 %87, 16515072
%89 = zext i32 %88 to i64
%90 = or i64 %14, %89
br label %123
91: ; preds = %8
%92 = and i32 %16, 192
%93 = icmp eq i32 %92, 128
br i1 %93, label %94, label %99
94: ; preds = %91
%95 = shl nsw i32 %16, 24
%96 = and i32 %95, 1056964608
%97 = zext i32 %96 to i64
%98 = or i64 %14, %97
br label %123
99: ; preds = %52, %57, %60, %67, %75, %83, %91, %8
%100 = phi i64 [ 4294967295, %8 ], [ 4294967295, %91 ], [ 4294967295, %83 ], [ 4294967295, %75 ], [ 4294967295, %67 ], [ 4294967295, %57 ], [ %66, %60 ], [ 0, %52 ]
switch i32 %12, label %123 [
i32 1, label %101
i32 2, label %103
i32 3, label %106
i32 4, label %109
i32 5, label %112
i32 6, label %115
]
101: ; preds = %99
%102 = icmp ugt i64 %100, 127
br i1 %102, label %123, label %118
103: ; preds = %99
%104 = add nsw i64 %100, -2048
%105 = icmp ult i64 %104, -1920
br i1 %105, label %123, label %118
106: ; preds = %99
%107 = add nsw i64 %100, -65536
%108 = icmp ult i64 %107, -63488
br i1 %108, label %123, label %118
109: ; preds = %99
%110 = add nsw i64 %100, -2097152
%111 = icmp ult i64 %110, -2031616
br i1 %111, label %123, label %118
112: ; preds = %99
%113 = add nsw i64 %100, -67108864
%114 = icmp ult i64 %113, -65011712
br i1 %114, label %123, label %118
115: ; preds = %99
%116 = add nsw i64 %100, -2147483648
%117 = icmp ult i64 %116, -2080374784
br i1 %117, label %123, label %118
118: ; preds = %55, %101, %103, %106, %109, %112, %115
%119 = phi i32 [ 1, %101 ], [ 2, %103 ], [ 3, %106 ], [ 4, %109 ], [ 5, %112 ], [ 6, %115 ], [ 1, %55 ]
%120 = phi i64 [ %100, %101 ], [ %100, %103 ], [ %100, %106 ], [ %100, %109 ], [ %100, %112 ], [ %100, %115 ], [ %56, %55 ]
%121 = trunc i64 %120 to i8
%122 = getelementptr inbounds i8, i8* %11, i64 1
store i8 %121, i8* %11
br label %123
123: ; preds = %115, %112, %109, %106, %103, %101, %99, %27, %41, %48, %34, %20, %70, %78, %86, %94, %118
%124 = phi i32 [ %119, %118 ], [ %12, %94 ], [ %12, %86 ], [ %12, %78 ], [ %12, %70 ], [ 6, %20 ], [ 5, %27 ], [ 4, %34 ], [ 3, %41 ], [ 2, %48 ], [ %12, %99 ], [ 1, %101 ], [ 2, %103 ], [ 3, %106 ], [ 4, %109 ], [ 5, %112 ], [ 6, %115 ]
%125 = phi i32 [ 0, %118 ], [ 4, %94 ], [ 3, %86 ], [ 2, %78 ], [ 1, %70 ], [ 5, %20 ], [ 4, %27 ], [ 3, %34 ], [ 2, %41 ], [ 1, %48 ], [ 0, %99 ], [ 0, %101 ], [ 0, %103 ], [ 0, %106 ], [ 0, %109 ], [ 0, %112 ], [ 0, %115 ]
%126 = phi i64 [ %120, %118 ], [ %98, %94 ], [ %90, %86 ], [ %82, %78 ], [ %74, %70 ], [ %23, %20 ], [ %30, %27 ], [ %37, %34 ], [ %44, %41 ], [ %51, %48 ], [ 4294967295, %99 ], [ 4294967295, %101 ], [ 4294967295, %103 ], [ 4294967295, %106 ], [ 4294967295, %109 ], [ 4294967295, %112 ], [ 4294967295, %115 ]
%127 = phi i8* [ %122, %118 ], [ %11, %94 ], [ %11, %86 ], [ %11, %78 ], [ %11, %70 ], [ %11, %20 ], [ %11, %27 ], [ %11, %34 ], [ %11, %41 ], [ %11, %48 ], [ %11, %99 ], [ %11, %101 ], [ %11, %103 ], [ %11, %106 ], [ %11, %109 ], [ %11, %112 ], [ %11, %115 ]
%128 = load i8, i8* %15
%129 = icmp eq i8 %128, 0
br i1 %129, label %130, label %8
130: ; preds = %123, %1
%131 = phi i8* [ %5, %1 ], [ %127, %123 ]
store i8 0, i8* %131
ret i8* %5
}