#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 power(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n = 0, count = 1;
  scanf("%d", &n);
  printf("%d\n", power(n - 2, 2));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - i - 1; j++) {
      printf(" ");
    }
    if (i == 0) {
      printf("*");
    } else if (i == n - 1) {
      for (int j = 0; j < (2 * n) - 1; j++) {
        printf("*");
      }
    } else {
      printf("*");
      for (int j = 0; j < count; j++) {
        printf("#");
      }
      count += 2;
      printf("*");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xeac(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
mov    $0x2,%esi
call   1030 <power@plt>
mov    %eax,%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a6 <main+0x176>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11c7 <main+0x97>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1197 <main+0x67>
cmpl   $0x0,-0x10(%rbp)
jne    11e4 <main+0xb4>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128a <main+0x15a>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1231 <main+0x101>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    122c <main+0xfc>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11fc <main+0xcc>
jmp    1285 <main+0x155>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    126e <main+0x13e>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1246 <main+0x116>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128a <main+0x15a>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1184 <main+0x54>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeaa(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
add    $0xfffffffe,%edi
mov    $0x2,%esi
call   1040 <power@plt>
lea    0xe8b(%rip),%rdi
xor    %r15d,%r15d
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1264 <main+0x124>
mov    $0x1,%r14d
jmp    11c9 <main+0x89>
nopl   0x0(%rax,%rax,1)
add    $0x2,%r14d
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15d
mov    0x4(%rsp),%eax
cmp    %eax,%r15d
jge    1264 <main+0x124>
mov    %r15d,%ebp
not    %ebp
lea    (%rax,%rbp,1),%ecx
test   %ecx,%ecx
jle    11f8 <main+0xb8>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
lea    (%rax,%rbp,1),%ecx
cmp    %ecx,%ebx
jl     11e0 <main+0xa0>
test   %r15d,%r15d
je     11a4 <main+0x64>
lea    -0x1(%rax),%ecx
cmp    %ecx,%r15d
jne    1230 <main+0xf0>
test   %eax,%eax
jle    11ae <main+0x6e>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
add    %eax,%eax
add    $0xffffffff,%eax
cmp    %eax,%ebx
jl     1210 <main+0xd0>
jmp    11ae <main+0x6e>
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    %r14d,%ebx
test   %r14d,%r14d
jle    11a0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1250 <main+0x110>
jmp    11a0 <main+0x60>
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
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 1, i32* %3
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, 2
%11 = call i32 @power(i32 %10, i32 2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
store i32 0, i32* %4
br label %13
13: ; preds = %71, %0
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %74
17: ; preds = %13
store i32 0, i32* %5
br label %18
18: ; preds = %27, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %2
%21 = load i32, i32* %4
%22 = sub nsw i32 %20, %21
%23 = sub nsw i32 %22, 1
%24 = icmp slt i32 %19, %23
br i1 %24, label %25, label %30
25: ; preds = %18
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %18
30: ; preds = %18
%31 = load i32, i32* %4
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %69
35: ; preds = %30
%36 = load i32, i32* %4
%37 = load i32, i32* %2
%38 = sub nsw i32 %37, 1
%39 = icmp eq i32 %36, %38
br i1 %39, label %40, label %53
40: ; preds = %35
store i32 0, i32* %6
br label %41
41: ; preds = %49, %40
%42 = load i32, i32* %6
%43 = load i32, i32* %2
%44 = mul nsw i32 2, %43
%45 = sub nsw i32 %44, 1
%46 = icmp slt i32 %42, %45
br i1 %46, label %47, label %52
47: ; preds = %41
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %47
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %41
52: ; preds = %41
br label %68
53: ; preds = %35
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %55
55: ; preds = %61, %53
%56 = load i32, i32* %7
%57 = load i32, i32* %3
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %64
59: ; preds = %55
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %61
61: ; preds = %59
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
store i32 %63, i32* %7
br label %55
64: ; preds = %55
%65 = load i32, i32* %3
%66 = add nsw i32 %65, 2
store i32 %66, i32* %3
%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 = %64, %52
br label %69
69: ; preds = %68, %33
%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*
store i32 0, i32* %1
%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 = call i32 @power(i32 %5, i32 2)
%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, 0
br i1 %9, label %10, label %17
10: ; preds = %0, %54
%11 = phi i32 [ %58, %54 ], [ %8, %0 ]
%12 = phi i32 [ %57, %54 ], [ 0, %0 ]
%13 = phi i32 [ %55, %54 ], [ 1, %0 ]
%14 = xor i32 %12, -1
%15 = add i32 %11, %14
%16 = icmp sgt i32 %15, 0
br i1 %16, label %21, label %18
17: ; preds = %54, %0
ret i32 0
18: ; preds = %21, %10
%19 = phi i32 [ %11, %10 ], [ %25, %21 ]
%20 = icmp eq i32 %12, 0
br i1 %20, label %51, label %28
21: ; preds = %10, %21
%22 = phi i32 [ %24, %21 ], [ 0, %10 ]
%23 = call i32 @putchar(i32 32)
%24 = add nuw nsw i32 %22, 1
%25 = load i32, i32* %1
%26 = add i32 %25, %14
%27 = icmp slt i32 %24, %26
br i1 %27, label %21, label %18
28: ; preds = %18
%29 = add nsw i32 %19, -1
%30 = icmp eq i32 %12, %29
br i1 %30, label %31, label %41
31: ; preds = %28
%32 = icmp sgt i32 %19, 0
br i1 %32, label %33, label %54
33: ; preds = %31, %33
%34 = phi i32 [ %36, %33 ], [ 0, %31 ]
%35 = call i32 @putchar(i32 42)
%36 = add nuw nsw i32 %34, 1
%37 = load i32, i32* %1
%38 = shl nsw i32 %37, 1
%39 = add nsw i32 %38, -1
%40 = icmp slt i32 %36, %39
br i1 %40, label %33, label %54
41: ; preds = %28
%42 = call i32 @putchar(i32 42)
%43 = icmp sgt i32 %13, 0
br i1 %43, label %46, label %44
44: ; preds = %46, %41
%45 = add nsw i32 %13, 2
br label %51
46: ; preds = %41, %46
%47 = phi i32 [ %49, %46 ], [ 0, %41 ]
%48 = call i32 @putchar(i32 35)
%49 = add nuw nsw i32 %47, 1
%50 = icmp eq i32 %49, %13
br i1 %50, label %44, label %46
51: ; preds = %18, %44
%52 = phi i32 [ %45, %44 ], [ %13, %18 ]
%53 = call i32 @putchar(i32 42)
br label %54
54: ; preds = %33, %51, %31
%55 = phi i32 [ %13, %31 ], [ %52, %51 ], [ %13, %33 ]
%56 = call i32 @putchar(i32 10)
%57 = add nuw nsw i32 %12, 1
%58 = load i32, i32* %1
%59 = icmp slt i32 %57, %58
br i1 %59, label %10, label %17
}