#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void print_board(FILE *file, int width, int height) {
  int c_w = width / 8, c_w_j, c_h = height / 8, c_h_i, i = 8, j = 8, uno = 1;
  fprintf(file, "P2\n%d\n%d\n1\n", width, height);
  while (i-- > 0) {
    c_h_i = c_h;
    while (c_h_i-- > 0) {
      j = 8;
      while (j-- > 0) {
        c_w_j = c_w;
        while (c_w_j-- > 0) {
          if (uno > 0)
            fputc('0' + (j % 2), file);
          else
            fputc('1' - (j % 2), file);
          fputc(' ', file);
        }
      }
      fputc('\n', file);
    }
    uno *= -1;
  }
}


x86 assembly (clang, -O0):
<print_board>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
movl   $0x8,-0x24(%rbp)
movl   $0x8,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe8c(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x0,%eax
jle    125c <print_board+0x13c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x20(%rbp)
cmp    $0x0,%eax
jle    1250 <print_board+0x130>
movl   $0x8,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x28(%rbp)
cmp    $0x0,%eax
jle    123d <print_board+0x11d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
jle    1238 <print_board+0x118>
cmpl   $0x0,-0x2c(%rbp)
jle    1207 <print_board+0xe7>
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    1225 <print_board+0x105>
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    $0x31,%eax
sub    %edx,%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1030 <fputc@plt>
jmp    11c8 <print_board+0xa8>
jmp    11ae <print_board+0x8e>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
jmp    1193 <print_board+0x73>
imul   $0xffffffff,-0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1179 <print_board+0x59>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_board>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,%ecx
mov    %esi,%edx
mov    %rdi,%r15
lea    0x7(%rdx),%ebx
test   %esi,%esi
cmovns %esi,%ebx
sar    $0x3,%ebx
lea    0x7(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x3,%eax
mov    %eax,0x20(%rsp)
lea    0xeaa(%rip),%rsi
mov    %rdx,0x10(%rsp)
mov    %rcx,0x28(%rsp)
call   1040 <fprintf@plt>
add    $0x1,%ebx
mov    %ebx,0xc(%rsp)
movl   $0x1,0x1c(%rsp)
mov    $0x7,%eax
jmp    1191 <print_board+0x71>
nopl   0x0(%rax,%rax,1)
negl   0x1c(%rsp)
mov    0x24(%rsp),%eax
sub    $0x1,%eax
jb     1375 <print_board+0x255>
mov    %eax,0x24(%rsp)
cmpl   $0x8,0x28(%rsp)
jl     1180 <print_board+0x60>
cmpl   $0x0,0x1c(%rsp)
setg   %r14b
lea    0x30(%r14),%r13d
xor    $0x31,%r14b
mov    0x20(%rsp),%eax
jmp    11dc <print_board+0xbc>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x30(%rsp),%rbp
lea    -0x1(%rbp),%ebx
mov    $0xa,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
cmp    $0x1,%ebp
mov    %ebx,%eax
jle    1180 <print_board+0x60>
mov    %rax,0x30(%rsp)
mov    0xc(%rsp),%ebx
cmpl   $0x8,0x10(%rsp)
jl     11c0 <print_board+0xa0>
nopl   0x0(%rax)
movzbl %r13b,%ebp
mov    %ebp,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
mov    $0x20,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     11f0 <print_board+0xd0>
cmpl   $0x8,0x10(%rsp)
jl     11c0 <print_board+0xa0>
mov    0xc(%rsp),%ebx
xchg   %ax,%ax
movzbl %r14b,%r12d
mov    %r12d,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
mov    $0x20,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     1220 <print_board+0x100>
cmpl   $0x8,0x10(%rsp)
jl     11c0 <print_board+0xa0>
mov    0xc(%rsp),%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
mov    $0x20,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     1260 <print_board+0x140>
cmpl   $0x8,0x10(%rsp)
jl     11c0 <print_board+0xa0>
mov    0xc(%rsp),%ebx
xchg   %ax,%ax
mov    %r12d,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
mov    $0x20,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     1290 <print_board+0x170>
cmpl   $0x8,0x10(%rsp)
jl     11c0 <print_board+0xa0>
mov    0xc(%rsp),%ebx
nop
mov    %ebp,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
mov    $0x20,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     12c0 <print_board+0x1a0>
cmpl   $0x8,0x10(%rsp)
jl     11c0 <print_board+0xa0>
mov    0xc(%rsp),%ebx
xchg   %ax,%ax
mov    %r12d,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
mov    $0x20,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     12f0 <print_board+0x1d0>
cmpl   $0x8,0x10(%rsp)
jl     11c0 <print_board+0xa0>
mov    0xc(%rsp),%ebx
nop
mov    %ebp,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
mov    $0x20,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     1320 <print_board+0x200>
cmpl   $0x8,0x10(%rsp)
jl     11c0 <print_board+0xa0>
mov    0xc(%rsp),%ebx
xchg   %ax,%ax
mov    %r12d,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
mov    $0x20,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jg     1350 <print_board+0x230>
jmp    11c0 <print_board+0xa0>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"P2\0A%d\0A%d\0A1\0A\00"
define void @print_board(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%14 = load i32, i32* %5
%15 = sdiv i32 %14, 8
store i32 %15, i32* %7
%16 = load i32, i32* %6
%17 = sdiv i32 %16, 8
store i32 %17, i32* %9
store i32 8, i32* %11
store i32 8, i32* %12
store i32 1, i32* %13
%18 = load i32*, i32** %4
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %20)
br label %22
22: ; preds = %67, %3
%23 = load i32, i32* %11
%24 = add nsw i32 %23, -1
store i32 %24, i32* %11
%25 = icmp sgt i32 %23, 0
br i1 %25, label %26, label %70
26: ; preds = %22
%27 = load i32, i32* %9
store i32 %27, i32* %10
br label %28
28: ; preds = %64, %26
%29 = load i32, i32* %10
%30 = add nsw i32 %29, -1
store i32 %30, i32* %10
%31 = icmp sgt i32 %29, 0
br i1 %31, label %32, label %67
32: ; preds = %28
store i32 8, i32* %12
br label %33
33: ; preds = %63, %32
%34 = load i32, i32* %12
%35 = add nsw i32 %34, -1
store i32 %35, i32* %12
%36 = icmp sgt i32 %34, 0
br i1 %36, label %37, label %64
37: ; preds = %33
%38 = load i32, i32* %7
store i32 %38, i32* %8
br label %39
39: ; preds = %60, %37
%40 = load i32, i32* %8
%41 = add nsw i32 %40, -1
store i32 %41, i32* %8
%42 = icmp sgt i32 %40, 0
br i1 %42, label %43, label %63
43: ; preds = %39
%44 = load i32, i32* %13
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %53
46: ; preds = %43
%47 = load i32, i32* %12
%48 = srem i32 %47, 2
%49 = add nsw i32 48, %48
%50 = trunc i32 %49 to i8
%51 = load i32*, i32** %4
%52 = call i32 @fputc(i8 signext %50, i32* %51)
br label %60
53: ; preds = %43
%54 = load i32, i32* %12
%55 = srem i32 %54, 2
%56 = sub nsw i32 49, %55
%57 = trunc i32 %56 to i8
%58 = load i32*, i32** %4
%59 = call i32 @fputc(i8 signext %57, i32* %58)
br label %60
60: ; preds = %53, %46
%61 = load i32*, i32** %4
%62 = call i32 @fputc(i8 signext 32, i32* %61)
br label %39
63: ; preds = %39
br label %33
64: ; preds = %33
%65 = load i32*, i32** %4
%66 = call i32 @fputc(i8 signext 10, i32* %65)
br label %28
67: ; preds = %28
%68 = load i32, i32* %13
%69 = mul nsw i32 %68, -1
store i32 %69, i32* %13
br label %22
70: ; preds = %22
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"P2\0A%d\0A%d\0A1\0A\00"
define void @print_board(i32* nocapture %0, i32 %1, i32 %2) {
%4 = sdiv i32 %1, 8
%5 = sdiv i32 %2, 8
%6 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
%7 = icmp sgt i32 %2, 7
%8 = icmp sgt i32 %1, 7
br label %9
9: ; preds = %3, %83
%10 = phi i32 [ 7, %3 ], [ %85, %83 ]
%11 = phi i32 [ 1, %3 ], [ %84, %83 ]
br i1 %7, label %12, label %83
12: ; preds = %9
%13 = icmp sgt i32 %11, 0
%14 = select i1 %13, i8 49, i8 48
%15 = select i1 %13, i8 48, i8 49
%16 = select i1 %13, i8 49, i8 48
%17 = select i1 %13, i8 48, i8 49
%18 = select i1 %13, i8 49, i8 48
%19 = select i1 %13, i8 48, i8 49
%20 = select i1 %13, i8 49, i8 48
%21 = select i1 %13, i8 48, i8 49
br label %22
22: ; preds = %12, %73
%23 = phi i32 [ %5, %12 ], [ %74, %73 ]
br i1 %8, label %77, label %73
24: ; preds = %77
br i1 %8, label %25, label %73
25: ; preds = %24, %25
%26 = phi i32 [ %27, %25 ], [ %4, %24 ]
%27 = add nsw i32 %26, -1
%28 = tail call i32 @fputc(i8 signext %15, i32* %0)
%29 = tail call i32 @fputc(i8 signext 32, i32* %0)
%30 = icmp sgt i32 %26, 1
br i1 %30, label %25, label %31
31: ; preds = %25
br i1 %8, label %32, label %73
32: ; preds = %31, %32
%33 = phi i32 [ %34, %32 ], [ %4, %31 ]
%34 = add nsw i32 %33, -1
%35 = tail call i32 @fputc(i8 signext %16, i32* %0)
%36 = tail call i32 @fputc(i8 signext 32, i32* %0)
%37 = icmp sgt i32 %33, 1
br i1 %37, label %32, label %38
38: ; preds = %32
br i1 %8, label %39, label %73
39: ; preds = %38, %39
%40 = phi i32 [ %41, %39 ], [ %4, %38 ]
%41 = add nsw i32 %40, -1
%42 = tail call i32 @fputc(i8 signext %17, i32* %0)
%43 = tail call i32 @fputc(i8 signext 32, i32* %0)
%44 = icmp sgt i32 %40, 1
br i1 %44, label %39, label %45
45: ; preds = %39
br i1 %8, label %46, label %73
46: ; preds = %45, %46
%47 = phi i32 [ %48, %46 ], [ %4, %45 ]
%48 = add nsw i32 %47, -1
%49 = tail call i32 @fputc(i8 signext %18, i32* %0)
%50 = tail call i32 @fputc(i8 signext 32, i32* %0)
%51 = icmp sgt i32 %47, 1
br i1 %51, label %46, label %52
52: ; preds = %46
br i1 %8, label %53, label %73
53: ; preds = %52, %53
%54 = phi i32 [ %55, %53 ], [ %4, %52 ]
%55 = add nsw i32 %54, -1
%56 = tail call i32 @fputc(i8 signext %19, i32* %0)
%57 = tail call i32 @fputc(i8 signext 32, i32* %0)
%58 = icmp sgt i32 %54, 1
br i1 %58, label %53, label %59
59: ; preds = %53
br i1 %8, label %60, label %73
60: ; preds = %59, %60
%61 = phi i32 [ %62, %60 ], [ %4, %59 ]
%62 = add nsw i32 %61, -1
%63 = tail call i32 @fputc(i8 signext %20, i32* %0)
%64 = tail call i32 @fputc(i8 signext 32, i32* %0)
%65 = icmp sgt i32 %61, 1
br i1 %65, label %60, label %66
66: ; preds = %60
br i1 %8, label %67, label %73
67: ; preds = %66, %67
%68 = phi i32 [ %69, %67 ], [ %4, %66 ]
%69 = add nsw i32 %68, -1
%70 = tail call i32 @fputc(i8 signext %21, i32* %0)
%71 = tail call i32 @fputc(i8 signext 32, i32* %0)
%72 = icmp sgt i32 %68, 1
br i1 %72, label %67, label %73
73: ; preds = %59, %45, %31, %22, %24, %38, %52, %67, %66
%74 = add nsw i32 %23, -1
%75 = tail call i32 @fputc(i8 signext 10, i32* %0)
%76 = icmp sgt i32 %23, 1
br i1 %76, label %22, label %83
77: ; preds = %22, %77
%78 = phi i32 [ %79, %77 ], [ %4, %22 ]
%79 = add nsw i32 %78, -1
%80 = tail call i32 @fputc(i8 signext %14, i32* %0)
%81 = tail call i32 @fputc(i8 signext 32, i32* %0)
%82 = icmp sgt i32 %78, 1
br i1 %82, label %77, label %24
83: ; preds = %73, %9
%84 = sub nsw i32 0, %11
%85 = add nsw i32 %10, -1
%86 = icmp eq i32 %10, 0
br i1 %86, label %87, label %9
87: ; preds = %83
ret void
}