#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int treeHeight = 0;
  while (treeHeight <= 0) {
    scanf("%d", &treeHeight);
  }
  int symbolCount = 0;
  int i;
  for (i = 1; i < treeHeight - 1; i++) {
    symbolCount += (i * 2) - 1;
  }
  printf("%d\n", symbolCount);
  int rowMaxSymbols = treeHeight * 2 - 1;
  int currentRowSpaces;
  int currentRowSymbols;
  int j;
  for (i = 0; i < treeHeight; i++) {
    currentRowSymbols = i * 2 + 1;
    currentRowSpaces = (rowMaxSymbols - currentRowSymbols) / 2;
    for (j = 0; j < currentRowSpaces; j++) {
      printf(" ");
    }
    for (j = 0; j < currentRowSymbols; j++) {
      if ((j == 0) || (j == currentRowSymbols - 1) || (i == treeHeight - 1)) {
        printf("*");
      } else {
        printf("#");
      }
    }
    currentRowSpaces = (rowMaxSymbols - currentRowSymbols) / 2;
    for (j = 0; j < currentRowSpaces; j++) {
      printf(" ");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1155 <main+0x35>
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1136 <main+0x16>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1191 <main+0x71>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1163 <main+0x43>
mov    -0xc(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12dc <main+0x1bc>
mov    -0x10(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    120d <main+0xed>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11e5 <main+0xc5>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1280 <main+0x160>
cmpl   $0x0,-0x20(%rbp)
je     124c <main+0x12c>
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     124c <main+0x12c>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    125f <main+0x13f>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126d <main+0x14d>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1272 <main+0x152>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1214 <main+0xf4>
mov    -0x14(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12c0 <main+0x1a0>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1298 <main+0x178>
lea    0xd3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b5 <main+0x95>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x4(%rsp)
lea    0xeb3(%rip),%r14
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1160 <main+0x30>
xor    %esi,%esi
cmp    $0x3,%eax
jb     118f <main+0x5f>
lea    (%rax,%rax,2),%ecx
lea    -0x3(%rax),%edx
add    $0xfffffffc,%eax
imul   %edx,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rcx,1),%esi
add    $0xfffffff8,%esi
lea    0xe6d(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
mov    %rax,0x8(%rsp)
test   %eax,%eax
jle    12a5 <main+0x175>
mov    0x8(%rsp),%rax
add    %eax,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%r12d
xor    %ebx,%ebx
jmp    11ef <main+0xbf>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
add    $0x2,%r12d
add    $0x2,%r15d
cmp    0x4(%rsp),%ebx
jge    12a5 <main+0x175>
mov    %ebx,%eax
not    %eax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,2),%eax
mov    %eax,%r13d
shr    $0x1f,%r13d
add    %eax,%r13d
sar    %r13d
mov    %r13d,%ebp
mov    %eax,0x14(%rsp)
cmp    $0x2,%eax
jl     122f <main+0xff>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1220 <main+0xf0>
xor    %r14d,%r14d
jmp    125a <main+0x12a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %r14d,%r15d
cmove  %eax,%edi
test   %r14d,%r14d
cmove  %eax,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
cmp    %r14d,%r12d
je     1280 <main+0x150>
mov    0x4(%rsp),%ecx
add    $0xffffffff,%ecx
mov    $0x2a,%eax
mov    $0x2a,%edi
cmp    %ecx,%ebx
je     1240 <main+0x110>
mov    $0x23,%edi
jmp    1240 <main+0x110>
cs nopw 0x0(%rax,%rax,1)
cmpl   $0x2,0x14(%rsp)
jl     11d0 <main+0xa0>
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r13d
jne    1290 <main+0x160>
jmp    11d0 <main+0xa0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"*\00"
@.str.4 = [2 x i8] c"#\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%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* %1
store i32 0, i32* %2
br label %9
9: ; preds = %12, %0
%10 = load i32, i32* %2
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %9
14: ; preds = %9
store i32 0, i32* %3
store i32 1, i32* %4
br label %15
15: ; preds = %26, %14
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = sub nsw i32 %17, 1
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %29
20: ; preds = %15
%21 = load i32, i32* %4
%22 = mul nsw i32 %21, 2
%23 = sub nsw i32 %22, 1
%24 = load i32, i32* %3
%25 = add nsw i32 %24, %23
store i32 %25, i32* %3
br label %26
26: ; preds = %20
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %15
29: ; preds = %15
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %2
%33 = mul nsw i32 %32, 2
%34 = sub nsw i32 %33, 1
store i32 %34, i32* %5
store i32 0, i32* %4
br label %35
35: ; preds = %98, %29
%36 = load i32, i32* %4
%37 = load i32, i32* %2
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %101
39: ; preds = %35
%40 = load i32, i32* %4
%41 = mul nsw i32 %40, 2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
%43 = load i32, i32* %5
%44 = load i32, i32* %7
%45 = sub nsw i32 %43, %44
%46 = sdiv i32 %45, 2
store i32 %46, i32* %6
store i32 0, i32* %8
br label %47
47: ; preds = %53, %39
%48 = load i32, i32* %8
%49 = load i32, i32* %6
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %56
51: ; preds = %47
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %51
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %47
56: ; preds = %47
store i32 0, i32* %8
br label %57
57: ; preds = %79, %56
%58 = load i32, i32* %8
%59 = load i32, i32* %7
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %82
61: ; preds = %57
%62 = load i32, i32* %8
%63 = icmp eq i32 %62, 0
br i1 %63, label %74, label %64
64: ; preds = %61
%65 = load i32, i32* %8
%66 = load i32, i32* %7
%67 = sub nsw i32 %66, 1
%68 = icmp eq i32 %65, %67
br i1 %68, label %74, label %69
69: ; preds = %64
%70 = load i32, i32* %4
%71 = load i32, i32* %2
%72 = sub nsw i32 %71, 1
%73 = icmp eq i32 %70, %72
br i1 %73, label %74, label %76
74: ; preds = %69, %64, %61
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %78
76: ; preds = %69
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %78
78: ; preds = %76, %74
br label %79
79: ; preds = %78
%80 = load i32, i32* %8
%81 = add nsw i32 %80, 1
store i32 %81, i32* %8
br label %57
82: ; preds = %57
%83 = load i32, i32* %5
%84 = load i32, i32* %7
%85 = sub nsw i32 %83, %84
%86 = sdiv i32 %85, 2
store i32 %86, i32* %6
store i32 0, i32* %8
br label %87
87: ; preds = %93, %82
%88 = load i32, i32* %8
%89 = load i32, i32* %6
%90 = icmp slt i32 %88, %89
br i1 %90, label %91, label %96
91: ; preds = %87
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %93
93: ; preds = %91
%94 = load i32, i32* %8
%95 = add nsw i32 %94, 1
store i32 %95, i32* %8
br label %87
96: ; preds = %87
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %98
98: ; preds = %96
%99 = load i32, i32* %4
%100 = add nsw i32 %99, 1
store i32 %100, i32* %4
br label %35
101: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %13
3: ; preds = %13
%4 = icmp ugt i32 %15, 2
br i1 %4, label %5, label %17
5: ; preds = %3
%6 = mul i32 %15, 3
%7 = add nsw i32 %15, -3
%8 = add nsw i32 %15, -4
%9 = mul i32 %7, %8
%10 = and i32 %9, -2
%11 = add i32 %6, %10
%12 = add i32 %11, -8
br label %17
13: ; preds = %0, %13
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp slt i32 %15, 1
br i1 %16, label %13, label %3
17: ; preds = %5, %3
%18 = phi i32 [ 0, %3 ], [ %12, %5 ]
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %1
%21 = shl nsw i32 %20, 1
%22 = icmp sgt i32 %20, 0
br i1 %22, label %23, label %62
23: ; preds = %17, %56
%24 = phi i32 [ %61, %56 ], [ 1, %17 ]
%25 = phi i32 [ %58, %56 ], [ 0, %17 ]
%26 = shl nuw nsw i32 %25, 1
%27 = xor i32 %26, -2
%28 = add i32 %27, %21
%29 = sdiv i32 %28, 2
%30 = icmp sgt i32 %28, 1
br i1 %30, label %32, label %31
31: ; preds = %32, %23
br label %38
32: ; preds = %23, %32
%33 = phi i32 [ %35, %32 ], [ 0, %23 ]
%34 = call i32 @putchar(i32 32)
%35 = add nuw nsw i32 %33, 1
%36 = icmp eq i32 %35, %29
br i1 %36, label %31, label %32
37: ; preds = %38
br i1 %30, label %51, label %56
38: ; preds = %31, %38
%39 = phi i32 [ %49, %38 ], [ 0, %31 ]
%40 = icmp eq i32 %39, 0
%41 = icmp eq i32 %39, %26
%42 = select i1 %40, i1 true, i1 %41
%43 = load i32, i32* %1
%44 = add nsw i32 %43, -1
%45 = icmp eq i32 %25, %44
%46 = select i1 %42, i1 true, i1 %45
%47 = select i1 %46, i32 42, i32 35
%48 = call i32 @putchar(i32 %47)
%49 = add nuw i32 %39, 1
%50 = icmp eq i32 %49, %24
br i1 %50, label %37, label %38
51: ; preds = %37, %51
%52 = phi i32 [ %54, %51 ], [ 0, %37 ]
%53 = call i32 @putchar(i32 32)
%54 = add nuw nsw i32 %52, 1
%55 = icmp eq i32 %54, %29
br i1 %55, label %56, label %51
56: ; preds = %51, %37
%57 = call i32 @putchar(i32 10)
%58 = add nuw nsw i32 %25, 1
%59 = load i32, i32* %1
%60 = icmp slt i32 %58, %59
%61 = add nuw i32 %24, 2
br i1 %60, label %23, label %62
62: ; preds = %56, %17
ret i32 0
}