#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*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int x, y, n;
  puts("The story says:");
  printf("\tWrite a function that outputs a right-side-up triangle");
  printf("\n\tof height n and base width 2n-1\n\n");
  printf("So, how big should your triangle be? - ");
  scanf("%d", &n);
  if (n > 10)
    puts("Uhmm.. Sometimes too big is just too big!!..\n\n");
  else {
    for (y = 1; y <= n; y++) {
      for (x = 0; x < n - y; x++)
        putchar(' ');
      for (x = (n - y); x < (n - y) + (2 * y - 1); x++)
        putchar('*');
      putchar('\n');
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <puts@plt>
lea    0xeae(%rip),%rdi
call   1050 <printf@plt>
lea    0xeda(%rip),%rdi
call   1050 <printf@plt>
lea    0xef2(%rip),%rdi
call   1050 <printf@plt>
lea    0xf0e(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0xa,-0x10(%rbp)
jle    11aa <main+0x6a>
lea    0xef7(%rip),%rdi
call   1040 <puts@plt>
jmp    1247 <main+0x107>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1242 <main+0x102>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    11ed <main+0xad>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c4 <main+0x84>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    -0xc(%rbp),%ecx
mov    -0xc(%rbp),%edx
shl    $0x1,%edx
sub    $0x1,%edx
add    %edx,%ecx
cmp    %ecx,%eax
jge    122a <main+0xea>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f6 <main+0xb6>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11b1 <main+0x71>
jmp    1247 <main+0x107>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb5(%rip),%rdi
call   1050 <printf@plt>
lea    0xf3b(%rip),%rdi
call   1040 <puts@plt>
lea    0xed5(%rip),%rdi
call   1050 <printf@plt>
lea    0xef1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0xa,%eax
jle    11a3 <main+0x63>
lea    0xeda(%rip),%rdi
call   1040 <puts@plt>
jmp    1239 <main+0xf9>
test   %eax,%eax
jle    1239 <main+0xf9>
mov    $0x1,%r14d
jmp    11da <main+0x9a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r14),%ecx
mov    0xc(%rsp),%eax
cmp    %eax,%r14d
mov    %ecx,%r14d
jge    1239 <main+0xf9>
mov    %eax,%ebp
sub    %r14d,%ebp
jle    120a <main+0xca>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0xc(%rsp),%eax
mov    %eax,%ebp
sub    %r14d,%ebp
cmp    %ebp,%ebx
jl     11f0 <main+0xb0>
mov    %r14d,%ecx
not    %ecx
lea    (%rcx,%r14,2),%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %ebx,%eax
cmp    %eax,%ebp
jge    11c0 <main+0x80>
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0xc(%rsp),%eax
jmp    1220 <main+0xe0>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"The story says:\00"
@.str.1 = [56 x i8] c"\09Write a function that outputs a right-side-up triangle\00"
@.str.2 = [36 x i8] c"\0A\09of height n and base width 2n-1\0A\0A\00"
@.str.3 = [40 x i8] c"So, how big should your triangle be? - \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [47 x i8] c"Uhmm.. Sometimes too big is just too big!!..\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 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* %4)
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 10
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @puts(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
br label %56
14: ; preds = %0
store i32 1, i32* %3
br label %15
15: ; preds = %52, %14
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %55
19: ; preds = %15
store i32 0, i32* %2
br label %20
20: ; preds = %28, %19
%21 = load i32, i32* %2
%22 = load i32, i32* %4
%23 = load i32, i32* %3
%24 = sub nsw i32 %22, %23
%25 = icmp slt i32 %21, %24
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = call i32 @putchar(i8 signext 32)
br label %28
28: ; preds = %26
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %20
31: ; preds = %20
%32 = load i32, i32* %4
%33 = load i32, i32* %3
%34 = sub nsw i32 %32, %33
store i32 %34, i32* %2
br label %35
35: ; preds = %47, %31
%36 = load i32, i32* %2
%37 = load i32, i32* %4
%38 = load i32, i32* %3
%39 = sub nsw i32 %37, %38
%40 = load i32, i32* %3
%41 = mul nsw i32 2, %40
%42 = sub nsw i32 %41, 1
%43 = add nsw i32 %39, %42
%44 = icmp slt i32 %36, %43
br i1 %44, label %45, label %50
45: ; preds = %35
%46 = call i32 @putchar(i8 signext 42)
br label %47
47: ; preds = %45
%48 = load i32, i32* %2
%49 = add nsw i32 %48, 1
store i32 %49, i32* %2
br label %35
50: ; preds = %35
%51 = call i32 @putchar(i8 signext 10)
br label %52
52: ; preds = %50
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %15
55: ; preds = %15
br label %56
56: ; preds = %55, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"The story says:\00"
@.str.1 = [56 x i8] c"\09Write a function that outputs a right-side-up triangle\00"
@.str.3 = [40 x i8] c"So, how big should your triangle be? - \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [47 x i8] c"Uhmm.. Sometimes too big is just too big!!..\0A\0A\00"
@str = [35 x i8] c"\0A\09of height n and base width 2n-1\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 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 = load i32, i32* %1
%9 = icmp sgt i32 %8, 10
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = icmp slt i32 %8, 1
br i1 %11, label %46, label %14
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
br label %46
14: ; preds = %10, %41
%15 = phi i32 [ %44, %41 ], [ %8, %10 ]
%16 = phi i32 [ %43, %41 ], [ 1, %10 ]
%17 = sub nsw i32 %15, %16
%18 = icmp sgt i32 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %27, %14
%20 = phi i32 [ %15, %14 ], [ %31, %27 ]
%21 = phi i32 [ %17, %14 ], [ %32, %27 ]
%22 = shl nuw nsw i32 %16, 1
%23 = xor i32 %16, -1
%24 = add nsw i32 %22, %23
%25 = add i32 %24, %20
%26 = icmp slt i32 %21, %25
br i1 %26, label %34, label %41
27: ; preds = %14, %27
%28 = phi i32 [ %30, %27 ], [ 0, %14 ]
%29 = call i32 @putchar(i8 signext 32)
%30 = add nuw nsw i32 %28, 1
%31 = load i32, i32* %1
%32 = sub nsw i32 %31, %16
%33 = icmp slt i32 %30, %32
br i1 %33, label %27, label %19
34: ; preds = %19, %34
%35 = phi i32 [ %37, %34 ], [ %21, %19 ]
%36 = call i32 @putchar(i8 signext 42)
%37 = add nsw i32 %35, 1
%38 = load i32, i32* %1
%39 = add i32 %24, %38
%40 = icmp slt i32 %37, %39
br i1 %40, label %34, label %41
41: ; preds = %34, %19
%42 = call i32 @putchar(i8 signext 10)
%43 = add nuw nsw i32 %16, 1
%44 = load i32, i32* %1
%45 = icmp slt i32 %16, %44
br i1 %45, label %14, label %46
46: ; preds = %41, %10, %12
ret i32 0
}