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

/* Variables and functions */
int getchar();
int /*<<< orphan*/ isdigit(int);
int /*<<< orphan*/ memmove(int *, int *, int);
wchar_t term_getc() {
  static wchar_t queue[4];
  static wchar_t queuelen;
  int result;
  int newqueuelen = 0;
  if (queuelen) {
    result = queue[0];
    --queuelen;
    memmove(&queue[0], &queue[1], queuelen * sizeof(wchar_t));
    return result;
  }
  result = getchar();
  if (result & 0x80) {
    int n;
    if ((result & 0xE0) == 0xC0) {
      result &= 0x1F;
      n = 1;
    } else if ((result & 0xF0) == 0xE0) {
      result &= 0x0F;
      n = 2;
    } else if ((result & 0xF8) == 0xF0) {
      result &= 0x07;
      n = 3;
    } else if ((result & 0xFC) == 0xF8) {
      result &= 0x03;
      n = 4;
    } else if ((result & 0xFE) == 0xFC) {
      result &= 0x01;
      n = 5;
    } else {
      result = '?';
      n = 0;
    }
    while (n--) {
      int b;
      b = getchar();
      if ((b & 0xC0) != 0x80) {
        result = '?';
        break;
      }
      result <<= 6;
      result |= (b & 0x3F);
    }
  }
  switch (result) {
  case '\033':
    queue[newqueuelen++] = getchar();
    if (queue[0] == 'O' || queue[0] == '[') {
      int arg = 0;
      int double_bracket = 0;
      int ch;
      ch = getchar();
      if (ch == '[') {
        double_bracket = 1;
        ch = getchar();
      }
      while (isdigit(ch)) {
        if (!isdigit(ch))
          break;
        arg *= 10;
        arg += ch - '0';
        ch = getchar();
      }
      switch (ch) {
      case 'H':
        return 0x8007;
      case 'F':
        return 0x8008;
      }
      if (queue[0] == 'O') {
        switch (ch) {
        case 'P':
          return (0x800B + (1));
        case 'Q':
          return (0x800B + (2));
        case 'R':
          return (0x800B + (3));
        case 'S':
          return (0x800B + (4));
        }
      } else if (double_bracket) {
        switch (ch) {
        case 'A':
          return (0x800B + (1));
        case 'B':
          return (0x800B + (2));
        case 'C':
          return (0x800B + (3));
        case 'D':
          return (0x800B + (4));
        case 'E':
          return (0x800B + (5));
        }
      } else {
        switch (ch) {
        case '~':
          switch (arg) {
          case 1:
            return 0x8007;
          case 2:
            return 0x8009;
          case 3:
            return 0x800A;
          case 4:
            return 0x8008;
          case 5:
            return 0x8005;
          case 6:
            return 0x8006;
          case 15:
            return (0x800B + (5));
          case 17:
            return (0x800B + (6));
          case 18:
            return (0x800B + (7));
          case 19:
            return (0x800B + (8));
          case 20:
            return (0x800B + (9));
          case 21:
            return (0x800B + (10));
          case 23:
            return (0x800B + (11));
          case 24:
            return (0x800B + (12));
          }
          break;
        case 'A':
          return 0x8001;
        case 'B':
          return 0x8002;
        case 'C':
          return 0x8004;
        case 'D':
          return 0x8003;
        }
      }
    } else
      return queue[0] | 0x80000000;
    break;
  case '\n':
    return '\r';
  }
  queuelen = newqueuelen;
  return result;
}


