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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jl     1164 <main+0x44>
mov    -0x1c(%rbp),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126e <main+0x14e>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11e3 <main+0xc3>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bb <main+0x9b>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1240 <main+0x120>
cmpl   $0x1,-0x14(%rbp)
je     120c <main+0xec>
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    121f <main+0xff>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122d <main+0x10d>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1232 <main+0x112>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ea <main+0xca>
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a8 <main+0x88>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     129d <main+0x17d>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1275 <main+0x155>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%ebp
lea    -0x2(%rbp),%eax
cmp    $0x2,%eax
mov    $0x1,%r14d
cmovl  %r14d,%eax
lea    (%rax,%rax,2),%ecx
lea    -0x1(%rax),%edx
add    $0xfffffffe,%eax
imul   %edx,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rcx,1),%esi
add    $0xfffffffe,%esi
lea    0xe84(%rip),%rdi
xor    %r12d,%r12d
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%ebx
cmpl   $0x2,0x8(%rsp)
jl     1223 <main+0xf3>
mov    $0x2a,%r15d
mov    %ebp,%eax
mov    %ebp,0xc(%rsp)
mov    $0x1,%r13d
mov    %rbp,0x10(%rsp)
mov    %r14d,%ebx
mov    0xc(%rsp),%r14d
cmp    $0x2,%r14d
jl     11d2 <main+0xa2>
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    %ebp,%r13d
jne    11c0 <main+0x90>
add    $0xffffffff,%r14d
mov    %r14d,0xc(%rsp)
xor    %ebp,%ebp
nopl   (%rax)
cmp    %ebp,%r12d
mov    $0x23,%edi
cmove  %r15d,%edi
test   %ebp,%ebp
cmove  %r15d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    11e0 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x2(%rbx),%r14d
add    $0x1,%r13d
add    $0x2,%r12d
cmp    0x8(%rsp),%r13d
mov    0x10(%rsp),%rbp
jl     11b0 <main+0x80>
add    $0x3,%ebx
add    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1230 <main+0x100>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
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
%8 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %6
store i32 0, i32* %7
store i32 1, i32* %8
store i32 0, i32* %3
br label %12
12: ; preds = %20, %0
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = add nsw i32 %13, %14
store i32 %15, i32* %7
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = load i32, i32* %8
%19 = add nsw i32 %18, 2
store i32 %19, i32* %8
br label %20
20: ; preds = %12
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = sub nsw i32 %22, 2
%24 = icmp slt i32 %21, %23
br i1 %24, label %12, label %25
25: ; preds = %20
%26 = load i32, i32* %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
store i32 1, i32* %3
br label %28
28: ; preds = %68, %25
%29 = load i32, i32* %3
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %71
32: ; preds = %28
store i32 1, i32* %5
br label %33
33: ; preds = %39, %32
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = icmp sle i32 %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %37
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %33
42: ; preds = %33
store i32 1, i32* %5
br label %43
43: ; preds = %59, %42
%44 = load i32, i32* %5
%45 = load i32, i32* %4
%46 = icmp sle i32 %44, %45
br i1 %46, label %47, label %62
47: ; preds = %43
%48 = load i32, i32* %5
%49 = icmp eq i32 %48, 1
br i1 %49, label %54, label %50
50: ; preds = %47
%51 = load i32, i32* %5
%52 = load i32, i32* %4
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %56
54: ; preds = %50, %47
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %58
56: ; preds = %50
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %58
58: ; preds = %56, %54
br label %59
59: ; preds = %58
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 1
store i32 %61, i32* %5
br label %43
62: ; preds = %43
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%64 = load i32, i32* %4
%65 = add nsw i32 %64, 2
store i32 %65, i32* %4
%66 = load i32, i32* %6
%67 = sub nsw i32 %66, 1
store i32 %67, i32* %6
br label %68
68: ; preds = %62
%69 = load i32, i32* %3
%70 = add nsw i32 %69, 1
store i32 %70, i32* %3
br label %28
71: ; preds = %28
store i32 1, i32* %3
br label %72
72: ; preds = %78, %71
%73 = load i32, i32* %3
%74 = load i32, i32* %4
%75 = icmp sle i32 %73, %74
br i1 %75, label %76, label %81
76: ; preds = %72
%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* %3
%80 = add nsw i32 %79, 1
store i32 %80, i32* %3
br label %72
81: ; preds = %72
%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 i32 %4, -2
%6 = call i32 @llvm.smax.i32(i32 %5, i32 1)
%7 = mul i32 %6, 3
%8 = add nsw i32 %6, -1
%9 = add nsw i32 %6, -2
%10 = mul i32 %8, %9
%11 = and i32 %10, -2
%12 = add i32 %7, %11
%13 = add i32 %12, -2
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 1
br i1 %16, label %17, label %26
17: ; preds = %0, %43
%18 = phi i32 [ %49, %43 ], [ 2, %0 ]
%19 = phi i32 [ %22, %43 ], [ %4, %0 ]
%20 = phi i32 [ %45, %43 ], [ 1, %0 ]
%21 = phi i32 [ %46, %43 ], [ 1, %0 ]
%22 = add nsw i32 %19, -1
%23 = icmp sgt i32 %19, 1
br i1 %23, label %28, label %33
24: ; preds = %43
%25 = add nuw i32 %20, 3
br label %26
26: ; preds = %24, %0
%27 = phi i32 [ 2, %0 ], [ %25, %24 ]
br label %50
28: ; preds = %17, %28
%29 = phi i32 [ %31, %28 ], [ 1, %17 ]
%30 = call i32 @putchar(i32 32)
%31 = add nuw nsw i32 %29, 1
%32 = icmp eq i32 %31, %19
br i1 %32, label %33, label %28
33: ; preds = %28, %17
br label %34
34: ; preds = %33, %34
%35 = phi i32 [ %41, %34 ], [ 1, %33 ]
%36 = icmp eq i32 %35, 1
%37 = icmp eq i32 %35, %20
%38 = select i1 %36, i1 true, i1 %37
%39 = select i1 %38, i32 42, i32 35
%40 = call i32 @putchar(i32 %39)
%41 = add nuw i32 %35, 1
%42 = icmp eq i32 %41, %18
br i1 %42, label %43, label %34
43: ; preds = %34
%44 = call i32 @putchar(i32 10)
%45 = add nuw nsw i32 %20, 2
%46 = add nuw nsw i32 %21, 1
%47 = load i32, i32* %1
%48 = icmp slt i32 %46, %47
%49 = add nuw i32 %18, 2
br i1 %48, label %17, label %24
50: ; preds = %26, %50
%51 = phi i32 [ 1, %26 ], [ %53, %50 ]
%52 = call i32 @putchar(i32 42)
%53 = add nuw i32 %51, 1
%54 = icmp eq i32 %53, %27
br i1 %54, label %55, label %50
55: ; preds = %50
ret i32 0
}