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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
sub    $0x2,%esi
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
imul   %eax,%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     127c <main+0x15c>
cmpl   $0x1,-0x18(%rbp)
jne    11d4 <main+0xb4>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b8 <main+0x98>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1190 <main+0x70>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    124e <main+0x12e>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1203 <main+0xe3>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11db <main+0xbb>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1240 <main+0x120>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1218 <main+0xf8>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1173 <main+0x53>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12b3 <main+0x193>
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1283 <main+0x163>
mov    -0x4(%rbp),%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    0xebd(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%r14d
lea    -0x2(%r14),%esi
imul   %esi,%esi
lea    0xea3(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
cmpl   $0x1,0xc(%rsp)
jne    11b6 <main+0x86>
lea    (%rbx,%rbx,1),%eax
add    $0xffffffff,%eax
test   %eax,%eax
jle    11a7 <main+0x77>
add    $0xffffffff,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0xc(%rsp),%eax
add    %ebx,%eax
cmp    %eax,%ebp
jl     1190 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebx
mov    %r14d,%r12d
jmp    11e9 <main+0xb9>
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r15d
add    $0xffffffff,%r12d
add    $0x2,%r15d
add    $0x1,%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    0xc(%rsp),%ebx
je     1176 <main+0x46>
cmp    $0x1,%ebx
jne    1220 <main+0xf0>
cmp    $0x2,%r12d
jl     11c0 <main+0x90>
mov    %r14d,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    %ebp,%ebx
jne    1200 <main+0xd0>
jmp    11c0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14d,%ebp
cmp    $0x2,%r12d
jl     1241 <main+0x111>
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    %ebp,%ebx
jne    1230 <main+0x100>
mov    $0x2a,%edi
call   1030 <putchar@plt>
test   %r15d,%r15d
jle    126f <main+0x13f>
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1260 <main+0x130>
mov    $0x2a,%edi
call   1030 <putchar@plt>
jmp    11ce <main+0x9e>

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
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %6
store i32 0, i32* %4
%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, 1
store i32 %9, i32* %3
%10 = load i32, i32* %2
%11 = sub nsw i32 %10, 2
%12 = load i32, i32* %2
%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 %16
16: ; preds = %60, %0
%17 = load i32, i32* %6
%18 = load i32, i32* %2
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %68
20: ; preds = %16
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %37
23: ; preds = %20
store i32 0, i32* %5
br label %24
24: ; preds = %30, %23
%25 = load i32, i32* %5
%26 = load i32, i32* %3
%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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%35 = load i32, i32* %4
%36 = add nsw i32 %35, -1
store i32 %36, i32* %4
br label %60
37: ; preds = %20
store i32 0, i32* %5
br label %38
38: ; preds = %44, %37
%39 = load i32, i32* %5
%40 = load i32, i32* %3
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %47
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %38
47: ; preds = %38
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %49
49: ; preds = %55, %47
%50 = load i32, i32* %5
%51 = load i32, i32* %4
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %58
53: ; preds = %49
%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 = %53
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
store i32 %57, i32* %5
br label %49
58: ; preds = %49
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %60
60: ; preds = %58, %33
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 2
store i32 %62, i32* %4
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
%65 = load i32, i32* %3
%66 = add nsw i32 %65, -1
store i32 %66, i32* %3
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %16
68: ; preds = %16
store i32 0, i32* %5
br label %69
69: ; preds = %78, %68
%70 = load i32, i32* %5
%71 = load i32, i32* %6
%72 = load i32, i32* %2
%73 = add nsw i32 %71, %72
%74 = sub nsw i32 %73, 1
%75 = icmp slt i32 %70, %74
br i1 %75, label %76, label %81
76: ; preds = %69
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %78
78: ; preds = %76
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 1
store i32 %80, i32* %5
br label %69
81: ; preds = %69
%82 = load i32, i32* %1
ret i32 %82
}

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 eq i32 %8, 1
br i1 %9, label %10, label %15
10: ; preds = %49, %0
%11 = phi i32 [ 1, %0 ], [ %52, %49 ]
%12 = add i32 %11, -1
%13 = add i32 %12, %11
%14 = icmp sgt i32 %13, 0
br i1 %14, label %56, label %63
15: ; preds = %0, %49
%16 = phi i32 [ %20, %49 ], [ %4, %0 ]
%17 = phi i32 [ %21, %49 ], [ %4, %0 ]
%18 = phi i32 [ %52, %49 ], [ 1, %0 ]
%19 = phi i32 [ %51, %49 ], [ 0, %0 ]
%20 = add i32 %16, -1
%21 = add nsw i32 %17, -1
%22 = icmp eq i32 %18, 1
%23 = icmp sgt i32 %17, 1
br i1 %22, label %25, label %24
24: ; preds = %15
br i1 %23, label %34, label %39
25: ; preds = %15
br i1 %23, label %26, label %31
26: ; preds = %25, %26
%27 = phi i32 [ %29, %26 ], [ 0, %25 ]
%28 = call i32 @putchar(i32 32)
%29 = add nuw nsw i32 %27, 1
%30 = icmp eq i32 %29, %20
br i1 %30, label %31, label %26
31: ; preds = %26, %25
%32 = call i32 @putchar(i32 42)
%33 = add nsw i32 %19, -1
br label %49
34: ; preds = %24, %34
%35 = phi i32 [ %37, %34 ], [ 0, %24 ]
%36 = call i32 @putchar(i32 32)
%37 = add nuw nsw i32 %35, 1
%38 = icmp eq i32 %37, %20
br i1 %38, label %39, label %34
39: ; preds = %34, %24
%40 = call i32 @putchar(i32 42)
%41 = icmp sgt i32 %19, 0
br i1 %41, label %42, label %47
42: ; preds = %39, %42
%43 = phi i32 [ %45, %42 ], [ 0, %39 ]
%44 = call i32 @putchar(i32 35)
%45 = add nuw nsw i32 %43, 1
%46 = icmp eq i32 %45, %19
br i1 %46, label %47, label %42
47: ; preds = %42, %39
%48 = call i32 @putchar(i32 42)
br label %49
49: ; preds = %47, %31
%50 = phi i32 [ %33, %31 ], [ %19, %47 ]
%51 = add nsw i32 %50, 2
%52 = add nuw nsw i32 %18, 1
%53 = call i32 @putchar(i32 10)
%54 = load i32, i32* %1
%55 = icmp eq i32 %52, %54
br i1 %55, label %10, label %15
56: ; preds = %10, %56
%57 = phi i32 [ %59, %56 ], [ 0, %10 ]
%58 = call i32 @putchar(i32 42)
%59 = add nuw nsw i32 %57, 1
%60 = load i32, i32* %1
%61 = add i32 %12, %60
%62 = icmp slt i32 %59, %61
br i1 %62, label %56, label %63
63: ; preds = %56, %10
ret i32 0
}