#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, j;
  for (i = 0; i < 10; i++, printf("\n"))
    for (j = 0; j < 10; j++)
      if (i % 2) {
        if (j % 2 != 1)
          printf(" %c ", 1);
        else
          printf("%c", 2);
      } else {
        if (j % 2 != 1)
          printf(" %c ", 2);
        else
          printf("%c", 1);
      }
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1221 <main+0x101>
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1200 <main+0xe0>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11a9 <main+0x89>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
je     1191 <main+0x71>
lea    0xe80(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a4 <main+0x84>
lea    0xe6d(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ed <main+0xcd>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
je     11d5 <main+0xb5>
lea    0xe3c(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e8 <main+0xc8>
lea    0xe29(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ed <main+0xcd>
jmp    11f2 <main+0xd2>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1147 <main+0x27>
jmp    1205 <main+0xe5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1136 <main+0x16>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%r14
xor    %ebp,%ebp
jmp    1152 <main+0x22>
nop
add    $0x1,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0xa,%ebp
je     11b7 <main+0x87>
xor    %ebx,%ebx
jmp    1172 <main+0x42>
cs nopw 0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    $0xa,%ebx
je     1140 <main+0x10>
test   $0x1,%bpl
jne    1190 <main+0x60>
test   $0x1,%bl
jne    1160 <main+0x30>
mov    %r14,%rdi
mov    $0x2,%esi
jmp    119d <main+0x6d>
nopw   0x0(%rax,%rax,1)
test   $0x1,%bl
jne    11b0 <main+0x80>
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    116a <main+0x3a>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2,%edi
jmp    1165 <main+0x35>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c" %c \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %38, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %42
7: ; preds = %4
store i32 0, i32* %3
br label %8
8: ; preds = %34, %7
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %37
11: ; preds = %8
%12 = load i32, i32* %2
%13 = srem i32 %12, 2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load i32, i32* %3
%17 = srem i32 %16, 2
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 1)
br label %23
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %23
23: ; preds = %21, %19
br label %33
24: ; preds = %11
%25 = load i32, i32* %3
%26 = srem i32 %25, 2
%27 = icmp ne i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 2)
br label %32
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %32
32: ; preds = %30, %28
br label %33
33: ; preds = %32, %23
br label %34
34: ; preds = %33
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %8
37: ; preds = %8
br label %38
38: ; preds = %37
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %4
42: ; preds = %4
%43 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c" %c \00"
define i32 @main() {
br label %1
1: ; preds = %0, %22
%2 = phi i32 [ 0, %0 ], [ %23, %22 ]
%3 = and i32 %2, 1
%4 = icmp eq i32 %3, 0
br label %5
5: ; preds = %1, %19
%6 = phi i32 [ 0, %1 ], [ %20, %19 ]
%7 = and i32 %6, 1
%8 = icmp eq i32 %7, 0
br i1 %4, label %14, label %9
9: ; preds = %5
br i1 %8, label %10, label %12
10: ; preds = %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 1)
br label %19
12: ; preds = %9
%13 = tail call i32 @putchar(i32 2)
br label %19
14: ; preds = %5
br i1 %8, label %15, label %17
15: ; preds = %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 2)
br label %19
17: ; preds = %14
%18 = tail call i32 @putchar(i32 1)
br label %19
19: ; preds = %12, %10, %17, %15
%20 = add nuw nsw i32 %6, 1
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %5
22: ; preds = %19
%23 = add nuw nsw i32 %2, 1
%24 = tail call i32 @putchar(i32 10)
%25 = icmp eq i32 %23, 10
br i1 %25, label %26, label %1
26: ; preds = %22
%27 = tail call i32 (...) @getchar()
ret i32 0
}