#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 *, ...);
int drawBoard(int (*board)[][10], int hideShips) {
  printf("# - A - B - C - D - E - F - G - H - I - J\n");
  printf("-----------------------------------------\n");
  for (int i = 0; i < 10; i++) {
    printf("%i |", i);
    for (int j = 0; j < 10; j++) {
      if (!hideShips) {
        switch ((*board)[i][j]) {
        case 9:
          printf(" X  ");
          break;
        case 8:
          printf(" M  ");
          break;
        default:
          printf(" ?  ");
          break;
        }
      } else {
        switch ((*board)[i][j]) {
        case 0:
          printf(" ?  ");
          break;
        case 1:
          printf(" C  ");
          break;
        case 2:
          printf(" B  ");
          break;
        case 3:
          printf(" R  ");
          break;
        case 4:
          printf(" S  ");
          break;
        case 5:
          printf(" D  ");
          break;
        case 8:
          printf(" M  ");
          break;
        case 9:
          printf(" X  ");
          break;
        default:
          printf(" ?  ");
          break;
        }
      }
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<drawBoard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xf02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    12fd <drawBoard+0x1ed>
mov    -0x10(%rbp),%esi
lea    0xf28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    12e1 <drawBoard+0x1d1>
cmpl   $0x0,-0xc(%rbp)
jne    11ea <drawBoard+0xda>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
lea    (%rcx,%rcx,4),%rcx
lea    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
sub    $0x8,%eax
je     11c4 <drawBoard+0xb4>
jmp    11a0 <drawBoard+0x90>
mov    -0x18(%rbp),%eax
sub    $0x9,%eax
jne    11d7 <drawBoard+0xc7>
jmp    11b1 <drawBoard+0xa1>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e5 <drawBoard+0xd5>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e5 <drawBoard+0xd5>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ce <drawBoard+0x1be>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
lea    (%rcx,%rcx,4),%rcx
lea    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %rax,-0x20(%rbp)
sub    $0x9,%rax
ja     12bb <drawBoard+0x1ab>
mov    -0x20(%rbp),%rax
lea    0xde6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c9 <drawBoard+0x1b9>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c9 <drawBoard+0x1b9>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c9 <drawBoard+0x1b9>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c9 <drawBoard+0x1b9>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c9 <drawBoard+0x1b9>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c9 <drawBoard+0x1b9>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c9 <drawBoard+0x1b9>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c9 <drawBoard+0x1b9>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ce <drawBoard+0x1be>
jmp    12d3 <drawBoard+0x1c3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <drawBoard+0x54>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1142 <drawBoard+0x32>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawBoard>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xee6(%rip),%rdi
call   1040 <puts@plt>
lea    0xf04(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb0(%rip),%r13
lea    0xf1e(%rip),%r12
xor    %r15d,%r15d
jmp    1188 <drawBoard+0x58>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
add    $0x28,%rbx
cmp    $0xa,%r15
je     11ee <drawBoard+0xbe>
lea    0xe71(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %r14d,%r14d
jmp    11d0 <drawBoard+0xa0>
xchg   %ax,%ax
cmp    $0x8,%eax
mov    %r13,%rdi
lea    0xe5d(%rip),%rcx
cmove  %rcx,%rdi
cmp    $0x9,%eax
lea    0xe4a(%rip),%rax
cmove  %rax,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r14
cmp    $0xa,%r14
je     1170 <drawBoard+0x40>
mov    (%rbx,%r14,4),%eax
test   %ebp,%ebp
je     11a0 <drawBoard+0x70>
add    $0xffffffff,%eax
mov    %r13,%rdi
cmp    $0x8,%eax
ja     11bf <drawBoard+0x8f>
cltq
movslq (%r12,%rax,4),%rdi
add    %r12,%rdi
jmp    11bf <drawBoard+0x8f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"# - A - B - C - D - E - F - G - H - I - J\0A\00"
@.str.1 = [43 x i8] c"-----------------------------------------\0A\00"
@.str.2 = [5 x i8] c"%i |\00"
@.str.3 = [5 x i8] c" X \00"
@.str.4 = [5 x i8] c" M \00"
@.str.5 = [5 x i8] c" ? \00"
@.str.6 = [5 x i8] c" C \00"
@.str.7 = [5 x i8] c" B \00"
@.str.8 = [5 x i8] c" R \00"
@.str.9 = [5 x i8] c" S \00"
@.str.10 = [5 x i8] c" D \00"
@.str.11 = [2 x i8] c"\0A\00"
define i32 @drawBoard([0 x [10 x i32]]* %0, i32 %1) {
%3 = alloca [0 x [10 x i32]]*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store [0 x [10 x i32]]* %0, [0 x [10 x i32]]** %3
store i32 %1, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %9
9: ; preds = %71, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %74
12: ; preds = %9
%13 = load i32, i32* %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %13)
store i32 0, i32* %6
br label %15
15: ; preds = %66, %12
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 10
br i1 %17, label %18, label %69
18: ; preds = %15
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 0
br i1 %20, label %37, label %21
21: ; preds = %18
%22 = load [0 x [10 x i32]]*, [0 x [10 x i32]]** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [0 x [10 x i32]], [0 x [10 x i32]]* %22, i64 0, i64 %24
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %25, i64 0, i64 %27
%29 = load i32, i32* %28
switch i32 %29, label %34 [
i32 9, label %30
i32 8, label %32
]
30: ; preds = %21
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %36
32: ; preds = %21
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %36
34: ; preds = %21
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %32, %30
br label %65
37: ; preds = %18
%38 = load [0 x [10 x i32]]*, [0 x [10 x i32]]** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [0 x [10 x i32]], [0 x [10 x i32]]* %38, i64 0, i64 %40
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %41, i64 0, i64 %43
%45 = load i32, i32* %44
switch i32 %45, label %62 [
i32 0, label %46
i32 1, label %48
i32 2, label %50
i32 3, label %52
i32 4, label %54
i32 5, label %56
i32 8, label %58
i32 9, label %60
]
46: ; preds = %37
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %64
48: ; preds = %37
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %64
50: ; preds = %37
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %64
52: ; preds = %37
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %64
54: ; preds = %37
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %64
56: ; preds = %37
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %64
58: ; preds = %37
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %64
60: ; preds = %37
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %64
62: ; preds = %37
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %64
64: ; preds = %62, %60, %58, %56, %54, %52, %50, %48, %46
br label %65
65: ; preds = %64, %36
br label %66
66: ; preds = %65
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %15
69: ; preds = %15
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %71
71: ; preds = %69
%72 = load i32, i32* %5
%73 = add nsw i32 %72, 1
store i32 %73, i32* %5
br label %9
74: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [5 x i8] c"%i |\00"
@.str.3 = [5 x i8] c" X \00"
@.str.4 = [5 x i8] c" M \00"
@.str.5 = [5 x i8] c" ? \00"
@.str.6 = [5 x i8] c" C \00"
@.str.7 = [5 x i8] c" B \00"
@.str.8 = [5 x i8] c" R \00"
@.str.9 = [5 x i8] c" S \00"
@.str.10 = [5 x i8] c" D \00"
@str = [42 x i8] c"# - A - B - C - D - E - F - G - H - I - J\00"
@str.12 = [42 x i8] c"-----------------------------------------\00"
@reltable.drawBoard = [9 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([9 x i32]* @reltable.drawBoard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.7 to i64), i64 ptrtoint ([9 x i32]* @reltable.drawBoard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.8 to i64), i64 ptrtoint ([9 x i32]* @reltable.drawBoard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.9 to i64), i64 ptrtoint ([9 x i32]* @reltable.drawBoard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.10 to i64), i64 ptrtoint ([9 x i32]* @reltable.drawBoard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.drawBoard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([9 x i32]* @reltable.drawBoard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([9 x i32]* @reltable.drawBoard to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.3 to i64), i64 ptrtoint ([9 x i32]* @reltable.drawBoard to i64)) to i32)]
define i32 @drawBoard([0 x [10 x i32]]* nocapture %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.12, i64 0, i64 0))
%5 = icmp eq i32 %1, 0
br label %7
6: ; preds = %11
ret i32 0
7: ; preds = %2, %11
%8 = phi i64 [ 0, %2 ], [ %13, %11 ]
%9 = trunc i64 %8 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %15
11: ; preds = %31
%12 = tail call i32 @putchar(i32 10)
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, 10
br i1 %14, label %6, label %7
15: ; preds = %7, %31
%16 = phi i64 [ 0, %7 ], [ %34, %31 ]
%17 = getelementptr inbounds [0 x [10 x i32]], [0 x [10 x i32]]* %0, i64 0, i64 %8, i64 %16
%18 = load i32, i32* %17
br i1 %5, label %19, label %24
19: ; preds = %15
%20 = icmp eq i32 %18, 8
%21 = select i1 %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0)
%22 = icmp eq i32 %18, 9
%23 = select i1 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %21
br label %31
24: ; preds = %15
%25 = add i32 %18, -1
%26 = icmp ult i32 %25, 9
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = sext i32 %25 to i64
%29 = shl i64 %28, 2
%30 = call i8* @llvm.load.relative.i64(i8* bitcast ([9 x i32]* @reltable.drawBoard to i8*), i64 %29)
br label %31
31: ; preds = %27, %24, %19
%32 = phi i8* [ %23, %19 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), %24 ], [ %30, %27 ]
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %32)
%34 = add nuw nsw i64 %16, 1
%35 = icmp eq i64 %34, 10
br i1 %35, label %11, label %15
}