#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 r, p, k, m, c, v;
  k = 0;
  scanf("%d", &m);
  for (c = 1; c <= m - 2; c++) {
    k = k + c * 2 - 1;
  }
  printf("%d\n", k);
  for (c = 1; c <= m; c++) {
    for (v = 0; v < m - c; v++) {
      printf(" ");
    }
    if (c == m) {
      for (r = 1; r <= m + m - 1; r++) {
        printf("*");
      }
      continue;
    }
    printf("*");
    if (c >= 2) {
      for (p = 2; p < c * 2 - 1; p++) {
        printf("#");
      }
      printf("*");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jg     117d <main+0x5d>
mov    -0x10(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114d <main+0x2d>
mov    -0x10(%rbp),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1296 <main+0x176>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    11d5 <main+0xb5>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a8 <main+0x88>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    121d <main+0xfd>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1218 <main+0xf8>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e8 <main+0xc8>
jmp    1288 <main+0x168>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0x18(%rbp)
jl     127a <main+0x15a>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    126c <main+0x14c>
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    123c <main+0x11c>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1195 <main+0x75>
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),%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    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    125e <main+0x12e>
mov    $0x1,%r14d
mov    $0x1,%r15d
jmp    11b2 <main+0x82>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
lea    0x1(%r15),%ecx
add    $0x2,%r14d
cmp    %eax,%r15d
mov    %ecx,%r15d
jge    125e <main+0x12e>
cmp    $0x4,%r14d
mov    $0x3,%ebp
cmovge %r14d,%ebp
cmp    %r15d,%eax
jle    11ea <main+0xba>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
mov    %eax,%ecx
sub    %r15d,%ecx
cmp    %ecx,%ebx
jl     11d0 <main+0xa0>
cmp    %r15d,%eax
jne    1220 <main+0xf0>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
lea    (%rax,%rax,1),%ecx
cmp    %ecx,%ebx
jl     1200 <main+0xd0>
jmp    119e <main+0x6e>
nopw   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
cmp    $0x2,%r15d
jb     1190 <main+0x60>
add    $0xfffffffe,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1240 <main+0x110>
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
store i32 0, i32* %1
store i32 0, i32* %4
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
store i32 1, i32* %6
br label %9
9: ; preds = %20, %0
%10 = load i32, i32* %6
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 2
%13 = icmp sle i32 %10, %12
br i1 %13, label %14, label %23
14: ; preds = %9
%15 = load i32, i32* %4
%16 = load i32, i32* %6
%17 = mul nsw i32 %16, 2
%18 = add nsw i32 %15, %17
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %4
br label %20
20: ; preds = %14
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %9
23: ; preds = %9
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
store i32 1, i32* %6
br label %26
26: ; preds = %80, %23
%27 = load i32, i32* %6
%28 = load i32, i32* %5
%29 = icmp sle i32 %27, %28
br i1 %29, label %30, label %83
30: ; preds = %26
store i32 0, i32* %7
br label %31
31: ; preds = %39, %30
%32 = load i32, i32* %7
%33 = load i32, i32* %5
%34 = load i32, i32* %6
%35 = sub nsw i32 %33, %34
%36 = icmp slt i32 %32, %35
br i1 %36, label %37, label %42
37: ; preds = %31
%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* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %31
42: ; preds = %31
%43 = load i32, i32* %6
%44 = load i32, i32* %5
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %60
46: ; preds = %42
store i32 1, i32* %2
br label %47
47: ; preds = %56, %46
%48 = load i32, i32* %2
%49 = load i32, i32* %5
%50 = load i32, i32* %5
%51 = add nsw i32 %49, %50
%52 = sub nsw i32 %51, 1
%53 = icmp sle i32 %48, %52
br i1 %53, label %54, label %59
54: ; preds = %47
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %56
56: ; preds = %54
%57 = load i32, i32* %2
%58 = add nsw i32 %57, 1
store i32 %58, i32* %2
br label %47
59: ; preds = %47
br label %80
60: ; preds = %42
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%62 = load i32, i32* %6
%63 = icmp sge i32 %62, 2
br i1 %63, label %64, label %78
64: ; preds = %60
store i32 2, i32* %3
br label %65
65: ; preds = %73, %64
%66 = load i32, i32* %3
%67 = load i32, i32* %6
%68 = mul nsw i32 %67, 2
%69 = sub nsw i32 %68, 1
%70 = icmp slt i32 %66, %69
br i1 %70, label %71, label %76
71: ; preds = %65
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %73
73: ; preds = %71
%74 = load i32, i32* %3
%75 = add nsw i32 %74, 1
store i32 %75, i32* %3
br label %65
76: ; preds = %65
%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, %60
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %80
80: ; preds = %78, %59
%81 = load i32, i32* %6
%82 = add nsw i32 %81, 1
store i32 %82, i32* %6
br label %26
83: ; preds = %26
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 slt i32 %4, 3
br i1 %5, label %14, label %6
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 slt i32 %17, 1
br i1 %18, label %60, label %19
19: ; preds = %14, %55
%20 = phi i32 [ %56, %55 ], [ %17, %14 ]
%21 = phi i32 [ %59, %55 ], [ 1, %14 ]
%22 = phi i32 [ %57, %55 ], [ 1, %14 ]
%23 = call i32 @llvm.smax.i32(i32 %21, i32 3)
%24 = icmp sgt i32 %20, %22
br i1 %24, label %25, label %32
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 = load i32, i32* %1
%30 = sub nsw i32 %29, %22
%31 = icmp slt i32 %28, %30
br i1 %31, label %25, label %32
32: ; preds = %25, %19
%33 = phi i32 [ %20, %19 ], [ %29, %25 ]
%34 = icmp eq i32 %33, %22
br i1 %34, label %35, label %42
35: ; preds = %32, %35
%36 = phi i32 [ %38, %35 ], [ 1, %32 ]
%37 = call i32 @putchar(i32 42)
%38 = add nuw nsw i32 %36, 1
%39 = load i32, i32* %1
%40 = shl nsw i32 %39, 1
%41 = icmp slt i32 %38, %40
br i1 %41, label %35, label %55
42: ; preds = %32
%43 = call i32 @putchar(i32 42)
%44 = icmp ugt i32 %22, 1
br i1 %44, label %45, label %52
45: ; preds = %42, %45
%46 = phi i32 [ %48, %45 ], [ 2, %42 ]
%47 = call i32 @putchar(i32 35)
%48 = add nuw nsw i32 %46, 1
%49 = icmp eq i32 %48, %23
br i1 %49, label %50, label %45
50: ; preds = %45
%51 = call i32 @putchar(i32 42)
br label %52
52: ; preds = %50, %42
%53 = call i32 @putchar(i32 10)
%54 = load i32, i32* %1
br label %55
55: ; preds = %35, %52
%56 = phi i32 [ %54, %52 ], [ %39, %35 ]
%57 = add nuw nsw i32 %22, 1
%58 = icmp slt i32 %22, %56
%59 = add nuw i32 %21, 2
br i1 %58, label %19, label %60
60: ; preds = %55, %14
ret i32 0
}