#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 printGameBoard(short gameBoard[4][4], int score) {
  int width, height;
  for (height = 0; height < 4; height++) {
    for (width = 0; width < 4; width++) {
      if (gameBoard[height][width] != 0) {
        printf("[%4i]", gameBoard[height][width]);
      } else {
        printf("[    ]");
      }
    }
    printf("\n");
  }
  printf("Score: %i\n\n", score);
}


x86 assembly (clang, -O0):
<printGameBoard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11c8 <printGameBoard+0xb8>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    11ac <printGameBoard+0x9c>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
cmp    $0x0,%eax
je     118b <printGameBoard+0x7b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movswl (%rax,%rcx,2),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1199 <printGameBoard+0x89>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <printGameBoard+0x8e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1137 <printGameBoard+0x27>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <printGameBoard+0x16>
mov    -0xc(%rbp),%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printGameBoard>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xed1(%rip),%r15
lea    0xec4(%rip),%r12
xor    %ebp,%ebp
jmp    1162 <printGameBoard+0x42>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    $0x4,%rbp
je     11e6 <printGameBoard+0xc6>
movswl (%rbx,%rbp,8),%esi
test   %esi,%esi
je     1180 <printGameBoard+0x60>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118a <printGameBoard+0x6a>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl 0x2(%rbx,%rbp,8),%esi
test   %esi,%esi
je     11a0 <printGameBoard+0x80>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11aa <printGameBoard+0x8a>
nop
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl 0x4(%rbx,%rbp,8),%esi
test   %esi,%esi
je     11c0 <printGameBoard+0xa0>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ca <printGameBoard+0xaa>
nop
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movswl 0x6(%rbx,%rbp,8),%esi
test   %esi,%esi
je     1140 <printGameBoard+0x20>
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    114a <printGameBoard+0x2a>
lea    0xe20(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"[%4i]\00"
@.str.1 = [7 x i8] c"[ ]\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [12 x i8] c"Score: %i\0A\0A\00"
define void @printGameBoard([4 x i16]* %0, i32 %1) {
%3 = alloca [4 x i16]*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store [4 x i16]* %0, [4 x i16]** %3
store i32 %1, i32* %4
store i32 0, i32* %6
br label %7
7: ; preds = %44, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %47
10: ; preds = %7
store i32 0, i32* %5
br label %11
11: ; preds = %39, %10
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %42
14: ; preds = %11
%15 = load [4 x i16]*, [4 x i16]** %3
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [4 x i16], [4 x i16]* %15, i64 %17
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x i16], [4 x i16]* %18, i64 0, i64 %20
%22 = load i16, i16* %21
%23 = sext i16 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %36
25: ; preds = %14
%26 = load [4 x i16]*, [4 x i16]** %3
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x i16], [4 x i16]* %26, i64 %28
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [4 x i16], [4 x i16]* %29, i64 0, i64 %31
%33 = load i16, i16* %32
%34 = sext i16 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %34)
br label %38
36: ; preds = %14
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %36, %25
br label %39
39: ; preds = %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %11
42: ; preds = %11
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %7
47: ; preds = %7
%48 = load i32, i32* %4
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %48)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"[%4i]\00"
@.str.1 = [7 x i8] c"[ ]\00"
@.str.3 = [12 x i8] c"Score: %i\0A\0A\00"
define void @printGameBoard([4 x i16]* nocapture %0, i32 %1) {
br label %3
3: ; preds = %2, %40
%4 = phi i64 [ 0, %2 ], [ %42, %40 ]
%5 = getelementptr inbounds [4 x i16], [4 x i16]* %0, i64 %4, i64 0
%6 = load i16, i16* %5
%7 = icmp eq i16 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = sext i16 %6 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %13
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %8, %11
%14 = getelementptr inbounds [4 x i16], [4 x i16]* %0, i64 %4, i64 1
%15 = load i16, i16* %14
%16 = icmp eq i16 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = sext i16 %15 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %22
20: ; preds = %13
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = getelementptr inbounds [4 x i16], [4 x i16]* %0, i64 %4, i64 2
%24 = load i16, i16* %23
%25 = icmp eq i16 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = sext i16 %24 to i32
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %31
29: ; preds = %22
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = getelementptr inbounds [4 x i16], [4 x i16]* %0, i64 %4, i64 3
%33 = load i16, i16* %32
%34 = icmp eq i16 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %31
%36 = sext i16 %33 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %36)
br label %40
38: ; preds = %31
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38, %35
%41 = tail call i32 @putchar(i32 10)
%42 = add nuw nsw i64 %4, 1
%43 = icmp eq i64 %42, 4
br i1 %43, label %44, label %3
44: ; preds = %40
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %1)
ret void
}