#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*/ draw_bottom_line(int, int);
int /*<<< orphan*/ draw_inner_line(int, int);
int /*<<< orphan*/ draw_top_line(int);
int /*<<< orphan*/ printf(char *);
void draw_tree(int n, int total_hashtags) {
  int bottom_line_length = 2 * n - 1;
  int spaces_count = bottom_line_length / 2 - 1, hashtags_count = 1;
  draw_top_line(spaces_count);
  printf("\n");
  for (int i = 1; i < n - 1; i++) {
    draw_inner_line(spaces_count, hashtags_count);
    printf("\n");
    spaces_count--;
    hashtags_count += 2;
  }
  draw_bottom_line(spaces_count, bottom_line_length);
  printf("\n");
}


x86 assembly (clang, -O0):
<draw_tree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%edi
call   1050 <draw_top_line@plt>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11d5 <draw_tree+0x95>
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <draw_inner_line@plt>
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118d <draw_tree+0x4d>
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <draw_bottom_line@plt>
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_tree>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
lea    (%r15,%r15,1),%r14d
add    $0xffffffff,%r14d
mov    %r14d,%eax
shr    $0x1f,%eax
lea    (%rax,%r15,2),%ebp
add    $0xffffffff,%ebp
sar    %ebp
add    $0xffffffff,%ebp
mov    %ebp,%edi
call   1050 <draw_top_line@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0x3,%r15d
jl     11af <draw_tree+0x6f>
add    $0xfffffffe,%r15d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <draw_inner_line@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
add    $0x2,%ebx
add    $0xffffffff,%r15d
jne    1190 <draw_tree+0x50>
mov    %ebp,%edi
mov    %r14d,%esi
call   1060 <draw_bottom_line@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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