#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*/ repeat(char, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  char contour = '*';
  char body = '#';
  char background = ' ';
  int height;
  scanf("%d", &height);
  printf("%d\n", (height - 2) * (height - 2));
  repeat(background, height - 1);
  repeat(contour, 1);
  repeat(background, height - 1);
  printf("\n");
  for (int i = 0; i < height - 2; i++) {
    repeat(background, height - 2 - i);
    repeat(contour, 1);
    repeat(body, 2 * i + 1);
    repeat(contour, 1);
    repeat(background, height - 2 - i);
    printf("\n");
  }
  repeat(contour, 2 * height - 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x2a,-0x5(%rbp)
movb   $0x23,-0x6(%rbp)
movb   $0x20,-0x7(%rbp)
lea    0xeae(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%esi
sub    $0x2,%esi
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
imul   %eax,%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x7(%rbp),%al
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
movsbl %al,%edi
call   1030 <repeat@plt>
mov    $0x1,%esi
movsbl -0x5(%rbp),%edi
call   1030 <repeat@plt>
mov    -0x7(%rbp),%al
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
movsbl %al,%edi
call   1030 <repeat@plt>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    1242 <main+0x112>
mov    -0x7(%rbp),%al
mov    -0xc(%rbp),%esi
sub    $0x2,%esi
sub    -0x10(%rbp),%esi
movsbl %al,%edi
call   1030 <repeat@plt>
mov    $0x1,%esi
movsbl -0x5(%rbp),%edi
call   1030 <repeat@plt>
mov    -0x6(%rbp),%al
mov    -0x10(%rbp),%esi
shl    $0x1,%esi
add    $0x1,%esi
movsbl %al,%edi
call   1030 <repeat@plt>
mov    $0x1,%esi
movsbl -0x5(%rbp),%edi
call   1030 <repeat@plt>
mov    -0x7(%rbp),%al
mov    -0xc(%rbp),%esi
sub    $0x2,%esi
sub    -0x10(%rbp),%esi
movsbl %al,%edi
call   1030 <repeat@plt>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11bd <main+0x8d>
mov    -0x5(%rbp),%al
mov    -0xc(%rbp),%esi
shl    $0x1,%esi
sub    $0x1,%esi
movsbl %al,%edi
call   1030 <repeat@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
add    $0xfffffffe,%esi
imul   %esi,%esi
lea    0xe99(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
add    $0xffffffff,%esi
mov    $0x20,%edi
call   1040 <repeat@plt>
mov    $0x1,%ebx
mov    $0x2a,%edi
mov    $0x1,%esi
call   1040 <repeat@plt>
mov    0xc(%rsp),%esi
add    $0xffffffff,%esi
mov    $0x20,%edi
call   1040 <repeat@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
jl     123a <main+0xfa>
add    $0xfffffffe,%eax
mov    $0xfffffffe,%ebp
mov    %eax,%ecx
nopw   0x0(%rax,%rax,1)
lea    (%rcx,%rbp,1),%esi
add    $0x2,%esi
mov    $0x20,%edi
call   1040 <repeat@plt>
mov    $0x2a,%edi
mov    $0x1,%esi
call   1040 <repeat@plt>
mov    $0x23,%edi
mov    %ebx,%esi
call   1040 <repeat@plt>
mov    $0x2a,%edi
mov    $0x1,%esi
call   1040 <repeat@plt>
mov    0xc(%rsp),%esi
add    %ebp,%esi
mov    $0x20,%edi
call   1040 <repeat@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
mov    0xc(%rsp),%eax
lea    -0x2(%rax),%ecx
add    $0xffffffff,%ebp
add    $0x2,%ebx
cmp    %r14d,%ecx
jg     11d0 <main+0x90>
lea    (%rax,%rax,1),%esi
add    $0xffffffff,%esi
mov    $0x2a,%edi
call   1040 <repeat@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
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"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i8 42, i8* %2
store i8 35, i8* %3
store i8 32, i8* %4
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%8 = load i32, i32* %5
%9 = sub nsw i32 %8, 2
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 2
%12 = mul nsw i32 %9, %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i8, i8* %4
%15 = load i32, i32* %5
%16 = sub nsw i32 %15, 1
%17 = call i32 @repeat(i8 signext %14, i32 %16)
%18 = load i8, i8* %2
%19 = call i32 @repeat(i8 signext %18, i32 1)
%20 = load i8, i8* %4
%21 = load i32, i32* %5
%22 = sub nsw i32 %21, 1
%23 = call i32 @repeat(i8 signext %20, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %25
25: ; preds = %53, %0
%26 = load i32, i32* %6
%27 = load i32, i32* %5
%28 = sub nsw i32 %27, 2
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %56
30: ; preds = %25
%31 = load i8, i8* %4
%32 = load i32, i32* %5
%33 = sub nsw i32 %32, 2
%34 = load i32, i32* %6
%35 = sub nsw i32 %33, %34
%36 = call i32 @repeat(i8 signext %31, i32 %35)
%37 = load i8, i8* %2
%38 = call i32 @repeat(i8 signext %37, i32 1)
%39 = load i8, i8* %3
%40 = load i32, i32* %6
%41 = mul nsw i32 2, %40
%42 = add nsw i32 %41, 1
%43 = call i32 @repeat(i8 signext %39, i32 %42)
%44 = load i8, i8* %2
%45 = call i32 @repeat(i8 signext %44, i32 1)
%46 = load i8, i8* %4
%47 = load i32, i32* %5
%48 = sub nsw i32 %47, 2
%49 = load i32, i32* %6
%50 = sub nsw i32 %48, %49
%51 = call i32 @repeat(i8 signext %46, i32 %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %30
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %25
56: ; preds = %25
%57 = load i8, i8* %2
%58 = load i32, i32* %5
%59 = mul nsw i32 2, %58
%60 = sub nsw i32 %59, 1
%61 = call i32 @repeat(i8 signext %57, i32 %60)
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 = add nsw i32 %4, -2
%6 = mul nsw i32 %5, %5
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
%10 = call i32 @repeat(i8 signext 32, i32 %9)
%11 = call i32 @repeat(i8 signext 42, i32 1)
%12 = load i32, i32* %1
%13 = add nsw i32 %12, -1
%14 = call i32 @repeat(i8 signext 32, i32 %13)
%15 = call i32 @putchar(i32 10)
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, 2
br i1 %17, label %18, label %20
18: ; preds = %0
%19 = add nsw i32 %16, -2
br label %25
20: ; preds = %25, %0
%21 = phi i32 [ %16, %0 ], [ %41, %25 ]
%22 = shl nsw i32 %21, 1
%23 = add nsw i32 %22, -1
%24 = call i32 @repeat(i8 signext 42, i32 %23)
ret i32 0
25: ; preds = %18, %25
%26 = phi i32 [ %42, %25 ], [ %19, %18 ]
%27 = phi i32 [ %40, %25 ], [ 0, %18 ]
%28 = sub nsw i32 %26, %27
%29 = call i32 @repeat(i8 signext 32, i32 %28)
%30 = call i32 @repeat(i8 signext 42, i32 1)
%31 = shl nuw nsw i32 %27, 1
%32 = or i32 %31, 1
%33 = call i32 @repeat(i8 signext 35, i32 %32)
%34 = call i32 @repeat(i8 signext 42, i32 1)
%35 = load i32, i32* %1
%36 = sub nuw nsw i32 -2, %27
%37 = add i32 %36, %35
%38 = call i32 @repeat(i8 signext 32, i32 %37)
%39 = call i32 @putchar(i32 10)
%40 = add nuw nsw i32 %27, 1
%41 = load i32, i32* %1
%42 = add nsw i32 %41, -2
%43 = icmp sgt i32 %42, %40
br i1 %43, label %25, label %20
}