#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, a = 1, j, k, n1, i, v = 1, sum = 0;
  scanf("%d", &n);
  for (i = 2; i < n; i++) {
    sum = sum + a;
    a += 2;
  }
  printf("%d\n", sum);
  n1 = n;
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < n1 - 2; j++)
      printf(" ");
    if (i == 0) {
      printf(" *\n");
      continue;
    }
    n1--;
    printf("*");
    for (k = 1; k <= v; k++)
      printf("#");
    v += 2;
    printf("*");
    printf("\n");
  }
  if (n > 1)
    for (i = 0; i <= v + 1; i++)
      printf("*");
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1187 <main+0x67>
mov    -0x24(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115b <main+0x3b>
mov    -0x24(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1280 <main+0x160>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    11ea <main+0xca>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11bd <main+0x9d>
cmpl   $0x0,-0x1c(%rbp)
jne    1207 <main+0xe7>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1272 <main+0x152>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     124d <main+0x12d>
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1225 <main+0x105>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a5 <main+0x85>
cmpl   $0x1,-0x8(%rbp)
jle    12c3 <main+0x1a3>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     12be <main+0x19e>
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1291 <main+0x171>
jmp    12c3 <main+0x1a3>
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xead(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
xor    %esi,%esi
cmp    $0x3,%eax
jl     117d <main+0x3d>
lea    (%rax,%rax,2),%ecx
lea    -0x3(%rax),%edx
add    $0xfffffffc,%eax
imul   %edx,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rcx,1),%esi
add    $0xfffffff8,%esi
lea    0xe7f(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%r15d
cmp    $0x2,%r15d
jl     1250 <main+0x110>
mov    $0x1,%r12d
lea    0xe5e(%rip),%r14
jmp    11c6 <main+0x86>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
add    $0x1,%ebx
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    %ecx,%ebx
jge    122d <main+0xed>
cmp    $0x3,%r15d
jl     11df <main+0x9f>
lea    -0x2(%r15),%ebp
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0x90>
test   %ebx,%ebx
je     11b0 <main+0x70>
mov    $0x2a,%edi
call   1030 <putchar@plt>
test   %r12d,%r12d
jle    120f <main+0xcf>
mov    %r12d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1200 <main+0xc0>
add    $0xffffffff,%r15d
add    $0x2,%r12d
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11b8 <main+0x78>
cmp    $0x2,%eax
jl     1250 <main+0x110>
cmp    $0xffffffff,%r12d
jl     1250 <main+0x110>
add    $0x2,%r12d
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r12d
jne    1240 <main+0x100>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
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 = [4 x i8] c" *\0A\00"
@.str.4 = [2 x i8] c"*\00"
@.str.5 = [2 x i8] c"#\00"
@.str.6 = [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
%9 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
store i32 1, i32* %8
store i32 0, i32* %9
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 2, i32* %7
br label %11
11: ; preds = %21, %0
%12 = load i32, i32* %7
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load i32, i32* %9
%17 = load i32, i32* %3
%18 = add nsw i32 %16, %17
store i32 %18, i32* %9
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 2
store i32 %20, i32* %3
br label %21
21: ; preds = %15
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
br label %11
24: ; preds = %11
%25 = load i32, i32* %9
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %2
store i32 %27, i32* %6
store i32 0, i32* %7
br label %28
28: ; preds = %67, %24
%29 = load i32, i32* %7
%30 = load i32, i32* %2
%31 = sub nsw i32 %30, 1
%32 = icmp slt i32 %29, %31
br i1 %32, label %33, label %70
33: ; preds = %28
store i32 0, i32* %4
br label %34
34: ; preds = %41, %33
%35 = load i32, i32* %4
%36 = load i32, i32* %6
%37 = sub nsw i32 %36, 2
%38 = icmp slt i32 %35, %37
br i1 %38, label %39, label %44
39: ; preds = %34
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %39
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %34
44: ; preds = %34
%45 = load i32, i32* %7
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %67
49: ; preds = %44
%50 = load i32, i32* %6
%51 = add nsw i32 %50, -1
store i32 %51, i32* %6
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %5
br label %53
53: ; preds = %59, %49
%54 = load i32, i32* %5
%55 = load i32, i32* %8
%56 = icmp sle i32 %54, %55
br i1 %56, label %57, label %62
57: ; preds = %53
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %59
59: ; preds = %57
%60 = load i32, i32* %5
%61 = add nsw i32 %60, 1
store i32 %61, i32* %5
br label %53
62: ; preds = %53
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 2
store i32 %64, i32* %8
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %67
67: ; preds = %62, %47
%68 = load i32, i32* %7
%69 = add nsw i32 %68, 1
store i32 %69, i32* %7
br label %28
70: ; preds = %28
%71 = load i32, i32* %2
%72 = icmp sgt i32 %71, 1
br i1 %72, label %73, label %85
73: ; preds = %70
store i32 0, i32* %7
br label %74
74: ; preds = %81, %73
%75 = load i32, i32* %7
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
%78 = icmp sle i32 %75, %77
br i1 %78, label %79, label %84
79: ; preds = %74
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %81
81: ; preds = %79
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
store i32 %83, i32* %7
br label %74
84: ; preds = %74
br label %85
85: ; preds = %84, %70
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [3 x i8] c" *\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 = icmp sgt i32 %4, 2
br i1 %5, label %6, label %14
6: ; preds = %0
%7 = mul i32 %4, 3
%8 = add nsw i32 %4, -3
%9 = add nsw i32 %4, -4
%10 = mul i32 %8, %9
%11 = and i32 %10, -2
%12 = add i32 %7, %11
%13 = add i32 %12, -8
br label %14
14: ; preds = %6, %0
%15 = phi i32 [ 0, %0 ], [ %13, %6 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %1
%18 = icmp sgt i32 %17, 1
br i1 %18, label %19, label %65
19: ; preds = %14, %47
%20 = phi i32 [ %49, %47 ], [ 1, %14 ]
%21 = phi i32 [ %50, %47 ], [ 0, %14 ]
%22 = phi i32 [ %48, %47 ], [ %17, %14 ]
%23 = add i32 %22, -2
%24 = icmp sgt i32 %22, 2
br i1 %24, label %25, label %30
25: ; preds = %19, %25
%26 = phi i32 [ %28, %25 ], [ 0, %19 ]
%27 = call i32 @putchar(i32 32)
%28 = add nuw nsw i32 %26, 1
%29 = icmp eq i32 %28, %23
br i1 %29, label %30, label %25
30: ; preds = %25, %19
%31 = icmp eq i32 %21, 0
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %47
34: ; preds = %30
%35 = add nsw i32 %22, -1
%36 = call i32 @putchar(i32 42)
%37 = icmp slt i32 %20, 1
br i1 %37, label %43, label %38
38: ; preds = %34, %38
%39 = phi i32 [ %41, %38 ], [ 1, %34 ]
%40 = call i32 @putchar(i32 35)
%41 = add nuw i32 %39, 1
%42 = icmp eq i32 %39, %20
br i1 %42, label %43, label %38
43: ; preds = %38, %34
%44 = add nsw i32 %20, 2
%45 = call i32 @putchar(i32 42)
%46 = call i32 @putchar(i32 10)
br label %47
47: ; preds = %43, %32
%48 = phi i32 [ %22, %32 ], [ %35, %43 ]
%49 = phi i32 [ %20, %32 ], [ %44, %43 ]
%50 = add nuw nsw i32 %21, 1
%51 = load i32, i32* %1
%52 = add nsw i32 %51, -1
%53 = icmp slt i32 %50, %52
br i1 %53, label %19, label %54
54: ; preds = %47
%55 = icmp slt i32 %51, 2
%56 = icmp slt i32 %49, -1
%57 = select i1 %55, i1 true, i1 %56
br i1 %57, label %65, label %58
58: ; preds = %54
%59 = add i32 %49, 1
br label %60
60: ; preds = %58, %60
%61 = phi i32 [ %63, %60 ], [ 0, %58 ]
%62 = call i32 @putchar(i32 42)
%63 = add nuw i32 %61, 1
%64 = icmp eq i32 %61, %59
br i1 %64, label %65, label %60
65: ; preds = %60, %14, %54
%66 = call i32 @putchar(i32 10)
ret i32 0
}