#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 /*<<< orphan*/ clearscreen();
int /*<<< orphan*/ colorize(char, int);
int /*<<< orphan*/ printf(char *, ...);
void drawGrid(char grid[6][6], unsigned long int score) {
  int i = 0;
  int k = 0;
  int key = 1;
  clearscreen();
  printf("\n\n\t      ASCII MATCH");
  printf("\n\n\tSCORE: %ld", score);
  printf("\n\n\t   ");
  for (i = 0; i < 6; i++) {
    printf("%2d ", i + 1);
  }
  printf("\n\t   ");
  for (i = 0; i < 6; i++) {
    printf("---");
  }
  printf("\n");
  for (k = 0; k < 6; k++) {
    printf("\t%2d|", k + 1);
    for (i = 0; i < 6; i++) {
      printf(" ");
      switch ((int)grid[k][i]) {
      case 35:
        key = 1;
        break;
      case 35 + 1:
        key = 2;
        break;
      case 35 + 2:
        key = 3;
        break;
      case 35 + 3:
        key = 4;
        break;
      }
      colorize(grid[k][i], key);
      printf(" ");
    }
    printf("\n\n");
  }
}


x86 assembly (clang, -O0):
<drawGrid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <clearscreen@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    11bd <drawGrid+0x8d>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1191 <drawGrid+0x61>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    11f8 <drawGrid+0xc8>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d2 <drawGrid+0xa2>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x6,-0x18(%rbp)
jge    130c <drawGrid+0x1dc>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    12f0 <drawGrid+0x1c0>
lea    0xdf5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
lea    (%rcx,%rcx,2),%rcx
lea    (%rax,%rcx,2),%rcx
movslq -0x14(%rbp),%rax
movsbl (%rax,%rcx,1),%eax
add    $0xffffffdd,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     12b3 <drawGrid+0x183>
mov    -0x28(%rbp),%rax
lea    0xd81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x1c(%rbp)
jmp    12b3 <drawGrid+0x183>
movl   $0x2,-0x1c(%rbp)
jmp    12b3 <drawGrid+0x183>
movl   $0x3,-0x1c(%rbp)
jmp    12b3 <drawGrid+0x183>
movl   $0x4,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x6,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x1c(%rbp),%esi
movsbl %al,%edi
call   1050 <colorize@plt>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1232 <drawGrid+0x102>
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    120d <drawGrid+0xdd>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawGrid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r12
xor    %eax,%eax
call   1050 <clearscreen@plt>
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe98(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe8e(%rip),%rbx
mov    $0x1,%r13d
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe21(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe1e(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x5,%r14d
lea    0xdd5(%rip),%r15
mov    $0x1,%ebx
nopl   0x0(%rax)
lea    0xdbc(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
movsbl -0x5(%r12,%r14,1),%edi
lea    -0x23(%rdi),%eax
lea    -0x22(%rdi),%ebp
cmp    $0x4,%eax
cmovae %ebx,%ebp
mov    %ebp,%esi
call   1070 <colorize@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
movsbl -0x4(%r12,%r14,1),%edi
lea    -0x23(%rdi),%eax
lea    -0x22(%rdi),%ebx
cmp    $0x4,%eax
cmovae %ebp,%ebx
mov    %ebx,%esi
call   1070 <colorize@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
movsbl -0x3(%r12,%r14,1),%edi
lea    -0x23(%rdi),%eax
lea    -0x22(%rdi),%ebp
cmp    $0x4,%eax
cmovae %ebx,%ebp
mov    %ebp,%esi
call   1070 <colorize@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
movsbl -0x2(%r12,%r14,1),%edi
lea    -0x23(%rdi),%eax
lea    -0x22(%rdi),%ebx
cmp    $0x4,%eax
cmovae %ebp,%ebx
mov    %ebx,%esi
call   1070 <colorize@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
movsbl -0x1(%r12,%r14,1),%edi
lea    -0x23(%rdi),%eax
lea    -0x22(%rdi),%ebp
cmp    $0x4,%eax
cmovae %ebx,%ebp
mov    %ebp,%esi
call   1070 <colorize@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
movsbl (%r12,%r14,1),%edi
lea    -0x23(%rdi),%eax
lea    -0x22(%rdi),%ebx
cmp    $0x4,%eax
cmovae %ebp,%ebx
mov    %ebx,%esi
call   1070 <colorize@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
add    $0x6,%r14
add    $0x1,%r13d
cmp    $0x29,%r14
jne    1270 <drawGrid+0x120>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0A\0A\09 ASCII MATCH\00"
@.str.1 = [14 x i8] c"\0A\0A\09SCORE: %ld\00"
@.str.2 = [7 x i8] c"\0A\0A\09 \00"
@.str.3 = [5 x i8] c"%2d \00"
@.str.4 = [6 x i8] c"\0A\09 \00"
@.str.5 = [4 x i8] c"---\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [6 x i8] c"\09%2d|\00"
@.str.8 = [2 x i8] c" \00"
@.str.9 = [3 x i8] c"\0A\0A\00"
define void @drawGrid([6 x i8]* %0, i64 %1) {
%3 = alloca [6 x i8]*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store [6 x i8]* %0, [6 x i8]** %3
store i64 %1, i64* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 1, i32* %7
%8 = call i32 (...) @clearscreen()
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = load i64, i64* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %13
13: ; preds = %20, %2
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 6
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %16
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %13
23: ; preds = %13
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %5
br label %25
25: ; preds = %30, %23
%26 = load i32, i32* %5
%27 = icmp slt i32 %26, 6
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %30
30: ; preds = %28
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %25
33: ; preds = %25
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %6
br label %35
35: ; preds = %77, %33
%36 = load i32, i32* %6
%37 = icmp slt i32 %36, 6
br i1 %37, label %38, label %80
38: ; preds = %35
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %40)
store i32 0, i32* %5
br label %42
42: ; preds = %72, %38
%43 = load i32, i32* %5
%44 = icmp slt i32 %43, 6
br i1 %44, label %45, label %75
45: ; preds = %42
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%47 = load [6 x i8]*, [6 x i8]** %3
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [6 x i8], [6 x i8]* %47, i64 %49
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [6 x i8], [6 x i8]* %50, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
switch i32 %55, label %60 [
i32 35, label %56
i32 36, label %57
i32 37, label %58
i32 38, label %59
]
56: ; preds = %45
store i32 1, i32* %7
br label %60
57: ; preds = %45
store i32 2, i32* %7
br label %60
58: ; preds = %45
store i32 3, i32* %7
br label %60
59: ; preds = %45
store i32 4, i32* %7
br label %60
60: ; preds = %45, %59, %58, %57, %56
%61 = load [6 x i8]*, [6 x i8]** %3
%62 = load i32, i32* %6
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [6 x i8], [6 x i8]* %61, i64 %63
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [6 x i8], [6 x i8]* %64, i64 0, i64 %66
%68 = load i8, i8* %67
%69 = load i32, i32* %7
%70 = call i32 @colorize(i8 signext %68, i32 %69)
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %72
72: ; preds = %60
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 1
store i32 %74, i32* %5
br label %42
75: ; preds = %42
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %77
77: ; preds = %75
%78 = load i32, i32* %6
%79 = add nsw i32 %78, 1
store i32 %79, i32* %6
br label %35
80: ; preds = %35
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0A\0A\09 ASCII MATCH\00"
@.str.1 = [14 x i8] c"\0A\0A\09SCORE: %ld\00"
@.str.2 = [7 x i8] c"\0A\0A\09 \00"
@.str.3 = [5 x i8] c"%2d \00"
@.str.4 = [6 x i8] c"\0A\09 \00"
@.str.5 = [4 x i8] c"---\00"
@.str.7 = [6 x i8] c"\09%2d|\00"
@str = [2 x i8] c"\0A\00"
define void @drawGrid([6 x i8]* nocapture %0, i64 %1) {
%3 = tail call i32 (...) @clearscreen()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i64 %1)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 1)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 2)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 3)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 5)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 6)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%20 = tail call i32 @putchar(i32 10)
br label %21
21: ; preds = %2, %21
%22 = phi i64 [ 0, %2 ], [ %24, %21 ]
%23 = phi i32 [ 1, %2 ], [ %84, %21 ]
%24 = add nuw nsw i64 %22, 1
%25 = trunc i64 %24 to i32
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %25)
%27 = tail call i32 @putchar(i32 32)
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %22, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = add nsw i32 %30, -35
%32 = icmp ult i32 %31, 4
%33 = add nsw i32 %30, -34
%34 = select i1 %32, i32 %33, i32 %23
%35 = tail call i32 @colorize(i8 signext %29, i32 %34)
%36 = tail call i32 @putchar(i32 32)
%37 = tail call i32 @putchar(i32 32)
%38 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %22, i64 1
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = add nsw i32 %40, -35
%42 = icmp ult i32 %41, 4
%43 = add nsw i32 %40, -34
%44 = select i1 %42, i32 %43, i32 %34
%45 = tail call i32 @colorize(i8 signext %39, i32 %44)
%46 = tail call i32 @putchar(i32 32)
%47 = tail call i32 @putchar(i32 32)
%48 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %22, i64 2
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = add nsw i32 %50, -35
%52 = icmp ult i32 %51, 4
%53 = add nsw i32 %50, -34
%54 = select i1 %52, i32 %53, i32 %44
%55 = tail call i32 @colorize(i8 signext %49, i32 %54)
%56 = tail call i32 @putchar(i32 32)
%57 = tail call i32 @putchar(i32 32)
%58 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %22, i64 3
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = add nsw i32 %60, -35
%62 = icmp ult i32 %61, 4
%63 = add nsw i32 %60, -34
%64 = select i1 %62, i32 %63, i32 %54
%65 = tail call i32 @colorize(i8 signext %59, i32 %64)
%66 = tail call i32 @putchar(i32 32)
%67 = tail call i32 @putchar(i32 32)
%68 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %22, i64 4
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = add nsw i32 %70, -35
%72 = icmp ult i32 %71, 4
%73 = add nsw i32 %70, -34
%74 = select i1 %72, i32 %73, i32 %64
%75 = tail call i32 @colorize(i8 signext %69, i32 %74)
%76 = tail call i32 @putchar(i32 32)
%77 = tail call i32 @putchar(i32 32)
%78 = getelementptr inbounds [6 x i8], [6 x i8]* %0, i64 %22, i64 5
%79 = load i8, i8* %78
%80 = sext i8 %79 to i32
%81 = add nsw i32 %80, -35
%82 = icmp ult i32 %81, 4
%83 = add nsw i32 %80, -34
%84 = select i1 %82, i32 %83, i32 %74
%85 = tail call i32 @colorize(i8 signext %79, i32 %84)
%86 = tail call i32 @putchar(i32 32)
%87 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%88 = icmp eq i64 %24, 6
br i1 %88, label %89, label %21
89: ; preds = %21
ret void
}