#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 *);
void printTriangle(int a) {
  int i, j, k;
  for (i = 0; i <= a; i++) {
    for (j = a; j >= 0; j--) {
      printf(" ");
    }
    for (k = 0; k < 2 * i + 1; k++) {
      printf("*");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printTriangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11a7 <printTriangle+0x97>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1158 <printTriangle+0x48>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <printTriangle+0x24>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    118d <printTriangle+0x7d>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115f <printTriangle+0x4f>
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <printTriangle+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printTriangle>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
js     1189 <printTriangle+0x79>
mov    %edi,%r15d
lea    0x1(%r15),%r14d
xor    %r12d,%r12d
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
test   %ebx,%ebx
jg     1140 <printTriangle+0x30>
mov    %ebp,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1160 <printTriangle+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r12),%eax
add    $0x2,%ebp
cmp    %r15d,%r12d
mov    %eax,%r12d
jne    1130 <printTriangle+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"*\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @printTriangle(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %34, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %37
10: ; preds = %6
%11 = load i32, i32* %2
store i32 %11, i32* %4
br label %12
12: ; preds = %17, %10
%13 = load i32, i32* %4
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15
%18 = load i32, i32* %4
%19 = add nsw i32 %18, -1
store i32 %19, i32* %4
br label %12
20: ; preds = %12
store i32 0, i32* %5
br label %21
21: ; preds = %29, %20
%22 = load i32, i32* %5
%23 = load i32, i32* %3
%24 = mul nsw i32 2, %23
%25 = add nsw i32 %24, 1
%26 = icmp slt i32 %22, %25
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27
%30 = load i32, i32* %5
%31 = add nsw i32 %30, 1
store i32 %31, i32* %5
br label %21
32: ; preds = %21
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %32
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %6
37: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @printTriangle(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %21, label %3
3: ; preds = %1, %16
%4 = phi i32 [ %19, %16 ], [ 1, %1 ]
%5 = phi i32 [ %18, %16 ], [ 0, %1 ]
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ %9, %6 ], [ %0, %3 ]
%8 = tail call i32 @putchar(i32 32)
%9 = add nsw i32 %7, -1
%10 = icmp sgt i32 %7, 0
br i1 %10, label %6, label %11
11: ; preds = %6, %11
%12 = phi i32 [ %14, %11 ], [ 0, %6 ]
%13 = tail call i32 @putchar(i32 42)
%14 = add nuw i32 %12, 1
%15 = icmp eq i32 %14, %4
br i1 %15, label %16, label %11
16: ; preds = %11
%17 = tail call i32 @putchar(i32 10)
%18 = add nuw i32 %5, 1
%19 = add i32 %4, 2
%20 = icmp eq i32 %5, %0
br i1 %20, label %21, label %3
21: ; preds = %16, %1
ret void
}