#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 size, i, j;
  printf("Enter size of square: ");
  scanf("%d", &size);
  if (size < 1 || size > 20) {
    printf("Size must be in the range 1 through 20");
    return 0;
  }
  for (i = 0; i < size; i++) {
    for (j = 0; j < size; j++) {
      if (i == 0 || i == size - 1)
        printf("*");
      else if (j == 0 || j == size - 1)
        printf("*");
      else
        printf(" ");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     115f <main+0x3f>
cmpl   $0x14,-0x8(%rbp)
jle    1177 <main+0x57>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123a <main+0x11a>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1233 <main+0x113>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1219 <main+0xf9>
cmpl   $0x0,-0xc(%rbp)
je     11b8 <main+0x98>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11c9 <main+0xa9>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <main+0xe6>
cmpl   $0x0,-0x10(%rbp)
je     11e4 <main+0xc4>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11f5 <main+0xd5>
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
jmp    1201 <main+0xe1>
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
jmp    1206 <main+0xe6>
jmp    120b <main+0xeb>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1191 <main+0x71>
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117e <main+0x5e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x15(%rax),%ecx
cmp    $0xffffffec,%ecx
jae    1171 <main+0x41>
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %ebx,%ebx
jmp    1195 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
cmp    %eax,%ebx
jge    1168 <main+0x38>
test   %eax,%eax
jle    1180 <main+0x50>
xor    %ebp,%ebp
jmp    11b5 <main+0x85>
nopl   (%rax)
test   %ebp,%ebp
cmove  %ecx,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%eax
cmp    %eax,%ebp
jge    1180 <main+0x50>
mov    $0x2a,%edi
test   %ebx,%ebx
je     11a5 <main+0x75>
add    $0xffffffff,%eax
cmp    %eax,%ebx
je     11a5 <main+0x75>
mov    $0x2a,%ecx
mov    $0x2a,%edi
cmp    %eax,%ebp
je     11a0 <main+0x70>
mov    $0x20,%edi
jmp    11a0 <main+0x70>

LLVM IR (-O0):
@.str = [23 x i8] c"Enter size of square: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"Size must be in the range 1 through 20\00"
@.str.3 = [2 x i8] c"*\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 20
br i1 %11, label %12, label %14
12: ; preds = %9, %0
%13 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %57
14: ; preds = %9
store i32 0, i32* %3
br label %15
15: ; preds = %53, %14
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %56
19: ; preds = %15
store i32 0, i32* %4
br label %20
20: ; preds = %48, %19
%21 = load i32, i32* %4
%22 = load i32, i32* %2
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %51
24: ; preds = %20
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %24
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = sub nsw i32 %29, 1
%31 = icmp eq i32 %28, %30
br i1 %31, label %32, label %34
32: ; preds = %27, %24
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %47
34: ; preds = %27
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %34
%38 = load i32, i32* %4
%39 = load i32, i32* %2
%40 = sub nsw i32 %39, 1
%41 = icmp eq i32 %38, %40
br i1 %41, label %42, label %44
42: ; preds = %37, %34
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %46
44: ; preds = %37
%45 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
br label %47
47: ; preds = %46, %32
br label %48
48: ; preds = %47
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %20
51: ; preds = %20
%52 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %51
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %15
56: ; preds = %15
store i32 0, i32* %1
br label %57
57: ; preds = %56, %12
%58 = load i32, i32* %1
ret i32 %58
}

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