#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 tree(int rows) {
  int i, space, k = 0;
  for (i = 1; i <= rows; i++) {
    for (space = 1; space <= rows - i; space++) {
      printf(" ");
    }
    do {
      printf("*");
      k++;
    } while (k < 2 * i - 1);
    k = 0;
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b6 <tree+0xa6>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jg     1167 <tree+0x57>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113c <tree+0x2c>
jmp    116c <tree+0x5c>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     116c <tree+0x5c>
movl   $0x0,-0x14(%rbp)
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1129 <tree+0x19>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

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

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