#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 i, k, j;
  int tree_lenght;
  scanf("%d", &tree_lenght);
  if (tree_lenght > 1)
    printf("%d\n", (tree_lenght - 2) * (tree_lenght - 2));
  else
    printf("0\n");
  for (i = 0; i < tree_lenght; i++) {
    for (k = tree_lenght - i; k > 0; k--) {
      printf(" ");
    }
    printf("*");
    for (j = 0; j < (i * 2) - 1; j++) {
      if (i == (tree_lenght - 1))
        printf("*");
      else
        printf("#");
    }
    if (i != 0)
      printf("*");
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
jle    116b <main+0x4b>
mov    -0x14(%rbp),%esi
sub    $0x2,%esi
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
imul   %eax,%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1179 <main+0x59>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    125d <main+0x13d>
mov    -0x14(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11bb <main+0x9b>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1195 <main+0x75>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1229 <main+0x109>
mov    -0x8(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1208 <main+0xe8>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1216 <main+0xf6>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121b <main+0xfb>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d0 <main+0xb0>
cmpl   $0x0,-0x8(%rbp)
je     1241 <main+0x121>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <main+0x60>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xead(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0x2,%esi
jl     117c <main+0x3c>
add    $0xfffffffe,%esi
imul   %esi,%esi
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1188 <main+0x48>
lea    0xe84(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jle    1268 <main+0x128>
xor    %r12d,%r12d
mov    $0xffffffff,%r15d
mov    $0x1,%r14d
jmp    11d3 <main+0x93>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
mov    0xc(%rsp),%ebx
add    $0x2,%r15d
add    $0xffffffff,%r14d
cmp    %r12d,%ebx
jle    1268 <main+0x128>
cmp    $0x2,%r15d
mov    $0x1,%ebp
cmovge %r15d,%ebp
cmp    %r12d,%ebx
jle    1202 <main+0xc2>
add    %r14d,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     11f0 <main+0xb0>
mov    $0x2a,%edi
call   1030 <putchar@plt>
test   %r12d,%r12d
jne    122a <main+0xea>
jmp    11b0 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
je     1250 <main+0x110>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
mov    $0x2a,%edi
cmp    %eax,%r12d
je     1220 <main+0xe0>
mov    $0x23,%edi
jmp    1220 <main+0xe0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %r12d,%r12d
je     11b0 <main+0x70>
mov    $0x2a,%edi
call   1030 <putchar@plt>
jmp    11b0 <main+0x70>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
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 = [3 x i8] c"0\0A\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [2 x i8] c"*\00"
@.str.5 = [2 x i8] c"#\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = load i32, i32* %5
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %16
9: ; preds = %0
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 2
%12 = load i32, i32* %5
%13 = sub nsw i32 %12, 2
%14 = mul nsw i32 %11, %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %18
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %9
store i32 0, i32* %2
br label %19
19: ; preds = %63, %18
%20 = load i32, i32* %2
%21 = load i32, i32* %5
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %66
23: ; preds = %19
%24 = load i32, i32* %5
%25 = load i32, i32* %2
%26 = sub nsw i32 %24, %25
store i32 %26, i32* %3
br label %27
27: ; preds = %32, %23
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30
%33 = load i32, i32* %3
%34 = add nsw i32 %33, -1
store i32 %34, i32* %3
br label %27
35: ; preds = %27
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %37
37: ; preds = %53, %35
%38 = load i32, i32* %4
%39 = load i32, i32* %2
%40 = mul nsw i32 %39, 2
%41 = sub nsw i32 %40, 1
%42 = icmp slt i32 %38, %41
br i1 %42, label %43, label %56
43: ; preds = %37
%44 = load i32, i32* %2
%45 = load i32, i32* %5
%46 = sub nsw i32 %45, 1
%47 = icmp eq i32 %44, %46
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %52
50: ; preds = %43
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %52
52: ; preds = %50, %48
br label %53
53: ; preds = %52
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %37
56: ; preds = %37
%57 = load i32, i32* %2
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %61
61: ; preds = %59, %56
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %63
63: ; preds = %61
%64 = load i32, i32* %2
%65 = add nsw i32 %64, 1
store i32 %65, i32* %2
br label %19
66: ; preds = %19
ret i32 0
}

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