#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 getPositiveInt();
int /*<<< orphan*/ printf(char *);
int main(void) {
  int n = getPositiveInt();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int m = n - i;
      if (j <= m) {
        printf(" ");
      } else if (j == n) {
        printf("##\n");
      } else {
        printf("#");
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getPositiveInt@plt>
mov    %eax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11d9 <main+0xb9>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11c6 <main+0xa6>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1185 <main+0x65>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
jmp    11b3 <main+0x93>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11a2 <main+0x82>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
jmp    11ae <main+0x8e>
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
jmp    11b3 <main+0x93>
jmp    11b8 <main+0x98>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1153 <main+0x33>
jmp    11cb <main+0xab>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <main+0x20>
mov    -0x4(%rbp),%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
xor    %eax,%eax
call   1050 <getPositiveInt@plt>
test   %eax,%eax
jle    11b8 <main+0x88>
mov    %eax,%r14d
mov    %eax,%ebp
neg    %ebp
mov    $0x1,%r12d
lea    0xea6(%rip),%r15
jmp    116d <main+0x3d>
nopl   0x0(%rax)
lea    0x1(%r12),%eax
cmp    %r12d,%r14d
mov    %eax,%r12d
je     11b8 <main+0x88>
mov    %r14d,%r13d
sub    %r12d,%r13d
mov    $0x1,%ebx
jmp    119c <main+0x6c>
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     1160 <main+0x30>
cmp    %r13d,%ebx
jle    1180 <main+0x50>
mov    %ebp,%eax
add    %ebx,%eax
je     11ae <main+0x7e>
mov    $0x23,%edi
jmp    1185 <main+0x55>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    118a <main+0x5a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@str = [3 x i8] c"##\00"
define i32 @main() {
%1 = tail call i32 (...) @getPositiveInt()
%2 = icmp slt i32 %1, 1
br i1 %2, label %6, label %3
3: ; preds = %0, %7
%4 = phi i32 [ %8, %7 ], [ 1, %0 ]
%5 = sub nsw i32 %1, %4
br label %10
6: ; preds = %7, %0
ret i32 0
7: ; preds = %21
%8 = add nuw i32 %4, 1
%9 = icmp eq i32 %1, %4
br i1 %9, label %6, label %3
10: ; preds = %3, %21
%11 = phi i32 [ 1, %3 ], [ %22, %21 ]
%12 = icmp sgt i32 %11, %5
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @putchar(i32 32)
br label %21
15: ; preds = %10
%16 = icmp eq i32 %11, %1
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %21
19: ; preds = %15
%20 = tail call i32 @putchar(i32 35)
br label %21
21: ; preds = %17, %19, %13
%22 = add nuw i32 %11, 1
%23 = icmp eq i32 %11, %1
br i1 %23, label %7, label %10
}