#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 n, i, b, a, c;
  printf("Enter number:");
  scanf("%d", &n);
  b = 2 * n - 1;
  printf("\nEMPTY TRIANGLE\n\n");
  for (i = 1; i <= b; i += 2) {
    for (c = 0; c < (b - i) / 2; c++)
      printf(" ");
    printf("*");
    if (i == 1)
      printf("\n");
    for (a = 2; a <= i; a++) {
      if (i == b)
        printf("*");
      else if (a == i)
        printf("*\n");
      else
        printf(" ");
    }
  }
  printf("\n\nFILLED TRIANGLE\n\n");
  for (i = 1; i <= b; i += 2) {
    for (c = 0; c < (b - i) / 2; c++)
      printf(" ");
    for (a = 0; a < i; a++)
      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    0xecc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     125e <main+0x13e>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11b8 <main+0x98>
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117d <main+0x5d>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    11da <main+0xba>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     124b <main+0x12b>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    120a <main+0xea>
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
jmp    1238 <main+0x118>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1227 <main+0x107>
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
jmp    1233 <main+0x113>
lea    0xdf5(%rip),%rdi
call   1030 <printf@plt>
jmp    1238 <main+0x118>
jmp    123d <main+0x11d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e1 <main+0xc1>
jmp    1250 <main+0x130>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    116a <main+0x4a>
lea    0xdc5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1306 <main+0x1e6>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    12bf <main+0x19f>
lea    0xd77(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1284 <main+0x164>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12ec <main+0x1cc>
lea    0xd4c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12c6 <main+0x1a6>
lea    0xd49(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1271 <main+0x151>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeab(%rip),%rdi
call   1050 <printf@plt>
lea    0xead(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%ebx
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
jle    12c4 <main+0x184>
lea    (%rbx,%rbx,1),%eax
mov    %eax,0x8(%rsp)
mov    %rbx,0x10(%rsp)
lea    (%rbx,%rbx,1),%r14d
add    $0xffffffff,%r14d
mov    $0x1,%ebx
xor    %r15d,%r15d
lea    0xe8f(%rip),%r12
jmp    11cb <main+0x8b>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x2,%ebx
add    $0x2,%r15d
cmp    %ebx,0x8(%rsp)
jle    1247 <main+0x107>
mov    %r14d,%eax
sub    %ebx,%eax
cmp    $0x2,%eax
jl     11ef <main+0xaf>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11e0 <main+0xa0>
mov    $0x2a,%edi
call   1030 <putchar@plt>
cmp    $0x1,%ebx
je     11b0 <main+0x70>
mov    %r15d,%r13d
jmp    1220 <main+0xe0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r13d
je     11ba <main+0x7a>
cmp    %ebx,%r14d
je     1210 <main+0xd0>
cmp    $0x1,%r13d
jne    1240 <main+0x100>
mov    %r12,%rdi
call   1040 <puts@plt>
add    $0xffffffff,%r13d
jne    1220 <main+0xe0>
jmp    11ba <main+0x7a>
xchg   %ax,%ax
mov    $0x20,%edi
jmp    1215 <main+0xd5>
lea    0xdd4(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x10(%rsp)
jle    12d0 <main+0x190>
mov    $0x1,%ebx
nop
mov    %r14d,%eax
sub    %ebx,%eax
cmp    $0x2,%eax
jl     128f <main+0x14f>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1280 <main+0x140>
mov    %ebx,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    12a0 <main+0x160>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x2,%ebx
cmp    %ebx,0x8(%rsp)
jg     1260 <main+0x120>
jmp    12d0 <main+0x190>
lea    0xd57(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"\0AEMPTY TRIANGLE\0A\0A\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"*\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [3 x i8] c"*\0A\00"
@.str.7 = [20 x i8] c"\0A\0AFILLED TRIANGLE\0A\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 ([14 x i8], [14 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)
%9 = load i32, i32* %2
%10 = mul nsw i32 2, %9
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %4
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %13
13: ; preds = %61, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %64
17: ; preds = %13
store i32 0, i32* %6
br label %18
18: ; preds = %27, %17
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = sub nsw i32 %20, %21
%23 = sdiv i32 %22, 2
%24 = icmp slt i32 %19, %23
br i1 %24, label %25, label %30
25: ; preds = %18
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %18
30: ; preds = %18
%31 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %30
store i32 2, i32* %5
br label %37
37: ; preds = %57, %36
%38 = load i32, i32* %5
%39 = load i32, i32* %3
%40 = icmp sle i32 %38, %39
br i1 %40, label %41, label %60
41: ; preds = %37
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %56
47: ; preds = %41
%48 = load i32, i32* %5
%49 = load i32, i32* %3
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %55
53: ; preds = %47
%54 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %53, %51
br label %56
56: ; preds = %55, %45
br label %57
57: ; preds = %56
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
store i32 %59, i32* %5
br label %37
60: ; preds = %37
br label %61
61: ; preds = %60
%62 = load i32, i32* %3
%63 = add nsw i32 %62, 2
store i32 %63, i32* %3
br label %13
64: ; preds = %13
%65 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %66
66: ; preds = %95, %64
%67 = load i32, i32* %3
%68 = load i32, i32* %4
%69 = icmp sle i32 %67, %68
br i1 %69, label %70, label %98
70: ; preds = %66
store i32 0, i32* %6
br label %71
71: ; preds = %80, %70
%72 = load i32, i32* %6
%73 = load i32, i32* %4
%74 = load i32, i32* %3
%75 = sub nsw i32 %73, %74
%76 = sdiv i32 %75, 2
%77 = icmp slt i32 %72, %76
br i1 %77, label %78, label %83
78: ; preds = %71
%79 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %80
80: ; preds = %78
%81 = load i32, i32* %6
%82 = add nsw i32 %81, 1
store i32 %82, i32* %6
br label %71
83: ; preds = %71
store i32 0, i32* %5
br label %84
84: ; preds = %90, %83
%85 = load i32, i32* %5
%86 = load i32, i32* %3
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %93
88: ; preds = %84
%89 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %90
90: ; preds = %88
%91 = load i32, i32* %5
%92 = add nsw i32 %91, 1
store i32 %92, i32* %5
br label %84
93: ; preds = %84
%94 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %95
95: ; preds = %93
%96 = load i32, i32* %3
%97 = add nsw i32 %96, 2
store i32 %97, i32* %3
br label %66
98: ; preds = %66
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"Enter number:\00"
@.str.1 = [3 x i8] c"%d\00"
@str = [17 x i8] c"\0AEMPTY TRIANGLE\0A\00"
@str.8 = [19 x i8] c"\0A\0AFILLED TRIANGLE\0A\00"
@str.9 = [2 x i8] c"*\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 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 = shl nsw i32 %5, 1
%7 = add nsw i32 %6, -1
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%9 = icmp sgt i32 %5, 0
br i1 %9, label %12, label %10
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0))
br label %69
12: ; preds = %0, %43
%13 = phi i32 [ %46, %43 ], [ 2, %0 ]
%14 = phi i32 [ %44, %43 ], [ 1, %0 ]
%15 = sub nsw i32 %7, %14
%16 = sdiv i32 %15, 2
%17 = icmp sgt i32 %15, 1
br i1 %17, label %18, label %23
18: ; preds = %12, %18
%19 = phi i32 [ %21, %18 ], [ 0, %12 ]
%20 = call i32 @putchar(i32 32)
%21 = add nuw nsw i32 %19, 1
%22 = icmp eq i32 %21, %16
br i1 %22, label %23, label %18
23: ; preds = %18, %12
%24 = call i32 @putchar(i32 42)
%25 = icmp eq i32 %14, 1
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @putchar(i32 10)
br label %43
28: ; preds = %23
%29 = icmp eq i32 %7, %14
br label %30
30: ; preds = %28, %40
%31 = phi i32 [ 2, %28 ], [ %41, %40 ]
br i1 %29, label %32, label %34
32: ; preds = %30
%33 = call i32 @putchar(i32 42)
br label %40
34: ; preds = %30
%35 = icmp eq i32 %31, %14
br i1 %35, label %36, label %38
36: ; preds = %34
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.9, i64 0, i64 0))
br label %40
38: ; preds = %34
%39 = call i32 @putchar(i32 32)
br label %40
40: ; preds = %32, %38, %36
%41 = add nuw nsw i32 %31, 1
%42 = icmp eq i32 %41, %13
br i1 %42, label %43, label %30
43: ; preds = %40, %26
%44 = add nuw nsw i32 %14, 2
%45 = icmp sgt i32 %6, %44
%46 = add nuw i32 %13, 2
br i1 %45, label %12, label %47
47: ; preds = %43
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.8, i64 0, i64 0))
br i1 %9, label %49, label %69
49: ; preds = %47, %65
%50 = phi i32 [ %67, %65 ], [ 1, %47 ]
%51 = sub nsw i32 %7, %50
%52 = sdiv i32 %51, 2
%53 = icmp sgt i32 %51, 1
br i1 %53, label %54, label %59
54: ; preds = %49, %54
%55 = phi i32 [ %57, %54 ], [ 0, %49 ]
%56 = call i32 @putchar(i32 32)
%57 = add nuw nsw i32 %55, 1
%58 = icmp eq i32 %57, %52
br i1 %58, label %59, label %54
59: ; preds = %54, %49
br label %60
60: ; preds = %59, %60
%61 = phi i32 [ %63, %60 ], [ 0, %59 ]
%62 = call i32 @putchar(i32 42)
%63 = add nuw nsw i32 %61, 1
%64 = icmp eq i32 %63, %50
br i1 %64, label %65, label %60
65: ; preds = %60
%66 = call i32 @putchar(i32 10)
%67 = add nuw nsw i32 %50, 2
%68 = icmp sgt i32 %6, %67
br i1 %68, label %49, label %69
69: ; preds = %65, %10, %47
ret i32 0
}