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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xec3(%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    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1278 <main+0x158>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jg     11a3 <main+0x83>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1176 <main+0x56>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jle    125c <main+0x13c>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1203 <main+0xe3>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    11fe <main+0xde>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ce <main+0xae>
jmp    124e <main+0x12e>
cmpl   $0x1,-0xc(%rbp)
jle    1249 <main+0x129>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    1244 <main+0x124>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%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    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <main+0x43>
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    0xec2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
add    $0xfffffffe,%esi
imul   %esi,%esi
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1224 <main+0xf4>
mov    $0x1,%r15d
mov    $0xffffffff,%r14d
jmp    11a8 <main+0x78>
nopw   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r15),%ecx
mov    0x4(%rsp),%eax
add    $0x2,%r14d
cmp    %eax,%r15d
mov    %ecx,%r15d
jge    1224 <main+0xf4>
cmp    $0x2,%r14d
mov    $0x1,%ebp
cmovge %r14d,%ebp
cmp    %r15d,%eax
jle    11d8 <main+0xa8>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
sub    %r15d,%eax
add    $0x1,%ebx
cmp    %eax,%ebx
jl     11c0 <main+0x90>
mov    $0x2a,%edi
call   1030 <putchar@plt>
cmp    $0x2,%r15d
jb     118a <main+0x5a>
cmp    0x4(%rsp),%r15d
jne    1210 <main+0xe0>
nop
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    $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"%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
store i32 1, i32* %3
%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)
br label %13
13: ; preds = %69, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %73
17: ; preds = %13
store i32 1, i32* %4
br label %18
18: ; preds = %26, %17
%19 = load i32, i32* %4
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%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* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
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* %3
%32 = icmp sgt i32 %31, 1
br i1 %32, label %33, label %69
33: ; preds = %29
%34 = load i32, i32* %3
%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* %5
br label %38
38: ; preds = %46, %37
%39 = load i32, i32* %5
%40 = load i32, i32* %3
%41 = mul nsw i32 %40, 2
%42 = sub nsw i32 %41, 3
%43 = icmp slt 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* %5
%48 = add nsw i32 %47, 1
store i32 %48, i32* %5
br label %38
49: ; preds = %38
br label %67
50: ; preds = %33
%51 = load i32, i32* %3
%52 = icmp sgt i32 %51, 1
br i1 %52, label %53, label %66
53: ; preds = %50
store i32 0, i32* %5
br label %54
54: ; preds = %62, %53
%55 = load i32, i32* %5
%56 = load i32, i32* %3
%57 = mul nsw i32 %56, 2
%58 = sub nsw i32 %57, 3
%59 = icmp slt 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* %5
%64 = add nsw i32 %63, 1
store i32 %64, i32* %5
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))
%71 = load i32, i32* %3
%72 = add nsw i32 %71, 1
store i32 %72, i32* %3
br label %13
73: ; 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 %47, label %10
10: ; preds = %0, %41
%11 = phi i32 [ %44, %41 ], [ %8, %0 ]
%12 = phi i32 [ %46, %41 ], [ -1, %0 ]
%13 = phi i32 [ %43, %41 ], [ 1, %0 ]
%14 = call i32 @llvm.smax.i32(i32 %12, i32 1)
%15 = icmp sgt i32 %11, %13
br i1 %15, label %16, label %23
16: ; preds = %10, %16
%17 = phi i32 [ %19, %16 ], [ 1, %10 ]
%18 = call i32 @putchar(i32 32)
%19 = add nuw nsw i32 %17, 1
%20 = load i32, i32* %1
%21 = sub nsw i32 %20, %13
%22 = icmp slt i32 %17, %21
br i1 %22, label %16, label %23
23: ; preds = %16, %10
%24 = call i32 @putchar(i32 42)
%25 = icmp ugt i32 %13, 1
br i1 %25, label %26, label %41
26: ; preds = %23
%27 = load i32, i32* %1
%28 = icmp eq i32 %13, %27
br i1 %28, label %29, label %34
29: ; preds = %26, %29
%30 = phi i32 [ %32, %29 ], [ 0, %26 ]
%31 = call i32 @putchar(i32 42)
%32 = add nuw nsw i32 %30, 1
%33 = icmp eq i32 %32, %14
br i1 %33, label %39, label %29
34: ; preds = %26, %34
%35 = phi i32 [ %37, %34 ], [ 0, %26 ]
%36 = call i32 @putchar(i32 35)
%37 = add nuw nsw i32 %35, 1
%38 = icmp eq i32 %37, %14
br i1 %38, label %39, label %34
39: ; preds = %34, %29
%40 = call i32 @putchar(i32 42)
br label %41
41: ; preds = %39, %23
%42 = call i32 @putchar(i32 10)
%43 = add nuw nsw i32 %13, 1
%44 = load i32, i32* %1
%45 = icmp slt i32 %13, %44
%46 = add i32 %12, 2
br i1 %45, label %10, label %47
47: ; preds = %41, %0
ret i32 0
}