#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 i, t = 0, c, k, broi = 1, p = 0, sum = 0, space, rows = 0;
  scanf("%d", &rows);
  space = rows - 1;
  for (p = 2; p <= rows - 1; p++) {
    sum += broi;
    broi = broi + 2;
  }
  printf("%d\n", sum);
  for (i = 1; i <= rows; i++) {
    if (i == rows) {
      for (t = 0; t < (rows * 2) - 1; t++)
        printf("*");
      break;
    }
    for (c = 1; c < space; c++) {
      printf(" ");
    }
    if (i == 1) {
      printf(" *\n");
      continue;
    }
    for (k = 1; k < (i * 2) - 1; k++) {
      if (k == 1)
        printf("*");
      else
        printf("#");
    }
    printf("*");
    space--;
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11a3 <main+0x83>
mov    -0x18(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1172 <main+0x52>
mov    -0x20(%rbp),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     12e7 <main+0x1c7>
mov    -0x8(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    120f <main+0xef>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x28(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    120a <main+0xea>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11da <main+0xba>
jmp    12e7 <main+0x1c7>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    123e <main+0x11e>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1216 <main+0xf6>
cmpl   $0x1,-0x8(%rbp)
jne    125b <main+0x13b>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d9 <main+0x1b9>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12b4 <main+0x194>
cmpl   $0x1,-0x14(%rbp)
jne    1293 <main+0x173>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a1 <main+0x181>
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a6 <main+0x186>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1262 <main+0x142>
lea    0xd4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11bb <main+0x9b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xea6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%r15d
xor    %esi,%esi
cmp    $0x3,%r15d
jl     1189 <main+0x49>
lea    (%r15,%r15,2),%eax
lea    -0x3(%r15),%ecx
lea    -0x4(%r15),%edx
imul   %ecx,%edx
and    $0xfffffffe,%edx
lea    (%rdx,%rax,1),%esi
add    $0xfffffff8,%esi
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    128a <main+0x14a>
add    $0xffffffff,%r15d
mov    $0x1,%r13d
lea    0xe53(%rip),%r14
mov    $0x1,%r12d
jmp    11e1 <main+0xa1>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0x1(%r12),%ecx
mov    0x4(%rsp),%eax
add    $0x2,%r13d
cmp    %eax,%r12d
mov    %ecx,%r12d
jge    128a <main+0x14a>
cmp    $0x3,%r13d
mov    $0x2,%ebx
cmovge %r13d,%ebx
cmp    %eax,%r12d
je     125c <main+0x11c>
cmp    $0x2,%r15d
jl     120f <main+0xcf>
lea    -0x1(%r15),%ebp
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1200 <main+0xc0>
cmp    $0x1,%r12d
je     11c0 <main+0x80>
mov    $0x2a,%edi
call   1030 <putchar@plt>
cmp    $0x3,%r13d
jl     123f <main+0xff>
add    $0xfffffffe,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1230 <main+0xf0>
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%r15d
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11c8 <main+0x88>
test   %eax,%eax
jle    128a <main+0x14a>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
add    %eax,%eax
add    $0xffffffff,%eax
cmp    %eax,%ebx
jl     1270 <main+0x130>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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 = [4 x i8] c" *\0A\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
%10 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 1, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %10
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %10)
%12 = load i32, i32* %10
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %9
store i32 2, i32* %7
br label %14
14: ; preds = %25, %0
%15 = load i32, i32* %7
%16 = load i32, i32* %10
%17 = sub nsw i32 %16, 1
%18 = icmp sle i32 %15, %17
br i1 %18, label %19, label %28
19: ; preds = %14
%20 = load i32, i32* %6
%21 = load i32, i32* %8
%22 = add nsw i32 %21, %20
store i32 %22, i32* %8
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 2
store i32 %24, i32* %6
br label %25
25: ; preds = %19
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %14
28: ; preds = %14
%29 = load i32, i32* %8
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
store i32 1, i32* %2
br label %31
31: ; preds = %90, %28
%32 = load i32, i32* %2
%33 = load i32, i32* %10
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %93
35: ; preds = %31
%36 = load i32, i32* %2
%37 = load i32, i32* %10
%38 = icmp eq i32 %36, %37
br i1 %38, label %39, label %52
39: ; preds = %35
store i32 0, i32* %3
br label %40
40: ; preds = %48, %39
%41 = load i32, i32* %3
%42 = load i32, i32* %10
%43 = mul nsw i32 %42, 2
%44 = sub nsw i32 %43, 1
%45 = icmp slt i32 %41, %44
br i1 %45, label %46, label %51
46: ; preds = %40
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %48
48: ; preds = %46
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %40
51: ; preds = %40
br label %93
52: ; preds = %35
store i32 1, i32* %4
br label %53
53: ; preds = %59, %52
%54 = load i32, i32* %4
%55 = load i32, i32* %9
%56 = icmp slt 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.3, i64 0, i64 0))
br label %59
59: ; preds = %57
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
br label %53
62: ; preds = %53
%63 = load i32, i32* %2
%64 = icmp eq i32 %63, 1
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %90
67: ; preds = %62
store i32 1, i32* %5
br label %68
68: ; preds = %82, %67
%69 = load i32, i32* %5
%70 = load i32, i32* %2
%71 = mul nsw i32 %70, 2
%72 = sub nsw i32 %71, 1
%73 = icmp slt i32 %69, %72
br i1 %73, label %74, label %85
74: ; preds = %68
%75 = load i32, i32* %5
%76 = icmp eq i32 %75, 1
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %81
79: ; preds = %74
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %81
81: ; preds = %79, %77
br label %82
82: ; preds = %81
%83 = load i32, i32* %5
%84 = add nsw i32 %83, 1
store i32 %84, i32* %5
br label %68
85: ; preds = %68
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%87 = load i32, i32* %9
%88 = add nsw i32 %87, -1
store i32 %88, i32* %9
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %90
90: ; preds = %85, %65
%91 = load i32, i32* %2
%92 = add nsw i32 %91, 1
store i32 %92, i32* %2
br label %31
93: ; preds = %51, %31
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*
store i32 0, i32* %1
%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 nsw i32 %4, -1
%6 = icmp sgt i32 %4, 2
br i1 %6, label %7, label %15
7: ; preds = %0
%8 = mul i32 %4, 3
%9 = add nsw i32 %4, -3
%10 = add nsw i32 %4, -4
%11 = mul i32 %9, %10
%12 = and i32 %11, -2
%13 = add i32 %8, %12
%14 = add i32 %13, -8
br label %15
15: ; preds = %7, %0
%16 = phi i32 [ 0, %0 ], [ %14, %7 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %1
%19 = icmp slt i32 %18, 1
br i1 %19, label %66, label %20
20: ; preds = %15, %60
%21 = phi i32 [ %65, %60 ], [ 1, %15 ]
%22 = phi i32 [ %63, %60 ], [ %18, %15 ]
%23 = phi i32 [ %61, %60 ], [ %5, %15 ]
%24 = phi i32 [ %62, %60 ], [ 1, %15 ]
%25 = call i32 @llvm.smax.i32(i32 %21, i32 2)
%26 = icmp eq i32 %24, %22
br i1 %26, label %29, label %27
27: ; preds = %20
%28 = icmp sgt i32 %23, 1
br i1 %28, label %39, label %44
29: ; preds = %20
%30 = icmp sgt i32 %22, 0
br i1 %30, label %31, label %66
31: ; preds = %29, %31
%32 = phi i32 [ %34, %31 ], [ 0, %29 ]
%33 = call i32 @putchar(i32 42)
%34 = add nuw nsw i32 %32, 1
%35 = load i32, i32* %1
%36 = shl nsw i32 %35, 1
%37 = add nsw i32 %36, -1
%38 = icmp slt i32 %34, %37
br i1 %38, label %31, label %66
39: ; preds = %27, %39
%40 = phi i32 [ %42, %39 ], [ 1, %27 ]
%41 = call i32 @putchar(i32 32)
%42 = add nuw nsw i32 %40, 1
%43 = icmp eq i32 %42, %23
br i1 %43, label %44, label %39
44: ; preds = %39, %27
%45 = icmp eq i32 %24, 1
br i1 %45, label %49, label %46
46: ; preds = %44
%47 = call i32 @putchar(i32 42)
%48 = icmp slt i32 %21, 3
br i1 %48, label %56, label %51
49: ; preds = %44
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %60
51: ; preds = %46, %51
%52 = phi i32 [ %54, %51 ], [ 2, %46 ]
%53 = call i32 @putchar(i32 35)
%54 = add nuw nsw i32 %52, 1
%55 = icmp eq i32 %54, %25
br i1 %55, label %56, label %51
56: ; preds = %51, %46
%57 = call i32 @putchar(i32 42)
%58 = add nsw i32 %23, -1
%59 = call i32 @putchar(i32 10)
br label %60
60: ; preds = %56, %49
%61 = phi i32 [ %23, %49 ], [ %58, %56 ]
%62 = add nuw nsw i32 %24, 1
%63 = load i32, i32* %1
%64 = icmp slt i32 %24, %63
%65 = add nuw i32 %21, 2
br i1 %64, label %20, label %66
66: ; preds = %60, %31, %15, %29
ret i32 0
}