#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 x, i, n, y;
  printf("n=");
  scanf("%d", &n);
  for (i = 0; i <= n; i++) {
    for (y = 0, x = n - i; y <= 2 * n; y++) {
      if (y >= x && y <= n + i) {
        printf("0");
      } else {
        printf("");
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11e6 <main+0xc6>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jg     11cc <main+0xac>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     11ad <main+0x8d>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jg     11ad <main+0x8d>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    11b9 <main+0x99>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
jmp    11be <main+0x9e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <main+0x4e>
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <main+0x32>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
js     11c6 <main+0x96>
xor    %r14d,%r14d
jmp    118a <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r14),%ecx
mov    0xc(%rsp),%eax
cmp    %r14d,%eax
mov    %ecx,%r14d
jle    11c6 <main+0x96>
test   %eax,%eax
js     1170 <main+0x40>
mov    %eax,%ebp
sub    %r14d,%ebp
mov    $0xffffffff,%ebx
jmp    11a7 <main+0x77>
nopw   0x0(%rax,%rax,1)
lea    (%rax,%rax,1),%ecx
cmp    %ecx,%ebx
jge    1170 <main+0x40>
add    $0x1,%ebx
cmp    %ebp,%ebx
jl     11a0 <main+0x70>
lea    (%rax,%r14,1),%ecx
cmp    %ecx,%ebx
jg     11a0 <main+0x70>
mov    $0x30,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
jmp    11a0 <main+0x70>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"n=\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 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, 0
br i1 %6, label %32, label %7
7: ; preds = %0, %27
%8 = phi i32 [ %30, %27 ], [ %5, %0 ]
%9 = phi i32 [ %29, %27 ], [ 0, %0 ]
%10 = sub nsw i32 %8, %9
%11 = icmp slt i32 %8, 0
br i1 %11, label %27, label %12
12: ; preds = %7, %22
%13 = phi i32 [ %23, %22 ], [ %8, %7 ]
%14 = phi i32 [ %24, %22 ], [ 0, %7 ]
%15 = icmp slt i32 %14, %10
%16 = add nsw i32 %13, %9
%17 = icmp sgt i32 %14, %16
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %22, label %19
19: ; preds = %12
%20 = call i32 @putchar(i32 48)
%21 = load i32, i32* %1
br label %22
22: ; preds = %12, %19
%23 = phi i32 [ %13, %12 ], [ %21, %19 ]
%24 = add nuw nsw i32 %14, 1
%25 = shl nsw i32 %23, 1
%26 = icmp slt i32 %14, %25
br i1 %26, label %12, label %27
27: ; preds = %22, %7
%28 = call i32 @putchar(i32 10)
%29 = add nuw nsw i32 %9, 1
%30 = load i32, i32* %1
%31 = icmp sgt i32 %30, %9
br i1 %31, label %7, label %32
32: ; preds = %27, %0
ret i32 0
}