#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int row, col;
  int n;
  printf("Enter a number: ");
  scanf("%d", &n);
  row = 0;
  while (row < n) {
    col = 0;
    while (col < n) {
      if ((row % 2 == 0 && col % 2 == 0) || (row % 2 == 1 && col % 2 == 1)) {
        printf("*");
      } else {
        printf(" ");
      }
      col++;
    }
    printf("\n");
    row++;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    120d <main+0xed>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11f3 <main+0xd3>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11a0 <main+0x80>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11c8 <main+0xa8>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11d9 <main+0xb9>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11d9 <main+0xb9>
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
jmp    11e5 <main+0xc5>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116c <main+0x4c>
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <main+0x39>
mov    0x2dcc(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11bf <main+0x8f>
xor    %ebx,%ebx
mov    $0x20,%r15d
mov    $0x2a,%r14d
jmp    1185 <main+0x55>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
cmp    %eax,%ebx
jge    11bf <main+0x8f>
test   %eax,%eax
jle    1170 <main+0x40>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
and    $0x1,%eax
mov    %ebp,%ecx
and    $0x1,%ecx
mov    $0x2a,%edi
cmove  %r15d,%edi
test   %eax,%eax
cmove  %r15d,%edi
or     %eax,%ecx
cmove  %r14d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     1190 <main+0x60>
jmp    1170 <main+0x40>
mov    0x2e1a(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %33
9: ; preds = %2, %28
%10 = phi i32 [ %31, %28 ], [ %7, %2 ]
%11 = phi i32 [ %30, %28 ], [ 0, %2 ]
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = and i32 %11, 1
%15 = icmp eq i32 %14, 0
br label %16
16: ; preds = %13, %16
%17 = phi i32 [ 0, %13 ], [ %25, %16 ]
%18 = and i32 %17, 1
%19 = icmp eq i32 %18, 0
%20 = select i1 %15, i1 %19, i1 false
%21 = select i1 %15, i1 true, i1 %19
%22 = select i1 %21, i32 32, i32 42
%23 = select i1 %20, i32 42, i32 %22
%24 = call i32 @putchar(i32 %23)
%25 = add nuw nsw i32 %17, 1
%26 = load i32, i32* %3
%27 = icmp slt i32 %25, %26
br i1 %27, label %16, label %28
28: ; preds = %16, %9
%29 = call i32 @putchar(i32 10)
%30 = add nuw nsw i32 %11, 1
%31 = load i32, i32* %3
%32 = icmp slt i32 %30, %31
br i1 %32, label %9, label %33
33: ; preds = %28, %2
%34 = load i32, i32* @EXIT_SUCCESS
ret i32 %34
}