#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 height = 0;
  int j;
  do {
    printf("Enter desired height of pyramid (2 > h > 23): ");
    scanf("%d", &height);
    if (height == 0)
      return 0;
  } while (height > 23 || height < 1);
  for (int i = 0; i < height; i++) {
    for (j = height - i - 1; j--; printf(" "))
      ;
    for (j = i + 1; j--; printf("#"))
      ;
    printf("  ");
    for (j = i + 1; j--; printf("#"))
      ;
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1168 <main+0x48>
movl   $0x0,-0x4(%rbp)
jmp    126d <main+0x14d>
jmp    116d <main+0x4d>
mov    $0x1,%al
cmpl   $0x17,-0x8(%rbp)
mov    %al,-0x11(%rbp)
jg     1186 <main+0x66>
cmpl   $0x1,-0x8(%rbp)
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1136 <main+0x16>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1266 <main+0x146>
mov    -0x8(%rbp),%eax
sub    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     11da <main+0xba>
jmp    11c9 <main+0xa9>
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
jmp    11b0 <main+0x90>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     120d <main+0xed>
jmp    11fc <main+0xdc>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
jmp    11e3 <main+0xc3>
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     124c <main+0x12c>
jmp    123b <main+0x11b>
lea    0xdf0(%rip),%rdi
call   1030 <printf@plt>
jmp    1222 <main+0x102>
lea    0xde4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1198 <main+0x78>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeba(%rip),%r14
lea    0xee2(%rip),%r15
lea    0x4(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ebx
test   %ebx,%ebx
je     1214 <main+0xe4>
lea    -0x18(%rbx),%eax
cmp    $0xffffffe9,%eax
jb     1160 <main+0x30>
xor    %ebp,%ebp
mov    $0xffffffff,%r15d
lea    0xe9c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%eax
not    %eax
add    %ebx,%eax
je     11c1 <main+0x91>
add    $0xffffffff,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    %ebx,%ebp
jne    11b0 <main+0x80>
add    $0x1,%ebp
mov    %r15d,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x23,%edi
call   1030 <putchar@plt>
inc    %ebx
jne    11d0 <main+0xa0>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15d,%ebx
nopl   0x0(%rax)
mov    $0x23,%edi
call   1030 <putchar@plt>
inc    %ebx
jne    11f0 <main+0xc0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%ebx
add    $0xffffffff,%r15d
cmp    %ebp,%ebx
jg     11a0 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Enter desired height of pyramid (2 > h > 23): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"#\00"
@.str.4 = [3 x i8] c" \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %5
5: ; preds = %18, %0
%6 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %5
store i32 0, i32* %1
br label %64
11: ; preds = %5
br label %12
12: ; preds = %11
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 23
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 1
br label %18
18: ; preds = %15, %12
%19 = phi i1 [ true, %12 ], [ %17, %15 ]
br i1 %19, label %5, label %20
20: ; preds = %18
store i32 0, i32* %4
br label %21
21: ; preds = %60, %20
%22 = load i32, i32* %4
%23 = load i32, i32* %2
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %63
25: ; preds = %21
%26 = load i32, i32* %2
%27 = load i32, i32* %4
%28 = sub nsw i32 %26, %27
%29 = sub nsw i32 %28, 1
store i32 %29, i32* %3
br label %30
30: ; preds = %35, %25
%31 = load i32, i32* %3
%32 = add nsw i32 %31, -1
store i32 %32, i32* %3
%33 = icmp ne i32 %31, 0
br i1 %33, label %34, label %37
34: ; preds = %30
br label %35
35: ; preds = %34
%36 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %30
37: ; preds = %30
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %40
40: ; preds = %45, %37
%41 = load i32, i32* %3
%42 = add nsw i32 %41, -1
store i32 %42, i32* %3
%43 = icmp ne i32 %41, 0
br i1 %43, label %44, label %47
44: ; preds = %40
br label %45
45: ; preds = %44
%46 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %40
47: ; preds = %40
%48 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %51
51: ; preds = %56, %47
%52 = load i32, i32* %3
%53 = add nsw i32 %52, -1
store i32 %53, i32* %3
%54 = icmp ne i32 %52, 0
br i1 %54, label %55, label %58
55: ; preds = %51
br label %56
56: ; preds = %55
%57 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %51
58: ; preds = %51
%59 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %60
60: ; preds = %58
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %21
63: ; preds = %21
store i32 0, i32* %1
br label %64
64: ; preds = %63, %10
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
@.str = [47 x i8] c"Enter desired height of pyramid (2 > h > 23): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c" \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %8, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 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 eq i32 %6, 0
br i1 %7, label %40, label %8
8: ; preds = %3
%9 = add i32 %6, -24
%10 = icmp ult i32 %9, -23
br i1 %10, label %3, label %11
11: ; preds = %8, %36
%12 = phi i32 [ %38, %36 ], [ %6, %8 ]
%13 = phi i32 [ %23, %36 ], [ 0, %8 ]
%14 = xor i32 %13, -1
%15 = add i32 %12, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %11, %17
%18 = phi i32 [ %19, %17 ], [ %15, %11 ]
%19 = add nsw i32 %18, -1
%20 = call i32 @putchar(i32 32)
%21 = icmp eq i32 %19, 0
br i1 %21, label %22, label %17
22: ; preds = %17, %11
%23 = add nuw nsw i32 %13, 1
br label %24
24: ; preds = %22, %24
%25 = phi i32 [ %23, %22 ], [ %26, %24 ]
%26 = add nsw i32 %25, -1
%27 = call i32 @putchar(i32 35)
%28 = icmp eq i32 %26, 0
br i1 %28, label %29, label %24
29: ; preds = %24
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %31
%32 = phi i32 [ %23, %29 ], [ %33, %31 ]
%33 = add nsw i32 %32, -1
%34 = call i32 @putchar(i32 35)
%35 = icmp eq i32 %33, 0
br i1 %35, label %36, label %31
36: ; preds = %31
%37 = call i32 @putchar(i32 10)
%38 = load i32, i32* %1
%39 = icmp sgt i32 %38, %23
br i1 %39, label %11, label %40
40: ; preds = %3, %36
ret i32 0
}