#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, j, lastline, hashtag = 0;
  scanf("%d", &n);
  for (i = 1; i <= n - 2; i++) {
    hashtag = hashtag + i * 2 - 1;
  }
  printf("%d\n", hashtag);
  for (i = 1; i <= n; i++) {
    for (j = 0; j < n - i; j++) {
      printf(" ");
    }
    if (i == n) {
      for (lastline = 1; lastline <= n + n - 1; lastline++) {
        printf("*");
      }
      continue;
    }
    printf("*");
    if (i >= 2) {
      for (hashtag = 2; hashtag < i * 2 - 1; hashtag++) {
        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,-0x18(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jg     117d <main+0x5d>
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <main+0x2d>
mov    -0x18(%rbp),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1296 <main+0x176>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    11d5 <main+0xb5>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a8 <main+0x88>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    121d <main+0xfd>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1218 <main+0xf8>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e8 <main+0xc8>
jmp    1288 <main+0x168>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0xc(%rbp)
jl     127a <main+0x15a>
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%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    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%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    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%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
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %8
8: ; preds = %19, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = sub nsw i32 %10, 2
%12 = icmp sle i32 %9, %11
br i1 %12, label %13, label %22
13: ; preds = %8
%14 = load i32, i32* %6
%15 = load i32, i32* %3
%16 = mul nsw i32 %15, 2
%17 = add nsw i32 %14, %16
%18 = sub nsw i32 %17, 1
store i32 %18, i32* %6
br label %19
19: ; preds = %13
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %8
22: ; preds = %8
%23 = load i32, i32* %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
store i32 1, i32* %3
br label %25
25: ; preds = %79, %22
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %82
29: ; preds = %25
store i32 0, i32* %4
br label %30
30: ; preds = %38, %29
%31 = load i32, i32* %4
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = sub nsw i32 %32, %33
%35 = icmp slt i32 %31, %34
br i1 %35, label %36, label %41
36: ; preds = %30
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %30
41: ; preds = %30
%42 = load i32, i32* %3
%43 = load i32, i32* %2
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %59
45: ; preds = %41
store i32 1, i32* %5
br label %46
46: ; preds = %55, %45
%47 = load i32, i32* %5
%48 = load i32, i32* %2
%49 = load i32, i32* %2
%50 = add nsw i32 %48, %49
%51 = sub nsw i32 %50, 1
%52 = icmp sle i32 %47, %51
br i1 %52, label %53, label %58
53: ; preds = %46
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %53
%56 = load i32, i32* %5
%57 = add nsw i32 %56, 1
store i32 %57, i32* %5
br label %46
58: ; preds = %46
br label %79
59: ; preds = %41
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%61 = load i32, i32* %3
%62 = icmp sge i32 %61, 2
br i1 %62, label %63, label %77
63: ; preds = %59
store i32 2, i32* %6
br label %64
64: ; preds = %72, %63
%65 = load i32, i32* %6
%66 = load i32, i32* %3
%67 = mul nsw i32 %66, 2
%68 = sub nsw i32 %67, 1
%69 = icmp slt i32 %65, %68
br i1 %69, label %70, label %75
70: ; preds = %64
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %72
72: ; preds = %70
%73 = load i32, i32* %6
%74 = add nsw i32 %73, 1
store i32 %74, i32* %6
br label %64
75: ; preds = %64
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %77
77: ; preds = %75, %59
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %79
79: ; preds = %77, %58
%80 = load i32, i32* %3
%81 = add nsw i32 %80, 1
store i32 %81, i32* %3
br label %25
82: ; preds = %25
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
}