#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, i, red, x = 0, spaces;
  scanf("%d", &n);
  x = (n - 2) * (n - 2);
  printf("%d \n", x);
  for (red = 1; red < n; red++) {
    spaces = n - red;
    for (i = 0; i < spaces; i++) {
      printf(" ");
    }
    if (red == 1) {
      printf("*");
      printf("\n");
    } else {
      printf("*");
      printf("#");
      for (i = 2; i < red; i++) {
        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)
movl   $0x0,-0x14(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
imul   %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1267 <main+0x147>
mov    -0x8(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b4 <main+0x94>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118c <main+0x6c>
cmpl   $0x1,-0x10(%rbp)
jne    11df <main+0xbf>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1254 <main+0x134>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1238 <main+0x118>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1202 <main+0xe2>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1259 <main+0x139>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1170 <main+0x50>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    129e <main+0x17e>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%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 = [5 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
store i32 0, i32* %1
store i32 0, i32* %5
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = sub nsw i32 %8, 2
%10 = load i32, i32* %2
%11 = sub nsw i32 %10, 2
%12 = mul nsw i32 %9, %11
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %13)
store i32 1, i32* %4
br label %15
15: ; preds = %55, %0
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %58
19: ; preds = %15
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = sub nsw i32 %20, %21
store i32 %22, i32* %6
store i32 0, i32* %3
br label %23
23: ; preds = %29, %19
%24 = load i32, i32* %3
%25 = load i32, i32* %6
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %32
27: ; preds = %23
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %23
32: ; preds = %23
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %54
38: ; preds = %32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %3
br label %41
41: ; preds = %48, %38
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %48
48: ; preds = %45
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %41
51: ; preds = %41
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %51, %35
br label %55
55: ; preds = %54
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
br label %15
58: ; preds = %15
store i32 0, i32* %3
br label %59
59: ; preds = %67, %58
%60 = load i32, i32* %3
%61 = load i32, i32* %2
%62 = mul nsw i32 %61, 2
%63 = sub nsw i32 %62, 1
%64 = icmp slt i32 %60, %63
br i1 %64, label %65, label %70
65: ; preds = %59
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %65
%68 = load i32, i32* %3
%69 = add nsw i32 %68, 1
store i32 %69, i32* %3
br label %59
70: ; preds = %59
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 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 ([5 x i8], [5 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
}