#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int main(void) {
  printf("Insert height:");
  int height;
  char input[20];
  fgets(input, 20, stdin);
  if (!isdigit(input[0])) {
    printf("Only numbers are accepted\n");
    return -1;
  } else {
    sscanf(input, "%d", &height);
    while (height < 0 || height > 23) {
      printf("Minimum height is 0 and maximum is 23. Insert height:");
      fgets(input, 20, stdin);
      sscanf(input, "%d", &height);
    }
  }
  int i;
  int s;
  int h;
  for (i = 1; i <= height; i++) {
    for (s = 1; s <= (height - i); s++) {
      printf(" ");
    }
    for (h = 1; h <= i; h++) {
      printf("#");
    }
    printf("  ");
    for (h = 1; h <= i; h++) {
      printf("#");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeef(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    0x2e82(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1050 <fgets@plt>
movsbl -0x20(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    119c <main+0x5c>
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12df <main+0x19f>
lea    -0x20(%rbp),%rdi
lea    0xe74(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1060 <sscanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x2d(%rbp)
jl     11c9 <main+0x89>
cmpl   $0x17,-0x8(%rbp)
setg   %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    11d9 <main+0x99>
jmp    1215 <main+0xd5>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    0x2df8(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1050 <fgets@plt>
lea    -0x20(%rbp),%rdi
lea    0xe14(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1060 <sscanf@plt>
jmp    11b0 <main+0x70>
jmp    121a <main+0xda>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     12df <main+0x19f>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0x24(%rbp),%ecx
cmp    %ecx,%eax
jg     125f <main+0x11f>
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1234 <main+0xf4>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     128c <main+0x14c>
lea    0xddb(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1266 <main+0x126>
lea    0xdc3(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     12c5 <main+0x185>
lea    0xda2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    129f <main+0x15f>
lea    0xd4d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1221 <main+0xe1>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
lea    0xeb7(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e69(%rip),%r12
mov    (%r12),%edx
lea    0x10(%rsp),%rdi
mov    $0x14,%esi
call   1070 <fgets@plt>
movsbl 0x10(%rsp),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
je     12a8 <main+0x148>
lea    0xe55(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1080 <sscanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x18,%eax
jb     1210 <main+0xb0>
lea    0xe39(%rip),%r14
lea    0x10(%rsp),%rbp
lea    0xe2a(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1060 <printf@plt>
mov    (%r12),%edx
mov    %rbp,%rdi
mov    $0x14,%esi
call   1070 <fgets@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1080 <sscanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x17,%eax
ja     11e0 <main+0x80>
xor    %r14d,%r14d
test   %eax,%eax
je     12ba <main+0x15a>
mov    $0x1,%ebp
lea    0xe12(%rip),%r15
nopw   0x0(%rax,%rax,1)
cmp    %ebp,%eax
jle    1257 <main+0xf7>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
sub    %ebp,%eax
add    $0x1,%ebx
cmp    %eax,%ebx
jl     1240 <main+0xe0>
mov    %ebp,%ebx
nopl   0x0(%rax)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1260 <main+0x100>
mov    %r15,%rdi
call   1060 <printf@plt>
mov    %ebp,%ebx
nopl   0x0(%rax)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1280 <main+0x120>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%rbp),%ecx
mov    0xc(%rsp),%eax
cmp    %eax,%ebp
mov    %ecx,%ebp
jl     1230 <main+0xd0>
jmp    12ba <main+0x15a>
lea    0xd8d(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Insert height:\00"
@stdin = global i32 0
@.str.1 = [27 x i8] c"Only numbers are accepted\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [54 x i8] c"Minimum height is 0 and maximum is 23. Insert height:\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [2 x i8] c"#\00"
@.str.6 = [3 x i8] c" \00"
@.str.7 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %8, i32 20, i32 %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%12 = load i8, i8* %11
%13 = call i32 @isdigit(i8 signext %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %79
17: ; preds = %0
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %20
20: ; preds = %28, %17
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i32, i32* %2
%25 = icmp sgt i32 %24, 23
br label %26
26: ; preds = %23, %20
%27 = phi i1 [ true, %20 ], [ %25, %23 ]
br i1 %27, label %28, label %35
28: ; preds = %26
%29 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%31 = load i32, i32* @stdin
%32 = call i32 @fgets(i8* %30, i32 20, i32 %31)
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%34 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %20
35: ; preds = %26
br label %36
36: ; preds = %35
store i32 1, i32* %4
br label %37
37: ; preds = %76, %36
%38 = load i32, i32* %4
%39 = load i32, i32* %2
%40 = icmp sle i32 %38, %39
br i1 %40, label %41, label %79
41: ; preds = %37
store i32 1, i32* %5
br label %42
42: ; preds = %50, %41
%43 = load i32, i32* %5
%44 = load i32, i32* %2
%45 = load i32, i32* %4
%46 = sub nsw i32 %44, %45
%47 = icmp sle i32 %43, %46
br i1 %47, label %48, label %53
48: ; preds = %42
%49 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %48
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %42
53: ; preds = %42
store i32 1, i32* %6
br label %54
54: ; preds = %60, %53
%55 = load i32, i32* %6
%56 = load i32, i32* %4
%57 = icmp sle i32 %55, %56
br i1 %57, label %58, label %63
58: ; preds = %54
%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* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %54
63: ; preds = %54
%64 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %6
br label %65
65: ; preds = %71, %63
%66 = load i32, i32* %6
%67 = load i32, i32* %4
%68 = icmp sle i32 %66, %67
br i1 %68, label %69, label %74
69: ; preds = %65
%70 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %71
71: ; preds = %69
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
store i32 %73, i32* %6
br label %65
74: ; preds = %65
%75 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %76
76: ; preds = %74
%77 = load i32, i32* %4
%78 = add nsw i32 %77, 1
store i32 %78, i32* %4
br label %37
79: ; preds = %15, %37
%80 = load i32, i32* %1
ret i32 %80
}

LLVM IR (-O2):
@.str = [15 x i8] c"Insert height:\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [54 x i8] c"Minimum height is 0 and maximum is 23. Insert height:\00"
@.str.6 = [3 x i8] c" \00"
@str = [26 x i8] c"Only numbers are accepted\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 20, i32 %6)
%8 = load i8, i8* %5
%9 = call i32 @isdigit(i8 signext %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %58
13: ; preds = %0
%14 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp ugt i32 %15, 23
br i1 %16, label %20, label %17
17: ; preds = %20, %13
%18 = phi i32 [ %15, %13 ], [ %25, %20 ]
%19 = icmp eq i32 %18, 0
br i1 %19, label %58, label %27
20: ; preds = %13, %20
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* @stdin
%23 = call i32 @fgets(i8* %5, i32 20, i32 %22)
%24 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%25 = load i32, i32* %1
%26 = icmp ugt i32 %25, 23
br i1 %26, label %20, label %17
27: ; preds = %17, %52
%28 = phi i32 [ %55, %52 ], [ %18, %17 ]
%29 = phi i32 [ %57, %52 ], [ 2, %17 ]
%30 = phi i32 [ %54, %52 ], [ 1, %17 ]
%31 = icmp sgt i32 %28, %30
br i1 %31, label %32, label %39
32: ; preds = %27, %32
%33 = phi i32 [ %35, %32 ], [ 1, %27 ]
%34 = call i32 @putchar(i32 32)
%35 = add nuw nsw i32 %33, 1
%36 = load i32, i32* %1
%37 = sub nsw i32 %36, %30
%38 = icmp slt i32 %33, %37
br i1 %38, label %32, label %39
39: ; preds = %32, %27
br label %40
40: ; preds = %39, %40
%41 = phi i32 [ %43, %40 ], [ 1, %39 ]
%42 = call i32 @putchar(i32 35)
%43 = add nuw i32 %41, 1
%44 = icmp eq i32 %43, %29
br i1 %44, label %45, label %40
45: ; preds = %40
%46 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %47
47: ; preds = %45, %47
%48 = phi i32 [ 1, %45 ], [ %50, %47 ]
%49 = call i32 @putchar(i32 35)
%50 = add nuw i32 %48, 1
%51 = icmp eq i32 %50, %29
br i1 %51, label %52, label %47
52: ; preds = %47
%53 = call i32 @putchar(i32 10)
%54 = add nuw nsw i32 %30, 1
%55 = load i32, i32* %1
%56 = icmp slt i32 %30, %55
%57 = add nuw i32 %29, 1
br i1 %56, label %27, label %58
58: ; preds = %52, %17, %11
%59 = phi i32 [ -1, %11 ], [ 0, %17 ], [ 0, %52 ]
ret i32 %59
}