#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, space, rows, k = 0, count = 0, count1 = 0;
  printf("Enter the number of rows: ");
  scanf("%d", &rows);
  for (i = 1; i <= rows; ++i) {
    for (space = 1; space <= rows - i; ++space) {
      printf(" ");
      ++count;
    }
    while (k != 2 * i - 1) {
      if (count <= rows - 1) {
        printf("%d ", (i + k));
        ++count;
      } else {
        ++count1;
        printf("%d ", (i + k - 2 * count1));
      }
      ++k;
    }
    count1 = count = k = 0;
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1262 <main+0x142>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jg     11b2 <main+0x92>
lea    0xe85(%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    117c <main+0x5c>
jmp    11b7 <main+0x97>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1231 <main+0x111>
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11fe <main+0xde>
mov    -0x8(%rbp),%esi
add    -0x14(%rbp),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1223 <main+0x103>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%esi
add    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
sub    %eax,%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b7 <main+0x97>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1169 <main+0x49>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    124c <main+0x11c>
mov    $0x1,%r13d
mov    $0xffffffff,%r14d
xor    %r15d,%r15d
jmp    11b0 <main+0x80>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r13),%ecx
mov    0xc(%rsp),%eax
mov    0x10(%rsp),%r15d
add    $0x2,%r15d
mov    0x14(%rsp),%r14d
add    $0x1,%r14d
cmp    %eax,%r13d
mov    %ecx,%r13d
jge    124c <main+0x11c>
xor    %ebp,%ebp
mov    $0x0,%ebx
cmp    %r13d,%eax
jle    11da <main+0xaa>
xor    %ebx,%ebx
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0xc(%rsp),%eax
mov    %eax,%ecx
sub    %r13d,%ecx
cmp    %ecx,%ebx
jl     11c0 <main+0x90>
mov    %r14d,0x14(%rsp)
mov    %r15d,0x10(%rsp)
cmp    %eax,%ebx
jge    1210 <main+0xe0>
nopl   0x0(%rax,%rax,1)
lea    0x2(%r14),%esi
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
sub    $0x1,%r15d
jae    123e <main+0x10e>
jmp    1180 <main+0x50>
mov    %ebp,%r12d
add    $0x1,%r12d
lea    0x2(%rbp,%rbp,1),%eax
mov    %r14d,%esi
sub    %eax,%esi
add    $0x2,%esi
lea    0xdf4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%ebp
sub    $0x1,%r15d
jb     1180 <main+0x50>
mov    0xc(%rsp),%eax
add    $0x1,%r14d
cmp    %eax,%ebx
jge    1210 <main+0xe0>
jmp    11f0 <main+0xc0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter the number of rows: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [4 x i8] c"%d \00"
@.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
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%9 = 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 %10
10: ; preds = %62, %0
%11 = load i32, i32* %2
%12 = load i32, i32* %4
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %65
14: ; preds = %10
store i32 1, i32* %3
br label %15
15: ; preds = %25, %14
%16 = load i32, i32* %3
%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 %28
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %25
25: ; preds = %21
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %15
28: ; preds = %15
br label %29
29: ; preds = %57, %28
%30 = load i32, i32* %5
%31 = load i32, i32* %2
%32 = mul nsw i32 2, %31
%33 = sub nsw i32 %32, 1
%34 = icmp ne i32 %30, %33
br i1 %34, label %35, label %60
35: ; preds = %29
%36 = load i32, i32* %6
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 1
%39 = icmp sle i32 %36, %38
br i1 %39, label %40, label %47
40: ; preds = %35
%41 = load i32, i32* %2
%42 = load i32, i32* %5
%43 = add nsw i32 %41, %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %57
47: ; preds = %35
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
%50 = load i32, i32* %2
%51 = load i32, i32* %5
%52 = add nsw i32 %50, %51
%53 = load i32, i32* %7
%54 = mul nsw i32 2, %53
%55 = sub nsw i32 %52, %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %47, %40
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %29
60: ; preds = %29
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60
%63 = load i32, i32* %2
%64 = add nsw i32 %63, 1
store i32 %64, i32* %2
br label %10
65: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter the number of rows: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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 %53, label %7
7: ; preds = %0, %48
%8 = phi i32 [ %51, %48 ], [ %5, %0 ]
%9 = phi i32 [ %50, %48 ], [ 1, %0 ]
%10 = icmp sgt i32 %8, %9
br i1 %10, label %16, label %11
11: ; preds = %16, %7
%12 = phi i32 [ %8, %7 ], [ %22, %16 ]
%13 = phi i32 [ 0, %7 ], [ %20, %16 ]
%14 = shl nuw nsw i32 %9, 1
%15 = add nsw i32 %14, -1
br label %25
16: ; preds = %7, %16
%17 = phi i32 [ %20, %16 ], [ 0, %7 ]
%18 = phi i32 [ %21, %16 ], [ 1, %7 ]
%19 = call i32 @putchar(i32 32)
%20 = add nuw nsw i32 %17, 1
%21 = add nuw nsw i32 %18, 1
%22 = load i32, i32* %1
%23 = sub nsw i32 %22, %9
%24 = icmp slt i32 %18, %23
br i1 %24, label %16, label %11
25: ; preds = %46, %11
%26 = phi i32 [ %12, %11 ], [ %47, %46 ]
%27 = phi i32 [ 0, %11 ], [ %43, %46 ]
%28 = phi i32 [ %13, %11 ], [ %42, %46 ]
%29 = phi i32 [ 0, %11 ], [ %44, %46 ]
%30 = icmp slt i32 %28, %26
br i1 %30, label %31, label %35
31: ; preds = %25
%32 = add nuw nsw i32 %29, %9
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = add nsw i32 %28, 1
br label %41
35: ; preds = %25
%36 = add nsw i32 %27, 1
%37 = add nuw nsw i32 %29, %9
%38 = mul i32 %36, -2
%39 = add i32 %37, %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %35, %31
%42 = phi i32 [ %34, %31 ], [ %28, %35 ]
%43 = phi i32 [ %27, %31 ], [ %36, %35 ]
%44 = add nuw nsw i32 %29, 1
%45 = icmp eq i32 %44, %15
br i1 %45, label %48, label %46
46: ; preds = %41
%47 = load i32, i32* %1
br label %25
48: ; preds = %41
%49 = call i32 @putchar(i32 10)
%50 = add nuw nsw i32 %9, 1
%51 = load i32, i32* %1
%52 = icmp slt i32 %9, %51
br i1 %52, label %7, label %53
53: ; preds = %48, %0
ret i32 0
}