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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movb   $0x2a,-0x9(%rbp)
movb   $0x20,-0xa(%rbp)
movb   $0x23,-0xb(%rbp)
mov    -0x8(%rbp),%esi
sub    $0x2,%esi
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
imul   %eax,%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa(%rbp),%al
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
movsbl %al,%edi
call   1040 <printing@plt>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa(%rbp),%al
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
movsbl %al,%edi
call   1040 <printing@plt>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    1242 <main+0x112>
mov    -0xa(%rbp),%al
mov    -0x8(%rbp),%esi
sub    $0x2,%esi
sub    -0x10(%rbp),%esi
movsbl %al,%edi
call   1040 <printing@plt>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xb(%rbp),%al
mov    -0x10(%rbp),%esi
shl    $0x1,%esi
add    $0x1,%esi
movsbl %al,%edi
call   1040 <printing@plt>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xa(%rbp),%al
mov    -0x8(%rbp),%esi
sub    $0x2,%esi
sub    -0x10(%rbp),%esi
movsbl %al,%edi
call   1040 <printing@plt>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11bd <main+0x8d>
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%esi
shl    $0x1,%esi
sub    $0x1,%esi
movsbl %al,%edi
call   1040 <printing@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   1040 <printf@plt>
mov    0xc(%rsp),%esi
add    $0xffffffff,%esi
mov    $0x20,%edi
call   1050 <printing@plt>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%esi
add    $0xffffffff,%esi
mov    $0x20,%edi
call   1050 <printing@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
jl     1230 <main+0xf0>
add    $0xfffffffe,%eax
mov    $0xfffffffe,%ebp
mov    $0x1,%ebx
mov    %eax,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%rcx,%rbp,1),%esi
add    $0x2,%esi
mov    $0x20,%edi
call   1050 <printing@plt>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0x23,%edi
mov    %ebx,%esi
call   1050 <printing@plt>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%esi
add    %ebp,%esi
mov    $0x20,%edi
call   1050 <printing@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   1050 <printing@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"*\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i8 42, i8* %3
store i8 32, i8* %4
store i8 35, i8* %5
%8 = load i32, i32* %2
%9 = sub nsw i32 %8, 2
%10 = load i32, i32* %2
%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* %2
%16 = sub nsw i32 %15, 1
%17 = call i32 @printing(i8 signext %14, i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = load i8, i8* %4
%20 = load i32, i32* %2
%21 = sub nsw i32 %20, 1
%22 = call i32 @printing(i8 signext %19, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %24
24: ; preds = %50, %0
%25 = load i32, i32* %6
%26 = load i32, i32* %2
%27 = sub nsw i32 %26, 2
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %53
29: ; preds = %24
%30 = load i8, i8* %4
%31 = load i32, i32* %2
%32 = sub nsw i32 %31, 2
%33 = load i32, i32* %6
%34 = sub nsw i32 %32, %33
%35 = call i32 @printing(i8 signext %30, i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%37 = load i8, i8* %5
%38 = load i32, i32* %6
%39 = mul nsw i32 2, %38
%40 = add nsw i32 %39, 1
%41 = call i32 @printing(i8 signext %37, i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%43 = load i8, i8* %4
%44 = load i32, i32* %2
%45 = sub nsw i32 %44, 2
%46 = load i32, i32* %6
%47 = sub nsw i32 %45, %46
%48 = call i32 @printing(i8 signext %43, i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %29
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %24
53: ; preds = %24
%54 = load i8, i8* %3
%55 = load i32, i32* %2
%56 = mul nsw i32 %55, 2
%57 = sub nsw i32 %56, 1
%58 = call i32 @printing(i8 signext %54, i32 %57)
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 @printing(i8 signext 32, i32 %9)
%11 = call i32 @putchar(i32 42)
%12 = load i32, i32* %1
%13 = add nsw i32 %12, -1
%14 = call i32 @printing(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 @printing(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 @printing(i8 signext 32, i32 %28)
%30 = call i32 @putchar(i32 42)
%31 = shl nuw nsw i32 %27, 1
%32 = or i32 %31, 1
%33 = call i32 @printing(i8 signext 35, i32 %32)
%34 = call i32 @putchar(i32 42)
%35 = load i32, i32* %1
%36 = sub nuw nsw i32 -2, %27
%37 = add i32 %36, %35
%38 = call i32 @printing(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
}