x86 assembly (clang, -O0):
<term_getc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,0x2f1a(%rip)
je     118f <term_getc+0x5f>
mov    0x2efe(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0x2f05(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2efc(%rip)
movslq 0x2ef5(%rip),%rax
shl    $0x2,%rax
mov    %eax,%edx
lea    0x2ed8(%rip),%rdi
lea    0x2ed5(%rip),%rsi
call   1050 <memmove@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     12f5 <term_getc+0x1c5>
mov    -0x8(%rbp),%eax
and    $0xe0,%eax
cmp    $0xc0,%eax
jne    11d2 <term_getc+0xa2>
mov    -0x8(%rbp),%eax
and    $0x1f,%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
jmp    1294 <term_getc+0x164>
mov    -0x8(%rbp),%eax
and    $0xf0,%eax
cmp    $0xe0,%eax
jne    11fa <term_getc+0xca>
mov    -0x8(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x8(%rbp)
movl   $0x2,-0x10(%rbp)
jmp    128f <term_getc+0x15f>
mov    -0x8(%rbp),%eax
and    $0xf8,%eax
cmp    $0xf0,%eax
jne    1222 <term_getc+0xf2>
mov    -0x8(%rbp),%eax
and    $0x7,%eax
mov    %eax,-0x8(%rbp)
movl   $0x3,-0x10(%rbp)
jmp    128a <term_getc+0x15a>
mov    -0x8(%rbp),%eax
and    $0xfc,%eax
cmp    $0xf8,%eax
jne    124a <term_getc+0x11a>
mov    -0x8(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x8(%rbp)
movl   $0x4,-0x10(%rbp)
jmp    1285 <term_getc+0x155>
mov    -0x8(%rbp),%eax
and    $0xfe,%eax
cmp    $0xfc,%eax
jne    1272 <term_getc+0x142>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x5,-0x10(%rbp)
jmp    1280 <term_getc+0x150>
movl   $0x3f,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    1285 <term_getc+0x155>
jmp    128a <term_getc+0x15a>
jmp    128f <term_getc+0x15f>
jmp    1294 <term_getc+0x164>
jmp    1299 <term_getc+0x169>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x0,%eax
je     12f0 <term_getc+0x1c0>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0xc0,%eax
cmp    $0x80,%eax
je     12d6 <term_getc+0x1a6>
movl   $0x3f,-0x8(%rbp)
jmp    12f0 <term_getc+0x1c0>
mov    -0x8(%rbp),%eax
shl    $0x6,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
and    $0x3f,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1299 <term_getc+0x169>
jmp    12f5 <term_getc+0x1c5>
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0xa,%eax
je     1677 <term_getc+0x547>
jmp    1309 <term_getc+0x1d9>
mov    -0x24(%rbp),%eax
sub    $0x1b,%eax
jne    1683 <term_getc+0x553>
jmp    131a <term_getc+0x1ea>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%edx
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
movslq %eax,%rcx
lea    0x2d18(%rip),%rax
mov    %edx,(%rax,%rcx,4)
cmpl   $0x4f,0x2d0e(%rip)
je     1355 <term_getc+0x225>
cmpl   $0x5b,0x2d01(%rip)
jne    165f <term_getc+0x52f>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x5b,-0x20(%rbp)
jne    1388 <term_getc+0x258>
movl   $0x1,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x20(%rbp)
jmp    138d <term_getc+0x25d>
mov    -0x20(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     13d6 <term_getc+0x2a6>
mov    -0x20(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    13b4 <term_getc+0x284>
jmp    13d6 <term_getc+0x2a6>
imul   $0xa,-0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x30,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x20(%rbp)
jmp    138d <term_getc+0x25d>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x46,%eax
je     1407 <term_getc+0x2d7>
jmp    13ea <term_getc+0x2ba>
mov    -0x28(%rbp),%eax
sub    $0x48,%eax
jne    1413 <term_getc+0x2e3>
jmp    13fb <term_getc+0x2cb>
movl   $0x8007,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8008,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
cmpl   $0x4f,0x2c36(%rip)
jne    147e <term_getc+0x34e>
mov    -0x20(%rbp),%eax
add    $0xffffffb0,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     1479 <term_getc+0x349>
mov    -0x30(%rbp),%rax
lea    0xc34(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x800c,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x800d,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x800e,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x800f,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
jmp    165a <term_getc+0x52a>
cmpl   $0x0,-0x1c(%rbp)
je     14f2 <term_getc+0x3c2>
mov    -0x20(%rbp),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x4,%eax
ja     14ed <term_getc+0x3bd>
mov    -0x38(%rbp),%rax
lea    0xbb8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x800c,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x800d,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x800e,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x800f,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8010,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
jmp    1655 <term_getc+0x525>
mov    -0x20(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x41,%eax
je     1620 <term_getc+0x4f0>
jmp    1506 <term_getc+0x3d6>
mov    -0x3c(%rbp),%eax
sub    $0x42,%eax
je     162c <term_getc+0x4fc>
jmp    1517 <term_getc+0x3e7>
mov    -0x3c(%rbp),%eax
sub    $0x43,%eax
je     1638 <term_getc+0x508>
jmp    1528 <term_getc+0x3f8>
mov    -0x3c(%rbp),%eax
sub    $0x44,%eax
je     1644 <term_getc+0x514>
jmp    1539 <term_getc+0x409>
mov    -0x3c(%rbp),%eax
sub    $0x7e,%eax
jne    1650 <term_getc+0x520>
jmp    154a <term_getc+0x41a>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x17,%eax
ja     161b <term_getc+0x4eb>
mov    -0x48(%rbp),%rax
lea    0xa96(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x8007,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8009,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x800a,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8008,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8005,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8006,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8010,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8011,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8012,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8013,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8014,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8015,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8016,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8017,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
jmp    1650 <term_getc+0x520>
movl   $0x8001,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8002,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8004,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
movl   $0x8003,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
jmp    1655 <term_getc+0x525>
jmp    165a <term_getc+0x52a>
jmp    1672 <term_getc+0x542>
mov    0x29eb(%rip),%eax
or     $0x80000000,%eax
mov    %eax,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
jmp    1683 <term_getc+0x553>
movl   $0xd,-0x4(%rbp)
jmp    1692 <term_getc+0x562>
mov    -0xc(%rbp),%eax
mov    %eax,0x29d4(%rip)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term_getc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmpl   $0x0,0x2f22(%rip)
je     1162 <term_getc+0x42>
mov    0x2f0a(%rip),%ebx
lea    0x2f03(%rip),%rdi
movl   $0x0,0x2f09(%rip)
lea    0x2ef6(%rip),%rsi
xor    %edx,%edx
call   1040 <memmove@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ebx
test   $0x80,%bl
jne    1207 <term_getc+0xe7>
cmp    $0xa,%ebx
je     1222 <term_getc+0x102>
cmp    $0x1b,%ebx
jne    122c <term_getc+0x10c>
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,0x2ead(%rip)
cmp    $0x5b,%eax
je     11a1 <term_getc+0x81>
cmp    $0x4f,%eax
jne    126e <term_getc+0x14e>
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%r14d
cmp    $0x5b,%eax
jne    11b7 <term_getc+0x97>
xor    %eax,%eax
call   1030 <getchar@plt>
lea    -0x30(%rax),%ecx
mov    $0xffffffff,%r15d
cmp    $0x9,%ecx
ja     11eb <term_getc+0xcb>
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
lea    (%r15,%r15,4),%eax
lea    (%rcx,%rax,2),%r15d
xor    %eax,%eax
call   1030 <getchar@plt>
lea    -0x30(%rax),%ecx
cmp    $0xa,%ecx
jb     11d0 <term_getc+0xb0>
add    $0xffffffff,%r15d
cmp    $0x48,%eax
je     1292 <term_getc+0x172>
cmp    $0x46,%eax
jne    129c <term_getc+0x17c>
mov    $0x8008,%ebx
jmp    1155 <term_getc+0x35>
mov    %ebx,%eax
and    $0xe0,%eax
cmp    $0xc0,%eax
jne    123b <term_getc+0x11b>
and    $0x1f,%ebx
mov    $0x1,%ebp
jmp    12e6 <term_getc+0x1c6>
mov    $0xd,%ebx
jmp    1155 <term_getc+0x35>
xor    %r14d,%r14d
mov    %r14d,0x2e1a(%rip)
jmp    1155 <term_getc+0x35>
mov    %ebx,%eax
and    $0xf0,%eax
cmp    $0xe0,%eax
jne    1256 <term_getc+0x136>
and    $0xf,%ebx
mov    $0x2,%ebp
jmp    12e6 <term_getc+0x1c6>
mov    %ebx,%eax
and    $0xf8,%eax
cmp    $0xf0,%eax
jne    127a <term_getc+0x15a>
and    $0x7,%ebx
mov    $0x3,%ebp
jmp    12e6 <term_getc+0x1c6>
or     $0x80000000,%eax
mov    %eax,%ebx
jmp    1155 <term_getc+0x35>
mov    %ebx,%eax
and    $0xfc,%eax
cmp    $0xf8,%eax
jne    12c7 <term_getc+0x1a7>
and    $0x3,%ebx
mov    $0x4,%ebp
jmp    12e6 <term_getc+0x1c6>
mov    $0x8007,%ebx
jmp    1155 <term_getc+0x35>
cmpl   $0x4f,0x2d9d(%rip)
jne    1329 <term_getc+0x209>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
mov    $0x1,%r14d
cmp    $0x50,%ecx
jne    138c <term_getc+0x26c>
add    $0x7fbc,%eax
jmp    1342 <term_getc+0x222>
mov    %ebx,%eax
and    $0xfe,%eax
and    $0x1,%ebx
xor    %ecx,%ecx
cmp    $0xfc,%eax
sete   %cl
mov    $0x3f,%eax
cmovne %eax,%ebx
lea    (%rcx,%rcx,4),%ebp
add    $0x1,%ebp
xor    %r14d,%r14d
nopl   0x0(%rax)
add    $0xffffffff,%ebp
je     1174 <term_getc+0x54>
xor    %eax,%eax
call   1030 <getchar@plt>
mov    %eax,%ecx
and    $0xc0,%ecx
shl    $0x6,%ebx
and    $0x3f,%eax
or     %eax,%ebx
cmp    $0x80,%ecx
je     12f0 <term_getc+0x1d0>
mov    $0x3f,%ebx
mov    %r14d,0x2d2c(%rip)
jmp    1155 <term_getc+0x35>
cmp    $0x5b,%r14d
jne    1349 <term_getc+0x229>
lea    -0x41(%rax),%ecx
mov    $0x1,%r14d
cmp    $0x5,%ecx
jae    138c <term_getc+0x26c>
add    $0x7fcb,%eax
mov    %eax,%ebx
jmp    1155 <term_getc+0x35>
lea    -0x41(%rax),%ecx
cmp    $0x3,%ecx
ja     1370 <term_getc+0x250>
mov    $0x8001,%ebx
lea    0xca3(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    $0x8002,%ebx
jmp    1155 <term_getc+0x35>
mov    $0x1,%r14d
cmp    $0x7e,%eax
jne    138c <term_getc+0x26c>
cmp    $0x18,%r15d
jae    138c <term_getc+0x26c>
mov    $0xdf403f,%eax
bt     %r15d,%eax
jb     13ac <term_getc+0x28c>
mov    %r14d,0x2cbd(%rip)
jmp    1155 <term_getc+0x35>
mov    $0x8004,%ebx
jmp    1155 <term_getc+0x35>
mov    $0x8003,%ebx
jmp    1155 <term_getc+0x35>
movslq %r15d,%rax
lea    0xc5a(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
jmp    1155 <term_getc+0x35>

LLVM IR (-O0):
@term_getc.queue = internal global [4 x i32] zeroinitializer
@term_getc.queuelen = internal global i32 0
define i32 @term_getc() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
%9 = load i32, i32* @term_getc.queuelen
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %0
%12 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 0)
store i32 %12, i32* %2
%13 = load i32, i32* @term_getc.queuelen
%14 = add nsw i32 %13, -1
store i32 %14, i32* @term_getc.queuelen
%15 = load i32, i32* @term_getc.queuelen
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 4
%18 = trunc i64 %17 to i32
%19 = call i32 @memmove(i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 0), i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 1), i32 %18)
%20 = load i32, i32* %2
store i32 %20, i32* %1
br label %181
21: ; preds = %0
%22 = call i32 (...) @getchar()
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = and i32 %23, 128
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %85
26: ; preds = %21
%27 = load i32, i32* %2
%28 = and i32 %27, 224
%29 = icmp eq i32 %28, 192
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %2
%32 = and i32 %31, 31
store i32 %32, i32* %2
store i32 1, i32* %4
br label %66
33: ; preds = %26
%34 = load i32, i32* %2
%35 = and i32 %34, 240
%36 = icmp eq i32 %35, 224
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %2
%39 = and i32 %38, 15
store i32 %39, i32* %2
store i32 2, i32* %4
br label %65
40: ; preds = %33
%41 = load i32, i32* %2
%42 = and i32 %41, 248
%43 = icmp eq i32 %42, 240
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32, i32* %2
%46 = and i32 %45, 7
store i32 %46, i32* %2
store i32 3, i32* %4
br label %64
47: ; preds = %40
%48 = load i32, i32* %2
%49 = and i32 %48, 252
%50 = icmp eq i32 %49, 248
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load i32, i32* %2
%53 = and i32 %52, 3
store i32 %53, i32* %2
store i32 4, i32* %4
br label %63
54: ; preds = %47
%55 = load i32, i32* %2
%56 = and i32 %55, 254
%57 = icmp eq i32 %56, 252
br i1 %57, label %58, label %61
58: ; preds = %54
%59 = load i32, i32* %2
%60 = and i32 %59, 1
store i32 %60, i32* %2
store i32 5, i32* %4
br label %62
61: ; preds = %54
store i32 63, i32* %2
store i32 0, i32* %4
br label %62
62: ; preds = %61, %58
br label %63
63: ; preds = %62, %51
br label %64
64: ; preds = %63, %44
br label %65
65: ; preds = %64, %37
br label %66
66: ; preds = %65, %30
br label %67
67: ; preds = %77, %66
%68 = load i32, i32* %4
%69 = add nsw i32 %68, -1
store i32 %69, i32* %4
%70 = icmp ne i32 %68, 0
br i1 %70, label %71, label %84
71: ; preds = %67
%72 = call i32 (...) @getchar()
store i32 %72, i32* %5
%73 = load i32, i32* %5
%74 = and i32 %73, 192
%75 = icmp ne i32 %74, 128
br i1 %75, label %76, label %77
76: ; preds = %71
store i32 63, i32* %2
br label %84
77: ; preds = %71
%78 = load i32, i32* %2
%79 = shl i32 %78, 6
store i32 %79, i32* %2
%80 = load i32, i32* %5
%81 = and i32 %80, 63
%82 = load i32, i32* %2
%83 = or i32 %82, %81
store i32 %83, i32* %2
br label %67
84: ; preds = %76, %67
br label %85
85: ; preds = %84, %21
%86 = load i32, i32* %2
switch i32 %86, label %178 [
i32 27, label %87
i32 10, label %177
]
87: ; preds = %85
%88 = call i32 (...) @getchar()
%89 = load i32, i32* %3
%90 = add nsw i32 %89, 1
store i32 %90, i32* %3
%91 = sext i32 %89 to i64
%92 = getelementptr inbounds [4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 %91
store i32 %88, i32* %92
%93 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 0)
%94 = icmp eq i32 %93, 79
br i1 %94, label %98, label %95
95: ; preds = %87
%96 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 0)
%97 = icmp eq i32 %96, 91
br i1 %97, label %98, label %173
98: ; preds = %95, %87
store i32 0, i32* %6
store i32 0, i32* %7
%99 = call i32 (...) @getchar()
store i32 %99, i32* %8
%100 = load i32, i32* %8
%101 = icmp eq i32 %100, 91
br i1 %101, label %102, label %104
102: ; preds = %98
store i32 1, i32* %7
%103 = call i32 (...) @getchar()
store i32 %103, i32* %8
br label %104
104: ; preds = %102, %98
br label %105
105: ; preds = %114, %104
%106 = load i32, i32* %8
%107 = call i32 @isdigit(i32 %106)
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %122
109: ; preds = %105
%110 = load i32, i32* %8
%111 = call i32 @isdigit(i32 %110)
%112 = icmp ne i32 %111, 0
br i1 %112, label %114, label %113
113: ; preds = %109
br label %122
114: ; preds = %109
%115 = load i32, i32* %6
%116 = mul nsw i32 %115, 10
store i32 %116, i32* %6
%117 = load i32, i32* %8
%118 = sub nsw i32 %117, 48
%119 = load i32, i32* %6
%120 = add nsw i32 %119, %118
store i32 %120, i32* %6
%121 = call i32 (...) @getchar()
store i32 %121, i32* %8
br label %105
122: ; preds = %113, %105
%123 = load i32, i32* %8
switch i32 %123, label %126 [
i32 72, label %124
i32 70, label %125
]
124: ; preds = %122
store i32 32775, i32* %1
br label %181
125: ; preds = %122
store i32 32776, i32* %1
br label %181
126: ; preds = %122
%127 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 0)
%128 = icmp eq i32 %127, 79
br i1 %128, label %129, label %136
129: ; preds = %126
%130 = load i32, i32* %8
switch i32 %130, label %135 [
i32 80, label %131
i32 81, label %132
i32 82, label %133
i32 83, label %134
]
131: ; preds = %129
store i32 32780, i32* %1
br label %181
132: ; preds = %129
store i32 32781, i32* %1
br label %181
133: ; preds = %129
store i32 32782, i32* %1
br label %181
134: ; preds = %129
store i32 32783, i32* %1
br label %181
135: ; preds = %129
br label %172
136: ; preds = %126
%137 = load i32, i32* %7
%138 = icmp ne i32 %137, 0
br i1 %138, label %139, label %147
139: ; preds = %136
%140 = load i32, i32* %8
switch i32 %140, label %146 [
i32 65, label %141
i32 66, label %142
i32 67, label %143
i32 68, label %144
i32 69, label %145
]
141: ; preds = %139
store i32 32780, i32* %1
br label %181
142: ; preds = %139
store i32 32781, i32* %1
br label %181
143: ; preds = %139
store i32 32782, i32* %1
br label %181
144: ; preds = %139
store i32 32783, i32* %1
br label %181
145: ; preds = %139
store i32 32784, i32* %1
br label %181
146: ; preds = %139
br label %171
147: ; preds = %136
%148 = load i32, i32* %8
switch i32 %148, label %170 [
i32 126, label %149
i32 65, label %166
i32 66, label %167
i32 67, label %168
i32 68, label %169
]
149: ; preds = %147
%150 = load i32, i32* %6
switch i32 %150, label %165 [
i32 1, label %151
i32 2, label %152
i32 3, label %153
i32 4, label %154
i32 5, label %155
i32 6, label %156
i32 15, label %157
i32 17, label %158
i32 18, label %159
i32 19, label %160
i32 20, label %161
i32 21, label %162
i32 23, label %163
i32 24, label %164
]
151: ; preds = %149
store i32 32775, i32* %1
br label %181
152: ; preds = %149
store i32 32777, i32* %1
br label %181
153: ; preds = %149
store i32 32778, i32* %1
br label %181
154: ; preds = %149
store i32 32776, i32* %1
br label %181
155: ; preds = %149
store i32 32773, i32* %1
br label %181
156: ; preds = %149
store i32 32774, i32* %1
br label %181
157: ; preds = %149
store i32 32784, i32* %1
br label %181
158: ; preds = %149
store i32 32785, i32* %1
br label %181
159: ; preds = %149
store i32 32786, i32* %1
br label %181
160: ; preds = %149
store i32 32787, i32* %1
br label %181
161: ; preds = %149
store i32 32788, i32* %1
br label %181
162: ; preds = %149
store i32 32789, i32* %1
br label %181
163: ; preds = %149
store i32 32790, i32* %1
br label %181
164: ; preds = %149
store i32 32791, i32* %1
br label %181
165: ; preds = %149
br label %170
166: ; preds = %147
store i32 32769, i32* %1
br label %181
167: ; preds = %147
store i32 32770, i32* %1
br label %181
168: ; preds = %147
store i32 32772, i32* %1
br label %181
169: ; preds = %147
store i32 32771, i32* %1
br label %181
170: ; preds = %147, %165
br label %171
171: ; preds = %170, %146
br label %172
172: ; preds = %171, %135
br label %176
173: ; preds = %95
%174 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 0)
%175 = or i32 %174, -2147483648
store i32 %175, i32* %1
br label %181
176: ; preds = %172
br label %178
177: ; preds = %85
store i32 13, i32* %1
br label %181
178: ; preds = %85, %176
%179 = load i32, i32* %3
store i32 %179, i32* @term_getc.queuelen
%180 = load i32, i32* %2
store i32 %180, i32* %1
br label %181
181: ; preds = %178, %177, %173, %169, %168, %167, %166, %164, %163, %162, %161, %160, %159, %158, %157, %156, %155, %154, %153, %152, %151, %145, %144, %143, %142, %141, %134, %133, %132, %131, %125, %124, %11
%182 = load i32, i32* %1
ret i32 %182
}

LLVM IR (-O2):
@term_getc.queue = internal global [4 x i32] zeroinitializer
@term_getc.queuelen = internal unnamed_addr global i32 0
@switch.table.term_getc = [24 x i32] [i32 32775, i32 32777, i32 32778, i32 32776, i32 32773, i32 32774, i32 32775, i32 32775, i32 32775, i32 32775, i32 32775, i32 32775, i32 32775, i32 32775, i32 32784, i32 32775, i32 32785, i32 32786, i32 32787, i32 32788, i32 32789, i32 32775, i32 32790, i32 32791]
define i32 @term_getc() {
%1 = load i32, i32* @term_getc.queuelen
%2 = icmp eq i32 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 0)
store i32 0, i32* @term_getc.queuelen
%5 = tail call i32 @memmove(i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 0), i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 1), i32 0)
br label %111
6: ; preds = %0
%7 = tail call i32 (...) @getchar()
%8 = and i32 %7, 128
%9 = icmp eq i32 %8, 0
br i1 %9, label %51, label %10
10: ; preds = %6
%11 = and i32 %7, 224
%12 = icmp eq i32 %11, 192
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = and i32 %7, 31
br label %36
15: ; preds = %10
%16 = and i32 %7, 240
%17 = icmp eq i32 %16, 224
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = and i32 %7, 15
br label %36
20: ; preds = %15
%21 = and i32 %7, 248
%22 = icmp eq i32 %21, 240
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = and i32 %7, 7
br label %36
25: ; preds = %20
%26 = and i32 %7, 252
%27 = icmp eq i32 %26, 248
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = and i32 %7, 3
br label %36
30: ; preds = %25
%31 = and i32 %7, 254
%32 = icmp eq i32 %31, 252
%33 = and i32 %7, 1
%34 = select i1 %32, i32 %33, i32 63
%35 = select i1 %32, i32 5, i32 0
br label %36
36: ; preds = %30, %18, %28, %23, %13
%37 = phi i32 [ %34, %30 ], [ %29, %28 ], [ %24, %23 ], [ %19, %18 ], [ %14, %13 ]
%38 = phi i32 [ %35, %30 ], [ 4, %28 ], [ 3, %23 ], [ 2, %18 ], [ 1, %13 ]
br label %39
39: ; preds = %36, %43
%40 = phi i32 [ %50, %43 ], [ %37, %36 ]
%41 = phi i32 [ %44, %43 ], [ %38, %36 ]
%42 = icmp eq i32 %41, 0
br i1 %42, label %51, label %43
43: ; preds = %39
%44 = add nsw i32 %41, -1
%45 = tail call i32 (...) @getchar()
%46 = and i32 %45, 192
%47 = icmp eq i32 %46, 128
%48 = shl i32 %40, 6
%49 = and i32 %45, 63
%50 = or i32 %49, %48
br i1 %47, label %39, label %96
51: ; preds = %39, %6
%52 = phi i32 [ %7, %6 ], [ %40, %39 ]
switch i32 %52, label %96 [
i32 27, label %53
i32 10, label %111
]
53: ; preds = %51
%54 = tail call i32 (...) @getchar()
store i32 %54, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 0)
switch i32 %54, label %94 [
i32 91, label %55
i32 79, label %55
]
55: ; preds = %53, %53
%56 = tail call i32 (...) @getchar()
%57 = icmp eq i32 %56, 91
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = tail call i32 (...) @getchar()
br label %60
60: ; preds = %58, %55
%61 = phi i32 [ %59, %58 ], [ %56, %55 ]
%62 = add i32 %61, -48
%63 = icmp ult i32 %62, 10
br i1 %63, label %64, label %74
64: ; preds = %60, %64
%65 = phi i32 [ %70, %64 ], [ %62, %60 ]
%66 = phi i32 [ %68, %64 ], [ 0, %60 ]
%67 = mul nsw i32 %66, 10
%68 = add nsw i32 %65, %67
%69 = tail call i32 (...) @getchar()
%70 = add i32 %69, -48
%71 = icmp ult i32 %70, 10
br i1 %71, label %64, label %72
72: ; preds = %64
%73 = add i32 %68, -1
br label %74
74: ; preds = %72, %60
%75 = phi i32 [ -1, %60 ], [ %73, %72 ]
%76 = phi i32 [ %61, %60 ], [ %69, %72 ]
switch i32 %76, label %78 [
i32 72, label %111
i32 70, label %77
]
77: ; preds = %74
br label %111
78: ; preds = %74
%79 = load i32, i32* getelementptr inbounds ([4 x i32], [4 x i32]* @term_getc.queue, i64 0, i64 0)
%80 = icmp eq i32 %79, 79
br i1 %80, label %81, label %84
81: ; preds = %78
%82 = and i32 %76, -4
%83 = icmp eq i32 %82, 80
br i1 %83, label %99, label %96
84: ; preds = %78
br i1 %57, label %85, label %88
85: ; preds = %84
%86 = add i32 %76, -65
%87 = icmp ult i32 %86, 5
br i1 %87, label %101, label %96
88: ; preds = %84
switch i32 %76, label %96 [
i32 126, label %89
i32 65, label %111
i32 66, label %91
i32 67, label %92
i32 68, label %93
]
89: ; preds = %88
%90 = icmp ult i32 %75, 24
br i1 %90, label %103, label %96
91: ; preds = %88
br label %111
92: ; preds = %88
br label %111
93: ; preds = %88
br label %111
94: ; preds = %53
%95 = or i32 %54, -2147483648
br label %111
96: ; preds = %43, %103, %89, %85, %81, %88, %51
%97 = phi i32 [ %52, %51 ], [ %52, %81 ], [ %52, %88 ], [ %52, %89 ], [ %52, %85 ], [ %52, %103 ], [ 63, %43 ]
%98 = phi i32 [ 0, %51 ], [ 1, %81 ], [ 1, %88 ], [ 1, %89 ], [ 1, %85 ], [ 1, %103 ], [ 0, %43 ]
store i32 %98, i32* @term_getc.queuelen
br label %111
99: ; preds = %81
%100 = add i32 %76, 32700
br label %111
101: ; preds = %85
%102 = add i32 %76, 32715
br label %111
103: ; preds = %89
%104 = lshr i32 14630975, %75
%105 = and i32 %104, 1
%106 = icmp eq i32 %105, 0
br i1 %106, label %96, label %107
107: ; preds = %103
%108 = sext i32 %75 to i64
%109 = getelementptr inbounds [24 x i32], [24 x i32]* @switch.table.term_getc, i64 0, i64 %108
%110 = load i32, i32* %109
br label %111
111: ; preds = %107, %101, %99, %88, %74, %77, %91, %92, %93, %51, %96, %94, %3
%112 = phi i32 [ %4, %3 ], [ %97, %96 ], [ %95, %94 ], [ 13, %51 ], [ 32769, %88 ], [ 32775, %74 ], [ 32776, %77 ], [ 32770, %91 ], [ 32772, %92 ], [ 32771, %93 ], [ %100, %99 ], [ %102, %101 ], [ %110, %107 ]
ret i32 %112
}