#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*/ printf(char *);
void drawMap(char **map, int map_w, int map_h, char this_player) {
  int x, y;
  printf("\033[19;0H");
  for (y = 0; y < map_h; y++) {
    for (x = 0; x < map_w; x++) {
      if (map[y][x] == this_player)
        printf("\e[1m");
      if (map[y][x] == 0)
        printf("\e[2m.\e[22m");
      else if (map[y][x] == 1) {
        printf("\e[31m1\e[39m\e[21m");
      } else if (map[y][x] == 3) {
        printf("\e[34m3\e[39m\e[21m");
      } else if (map[y][x] == 2) {
        printf("\e[31m2\e[39m\e[21m");
      } else if (map[y][x] == 4) {
        printf("\e[34m4\e[39m\e[21m");
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<drawMap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    12a7 <drawMap+0x197>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    128d <drawMap+0x17d>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    1185 <drawMap+0x75>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11b3 <drawMap+0xa3>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
jmp    127a <drawMap+0x16a>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x1,%eax
jne    11e1 <drawMap+0xd1>
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
jmp    1275 <drawMap+0x165>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3,%eax
jne    120f <drawMap+0xff>
lea    0xe24(%rip),%rdi
call   1030 <printf@plt>
jmp    1270 <drawMap+0x160>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2,%eax
jne    123d <drawMap+0x12d>
lea    0xe07(%rip),%rdi
call   1030 <printf@plt>
jmp    126b <drawMap+0x15b>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x4,%eax
jne    1266 <drawMap+0x156>
lea    0xdea(%rip),%rdi
call   1030 <printf@plt>
jmp    126b <drawMap+0x15b>
jmp    1270 <drawMap+0x160>
jmp    1275 <drawMap+0x165>
jmp    127a <drawMap+0x16a>
jmp    127f <drawMap+0x16f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114d <drawMap+0x3d>
lea    0xdc8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <drawMap+0x2a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawMap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r13d
mov    %edx,%r15d
mov    %esi,0xc(%rsp)
mov    %rdi,%rbp
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
test   %r15d,%r15d
jle    11e4 <drawMap+0xc4>
mov    %r15d,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%ebx
xor    %r14d,%r14d
lea    0xef6(%rip),%r12
jmp    1185 <drawMap+0x65>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     11e4 <drawMap+0xc4>
cmpl   $0x0,0xc(%rsp)
jle    1170 <drawMap+0x50>
xor    %r15d,%r15d
jmp    11a9 <drawMap+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    %r15,%rbx
je     1170 <drawMap+0x50>
mov    0x0(%rbp,%r14,8),%rax
movzbl (%rax,%r15,1),%eax
cmp    %r13b,%al
jne    11ce <drawMap+0xae>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
mov    0x0(%rbp,%r14,8),%rax
movzbl (%rax,%r15,1),%eax
cmp    $0x4,%al
ja     11a0 <drawMap+0x80>
movsbq %al,%rax
movslq (%r12,%rax,4),%rdi
add    %r12,%rdi
call   1040 <printf@plt>
jmp    11a0 <drawMap+0x80>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"\1B[19;0H\00"
@.str.1 = [5 x i8] c"\1B[1m\00"
@.str.2 = [11 x i8] c"\1B[2m.\1B[22m\00"
@.str.3 = [17 x i8] c"\1B[31m1\1B[39m\1B[21m\00"
@.str.4 = [17 x i8] c"\1B[34m3\1B[39m\1B[21m\00"
@.str.5 = [17 x i8] c"\1B[31m2\1B[39m\1B[21m\00"
@.str.6 = [17 x i8] c"\1B[34m4\1B[39m\1B[21m\00"
@.str.7 = [2 x i8] c"\0A\00"
define void @drawMap(i8** %0, i32 %1, i32 %2, i8 signext %3) {
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i8** %0, i8*** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8 %3, i8* %8
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %10
br label %12
12: ; preds = %117, %4
%13 = load i32, i32* %10
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %120
16: ; preds = %12
store i32 0, i32* %9
br label %17
17: ; preds = %112, %16
%18 = load i32, i32* %9
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %115
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %10
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = load i8, i8* %8
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %31, %33
br i1 %34, label %35, label %37
35: ; preds = %21
%36 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %21
%38 = load i8**, i8*** %5
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %37
%50 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %111
51: ; preds = %37
%52 = load i8**, i8*** %5
%53 = load i32, i32* %10
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %52, i64 %54
%56 = load i8*, i8** %55
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 1
br i1 %62, label %63, label %65
63: ; preds = %51
%64 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %110
65: ; preds = %51
%66 = load i8**, i8*** %5
%67 = load i32, i32* %10
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = load i32, i32* %9
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %70, i64 %72
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 3
br i1 %76, label %77, label %79
77: ; preds = %65
%78 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %109
79: ; preds = %65
%80 = load i8**, i8*** %5
%81 = load i32, i32* %10
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %80, i64 %82
%84 = load i8*, i8** %83
%85 = load i32, i32* %9
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8, i8* %84, i64 %86
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp eq i32 %89, 2
br i1 %90, label %91, label %93
91: ; preds = %79
%92 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %108
93: ; preds = %79
%94 = load i8**, i8*** %5
%95 = load i32, i32* %10
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8*, i8** %94, i64 %96
%98 = load i8*, i8** %97
%99 = load i32, i32* %9
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %98, i64 %100
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 4
br i1 %104, label %105, label %107
105: ; preds = %93
%106 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %107
107: ; preds = %105, %93
br label %108
108: ; preds = %107, %91
br label %109
109: ; preds = %108, %77
br label %110
110: ; preds = %109, %63
br label %111
111: ; preds = %110, %49
br label %112
112: ; preds = %111
%113 = load i32, i32* %9
%114 = add nsw i32 %113, 1
store i32 %114, i32* %9
br label %17
115: ; preds = %17
%116 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %117
117: ; preds = %115
%118 = load i32, i32* %10
%119 = add nsw i32 %118, 1
store i32 %119, i32* %10
br label %12
120: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"\1B[19;0H\00"
@.str.1 = [5 x i8] c"\1B[1m\00"
@.str.2 = [11 x i8] c"\1B[2m.\1B[22m\00"
@.str.3 = [17 x i8] c"\1B[31m1\1B[39m\1B[21m\00"
@.str.4 = [17 x i8] c"\1B[34m3\1B[39m\1B[21m\00"
@.str.5 = [17 x i8] c"\1B[31m2\1B[39m\1B[21m\00"
@.str.6 = [17 x i8] c"\1B[34m4\1B[39m\1B[21m\00"
@reltable.drawMap = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.2 to i64), i64 ptrtoint ([5 x i32]* @reltable.drawMap to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.3 to i64), i64 ptrtoint ([5 x i32]* @reltable.drawMap to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.5 to i64), i64 ptrtoint ([5 x i32]* @reltable.drawMap to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.4 to i64), i64 ptrtoint ([5 x i32]* @reltable.drawMap to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.6 to i64), i64 ptrtoint ([5 x i32]* @reltable.drawMap to i64)) to i32)]
define void @drawMap(i8** nocapture %0, i32 %1, i32 %2, i8 signext %3) {
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %41
7: ; preds = %4
%8 = icmp sgt i32 %1, 0
%9 = zext i32 %2 to i64
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %7, %37
%12 = phi i64 [ 0, %7 ], [ %39, %37 ]
br i1 %8, label %13, label %37
13: ; preds = %11
%14 = getelementptr inbounds i8*, i8** %0, i64 %12
br label %15
15: ; preds = %13, %34
%16 = phi i64 [ 0, %13 ], [ %35, %34 ]
%17 = load i8*, i8** %14
%18 = getelementptr inbounds i8, i8* %17, i64 %16
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, %3
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%23 = load i8*, i8** %14
%24 = getelementptr inbounds i8, i8* %23, i64 %16
%25 = load i8, i8* %24
br label %26
26: ; preds = %21, %15
%27 = phi i8 [ %25, %21 ], [ %19, %15 ]
%28 = icmp ult i8 %27, 5
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = sext i8 %27 to i64
%31 = shl i64 %30, 2
%32 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.drawMap to i8*), i64 %31)
%33 = tail call i32 @printf(i8* dereferenceable(1) %32)
br label %34
34: ; preds = %26, %29
%35 = add nuw nsw i64 %16, 1
%36 = icmp eq i64 %35, %10
br i1 %36, label %37, label %15
37: ; preds = %34, %11
%38 = tail call i32 @putchar(i32 10)
%39 = add nuw nsw i64 %12, 1
%40 = icmp eq i64 %39, %9
br i1 %40, label %41, label %11
41: ; preds = %37, %4
ret void
}