#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 christmas_tree(int h) {
  int i, n, p;
  int last = 1;
  int chars = 1;
  for (i = 2; i <= h; i++) {
    last = last + 2;
  }
  int freespaces = last / 2;
  for (i = 1; i <= h; i++) {
    for (n = 1; n <= freespaces; n++) {
      printf(" ");
    }
    for (p = 1; p <= chars; p++) {
      printf("*");
    }
    chars = chars + 2;
    freespaces = freespaces - 1;
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<christmas_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1153 <christmas_tree+0x43>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1130 <christmas_tree+0x20>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11fa <christmas_tree+0xea>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11a1 <christmas_tree+0x91>
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <christmas_tree+0x6b>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11ce <christmas_tree+0xbe>
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a8 <christmas_tree+0x98>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1168 <christmas_tree+0x58>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<christmas_tree>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
cmp    $0x2,%edi
jge    112e <christmas_tree+0x1e>
xor    %r12d,%r12d
cmp    $0x1,%r14d
je     1139 <christmas_tree+0x29>
jmp    11ac <christmas_tree+0x9c>
lea    -0x1(%r14),%r12d
and    $0x7fffffff,%r12d
mov    $0x1,%ebx
mov    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %r12d,%r12d
jle    116f <christmas_tree+0x5f>
mov    %r12d,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1160 <christmas_tree+0x50>
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    1180 <christmas_tree+0x70>
add    $0xffffffff,%r12d
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r15),%eax
add    $0x2,%ebx
cmp    %r14d,%r15d
mov    %eax,%r15d
jne    1150 <christmas_tree+0x40>
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 @christmas_tree(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %6
store i32 1, i32* %7
store i32 2, i32* %3
br label %9
9: ; preds = %16, %1
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i32, i32* %6
%15 = add nsw i32 %14, 2
store i32 %15, i32* %6
br label %16
16: ; preds = %13
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %9
19: ; preds = %9
%20 = load i32, i32* %6
%21 = sdiv i32 %20, 2
store i32 %21, i32* %8
store i32 1, i32* %3
br label %22
22: ; preds = %52, %19
%23 = load i32, i32* %3
%24 = load i32, i32* %2
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %55
26: ; preds = %22
store i32 1, i32* %4
br label %27
27: ; preds = %33, %26
%28 = load i32, i32* %4
%29 = load i32, i32* %8
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %31
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %27
36: ; preds = %27
store i32 1, i32* %5
br label %37
37: ; preds = %43, %36
%38 = load i32, i32* %5
%39 = load i32, i32* %7
%40 = icmp sle i32 %38, %39
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %43
43: ; preds = %41
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %37
46: ; preds = %37
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 2
store i32 %48, i32* %7
%49 = load i32, i32* %8
%50 = sub nsw i32 %49, 1
store i32 %50, i32* %8
%51 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %46
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %22
55: ; preds = %22
ret void
}

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