#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 *);
void pr_stair(int n) {
  int i, k, j;
  for (k = 0; k <= n; k++) {
    for (j = 0; j <= n - k; j++)
      printf(" ");
    for (i = 0; i < k; i++)
      printf("#");
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<pr_stair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11a7 <pr_stair+0x97>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jg     1160 <pr_stair+0x50>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1135 <pr_stair+0x25>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118d <pr_stair+0x7d>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1167 <pr_stair+0x57>
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1122 <pr_stair+0x12>
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_stair>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
js     1181 <pr_stair+0x71>
mov    %edi,%r14d
lea    0x1(%r14),%ebp
xor    %r15d,%r15d
jmp    1149 <pr_stair+0x39>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r15),%eax
add    $0xffffffff,%ebp
cmp    %r14d,%r15d
mov    %eax,%r15d
je     1181 <pr_stair+0x71>
cmp    %r14d,%r15d
jg     1161 <pr_stair+0x51>
xor    %ebx,%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1150 <pr_stair+0x40>
mov    %r15d,%ebx
test   %r15d,%r15d
je     1130 <pr_stair+0x20>
nopl   0x0(%rax)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1170 <pr_stair+0x60>
jmp    1130 <pr_stair+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @pr_stair(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %26, label %3
3: ; preds = %1
%4 = add nuw i32 %0, 1
br label %5
5: ; preds = %3, %21
%6 = phi i32 [ %4, %3 ], [ %24, %21 ]
%7 = phi i32 [ 0, %3 ], [ %23, %21 ]
%8 = icmp sgt i32 %7, %0
br i1 %8, label %9, label %11
9: ; preds = %11, %5
%10 = icmp eq i32 %7, 0
br i1 %10, label %21, label %16
11: ; preds = %5, %11
%12 = phi i32 [ %14, %11 ], [ 0, %5 ]
%13 = tail call i32 @putchar(i32 32)
%14 = add nuw i32 %12, 1
%15 = icmp eq i32 %14, %6
br i1 %15, label %9, label %11
16: ; preds = %9, %16
%17 = phi i32 [ %19, %16 ], [ 0, %9 ]
%18 = tail call i32 @putchar(i32 35)
%19 = add nuw nsw i32 %17, 1
%20 = icmp eq i32 %19, %7
br i1 %20, label %21, label %16
21: ; preds = %16, %9
%22 = tail call i32 @putchar(i32 10)
%23 = add nuw i32 %7, 1
%24 = add i32 %6, -1
%25 = icmp eq i32 %7, %0
br i1 %25, label %26, label %5
26: ; preds = %21, %1
%27 = tail call i32 @putchar(i32 10)
ret void
}