#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++) {
      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    11d8 <main+0xb8>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d1 <main+0xb1>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b7 <main+0x97>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1191 <main+0x71>
lea    0xe85(%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
nopl   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     11a0 <main+0x70>
jmp    1180 <main+0x50>

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"\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 %35
14: ; preds = %9
store i32 0, i32* %3
br label %15
15: ; preds = %31, %14
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
store i32 0, i32* %4
br label %20
20: ; preds = %26, %19
%21 = load i32, i32* %4
%22 = load i32, i32* %2
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %20
29: ; preds = %20
%30 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %15
34: ; preds = %15
store i32 0, i32* %1
br label %35
35: ; preds = %34, %12
%36 = load i32, i32* %1
ret i32 %36
}

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 %25
10: ; preds = %0, %20
%11 = phi i32 [ %23, %20 ], [ %5, %0 ]
%12 = phi i32 [ %22, %20 ], [ 0, %0 ]
%13 = icmp sgt i32 %11, 0
br i1 %13, label %14, label %20
14: ; preds = %10, %14
%15 = phi i32 [ %17, %14 ], [ 0, %10 ]
%16 = call i32 @putchar(i32 42)
%17 = add nuw nsw i32 %15, 1
%18 = load i32, i32* %1
%19 = icmp slt i32 %17, %18
br i1 %19, label %14, label %20
20: ; preds = %14, %10
%21 = call i32 @putchar(i32 10)
%22 = add nuw nsw i32 %12, 1
%23 = load i32, i32* %1
%24 = icmp slt i32 %22, %23
br i1 %24, label %10, label %25
25: ; preds = %20, %8
ret i32 0
}