#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 h, d, d_total, l, i;
  scanf("%d", &h);
  d = 0;
  l = h - 1;
  if (h > 2) {
    d_total = (h - 2) * (h - 2);
  } else {
    d_total = 0;
  }
  printf("\n%d", d_total);
  while (l > 0) {
    printf("\n");
    for (i = 0; i < l; i++) {
      printf(" ");
    }
    printf("*");
    if (l == h - 1) {
      d = 1;
    } else {
      for (i = 0; i < d; i++) {
        printf("#");
      }
      printf("*");
      d = d + 2;
    }
    l--;
  }
  printf("\n");
  if (h > 2) {
    for (i = 0; i < d + 2; i++) {
      printf("*");
    }
  } else {
    if (h == 2) {
      printf("***");
    }
    if (h == 1) {
      printf("*");
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1170 <main+0x50>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
imul   %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    1177 <main+0x57>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jle    124e <main+0x12e>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11cf <main+0xaf>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a7 <main+0x87>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11fa <main+0xda>
movl   $0x1,-0xc(%rbp)
jmp    1240 <main+0x120>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1229 <main+0x109>
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1201 <main+0xe1>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <main+0x68>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jle    129f <main+0x17f>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    129a <main+0x17a>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    126d <main+0x14d>
jmp    12d4 <main+0x1b4>
cmpl   $0x2,-0x8(%rbp)
jne    12b7 <main+0x197>
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    12cf <main+0x1af>
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d4 <main+0x1b4>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec3(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r14d
lea    -0x2(%r14),%esi
imul   %esi,%esi
xor    %ebp,%ebp
cmp    $0x3,%r14d
cmovl  %ebp,%esi
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%r14d
jl     11f1 <main+0xc1>
xor    %r15d,%r15d
jmp    1199 <main+0x69>
nopw   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x2,%r15d
mov    %r15d,%ebp
mov    %ebp,%r15d
cmp    $0x2,%ebx
jle    11f1 <main+0xc1>
mov    %r14d,%ebx
lea    -0x1(%rbx),%r14d
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebp
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    11b0 <main+0x80>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebp
cmp    0x4(%rsp),%ebx
je     1191 <main+0x61>
test   %r15d,%r15d
jle    1180 <main+0x50>
mov    %r15d,%ebp
xchg   %ax,%ax
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11e0 <main+0xb0>
jmp    1180 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
jl     1221 <main+0xf1>
cmp    $0xffffffff,%ebp
jl     1247 <main+0x117>
add    $0x2,%ebp
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1210 <main+0xe0>
jmp    1247 <main+0x117>
cmp    $0x2,%eax
jne    1238 <main+0x108>
lea    0xdd7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
jne    1247 <main+0x117>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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