#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 = 0, s = 0, h = 0, k = 0, sumc = 0, sum = 0, b = 1;
  scanf("%d", &a);
  while (sumc < a - 2) {
    sum = sum + b;
    b = b + 2;
    sumc++;
  }
  printf("%d\n", sum);
  while (i < a) {
    while (s < a - 1) {
      printf(" ");
      s++;
    }
    printf("*");
    while (h < k) {
      if (i == a - 1) {
        printf("*");
      } else {
        printf("#");
      }
      h++;
    }
    if (i > 0) {
      printf("*");
    }
    printf("\n");
    if (k == 0) {
      k++;
    } else {
      k = k + 2;
    }
    i++;
    s = i;
    h = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
lea    0xe99(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    11a1 <main+0x81>
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1170 <main+0x50>
mov    -0x20(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12ac <main+0x18c>
jmp    11c3 <main+0xa3>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11f0 <main+0xd0>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c3 <main+0xa3>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    124a <main+0x12a>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    122e <main+0x10e>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123c <main+0x11c>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fe <main+0xde>
cmpl   $0x0,-0xc(%rbp)
jle    1262 <main+0x142>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1288 <main+0x168>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1291 <main+0x171>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
jmp    11b2 <main+0x92>
xor    %eax,%eax
add    $0x30,%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),%eax
xor    %esi,%esi
cmp    $0x3,%eax
jl     1168 <main+0x38>
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    0xe94(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1237 <main+0x107>
mov    $0x1,%r14d
xor    %ebp,%ebp
jmp    11b7 <main+0x87>
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r15d,%r15d
lea    0x2(%r15),%ecx
cmove  %r14d,%ecx
add    $0x1,%ebp
mov    0x4(%rsp),%eax
mov    %ecx,%r15d
cmp    %eax,%ebp
jge    1237 <main+0x107>
add    $0xffffffff,%eax
cmp    %eax,%ebp
jge    11d8 <main+0xa8>
mov    %ebp,%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%ebx
jl     11c0 <main+0x90>
mov    $0x2a,%edi
call   1030 <putchar@plt>
test   %r15d,%r15d
jle    1220 <main+0xf0>
mov    %r15d,%ebx
jmp    11fa <main+0xca>
nopl   0x0(%rax)
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
je     1220 <main+0xf0>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
mov    $0x2a,%edi
cmp    %eax,%ebp
je     11f0 <main+0xc0>
mov    $0x23,%edi
jmp    11f0 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %ebp,%ebp
je     1190 <main+0x60>
mov    $0x2a,%edi
call   1030 <putchar@plt>
jmp    1190 <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
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 1, i32* %9
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %11
11: ; preds = %16, %0
%12 = load i32, i32* %7
%13 = load i32, i32* %2
%14 = sub nsw i32 %13, 2
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %24
16: ; preds = %11
%17 = load i32, i32* %8
%18 = load i32, i32* %9
%19 = add nsw i32 %17, %18
store i32 %19, i32* %8
%20 = load i32, i32* %9
%21 = add nsw i32 %20, 2
store i32 %21, i32* %9
%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* %8
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %74, %24
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %78
31: ; preds = %27
br label %32
32: ; preds = %37, %31
%33 = load i32, i32* %4
%34 = load i32, i32* %2
%35 = sub nsw i32 %34, 1
%36 = icmp slt i32 %33, %35
br i1 %36, label %37, label %41
37: ; preds = %32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %32
41: ; preds = %32
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %56, %41
%44 = load i32, i32* %5
%45 = load i32, i32* %6
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %59
47: ; preds = %43
%48 = load i32, i32* %3
%49 = load i32, i32* %2
%50 = sub nsw i32 %49, 1
%51 = icmp eq i32 %48, %50
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %56
54: ; preds = %47
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %54, %52
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 1
store i32 %58, i32* %5
br label %43
59: ; preds = %43
%60 = load i32, i32* %3
%61 = icmp sgt i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %62, %59
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%66 = load i32, i32* %6
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %64
%69 = load i32, i32* %6
%70 = add nsw i32 %69, 1
store i32 %70, i32* %6
br label %74
71: ; preds = %64
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 2
store i32 %73, i32* %6
br label %74
74: ; preds = %71, %68
%75 = load i32, i32* %3
%76 = add nsw i32 %75, 1
store i32 %76, i32* %3
%77 = load i32, i32* %3
store i32 %77, i32* %4
store i32 0, i32* %5
br label %27
78: ; preds = %27
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 = 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, 0
br i1 %18, label %19, label %56
19: ; preds = %14, %48
%20 = phi i32 [ %54, %48 ], [ %17, %14 ]
%21 = phi i32 [ %52, %48 ], [ 0, %14 ]
%22 = phi i32 [ %53, %48 ], [ 0, %14 ]
%23 = add nsw i32 %20, -1
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %19, %25
%26 = phi i32 [ %28, %25 ], [ %22, %19 ]
%27 = call i32 @putchar(i32 32)
%28 = add nuw nsw i32 %26, 1
%29 = load i32, i32* %1
%30 = add nsw i32 %29, -1
%31 = icmp slt i32 %28, %30
br i1 %31, label %25, label %32
32: ; preds = %25, %19
%33 = call i32 @putchar(i32 42)
%34 = icmp sgt i32 %21, 0
br i1 %34, label %35, label %44
35: ; preds = %32, %35
%36 = phi i32 [ %42, %35 ], [ 0, %32 ]
%37 = load i32, i32* %1
%38 = add nsw i32 %37, -1
%39 = icmp eq i32 %22, %38
%40 = select i1 %39, i32 42, i32 35
%41 = call i32 @putchar(i32 %40)
%42 = add nuw nsw i32 %36, 1
%43 = icmp eq i32 %42, %21
br i1 %43, label %44, label %35
44: ; preds = %35, %32
%45 = icmp eq i32 %22, 0
br i1 %45, label %48, label %46
46: ; preds = %44
%47 = call i32 @putchar(i32 42)
br label %48
48: ; preds = %46, %44
%49 = call i32 @putchar(i32 10)
%50 = icmp eq i32 %21, 0
%51 = add nsw i32 %21, 2
%52 = select i1 %50, i32 1, i32 %51
%53 = add nuw nsw i32 %22, 1
%54 = load i32, i32* %1
%55 = icmp slt i32 %53, %54
br i1 %55, label %19, label %56
56: ; preds = %48, %14
ret i32 0
}