#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() {
  int iter, i, j;
  printf("Cuantos niveles?\n");
  scanf("%d", &iter);
  for (i = 0; i < iter; i++) {
    int esp = iter - (i + 1);
    int ast = iter - esp;
    for (j = 0; j < esp; j++) {
      printf(" ");
    }
    for (j = 0; j < ast; j++) {
      printf("*");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e9 <main+0xc9>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a2 <main+0x82>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117c <main+0x5c>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11cf <main+0xaf>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a9 <main+0x89>
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <main+0x32>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    11c5 <main+0x95>
xor    %r14d,%r14d
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r14d
cmp    %r14d,%ebx
jle    1191 <main+0x61>
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    %ebx,%ebp
jne    1180 <main+0x50>
mov    %ebp,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11a0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%ebx
add    $0x1,%ebp
cmp    %ebx,%r14d
jl     1170 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Cuantos niveles?\0A\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 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %9
9: ; preds = %42, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %45
13: ; preds = %9
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
%17 = sub nsw i32 %14, %16
store i32 %17, i32* %5
%18 = load i32, i32* %2
%19 = load i32, i32* %5
%20 = sub nsw i32 %18, %19
store i32 %20, i32* %6
store i32 0, i32* %4
br label %21
21: ; preds = %27, %13
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %21
30: ; preds = %21
store i32 0, i32* %4
br label %31
31: ; preds = %37, %30
%32 = load i32, i32* %4
%33 = load i32, i32* %6
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %35
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %31
40: ; preds = %31
%41 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %40
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %9
45: ; preds = %9
ret i32 0
}

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