#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, c, s, i, j;
  scanf("%d", &n);
  int br = 0;
  br = (n - 2) * (n - 2);
  printf("%d\n", br);
  for (c = 1; c < n; c++) {
    s = n - c;
    for (i = 0; i < s; i++)
      printf(" ");
    if (c == 1) {
      printf("*");
      printf("\n");
    } else {
      printf("*");
      printf("#");
      for (j = 2; j < c; j++) {
        printf("#");
        printf("#");
      }
      printf("*");
      printf("\n");
    }
  }
  for (i = 0; i < (n * 2) - 1; i++)
    printf("*");
  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>
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
imul   %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1267 <main+0x147>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b4 <main+0x94>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118c <main+0x6c>
cmpl   $0x1,-0xc(%rbp)
jne    11df <main+0xbf>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1254 <main+0x134>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1238 <main+0x118>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1202 <main+0xe2>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1259 <main+0x139>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1170 <main+0x50>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    129e <main+0x17e>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    126e <main+0x14e>
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),%ebp
cmp    $0x2,%ebp
jl     120e <main+0xde>
mov    $0x1,%ebx
mov    $0xffffffff,%r14d
jmp    11a3 <main+0x73>
nopl   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0xc(%rsp),%ebp
add    $0x1,%r14d
cmp    %ebx,%ebp
jle    120e <main+0xde>
cmp    %ebx,%ebp
jle    11c1 <main+0x91>
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    %ebp,%ebx
jne    11b0 <main+0x80>
mov    $0x2a,%edi
call   1030 <putchar@plt>
cmp    $0x1,%ebx
je     118a <main+0x5a>
mov    $0x23,%edi
call   1030 <putchar@plt>
cmp    $0x3,%ebx
jb     1180 <main+0x50>
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11f0 <main+0xc0>
jmp    1180 <main+0x50>
test   %ebp,%ebp
jle    123a <main+0x10a>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0xc(%rsp),%eax
add    %eax,%eax
add    $0xffffffff,%eax
cmp    %eax,%ebx
jl     1220 <main+0xf0>
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"\0A\00"
@.str.5 = [2 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
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %7
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, 2
%11 = load i32, i32* %2
%12 = sub nsw i32 %11, 2
%13 = mul nsw i32 %10, %12
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
store i32 1, i32* %3
br label %16
16: ; preds = %56, %0
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %59
20: ; preds = %16
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = sub nsw i32 %21, %22
store i32 %23, i32* %4
store i32 0, i32* %5
br label %24
24: ; preds = %30, %20
%25 = load i32, i32* %5
%26 = load i32, i32* %4
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %28
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %24
33: ; preds = %24
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %55
39: ; preds = %33
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %6
br label %42
42: ; preds = %49, %39
%43 = load i32, i32* %6
%44 = load i32, i32* %3
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %52
46: ; preds = %42
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %46
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %42
52: ; preds = %42
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %55
55: ; preds = %52, %36
br label %56
56: ; preds = %55
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %16
59: ; preds = %16
store i32 0, i32* %5
br label %60
60: ; preds = %68, %59
%61 = load i32, i32* %5
%62 = load i32, i32* %2
%63 = mul nsw i32 %62, 2
%64 = sub nsw i32 %63, 1
%65 = icmp slt i32 %61, %64
br i1 %65, label %66, label %71
66: ; preds = %60
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %68
68: ; preds = %66
%69 = load i32, i32* %5
%70 = add nsw i32 %69, 1
store i32 %70, i32* %5
br label %60
71: ; preds = %60
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 sgt i32 %8, 1
br i1 %9, label %13, label %10
10: ; preds = %39, %0
%11 = phi i32 [ %8, %0 ], [ %42, %39 ]
%12 = icmp sgt i32 %11, 0
br i1 %12, label %45, label %53
13: ; preds = %0, %39
%14 = phi i32 [ %44, %39 ], [ -1, %0 ]
%15 = phi i32 [ %42, %39 ], [ %8, %0 ]
%16 = phi i32 [ %41, %39 ], [ 1, %0 ]
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = add i32 %15, %14
br label %20
20: ; preds = %18, %20
%21 = phi i32 [ %23, %20 ], [ 0, %18 ]
%22 = call i32 @putchar(i32 32)
%23 = add nuw nsw i32 %21, 1
%24 = icmp eq i32 %23, %19
br i1 %24, label %25, label %20
25: ; preds = %20, %13
%26 = icmp eq i32 %16, 1
%27 = call i32 @putchar(i32 42)
br i1 %26, label %39, label %28
28: ; preds = %25
%29 = call i32 @putchar(i32 35)
%30 = icmp ugt i32 %16, 2
br i1 %30, label %31, label %37
31: ; preds = %28, %31
%32 = phi i32 [ %35, %31 ], [ 2, %28 ]
%33 = call i32 @putchar(i32 35)
%34 = call i32 @putchar(i32 35)
%35 = add nuw nsw i32 %32, 1
%36 = icmp eq i32 %35, %16
br i1 %36, label %37, label %31
37: ; preds = %31, %28
%38 = call i32 @putchar(i32 42)
br label %39
39: ; preds = %25, %37
%40 = call i32 @putchar(i32 10)
%41 = add nuw nsw i32 %16, 1
%42 = load i32, i32* %1
%43 = icmp sgt i32 %42, %41
%44 = add i32 %14, -1
br i1 %43, label %13, label %10
45: ; preds = %10, %45
%46 = phi i32 [ %48, %45 ], [ 0, %10 ]
%47 = call i32 @putchar(i32 42)
%48 = add nuw nsw i32 %46, 1
%49 = load i32, i32* %1
%50 = shl nsw i32 %49, 1
%51 = add nsw i32 %50, -1
%52 = icmp slt i32 %48, %51
br i1 %52, label %45, label %53
53: ; preds = %45, %10
ret i32 0
}