#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 canIWin(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int main() {
  int i, j;
  for (i = 1; i <= 20; i++) {
    printf("%d ", i);
    for (j = i * (i + 1) / 2; j >= 1; j--) {
      printf("%d", canIWin(i, j));
    }
    puts("");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jg     11c1 <main+0x91>
mov    -0x8(%rbp),%esi
lea    0xea6(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     11a7 <main+0x77>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <canIWin@plt>
mov    %eax,%esi
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1176 <main+0x46>
lea    0xe55(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%r12d
lea    0xebb(%rip),%r14
lea    0xeb8(%rip),%r15
jmp    1162 <main+0x32>
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%r12d
cmp    $0x15,%ebp
je     11a0 <main+0x70>
mov    %r14,%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
lea    0x1(%r12),%ebp
mov    %ebp,%ebx
imul   %r12d,%ebx
cmp    $0x2,%ebx
jb     1150 <main+0x20>
shr    %ebx
nop
mov    %r12d,%edi
mov    %ebx,%esi
call   1050 <canIWin@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     1180 <main+0x50>
jmp    1150 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
br label %4
4: ; preds = %28, %0
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 20
br i1 %6, label %7, label %31
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
%13 = mul nsw i32 %10, %12
%14 = sdiv i32 %13, 2
store i32 %14, i32* %3
br label %15
15: ; preds = %23, %7
%16 = load i32, i32* %3
%17 = icmp sge i32 %16, 1
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call i32 @canIWin(i32 %19, i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %3
%25 = add nsw i32 %24, -1
store i32 %25, i32* %3
br label %15
26: ; preds = %15
%27 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %4
31: ; preds = %4
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
br label %1
1: ; preds = %0, %15
%2 = phi i32 [ 1, %0 ], [ %4, %15 ]
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = add nuw nsw i32 %2, 1
%5 = mul nsw i32 %4, %2
%6 = icmp ult i32 %5, 2
br i1 %6, label %15, label %7
7: ; preds = %1
%8 = lshr i32 %5, 1
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ %13, %9 ], [ %8, %7 ]
%11 = tail call i32 @canIWin(i32 %2, i32 %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = add nsw i32 %10, -1
%14 = icmp ugt i32 %10, 1
br i1 %14, label %9, label %15
15: ; preds = %9, %1
%16 = tail call i32 @putchar(i32 10)
%17 = icmp eq i32 %4, 21
br i1 %17, label %18, label %1
18: ; preds = %15
ret i32 0
}