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


x86 assembly (clang, -O0):
<printf_trangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11af <printf_trangle+0x9f>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    1160 <printf_trangle+0x50>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1135 <printf_trangle+0x25>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1195 <printf_trangle+0x85>
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <printf_trangle+0x57>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <printf_trangle+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf_trangle>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
jle    119a <printf_trangle+0x8a>
mov    %edi,%r14d
mov    $0x1,%r15d
mov    $0x1,%r12d
nopl   0x0(%rax,%rax,1)
cmp    $0x2,%r15d
mov    $0x1,%ebp
cmovge %r15d,%ebp
cmp    %r14d,%r12d
jge    1170 <printf_trangle+0x60>
mov    %r14d,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    %ebx,%r12d
jne    1150 <printf_trangle+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1170 <printf_trangle+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r12),%eax
add    $0x2,%r15d
cmp    %r14d,%r12d
mov    %eax,%r12d
jne    1130 <printf_trangle+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 @printf_trangle(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %5
5: ; preds = %35, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp sle i32 %6, %7
br i1 %8, label %9, label %38
9: ; preds = %5
store i32 0, i32* %4
br label %10
10: ; preds = %18, %9
%11 = load i32, i32* %4
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = sub nsw i32 %12, %13
%15 = icmp slt i32 %11, %14
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %10
21: ; preds = %10
store i32 0, i32* %4
br label %22
22: ; preds = %30, %21
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = mul nsw i32 2, %24
%26 = sub nsw i32 %25, 1
%27 = icmp slt i32 %23, %26
br i1 %27, label %28, label %33
28: ; preds = %22
%29 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %22
33: ; preds = %22
%34 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %5
38: ; preds = %5
ret void
}

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