#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 n, k, v, h;
  scanf("%d", &n);
  printf("%d\n", (n - 2) * (n - 2));
  for (v = 1; v <= n; v++) {
    for (h = 1; h <= n - v; h++)
      printf(" ");
    printf("*");
    if (v >= 2) {
      if (v == n)
        for (k = 0; k != 2 * v - 3; k++)
          printf("*");
      else if (v >= 2)
        for (k = 0; k != 2 * v - 3; k++)
          printf("#");
      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    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
sub    $0x2,%esi
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
imul   %eax,%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1278 <main+0x158>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0x10(%rbp),%ecx
cmp    %ecx,%eax
jg     11a3 <main+0x83>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1176 <main+0x56>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x10(%rbp)
jl     125c <main+0x13c>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1203 <main+0xe3>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
je     11fe <main+0xde>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ce <main+0xae>
jmp    124e <main+0x12e>
cmpl   $0x2,-0x10(%rbp)
jl     1249 <main+0x129>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
je     1244 <main+0x124>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1214 <main+0xf4>
jmp    1249 <main+0x129>
jmp    124e <main+0x12e>
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1163 <main+0x43>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
add    $0xfffffffe,%esi
imul   %esi,%esi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1224 <main+0xf4>
mov    $0x1,%ebx
mov    $0xffffffff,%r14d
jmp    11a5 <main+0x75>
nopw   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%ecx
mov    0xc(%rsp),%eax
add    $0x2,%r14d
cmp    %eax,%ebx
mov    %ecx,%ebx
jge    1224 <main+0xf4>
cmp    %ebx,%eax
jle    11c7 <main+0x97>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
sub    %ebx,%eax
add    $0x1,%ebp
cmp    %eax,%ebp
jl     11b0 <main+0x80>
mov    $0x2a,%edi
call   1030 <putchar@plt>
cmp    $0x2,%ebx
jb     118a <main+0x5a>
mov    %r14d,%ebp
cmp    0xc(%rsp),%ebx
jne    1210 <main+0xe0>
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11f0 <main+0xc0>
jmp    1180 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1210 <main+0xe0>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
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
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = sub nsw i32 %7, 2
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, 2
%11 = mul nsw i32 %8, %10
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
store i32 1, i32* %4
br label %13
13: ; preds = %71, %0
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %74
17: ; preds = %13
store i32 1, i32* %5
br label %18
18: ; preds = %26, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = sub nsw i32 %20, %21
%23 = icmp sle i32 %19, %22
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %18
29: ; preds = %18
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = load i32, i32* %4
%32 = icmp sge i32 %31, 2
br i1 %32, label %33, label %69
33: ; preds = %29
%34 = load i32, i32* %4
%35 = load i32, i32* %2
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %50
37: ; preds = %33
store i32 0, i32* %3
br label %38
38: ; preds = %46, %37
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = mul nsw i32 2, %40
%42 = sub nsw i32 %41, 3
%43 = icmp ne i32 %39, %42
br i1 %43, label %44, label %49
44: ; preds = %38
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %38
49: ; preds = %38
br label %67
50: ; preds = %33
%51 = load i32, i32* %4
%52 = icmp sge i32 %51, 2
br i1 %52, label %53, label %66
53: ; preds = %50
store i32 0, i32* %3
br label %54
54: ; preds = %62, %53
%55 = load i32, i32* %3
%56 = load i32, i32* %4
%57 = mul nsw i32 2, %56
%58 = sub nsw i32 %57, 3
%59 = icmp ne i32 %55, %58
br i1 %59, label %60, label %65
60: ; preds = %54
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60
%63 = load i32, i32* %3
%64 = add nsw i32 %63, 1
store i32 %64, i32* %3
br label %54
65: ; preds = %54
br label %66
66: ; preds = %65, %50
br label %67
67: ; preds = %66, %49
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %69
69: ; preds = %67, %29
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %71
71: ; preds = %69
%72 = load i32, i32* %4
%73 = add nsw i32 %72, 1
store i32 %73, i32* %4
br label %13
74: ; preds = %13
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*
%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 = add nsw i32 %4, -2
%6 = mul nsw i32 %5, %5
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1
br i1 %9, label %46, label %10
10: ; preds = %0, %41
%11 = phi i32 [ %44, %41 ], [ %8, %0 ]
%12 = phi i32 [ %43, %41 ], [ 1, %0 ]
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %10, %14
%15 = phi i32 [ %17, %14 ], [ 1, %10 ]
%16 = call i32 @putchar(i32 32)
%17 = add nuw nsw i32 %15, 1
%18 = load i32, i32* %1
%19 = sub nsw i32 %18, %12
%20 = icmp slt i32 %15, %19
br i1 %20, label %14, label %21
21: ; preds = %14, %10
%22 = call i32 @putchar(i32 42)
%23 = icmp ugt i32 %12, 1
br i1 %23, label %24, label %41
24: ; preds = %21
%25 = load i32, i32* %1
%26 = icmp eq i32 %12, %25
%27 = shl nuw nsw i32 %12, 1
%28 = add nsw i32 %27, -3
br i1 %26, label %29, label %34
29: ; preds = %24, %29
%30 = phi i32 [ %32, %29 ], [ 0, %24 ]
%31 = call i32 @putchar(i32 42)
%32 = add nuw nsw i32 %30, 1
%33 = icmp eq i32 %32, %28
br i1 %33, label %39, label %29
34: ; preds = %24, %34
%35 = phi i32 [ %37, %34 ], [ 0, %24 ]
%36 = call i32 @putchar(i32 35)
%37 = add nuw nsw i32 %35, 1
%38 = icmp eq i32 %37, %28
br i1 %38, label %39, label %34
39: ; preds = %34, %29
%40 = call i32 @putchar(i32 42)
br label %41
41: ; preds = %39, %21
%42 = call i32 @putchar(i32 10)
%43 = add nuw nsw i32 %12, 1
%44 = load i32, i32* %1
%45 = icmp slt i32 %12, %44
br i1 %45, label %10, label %46
46: ; preds = %41, %0
ret i32 0
}