#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 *);
int main() {
  int h, w, i, j;
  while (1) {
    scanf("%d%d\n", &h, &w);
    if (h == 0)
      break;
    for (i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
        if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
          printf("#");
        else
          printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1152 <main+0x32>
jmp    1209 <main+0xe9>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f8 <main+0xd8>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11de <main+0xbe>
cmpl   $0x0,-0x10(%rbp)
je     11ae <main+0x8e>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11ae <main+0x8e>
cmpl   $0x0,-0x14(%rbp)
je     11ae <main+0x8e>
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11bf <main+0x9f>
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
jmp    11cb <main+0xab>
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
jmp    11d0 <main+0xb0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <main+0x4c>
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1159 <main+0x39>
lea    0xe05(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
je     1207 <main+0xe7>
lea    0xeab(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xc(%rsp),%r12
jmp    1190 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
je     1207 <main+0xe7>
test   %eax,%eax
jle    1170 <main+0x50>
xor    %ebp,%ebp
jmp    11b3 <main+0x93>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jge    1170 <main+0x50>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11a0 <main+0x80>
xor    %ebx,%ebx
jmp    11da <main+0xba>
nop
test   %ebx,%ebx
cmove  %edx,%edi
cmp    %ecx,%ebp
cmove  %edx,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0xc(%rsp),%eax
cmp    %eax,%ebx
jge    11a0 <main+0x80>
test   %ebp,%ebp
je     1200 <main+0xe0>
mov    0x8(%rsp),%ecx
add    $0xffffffff,%ecx
add    $0xffffffff,%eax
mov    $0x23,%edx
mov    $0x23,%edi
cmp    %eax,%ebx
je     11c0 <main+0xa0>
mov    $0x2e,%edi
jmp    11c0 <main+0xa0>
nopl   (%rax)
mov    $0x23,%edi
jmp    11ca <main+0xaa>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d%d\0A\00"
@.str.1 = [2 x i8] c"#\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 i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %0, %50
%7 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %6
br label %52
11: ; preds = %6
store i32 0, i32* %4
br label %12
12: ; preds = %47, %11
%13 = load i32, i32* %4
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %50
16: ; preds = %12
store i32 0, i32* %5
br label %17
17: ; preds = %42, %16
%18 = load i32, i32* %5
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %45
21: ; preds = %17
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 0
br i1 %23, label %37, label %24
24: ; preds = %21
%25 = load i32, i32* %4
%26 = load i32, i32* %2
%27 = sub nsw i32 %26, 1
%28 = icmp eq i32 %25, %27
br i1 %28, label %37, label %29
29: ; preds = %24
%30 = load i32, i32* %5
%31 = icmp eq i32 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = load i32, i32* %5
%34 = load i32, i32* %3
%35 = sub nsw i32 %34, 1
%36 = icmp eq i32 %33, %35
br i1 %36, label %37, label %39
37: ; preds = %32, %29, %24, %21
%38 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %41
39: ; preds = %32
%40 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %39, %37
br label %42
42: ; preds = %41
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %17
45: ; preds = %17
%46 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %45
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %12
50: ; preds = %12
%51 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %6
52: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %46, label %8
8: ; preds = %0, %41
%9 = phi i32 [ %44, %41 ], [ %6, %0 ]
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %41
11: ; preds = %8, %36
%12 = phi i32 [ %38, %36 ], [ 0, %8 ]
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %36
15: ; preds = %11
%16 = icmp eq i32 %12, 0
br label %17
17: ; preds = %15, %30
%18 = phi i32 [ %13, %15 ], [ %34, %30 ]
%19 = phi i32 [ 0, %15 ], [ %33, %30 ]
br i1 %16, label %30, label %20
20: ; preds = %17
%21 = load i32, i32* %1
%22 = add nsw i32 %21, -1
%23 = icmp eq i32 %12, %22
%24 = icmp eq i32 %19, 0
%25 = select i1 %23, i1 true, i1 %24
%26 = add nsw i32 %18, -1
%27 = icmp eq i32 %19, %26
%28 = select i1 %25, i1 true, i1 %27
%29 = select i1 %28, i32 35, i32 46
br label %30
30: ; preds = %20, %17
%31 = phi i32 [ 35, %17 ], [ %29, %20 ]
%32 = call i32 @putchar(i32 %31)
%33 = add nuw nsw i32 %19, 1
%34 = load i32, i32* %2
%35 = icmp slt i32 %33, %34
br i1 %35, label %17, label %36
36: ; preds = %30, %11
%37 = call i32 @putchar(i32 10)
%38 = add nuw nsw i32 %12, 1
%39 = load i32, i32* %1
%40 = icmp slt i32 %38, %39
br i1 %40, label %11, label %41
41: ; preds = %36, %8
%42 = call i32 @putchar(i32 10)
%43 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%44 = load i32, i32* %1
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %8
46: ; preds = %41, %0
ret i32 0
}