#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;
  scanf("%d", &n);
  int i = 0, y = 0, help = 0, x = 0, help2 = 0, zvez = 0, reds = n - 2,
      dies = 1, broi = 0;
  do {
    broi = broi + dies;
    i++;
    dies = dies + 2;
  } while (i < reds);
  printf("%d\n", broi);
  for (i = 1; i <= n; i++) {
    x = 0;
    for (; y < n - 1; y++) {
      printf(" ");
    }
    if (i == 1) {
      printf("*\n");
    }
    if (i == 2) {
      printf("*");
      printf("#");
      printf("*\n");
      help++;
      y = help;
      continue;
    }
    if (i == n) {
      do {
        printf("*");
        zvez++;
      } while (zvez < n + (n - 1));
      break;
    }
    if (i > 2) {
      printf("*");
      for (; x < i + help2; x++) {
        printf("#");
      }
      printf("*\n");
      help2++;
    }
    help++;
    y = help;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x28(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x24(%rbp),%eax
jl     1180 <main+0x60>
mov    -0x2c(%rbp),%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     131b <main+0x1fb>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ff <main+0xdf>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d2 <main+0xb2>
cmpl   $0x1,-0xc(%rbp)
jne    1217 <main+0xf7>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x2,-0xc(%rbp)
jne    125f <main+0x13f>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    130d <main+0x1ed>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    12a2 <main+0x182>
jmp    1270 <main+0x150>
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
add    %edx,%ecx
cmp    %ecx,%eax
jl     1270 <main+0x150>
jmp    131b <main+0x1fb>
cmpl   $0x2,-0xc(%rbp)
jle    12fe <main+0x1de>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    12e7 <main+0x1c7>
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12ba <main+0x19a>
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11bf <main+0x9f>
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
add    $0xfffffffe,%eax
cmp    $0x2,%eax
mov    $0x1,%r12d
cmovl  %r12d,%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    0xe76(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    129a <main+0x15a>
lea    0xe5d(%rip),%r14
xor    %ebx,%ebx
jmp    11e4 <main+0xa4>
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
add    $0x1,%ebx
lea    0x1(%r12),%ecx
mov    0xc(%rsp),%eax
cmp    %eax,%r12d
mov    %ecx,%r12d
jge    129a <main+0x15a>
lea    -0x1(%rax),%ecx
cmp    %ecx,%ebx
jge    1208 <main+0xc8>
mov    %ebx,%ebp
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    %ecx,%ebp
jl     11f0 <main+0xb0>
cmp    $0x1,%r12d
je     1260 <main+0x120>
cmp    $0x2,%r12d
je     11b0 <main+0x70>
cmp    %eax,%r12d
je     1273 <main+0x133>
cmp    $0x3,%r12d
jb     11cc <main+0x8c>
mov    $0x2a,%edi
call   1030 <putchar@plt>
lea    (%r12,%r15,1),%ebp
test   %ebp,%ebp
jle    124f <main+0x10f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1240 <main+0x100>
mov    %r14,%rdi
call   1040 <puts@plt>
add    $0x1,%r15d
jmp    11cc <main+0x8c>
mov    %r14,%rdi
call   1040 <puts@plt>
cmpl   $0x1,0xc(%rsp)
jne    11cc <main+0x8c>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0xc(%rsp),%eax
add    %eax,%eax
add    $0xffffffff,%eax
cmp    %eax,%ebx
jl     1280 <main+0x140>
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 = [3 x i8] c"*\0A\00"
@.str.4 = [2 x i8] c"*\00"
@.str.5 = [2 x i8] c"#\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
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
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
%13 = load i32, i32* %2
%14 = sub nsw i32 %13, 2
store i32 %14, i32* %9
store i32 1, i32* %10
store i32 0, i32* %11
br label %15
15: ; preds = %23, %0
%16 = load i32, i32* %11
%17 = load i32, i32* %10
%18 = add nsw i32 %16, %17
store i32 %18, i32* %11
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
%21 = load i32, i32* %10
%22 = add nsw i32 %21, 2
store i32 %22, i32* %10
br label %23
23: ; preds = %15
%24 = load i32, i32* %3
%25 = load i32, i32* %9
%26 = icmp slt i32 %24, %25
br i1 %26, label %15, label %27
27: ; preds = %23
%28 = load i32, i32* %11
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
store i32 1, i32* %3
br label %30
30: ; preds = %101, %27
%31 = load i32, i32* %3
%32 = load i32, i32* %2
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %104
34: ; preds = %30
store i32 0, i32* %6
br label %35
35: ; preds = %42, %34
%36 = load i32, i32* %4
%37 = load i32, i32* %2
%38 = sub nsw i32 %37, 1
%39 = icmp slt i32 %36, %38
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %40
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %35
45: ; preds = %35
%46 = load i32, i32* %3
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %50
48: ; preds = %45
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %48, %45
%51 = load i32, i32* %3
%52 = icmp eq i32 %51, 2
br i1 %52, label %53, label %60
53: ; preds = %50
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 1
store i32 %58, i32* %5
%59 = load i32, i32* %5
store i32 %59, i32* %4
br label %101
60: ; preds = %50
%61 = load i32, i32* %3
%62 = load i32, i32* %2
%63 = icmp eq i32 %61, %62
br i1 %63, label %64, label %77
64: ; preds = %60
br label %65
65: ; preds = %69, %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %69
69: ; preds = %65
%70 = load i32, i32* %8
%71 = load i32, i32* %2
%72 = load i32, i32* %2
%73 = sub nsw i32 %72, 1
%74 = add nsw i32 %71, %73
%75 = icmp slt i32 %70, %74
br i1 %75, label %65, label %76
76: ; preds = %69
br label %104
77: ; preds = %60
%78 = load i32, i32* %3
%79 = icmp sgt i32 %78, 2
br i1 %79, label %80, label %97
80: ; preds = %77
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %82
82: ; preds = %90, %80
%83 = load i32, i32* %6
%84 = load i32, i32* %3
%85 = load i32, i32* %7
%86 = add nsw i32 %84, %85
%87 = icmp slt i32 %83, %86
br i1 %87, label %88, label %93
88: ; preds = %82
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %90
90: ; preds = %88
%91 = load i32, i32* %6
%92 = add nsw i32 %91, 1
store i32 %92, i32* %6
br label %82
93: ; preds = %82
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%95 = load i32, i32* %7
%96 = add nsw i32 %95, 1
store i32 %96, i32* %7
br label %97
97: ; preds = %93, %77
%98 = load i32, i32* %5
%99 = add nsw i32 %98, 1
store i32 %99, i32* %5
%100 = load i32, i32* %5
store i32 %100, i32* %4
br label %101
101: ; preds = %97, %53
%102 = load i32, i32* %3
%103 = add nsw i32 %102, 1
store i32 %103, i32* %3
br label %30
104: ; preds = %76, %30
ret i32 0
}

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