#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 */
char getPieceAt(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
void printBoard(char *board) {
  char black = '#';
  char white = '@';
  char pieceId;
  int i, j;
  for (i = 7; i >= 0; i--) {
    printf("%d|", i + 1);
    for (j = 0; j < 8; j++) {
      pieceId = getPieceAt(board, i, j);
      if (pieceId == 0) {
        printf("  ");
      } else if (pieceId > 50) {
        pieceId = (char)(pieceId - 50);
        switch (pieceId) {
        case 1:
          printf("%cP", black);
          break;
        case 2:
          printf("%cR", black);
          break;
        case 3:
          printf("%cN", black);
          break;
        case 4:
          printf("%cB", black);
          break;
        case 5:
          printf("%cQ", black);
          break;
        case 6:
          printf("%cK", black);
          break;
        }
      } else {
        switch (pieceId) {
        case 1:
          printf("%cP", white);
          break;
        case 2:
          printf("%cR", white);
          break;
        case 3:
          printf("%cN", white);
          break;
        case 4:
          printf("%cB", white);
          break;
        case 5:
          printf("%cQ", white);
          break;
        case 6:
          printf("%cK", white);
          break;
        }
      }
      if (j < 8) {
        printf("|");
      }
    }
    printf("\n");
  }
  printf("-|--|--|--|--|--|--|--|--|\n");
  printf(" | A| B| C| D| E| F| G| H|\n");
}


x86 assembly (clang, -O0):
<printBoard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x23,-0x9(%rbp)
movb   $0x40,-0xa(%rbp)
movl   $0x7,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1365 <printBoard+0x245>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    1349 <printBoard+0x229>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <getPieceAt@plt>
mov    %al,-0xb(%rbp)
movsbl -0xb(%rbp),%eax
cmp    $0x0,%eax
jne    119c <printBoard+0x7c>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    131e <printBoard+0x1fe>
movsbl -0xb(%rbp),%eax
cmp    $0x32,%eax
jle    1265 <printBoard+0x145>
mov    -0xb(%rbp),%al
add    $0xce,%al
mov    %al,-0xb(%rbp)
movsbl -0xb(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     1260 <printBoard+0x140>
mov    -0x20(%rbp),%rax
lea    0xe46(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0x9(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1260 <printBoard+0x140>
movsbl -0x9(%rbp),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1260 <printBoard+0x140>
movsbl -0x9(%rbp),%esi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1260 <printBoard+0x140>
movsbl -0x9(%rbp),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1260 <printBoard+0x140>
movsbl -0x9(%rbp),%esi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1260 <printBoard+0x140>
movsbl -0x9(%rbp),%esi
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1319 <printBoard+0x1f9>
movsbl -0xb(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     1314 <printBoard+0x1f4>
mov    -0x28(%rbp),%rax
lea    0xd7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl -0xa(%rbp),%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1314 <printBoard+0x1f4>
movsbl -0xa(%rbp),%esi
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1314 <printBoard+0x1f4>
movsbl -0xa(%rbp),%esi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1314 <printBoard+0x1f4>
movsbl -0xa(%rbp),%esi
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1314 <printBoard+0x1f4>
movsbl -0xa(%rbp),%esi
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1314 <printBoard+0x1f4>
movsbl -0xa(%rbp),%esi
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1319 <printBoard+0x1f9>
jmp    131e <printBoard+0x1fe>
cmpl   $0x8,-0x14(%rbp)
jge    1336 <printBoard+0x216>
lea    0xd03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133b <printBoard+0x21b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <printBoard+0x40>
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    113b <printBoard+0x1b>
lea    0xce3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printBoard>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x7,%ebx
lea    0xeda(%rip),%r12
lea    0xeb7(%rip),%rbp
lea    0xe98(%rip),%r15
jmp    1183 <printBoard+0x43>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
sub    $0x1,%ebx
jb     12a1 <printBoard+0x161>
lea    0x1(%rbx),%esi
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %r13d,%r13d
jmp    11be <printBoard+0x7e>
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
add    $0x1,%r13d
cmp    $0x8,%r13d
je     1170 <printBoard+0x30>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
call   1040 <getPieceAt@plt>
test   %al,%al
je     11a0 <printBoard+0x60>
cmp    $0x33,%al
jl     1200 <printBoard+0xc0>
add    $0xcd,%al
cmp    $0x5,%al
ja     11aa <printBoard+0x6a>
movzbl %al,%eax
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
lea    0xe4a(%rip),%rdi
mov    $0x23,%esi
jmp    1295 <printBoard+0x155>
nopw   0x0(%rax,%rax,1)
movsbl %al,%eax
add    $0xffffffff,%eax
cmp    $0x5,%eax
ja     11aa <printBoard+0x6a>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
lea    0xe1c(%rip),%rdi
jmp    1290 <printBoard+0x150>
lea    0xe17(%rip),%rdi
mov    $0x23,%esi
jmp    1295 <printBoard+0x155>
lea    0xe0d(%rip),%rdi
mov    $0x23,%esi
jmp    1295 <printBoard+0x155>
lea    0xe03(%rip),%rdi
mov    $0x23,%esi
jmp    1295 <printBoard+0x155>
lea    0xdf9(%rip),%rdi
mov    $0x23,%esi
jmp    1295 <printBoard+0x155>
lea    0xdef(%rip),%rdi
mov    $0x23,%esi
jmp    1295 <printBoard+0x155>
lea    0xdd1(%rip),%rdi
jmp    1290 <printBoard+0x150>
lea    0xdcc(%rip),%rdi
jmp    1290 <printBoard+0x150>
lea    0xdc7(%rip),%rdi
jmp    1290 <printBoard+0x150>
lea    0xdc2(%rip),%rdi
jmp    1290 <printBoard+0x150>
lea    0xdbd(%rip),%rdi
xchg   %ax,%ax
mov    $0x40,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11aa <printBoard+0x6a>
lea    0xda7(%rip),%rdi
call   1050 <puts@plt>
lea    0xdb6(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <puts@plt>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d|\00"
@.str.1 = [3 x i8] c" \00"
@.str.2 = [4 x i8] c"%cP\00"
@.str.3 = [4 x i8] c"%cR\00"
@.str.4 = [4 x i8] c"%cN\00"
@.str.5 = [4 x i8] c"%cB\00"
@.str.6 = [4 x i8] c"%cQ\00"
@.str.7 = [4 x i8] c"%cK\00"
@str = [27 x i8] c"-|--|--|--|--|--|--|--|--|\00"
@str.12 = [27 x i8] c" | A| B| C| D| E| F| G| H|\00"
define void @printBoard(i8* %0) {
br label %2
2: ; preds = %1, %45
%3 = phi i32 [ 7, %1 ], [ %47, %45 ]
%4 = add nuw nsw i32 %3, 1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %6
6: ; preds = %2, %41
%7 = phi i32 [ 0, %2 ], [ %43, %41 ]
%8 = tail call signext i8 @getPieceAt(i8* %0, i32 %3, i32 %7)
%9 = sext i8 %8 to i32
%10 = icmp eq i8 %8, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %41
13: ; preds = %6
%14 = icmp sgt i8 %8, 50
br i1 %14, label %15, label %28
15: ; preds = %13
switch i8 %8, label %41 [
i8 51, label %16
i8 52, label %18
i8 53, label %20
i8 54, label %22
i8 55, label %24
i8 56, label %26
]
16: ; preds = %15
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 35)
br label %41
18: ; preds = %15
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 35)
br label %41
20: ; preds = %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 35)
br label %41
22: ; preds = %15
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 35)
br label %41
24: ; preds = %15
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 35)
br label %41
26: ; preds = %15
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 35)
br label %41
28: ; preds = %13
switch i32 %9, label %41 [
i32 1, label %29
i32 2, label %31
i32 3, label %33
i32 4, label %35
i32 5, label %37
i32 6, label %39
]
29: ; preds = %28
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 64)
br label %41
31: ; preds = %28
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 64)
br label %41
33: ; preds = %28
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 64)
br label %41
35: ; preds = %28
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 64)
br label %41
37: ; preds = %28
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 64)
br label %41
39: ; preds = %28
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 64)
br label %41
41: ; preds = %11, %29, %31, %33, %35, %37, %39, %28, %16, %18, %20, %22, %24, %26, %15
%42 = tail call i32 @putchar(i32 124)
%43 = add nuw nsw i32 %7, 1
%44 = icmp eq i32 %43, 8
br i1 %44, label %45, label %6
45: ; preds = %41
%46 = tail call i32 @putchar(i32 10)
%47 = add nsw i32 %3, -1
%48 = icmp eq i32 %3, 0
br i1 %48, label %49, label %2
49: ; preds = %45
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.12, i64 0, i64 0))
ret void
}