#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);
int /*<<< orphan*/ scanf(char *, int *);
int start(int);
int main() {
  int size;
  int count = 0;
  scanf("%d", &size);
  count = start(size);
  for (int i = 1; i <= size; i++) {
    for (int j = 1; j <= size - i; j++) {
      printf("%d ", count);
      count += 1;
    }
    printf("%d\n", count);
    count = start(size - i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1040 <start@plt>
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11dd <main+0xad>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jg     11b2 <main+0x82>
mov    -0xc(%rbp),%esi
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117b <main+0x4b>
mov    -0xc(%rbp),%esi
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
sub    -0x10(%rbp),%edi
call   1040 <start@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1168 <main+0x38>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
call   1040 <start@plt>
mov    %eax,%r12d
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11df <main+0xaf>
mov    $0x1,%r13d
lea    0xe94(%rip),%r15
lea    0xe91(%rip),%r14
jmp    11aa <main+0x7a>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
mov    0xc(%rsp),%edi
sub    %r13d,%edi
call   1040 <start@plt>
mov    %eax,%r12d
lea    0x1(%r13),%ecx
mov    0xc(%rsp),%eax
cmp    %eax,%r13d
mov    %ecx,%r13d
jge    11df <main+0xaf>
cmp    %r13d,%eax
jle    1180 <main+0x50>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
sub    %r13d,%eax
add    $0x1,%ebx
cmp    %eax,%ebx
jl     11c0 <main+0x90>
add    %ebx,%r12d
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [4 x i8] c"%d\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
store i32 0, i32* %3
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = call i32 @start(i32 %7)
store i32 %8, i32* %3
store i32 1, i32* %4
br label %9
9: ; preds = %35, %0
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %38
13: ; preds = %9
store i32 1, i32* %5
br label %14
14: ; preds = %25, %13
%15 = load i32, i32* %5
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = sub nsw i32 %16, %17
%19 = icmp sle i32 %15, %18
br i1 %19, label %20, label %28
20: ; preds = %14
%21 = load i32, i32* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %25
25: ; preds = %20
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %14
28: ; preds = %14
%29 = load i32, i32* %3
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %2
%32 = load i32, i32* %4
%33 = sub nsw i32 %31, %32
%34 = call i32 @start(i32 %33)
store i32 %34, i32* %3
br label %35
35: ; preds = %28
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %9
38: ; preds = %9
ret i32 0
}

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