#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, j, h, b, count = 1;
  printf("Enter the height\n");
  scanf("%d", &h);
  for (i = 1; i <= h; i++) {
    printf("\n");
    for (b = 1; b <= h - i; b++) {
      printf(" ");
    }
    for (j = 1; j <= i; j++) {
      printf("%d", count % 2);
      count++;
    }
    if (i % 2 == 0)
      count = 1;
    else
      count = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x18(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1228 <main+0x108>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jg     11a9 <main+0x89>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117c <main+0x5c>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ee <main+0xce>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b0 <main+0x90>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    120e <main+0xee>
movl   $0x1,-0x18(%rbp)
jmp    1215 <main+0xf5>
movl   $0x0,-0x18(%rbp)
jmp    121a <main+0xfa>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <main+0x3b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
lea    0xea5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11f7 <main+0xb7>
mov    $0x1,%r15d
lea    0xe83(%rip),%r14
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    %r15d,0x4(%rsp)
jle    11b8 <main+0x78>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
sub    %r15d,%eax
add    $0x1,%ebx
cmp    %eax,%ebx
jl     11a0 <main+0x60>
mov    %r15d,%r12d
and    $0x1,%r12d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%esi
and    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%r15d
jne    11d0 <main+0x90>
lea    0x1(%r15),%eax
cmp    0x4(%rsp),%r15d
mov    %eax,%r15d
jl     1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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