#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 *piece_name(int);
int /*<<< orphan*/ printf(char *, ...);
void print_board(int boardcopy[8][8]) {
  int a, b;
  printf("\n");
  printf(
      "## ## ***************************************************************** "
      "## ##\n");
  printf("  *   |   A   |   B   |   C   |   D   |   E   |   F   |   G   |   H  "
         " |   *  \n");
  printf(
      "## ## ***************************************************************** "
      "## ##\n");
  for (a = 0; a < 8; a++) {
    printf("*****                                                              "
           "     *****\n");
    printf("| %d |\t", a + 1);
    for (b = 0; b < 8; b++) {
      if (boardcopy[a][b] > 0)
        printf("w%s\t", piece_name(boardcopy[a][b]));
      else if (boardcopy[a][b] < 0)
        printf("b%s\t", piece_name(boardcopy[a][b]));
      else
        printf("0\t");
    }
    printf("| %d |\n", a + 1);
    printf("*****                                                              "
           "     *****\n");
  }
  printf(
      "## ## ***************************************************************** "
      "## ##\n");
  printf("  *   |   A   |   B   |   C   |   D   |   E   |   F   |   G   |   H  "
         " |   *  \n");
  printf(
      "## ## ***************************************************************** "
      "## ##\n");
}


x86 assembly (clang, -O0):
<print_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xf69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    129a <print_board+0x17a>
lea    0xf22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xf5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x8,-0x10(%rbp)
jge    126a <print_board+0x14a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    11f6 <print_board+0xd6>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <piece_name@plt>
mov    %rax,%rsi
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1257 <print_board+0x137>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jge    1244 <print_board+0x124>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <piece_name@plt>
mov    %rax,%rsi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1252 <print_board+0x132>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1257 <print_board+0x137>
jmp    125c <print_board+0x13c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119e <print_board+0x7e>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116b <print_board+0x4b>
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_board>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xf0c(%rip),%rbp
mov    %rbp,%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
lea    0xf37(%rip),%rbp
lea    0xe7f(%rip),%r12
lea    0xe82(%rip),%r15
xor    %r13d,%r13d
jmp    11ca <print_board+0x8a>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe6e(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf01(%rip),%rbp
mov    %rbp,%rdi
call   1040 <puts@plt>
add    $0x20,%rbx
cmp    $0x8,%r13
je     123c <print_board+0xfc>
mov    %rbp,%rdi
call   1040 <puts@plt>
add    $0x1,%r13
lea    0xe23(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %r14d,%r14d
lea    0xe1c(%rip),%rbp
jmp    121c <print_board+0xdc>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1050 <piece_name@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r14
cmp    $0x8,%r14
je     11a0 <print_board+0x60>
mov    (%rbx,%r14,4),%edi
test   %edi,%edi
jg     1200 <print_board+0xc0>
js     1232 <print_board+0xf2>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1212 <print_board+0xd2>
call   1050 <piece_name@plt>
mov    %rbp,%rdi
jmp    1208 <print_board+0xc8>
lea    0xe28(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xdcb(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@.str.4 = [8 x i8] c"| %d |\09\00"
@.str.5 = [5 x i8] c"w%s\09\00"
@.str.6 = [5 x i8] c"b%s\09\00"
@.str.7 = [3 x i8] c"0\09\00"
@.str.8 = [8 x i8] c"| %d |\0A\00"
@str.12 = [78 x i8] c" * | A | B | C | D | E | F | G | H | * \00"
@str.13 = [78 x i8] c"## ## ***************************************************************** ## ##\00"
@str.15 = [78 x i8] c"***** *****\00"
define void @print_board([8 x i32]* nocapture %0) {
%2 = tail call i32 @putchar(i32 10)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.13, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.12, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.13, i64 0, i64 0))
br label %6
6: ; preds = %1, %30
%7 = phi i64 [ 0, %1 ], [ %9, %30 ]
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.15, i64 0, i64 0))
%9 = add nuw nsw i64 %7, 1
%10 = trunc i64 %9 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %6, %27
%13 = phi i64 [ 0, %6 ], [ %28, %27 ]
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 %7, i64 %13
%15 = load i32, i32* %14
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = tail call i8* @piece_name(i32 %15)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %18)
br label %27
20: ; preds = %12
%21 = icmp slt i32 %15, 0
br i1 %21, label %22, label %25
22: ; preds = %20
%23 = tail call i8* @piece_name(i32 %15)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %23)
br label %27
25: ; preds = %20
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
br label %27
27: ; preds = %17, %25, %22
%28 = add nuw nsw i64 %13, 1
%29 = icmp eq i64 %28, 8
br i1 %29, label %30, label %12
30: ; preds = %27
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %10)
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.15, i64 0, i64 0))
%33 = icmp eq i64 %9, 8
br i1 %33, label %34, label %6
34: ; preds = %30
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.13, i64 0, i64 0))
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.12, i64 0, i64 0))
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.13, i64 0, i64 0))
ret void
}