#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(void) {
  int pH, n;
  char octothorpe = '#';
  char space = ' ';
  do {
    printf("How tall should the pyramid be, between 0 and 23?\n");
    scanf("%i", &pH);
  } while (pH < 0 || pH > 23);
  for (n = 1; n <= pH; n++) {
    for (int i = 0; i < (pH + 1); i++) {
      if (i < (pH - n)) {
        printf("%c", space);
      } else {
        printf("%c", octothorpe);
      }
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x23,-0xd(%rbp)
movb   $0x20,-0xe(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x15(%rbp)
jl     116e <main+0x4e>
cmpl   $0x17,-0x8(%rbp)
setg   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1137 <main+0x17>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     120d <main+0xed>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11f1 <main+0xd1>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    11cc <main+0xac>
movsbl -0xe(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11de <main+0xbe>
movsbl -0xd(%rbp),%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e3 <main+0xc3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <main+0x73>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1180 <main+0x60>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%r14
lea    0xebb(%rip),%r15
lea    0x4(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x17,%eax
ja     1150 <main+0x20>
test   %eax,%eax
je     11c1 <main+0x91>
mov    $0x1,%ebx
jmp    1197 <main+0x67>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%ecx
mov    0x4(%rsp),%eax
cmp    %eax,%ebx
mov    %ecx,%ebx
jge    11c1 <main+0x91>
test   %eax,%eax
js     1180 <main+0x50>
mov    $0xffffffff,%ebp
add    $0x1,%ebp
sub    %ebx,%eax
xor    %ecx,%ecx
cmp    %eax,%ebp
setge  %cl
lea    (%rcx,%rcx,2),%edi
or     $0x20,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
cmp    %eax,%ebp
jl     11a0 <main+0x70>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"How tall should the pyramid be, between 0 and 23?\0A\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
store i32 0, i32* %1
store i8 35, i8* %4
store i8 32, i8* %5
br label %7
7: ; preds = %16, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 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* %2)
br label %10
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 23
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ true, %10 ], [ %15, %13 ]
br i1 %17, label %7, label %18
18: ; preds = %16
store i32 1, i32* %3
br label %19
19: ; preds = %49, %18
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %52
23: ; preds = %19
store i32 0, i32* %6
br label %24
24: ; preds = %44, %23
%25 = load i32, i32* %6
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %47
29: ; preds = %24
%30 = load i32, i32* %6
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = sub nsw i32 %31, %32
%34 = icmp slt i32 %30, %33
br i1 %34, label %35, label %39
35: ; preds = %29
%36 = load i8, i8* %5
%37 = sext i8 %36 to i32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %37)
br label %43
39: ; preds = %29
%40 = load i8, i8* %4
%41 = sext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %39, %35
br label %44
44: ; preds = %43
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %24
47: ; preds = %24
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %47
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
br label %19
52: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%i\00"
@str = [50 x i8] c"How tall should the pyramid be, between 0 and 23?\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp ugt i32 %6, 23
br i1 %7, label %3, label %8
8: ; preds = %3
%9 = icmp eq i32 %6, 0
br i1 %9, label %29, label %10
10: ; preds = %8, %14
%11 = phi i32 [ %17, %14 ], [ %6, %8 ]
%12 = phi i32 [ %16, %14 ], [ 1, %8 ]
%13 = icmp slt i32 %11, 0
br i1 %13, label %14, label %19
14: ; preds = %19, %10
%15 = call i32 @putchar(i32 10)
%16 = add nuw nsw i32 %12, 1
%17 = load i32, i32* %1
%18 = icmp slt i32 %12, %17
br i1 %18, label %10, label %29
19: ; preds = %10, %19
%20 = phi i32 [ %27, %19 ], [ %11, %10 ]
%21 = phi i32 [ %26, %19 ], [ 0, %10 ]
%22 = sub nsw i32 %20, %12
%23 = icmp slt i32 %21, %22
%24 = select i1 %23, i32 32, i32 35
%25 = call i32 @putchar(i32 %24)
%26 = add nuw nsw i32 %21, 1
%27 = load i32, i32* %1
%28 = icmp slt i32 %21, %27
br i1 %28, label %19, label %14
29: ; preds = %14, %8
ret i32 0
}