#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stderr;
int main() {
  int height;
  printf("Right Triangle of * \n");
  printf("\n");
  printf("Maximum Permissible Height = 40 \n");
  printf("Height of Triangle = ");
  scanf("%d", &height);
  printf("\n");
  if (height > 40) {
    fprintf(stderr, "Height > 40 \nAborting! \n");
    return -1;
  }
  int i, j;
  for (i = 1; i <= height; i++) {
    for (j = 1; j <= i; j++) {
      printf("*");
    }
    printf("\n");
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xf16(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xee2(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x28,-0x8(%rbp)
jle    11b6 <main+0x86>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1223 <main+0xf3>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1210 <main+0xe0>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11f6 <main+0xc6>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d0 <main+0xa0>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11bd <main+0x8d>
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xed8(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe84(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
cmp    $0x28,%eax
jle    11c1 <main+0x71>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    1210 <main+0xc0>
test   %eax,%eax
jle    1204 <main+0xb4>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebx,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11e0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%eax
cmp    0x4(%rsp),%ebx
mov    %eax,%ebx
jl     11d0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Right Triangle of * \0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [34 x i8] c"Maximum Permissible Height = 40 \0A\00"
@.str.3 = [22 x i8] c"Height of Triangle = \00"
@.str.4 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.5 = [25 x i8] c"Height > 40 \0AAborting! \0A\00"
@.str.6 = [2 x i8] c"*\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%10 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 40
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %38
16: ; preds = %0
store i32 1, i32* %3
br label %17
17: ; preds = %33, %16
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %36
21: ; preds = %17
store i32 1, i32* %4
br label %22
22: ; preds = %28, %21
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %28
28: ; preds = %26
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %22
31: ; preds = %22
%32 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %17
36: ; preds = %17
%37 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %38
38: ; preds = %36, %13
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str.3 = [22 x i8] c"Height of Triangle = \00"
@.str.4 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.5 = [25 x i8] c"Height > 40 \0AAborting! \0A\00"
@str = [21 x i8] c"Right Triangle of * \00"
@str.7 = [33 x i8] c"Maximum Permissible Height = 40 \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @putchar(i32 10)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.7, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%8 = call i32 @putchar(i32 10)
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 40
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = icmp slt i32 %9, 1
br i1 %12, label %30, label %16
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %32
16: ; preds = %11, %24
%17 = phi i32 [ %29, %24 ], [ 2, %11 ]
%18 = phi i32 [ %26, %24 ], [ 1, %11 ]
br label %19
19: ; preds = %16, %19
%20 = phi i32 [ 1, %16 ], [ %22, %19 ]
%21 = call i32 @putchar(i32 42)
%22 = add nuw i32 %20, 1
%23 = icmp eq i32 %22, %17
br i1 %23, label %24, label %19
24: ; preds = %19
%25 = call i32 @putchar(i32 10)
%26 = add nuw nsw i32 %18, 1
%27 = load i32, i32* %1
%28 = icmp slt i32 %18, %27
%29 = add nuw i32 %17, 1
br i1 %28, label %16, label %30
30: ; preds = %24, %11
%31 = call i32 @putchar(i32 10)
br label %32
32: ; preds = %30, %13
%33 = phi i32 [ -1, %13 ], [ 0, %30 ]
ret i32 %33
}