#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 */
int BUFSIZ;
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putfont(char, int, int);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char buffer[BUFSIZ];
  char *result;
  int i, color, newcolor = 0;
  int fore, back;
  printf("tile_data:\n");
  while (1) {
    result = fgets(buffer, BUFSIZ, stdin);
    if (result <= 0)
      break;
    i = 0;
    while (1) {
      if (buffer[i] == 27) {
        i++;
        if (buffer[i] == '[') {
          i++;
        }
        color = 0;
        while (1) {
          if ((buffer[i] == 'm') || (buffer[i] == ';')) {
            if (color == 0) {
              newcolor &= 0xbf;
            } else if (color == 1) {
              newcolor |= 0x40;
            } else if ((color >= 30) && (color <= 39)) {
              newcolor &= 0xc7;
              newcolor |= ((color - 30) & 0x7) << 3;
            } else if ((color >= 40) && (color <= 49)) {
              newcolor &= 0xf8;
              newcolor |= ((color - 40) & 0x7);
            }
            color = 0;
            if (buffer[i] == 'm') {
              printf("; Color=%02x\n", newcolor);
              break;
            }
            i++;
            continue;
          }
          color *= 10;
          color += buffer[i] - 0x30;
          i++;
        }
      } else {
        printf("; Color=%x\n", newcolor);
        if (newcolor == 0x47) {
          fore = 1;
          back = 3;
        } else if (newcolor == 0x4f) {
          fore = 2;
          back = 3;
        } else if (newcolor == 0x5f) {
          fore = 4;
          back = 3;
        } else if (newcolor == 0x7f) {
          fore = 5;
          back = 3;
        } else if (newcolor == 0x7) {
          fore = 0;
          back = 3;
        } else if (newcolor == 0x78) {
          fore = 5;
          back = 0;
        } else
          printf("; Unknown color %x!\n", newcolor);
        putfont(buffer[i], fore, back);
      }
      if (buffer[i] == '\n')
        break;
      i++;
    }
  }
  printf("tile_palette:\n");
  printf("\t.word $0        ; black    r=0 g=0 b=0\n");
  printf("\t.word $3def     ; d. grey  r=7d g=7d b=7d\n");
  printf("\t.word $3dff     ; red      r=ff g=7d b=7d\n");
  printf("\t.word $56b5     ; l. grey  r=aa g=aa b=aa\n");
  printf("\t.word $3ff      ; yellow   r=ff g=ff b=0\n");
  printf("\t.word $7fff     ; white    r=ff g=ff b=ff\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118c <main+0x5c>
mov    -0x48(%rbp),%rdi
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
mov    0x2e48(%rip),%rax
mov    (%rax),%edx
call   1050 <fgets@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
ja     11bb <main+0x8b>
jmp    147c <main+0x34c>
movl   $0x0,-0x2c(%rbp)
jmp    11c7 <main+0x97>
mov    -0x48(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x1b,%eax
jne    134d <main+0x21d>
mov    -0x48(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x2c(%rbp)
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5b,%eax
jne    1203 <main+0xd3>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
jmp    120f <main+0xdf>
mov    -0x48(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6d,%eax
je     1239 <main+0x109>
mov    -0x48(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3b,%eax
jne    131e <main+0x1ee>
cmpl   $0x0,-0x30(%rbp)
jne    1253 <main+0x123>
mov    -0x34(%rbp),%eax
and    $0xbf,%eax
mov    %eax,-0x34(%rbp)
jmp    12de <main+0x1ae>
cmpl   $0x1,-0x30(%rbp)
jne    126b <main+0x13b>
mov    -0x34(%rbp),%eax
or     $0x40,%eax
mov    %eax,-0x34(%rbp)
jmp    12d9 <main+0x1a9>
cmpl   $0x1e,-0x30(%rbp)
jl     12a1 <main+0x171>
cmpl   $0x27,-0x30(%rbp)
jg     12a1 <main+0x171>
mov    -0x34(%rbp),%eax
and    $0xc7,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
sub    $0x1e,%eax
and    $0x7,%eax
shl    $0x3,%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    12d4 <main+0x1a4>
cmpl   $0x28,-0x30(%rbp)
jl     12cf <main+0x19f>
cmpl   $0x31,-0x30(%rbp)
jg     12cf <main+0x19f>
mov    -0x34(%rbp),%eax
and    $0xf8,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%eax
sub    $0x28,%eax
and    $0x7,%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    12d4 <main+0x1a4>
jmp    12d9 <main+0x1a9>
jmp    12de <main+0x1ae>
mov    -0x48(%rbp),%rax
movl   $0x0,-0x30(%rbp)
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6d,%eax
jne    1310 <main+0x1e0>
mov    -0x34(%rbp),%esi
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1348 <main+0x218>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    120a <main+0xda>
mov    -0x48(%rbp),%rax
imul   $0xa,-0x30(%rbp),%ecx
mov    %ecx,-0x30(%rbp)
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    120a <main+0xda>
jmp    144f <main+0x31f>
mov    -0x34(%rbp),%esi
lea    0xcc3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x47,-0x34(%rbp)
jne    137b <main+0x24b>
movl   $0x1,-0x38(%rbp)
movl   $0x3,-0x3c(%rbp)
jmp    1436 <main+0x306>
cmpl   $0x4f,-0x34(%rbp)
jne    1398 <main+0x268>
movl   $0x2,-0x38(%rbp)
movl   $0x3,-0x3c(%rbp)
jmp    1431 <main+0x301>
cmpl   $0x5f,-0x34(%rbp)
jne    13b5 <main+0x285>
movl   $0x4,-0x38(%rbp)
movl   $0x3,-0x3c(%rbp)
jmp    142c <main+0x2fc>
cmpl   $0x7f,-0x34(%rbp)
jne    13d2 <main+0x2a2>
movl   $0x5,-0x38(%rbp)
movl   $0x3,-0x3c(%rbp)
jmp    1427 <main+0x2f7>
cmpl   $0x7,-0x34(%rbp)
jne    13ef <main+0x2bf>
movl   $0x0,-0x38(%rbp)
movl   $0x3,-0x3c(%rbp)
jmp    1422 <main+0x2f2>
cmpl   $0x78,-0x34(%rbp)
jne    140c <main+0x2dc>
movl   $0x5,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
jmp    141d <main+0x2ed>
mov    -0x34(%rbp),%esi
lea    0xc10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1422 <main+0x2f2>
jmp    1427 <main+0x2f7>
jmp    142c <main+0x2fc>
jmp    1431 <main+0x301>
jmp    1436 <main+0x306>
mov    -0x48(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x38(%rbp),%esi
mov    -0x3c(%rbp),%edx
movsbl %al,%edi
call   1040 <putfont@plt>
mov    -0x48(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1469 <main+0x339>
jmp    1477 <main+0x347>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c2 <main+0x92>
jmp    1187 <main+0x57>
lea    0xbb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xbb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xbd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xbf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e83(%rip),%rbx
mov    (%rbx),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%esi
mov    0x2e6b(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
call   1060 <fgets@plt>
test   %rax,%rax
je     138b <main+0x24b>
movabs $0x100000000,%r15
xor    %r14d,%r14d
xor    %ebx,%ebx
nop
movslq %r14d,%r12
cmpb   $0x1b,0x0(%r13,%r12,1)
jne    1280 <main+0x140>
lea    0x1(%r12),%rax
lea    0x2(%r12),%r14d
cmpb   $0x5b,0x1(%r13,%r12,1)
cmovne %eax,%r14d
jmp    11db <main+0x9b>
cs nopw 0x0(%rax,%rax,1)
nop
or     $0x40,%ebx
cmp    $0x6d,%al
je     12c0 <main+0x180>
movslq %r14d,%rdx
mov    %rdx,%r12
shl    $0x20,%r12
lea    0x1(%rdx),%r14d
add    %r13,%rdx
xor    %ecx,%ecx
xchg   %ax,%ax
movsbl (%rdx),%eax
cmp    $0x6d,%eax
je     1220 <main+0xe0>
cmp    $0x3b,%al
je     1220 <main+0xe0>
lea    (%rcx,%rcx,4),%ecx
lea    (%rax,%rcx,2),%ecx
add    $0xffffffd0,%ecx
add    %r15,%r12
add    $0x1,%r14d
add    $0x1,%rdx
jmp    11f0 <main+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x1,%ecx
je     11d0 <main+0x90>
test   %ecx,%ecx
jne    1240 <main+0x100>
and    $0xbf,%ebx
jmp    11d3 <main+0x93>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x1e(%rcx),%edx
cmp    $0x9,%edx
ja     125f <main+0x11f>
and    $0xc7,%ebx
lea    0x10(,%rcx,8),%ecx
and    $0x38,%ecx
or     %ecx,%ebx
jmp    11d3 <main+0x93>
lea    -0x28(%rcx),%edx
cmp    $0x9,%edx
ja     11d3 <main+0x93>
and    $0xf8,%ebx
and    $0x7,%ecx
or     %ebx,%ecx
mov    %ecx,%ebx
jmp    11d3 <main+0x93>
nopl   (%rax)
lea    0xd87(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x5e,%ebx
jg     12e0 <main+0x1a0>
cmp    $0x7,%ebx
je     12fb <main+0x1bb>
cmp    $0x47,%ebx
je     1304 <main+0x1c4>
cmp    $0x4f,%ebx
jne    1325 <main+0x1e5>
mov    $0x2,%esi
mov    $0x3,%edx
jmp    1340 <main+0x200>
nopw   0x0(%rax,%rax,1)
lea    0xd39(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
sar    $0x20,%r12
jmp    1356 <main+0x216>
nopl   0x0(%rax)
cmp    $0x5f,%ebx
je     1310 <main+0x1d0>
cmp    $0x78,%ebx
je     131c <main+0x1dc>
cmp    $0x7f,%ebx
jne    1325 <main+0x1e5>
mov    $0x5,%esi
mov    $0x3,%edx
jmp    1340 <main+0x200>
xor    %esi,%esi
mov    $0x3,%edx
jmp    1340 <main+0x200>
mov    $0x1,%esi
mov    $0x3,%edx
jmp    1340 <main+0x200>
mov    $0x4,%esi
mov    $0x3,%edx
jmp    1340 <main+0x200>
xor    %edx,%edx
mov    $0x5,%esi
jmp    1340 <main+0x200>
lea    0xcee(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
nopl   0x0(%rax,%rax,1)
movsbl 0x0(%r13,%r12,1),%edi
mov    %esi,-0x30(%rbp)
mov    %edx,-0x2c(%rbp)
call   1050 <putfont@plt>
lea    0x1(%r12),%r14d
cmpb   $0xa,0x0(%r13,%r12,1)
jne    11a0 <main+0x60>
mov    0x2c6f(%rip),%rax
mov    (%rax),%esi
mov    0x2c76(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
call   1060 <fgets@plt>
mov    $0x0,%r14d
test   %rax,%rax
jne    11a0 <main+0x60>
lea    0xca8(%rip),%rdi
call   1030 <puts@plt>
lea    0xcaa(%rip),%rdi
call   1030 <puts@plt>
lea    0xcc6(%rip),%rdi
call   1030 <puts@plt>
lea    0xce5(%rip),%rdi
call   1030 <puts@plt>
lea    0xd04(%rip),%rdi
call   1030 <puts@plt>
lea    0xd23(%rip),%rdi
call   1030 <puts@plt>
lea    0xd41(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [12 x i8] c"tile_data:\0A\00"
@stdin = global i32 0
@.str.1 = [14 x i8] c"; Color=%02x\0A\00"
@.str.2 = [12 x i8] c"; Color=%x\0A\00"
@.str.3 = [21 x i8] c"; Unknown color %x!\0A\00"
@.str.4 = [15 x i8] c"tile_palette:\0A\00"
@.str.5 = [41 x i8] c"\09.word $0 ; black r=0 g=0 b=0\0A\00"
@.str.6 = [44 x i8] c"\09.word $3def ; d. grey r=7d g=7d b=7d\0A\00"
@.str.7 = [44 x i8] c"\09.word $3dff ; red r=ff g=7d b=7d\0A\00"
@.str.8 = [44 x i8] c"\09.word $56b5 ; l. grey r=aa g=aa b=aa\0A\00"
@.str.9 = [43 x i8] c"\09.word $3ff ; yellow r=ff g=ff b=0\0A\00"
@.str.10 = [44 x i8] c"\09.word $7fff ; white r=ff g=ff b=ff\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* @BUFSIZ
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %6
%17 = alloca i8, i64 %15
store i64 %15, i64* %7
store i32 0, i32* %11
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %188, %2
br label %20
20: ; preds = %19
%21 = load i32, i32* @BUFSIZ
%22 = load i32, i32* @stdin
%23 = call i8* @fgets(i8* %17, i32 %21, i32 %22)
store i8* %23, i8** %8
%24 = load i8*, i8** %8
%25 = icmp ule i8* %24, null
br i1 %25, label %26, label %27
26: ; preds = %20
br label %189
27: ; preds = %20
store i32 0, i32* %9
br label %28
28: ; preds = %185, %27
br label %29
29: ; preds = %28
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %17, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 27
br i1 %35, label %36, label %135
36: ; preds = %29
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %17, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 91
br i1 %44, label %45, label %48
45: ; preds = %36
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %48
48: ; preds = %45, %36
store i32 0, i32* %10
br label %49
49: ; preds = %121, %118, %48
br label %50
50: ; preds = %49
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %17, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 109
br i1 %56, label %64, label %57
57: ; preds = %50
%58 = load i32, i32* %9
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %17, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 59
br i1 %63, label %64, label %121
64: ; preds = %57, %50
%65 = load i32, i32* %10
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %64
%68 = load i32, i32* %11
%69 = and i32 %68, 191
store i32 %69, i32* %11
br label %108
70: ; preds = %64
%71 = load i32, i32* %10
%72 = icmp eq i32 %71, 1
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i32, i32* %11
%75 = or i32 %74, 64
store i32 %75, i32* %11
br label %107
76: ; preds = %70
%77 = load i32, i32* %10
%78 = icmp sge i32 %77, 30
br i1 %78, label %79, label %91
79: ; preds = %76
%80 = load i32, i32* %10
%81 = icmp sle i32 %80, 39
br i1 %81, label %82, label %91
82: ; preds = %79
%83 = load i32, i32* %11
%84 = and i32 %83, 199
store i32 %84, i32* %11
%85 = load i32, i32* %10
%86 = sub nsw i32 %85, 30
%87 = and i32 %86, 7
%88 = shl i32 %87, 3
%89 = load i32, i32* %11
%90 = or i32 %89, %88
store i32 %90, i32* %11
br label %106
91: ; preds = %79, %76
%92 = load i32, i32* %10
%93 = icmp sge i32 %92, 40
br i1 %93, label %94, label %105
94: ; preds = %91
%95 = load i32, i32* %10
%96 = icmp sle i32 %95, 49
br i1 %96, label %97, label %105
97: ; preds = %94
%98 = load i32, i32* %11
%99 = and i32 %98, 248
store i32 %99, i32* %11
%100 = load i32, i32* %10
%101 = sub nsw i32 %100, 40
%102 = and i32 %101, 7
%103 = load i32, i32* %11
%104 = or i32 %103, %102
store i32 %104, i32* %11
br label %105
105: ; preds = %97, %94, %91
br label %106
106: ; preds = %105, %82
br label %107
107: ; preds = %106, %73
br label %108
108: ; preds = %107, %67
store i32 0, i32* %10
%109 = load i32, i32* %9
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %17, i64 %110
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 109
br i1 %114, label %115, label %118
115: ; preds = %108
%116 = load i32, i32* %11
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %116)
br label %134
118: ; preds = %108
%119 = load i32, i32* %9
%120 = add nsw i32 %119, 1
store i32 %120, i32* %9
br label %49
121: ; preds = %57
%122 = load i32, i32* %10
%123 = mul nsw i32 %122, 10
store i32 %123, i32* %10
%124 = load i32, i32* %9
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i8, i8* %17, i64 %125
%127 = load i8, i8* %126
%128 = sext i8 %127 to i32
%129 = sub nsw i32 %128, 48
%130 = load i32, i32* %10
%131 = add nsw i32 %130, %129
store i32 %131, i32* %10
%132 = load i32, i32* %9
%133 = add nsw i32 %132, 1
store i32 %133, i32* %9
br label %49
134: ; preds = %115
br label %177
135: ; preds = %29
%136 = load i32, i32* %11
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %136)
%138 = load i32, i32* %11
%139 = icmp eq i32 %138, 71
br i1 %139, label %140, label %141
140: ; preds = %135
store i32 1, i32* %12
store i32 3, i32* %13
br label %169
141: ; preds = %135
%142 = load i32, i32* %11
%143 = icmp eq i32 %142, 79
br i1 %143, label %144, label %145
144: ; preds = %141
store i32 2, i32* %12
store i32 3, i32* %13
br label %168
145: ; preds = %141
%146 = load i32, i32* %11
%147 = icmp eq i32 %146, 95
br i1 %147, label %148, label %149
148: ; preds = %145
store i32 4, i32* %12
store i32 3, i32* %13
br label %167
149: ; preds = %145
%150 = load i32, i32* %11
%151 = icmp eq i32 %150, 127
br i1 %151, label %152, label %153
152: ; preds = %149
store i32 5, i32* %12
store i32 3, i32* %13
br label %166
153: ; preds = %149
%154 = load i32, i32* %11
%155 = icmp eq i32 %154, 7
br i1 %155, label %156, label %157
156: ; preds = %153
store i32 0, i32* %12
store i32 3, i32* %13
br label %165
157: ; preds = %153
%158 = load i32, i32* %11
%159 = icmp eq i32 %158, 120
br i1 %159, label %160, label %161
160: ; preds = %157
store i32 5, i32* %12
store i32 0, i32* %13
br label %164
161: ; preds = %157
%162 = load i32, i32* %11
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %162)
br label %164
164: ; preds = %161, %160
br label %165
165: ; preds = %164, %156
br label %166
166: ; preds = %165, %152
br label %167
167: ; preds = %166, %148
br label %168
168: ; preds = %167, %144
br label %169
169: ; preds = %168, %140
%170 = load i32, i32* %9
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds i8, i8* %17, i64 %171
%173 = load i8, i8* %172
%174 = load i32, i32* %12
%175 = load i32, i32* %13
%176 = call i32 @putfont(i8 signext %173, i32 %174, i32 %175)
br label %177
177: ; preds = %169, %134
%178 = load i32, i32* %9
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds i8, i8* %17, i64 %179
%181 = load i8, i8* %180
%182 = sext i8 %181 to i32
%183 = icmp eq i32 %182, 10
br i1 %183, label %184, label %185
184: ; preds = %177
br label %188
185: ; preds = %177
%186 = load i32, i32* %9
%187 = add nsw i32 %186, 1
store i32 %187, i32* %9
br label %28
188: ; preds = %184
br label %19
189: ; preds = %26
%190 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%192 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0))
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
%194 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0))
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0))
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %3
%197 = load i8*, i8** %6
%198 = load i32, i32* %3
ret i32 %198
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@stdin = global i32 0
@.str.1 = [14 x i8] c"; Color=%02x\0A\00"
@.str.2 = [12 x i8] c"; Color=%x\0A\00"
@.str.3 = [21 x i8] c"; Unknown color %x!\0A\00"
@str = [11 x i8] c"tile_data:\00"
@str.11 = [14 x i8] c"tile_palette:\00"
@str.12 = [40 x i8] c"\09.word $0 ; black r=0 g=0 b=0\00"
@str.13 = [43 x i8] c"\09.word $3def ; d. grey r=7d g=7d b=7d\00"
@str.14 = [43 x i8] c"\09.word $3dff ; red r=ff g=7d b=7d\00"
@str.15 = [43 x i8] c"\09.word $56b5 ; l. grey r=aa g=aa b=aa\00"
@str.16 = [42 x i8] c"\09.word $3ff ; yellow r=ff g=ff b=0\00"
@str.17 = [43 x i8] c"\09.word $7fff ; white r=ff g=ff b=ff\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @BUFSIZ
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%7 = load i32, i32* @BUFSIZ
%8 = load i32, i32* @stdin
%9 = call i8* @fgets(i8* %5, i32 %7, i32 %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %104, label %16
11: ; preds = %93
%12 = load i32, i32* @BUFSIZ
%13 = load i32, i32* @stdin
%14 = call i8* @fgets(i8* %5, i32 %12, i32 %13)
%15 = icmp eq i8* %14, null
br i1 %15, label %104, label %102
16: ; preds = %2, %102
%17 = phi i32 [ %103, %102 ], [ 0, %2 ]
%18 = phi i32 [ %96, %102 ], [ 0, %2 ]
%19 = phi i32 [ %97, %102 ], [ undef, %2 ]
%20 = phi i32 [ %98, %102 ], [ undef, %2 ]
%21 = sext i32 %17 to i64
%22 = getelementptr inbounds i8, i8* %5, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 27
br i1 %24, label %25, label %78
25: ; preds = %16
%26 = add nsw i32 %17, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %5, i64 %27
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 91
%31 = add nsw i32 %17, 2
%32 = select i1 %30, i32 %31, i32 %26
br label %33
33: ; preds = %64, %25
%34 = phi i32 [ %67, %64 ], [ %32, %25 ]
%35 = phi i32 [ %65, %64 ], [ %18, %25 ]
%36 = sext i32 %34 to i64
br label %37
37: ; preds = %33, %72
%38 = phi i64 [ %36, %33 ], [ %77, %72 ]
%39 = phi i32 [ 0, %33 ], [ %76, %72 ]
%40 = getelementptr inbounds i8, i8* %5, i64 %38
%41 = load i8, i8* %40
switch i8 %41, label %72 [
i8 109, label %42
i8 59, label %42
]
42: ; preds = %37, %37
%43 = trunc i64 %38 to i32
switch i32 %39, label %48 [
i32 0, label %44
i32 1, label %46
]
44: ; preds = %42
%45 = and i32 %35, 191
br label %64
46: ; preds = %42
%47 = or i32 %35, 64
br label %64
48: ; preds = %42
%49 = add i32 %39, -30
%50 = icmp ult i32 %49, 10
br i1 %50, label %51, label %57
51: ; preds = %48
%52 = and i32 %35, 199
%53 = shl nuw nsw i32 %39, 3
%54 = add nuw nsw i32 %53, 16
%55 = and i32 %54, 56
%56 = or i32 %55, %52
br label %64
57: ; preds = %48
%58 = add i32 %39, -40
%59 = icmp ult i32 %58, 10
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = and i32 %35, 248
%62 = and i32 %39, 7
%63 = or i32 %61, %62
br label %64
64: ; preds = %46, %57, %60, %51, %44
%65 = phi i32 [ %45, %44 ], [ %47, %46 ], [ %56, %51 ], [ %63, %60 ], [ %35, %57 ]
%66 = icmp eq i8 %41, 109
%67 = add nsw i32 %43, 1
br i1 %66, label %68, label %33
68: ; preds = %64
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %65)
%70 = shl i64 %38, 32
%71 = ashr exact i64 %70, 32
br label %93
72: ; preds = %37
%73 = sext i8 %41 to i32
%74 = mul nsw i32 %39, 10
%75 = add i32 %74, -48
%76 = add i32 %75, %73
%77 = add i64 %38, 1
br label %37
78: ; preds = %16
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %18)
switch i32 %18, label %85 [
i32 71, label %87
i32 79, label %80
i32 95, label %81
i32 127, label %82
i32 7, label %83
i32 120, label %84
]
80: ; preds = %78
br label %87
81: ; preds = %78
br label %87
82: ; preds = %78
br label %87
83: ; preds = %78
br label %87
84: ; preds = %78
br label %87
85: ; preds = %78
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %18)
br label %87
87: ; preds = %78, %80, %82, %84, %85, %83, %81
%88 = phi i32 [ 2, %80 ], [ 4, %81 ], [ 5, %82 ], [ 0, %83 ], [ 5, %84 ], [ %19, %85 ], [ 1, %78 ]
%89 = phi i32 [ 3, %80 ], [ 3, %81 ], [ 3, %82 ], [ 3, %83 ], [ 0, %84 ], [ %20, %85 ], [ 3, %78 ]
%90 = load i8, i8* %22
%91 = call i32 @putfont(i8 signext %90, i32 %88, i32 %89)
%92 = add nsw i32 %17, 1
br label %93
93: ; preds = %87, %68
%94 = phi i32 [ %92, %87 ], [ %67, %68 ]
%95 = phi i64 [ %21, %87 ], [ %71, %68 ]
%96 = phi i32 [ %18, %87 ], [ %65, %68 ]
%97 = phi i32 [ %88, %87 ], [ %19, %68 ]
%98 = phi i32 [ %89, %87 ], [ %20, %68 ]
%99 = getelementptr inbounds i8, i8* %5, i64 %95
%100 = load i8, i8* %99
%101 = icmp eq i8 %100, 10
br i1 %101, label %11, label %102
102: ; preds = %93, %11
%103 = phi i32 [ %94, %93 ], [ 0, %11 ]
br label %16
104: ; preds = %11, %2
%105 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.11, i64 0, i64 0))
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.12, i64 0, i64 0))
%107 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.13, i64 0, i64 0))
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.14, i64 0, i64 0))
%109 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.15, i64 0, i64 0))
%110 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.16, i64 0, i64 0))
%111 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.17, i64 0, i64 0))
ret i32 0
}