#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 size, counter;
  int rowCounter = 1;
  scanf("%d", &size);
  for (int row = size; row > 1; row--, rowCounter++) {
    counter = (size * size) - (size * rowCounter + 2);
    for (int column = 1; column < row; column++, counter++) {
      printf("%d ", counter);
    }
    if (counter < 0) {
      counter *= -1;
    }
    printf("%d\n", counter);
  }
  printf("1\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jle    11e0 <main+0xc0>
mov    -0x8(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    $0x2,%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a7 <main+0x87>
mov    -0xc(%rbp),%esi
lea    0xe7a(%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    1173 <main+0x53>
cmpl   $0x0,-0xc(%rbp)
jge    11b8 <main+0x98>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114c <main+0x2c>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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
push   %rax
lea    0xebe(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r15d
cmp    $0x2,%r15d
jl     11b7 <main+0x87>
mov    $0x1,%r13d
lea    0xe9f(%rip),%r12
lea    0xe9c(%rip),%r14
mov    %r15d,%eax
xchg   %ax,%ax
mov    %eax,%ebp
sub    %r13d,%ebp
imul   %eax,%ebp
add    $0xfffffffe,%ebp
mov    %r15d,%ebx
xchg   %ax,%ax
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
cmp    %ebx,%r13d
jne    1180 <main+0x50>
mov    %ebp,%esi
neg    %esi
cmovs  %ebp,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13d
cmp    %r15d,%r13d
je     11b7 <main+0x87>
mov    0x4(%rsp),%eax
jmp    1170 <main+0x40>
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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"
@.str.3 = [3 x i8] c"1\0A\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* %4
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
store i32 %8, i32* %5
br label %9
9: ; preds = %42, %0
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %47
12: ; preds = %9
%13 = load i32, i32* %2
%14 = load i32, i32* %2
%15 = mul nsw i32 %13, %14
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = mul nsw i32 %16, %17
%19 = add nsw i32 %18, 2
%20 = sub nsw i32 %15, %19
store i32 %20, i32* %3
store i32 1, i32* %6
br label %21
21: ; preds = %28, %12
%22 = load i32, i32* %6
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %33
25: ; preds = %21
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %21
33: ; preds = %21
%34 = load i32, i32* %3
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %3
%38 = mul nsw i32 %37, -1
store i32 %38, i32* %3
br label %39
39: ; preds = %36, %33
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %39
%43 = load i32, i32* %5
%44 = add nsw i32 %43, -1
store i32 %44, i32* %5
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %9
47: ; preds = %9
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
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"
@str = [2 x i8] c"1\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 = icmp sgt i32 %4, 1
br i1 %5, label %8, label %6
6: ; preds = %15, %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret i32 0
8: ; preds = %0, %20
%9 = phi i32 [ %22, %20 ], [ %4, %0 ]
%10 = phi i32 [ %21, %20 ], [ %4, %0 ]
%11 = phi i32 [ %18, %20 ], [ 1, %0 ]
%12 = sub i32 %9, %11
%13 = mul i32 %12, %9
%14 = add i32 %13, -2
br label %23
15: ; preds = %23
%16 = call i32 @llvm.abs.i32(i32 %28, i1 true)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i32 %11, 1
%19 = icmp eq i32 %18, %4
br i1 %19, label %6, label %20
20: ; preds = %15
%21 = add nsw i32 %10, -1
%22 = load i32, i32* %1
br label %8
23: ; preds = %8, %23
%24 = phi i32 [ %27, %23 ], [ 1, %8 ]
%25 = phi i32 [ %28, %23 ], [ %14, %8 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = add nuw nsw i32 %24, 1
%28 = add nsw i32 %25, 1
%29 = icmp eq i32 %27, %10
br i1 %29, label %15, label %23
}