#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 x;
  int i, h;
  printf("Inserisci le dimensioni del lato del quadrato: ");
  scanf("%d", &x);
  for (i = 0; i < x; i++) {
    for (h = 0; h < x; h++) {
      if ((h == 0 || h == (x - 1)) || (i == 0 || i == (x - 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    0xeee(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f1 <main+0xd1>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d7 <main+0xb7>
cmpl   $0x0,-0x10(%rbp)
je     11a7 <main+0x87>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11a7 <main+0x87>
cmpl   $0x0,-0xc(%rbp)
je     11a7 <main+0x87>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11b8 <main+0x98>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
jmp    11c4 <main+0xa4>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
jmp    11c9 <main+0xa9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1165 <main+0x45>
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <main+0x32>
xor    %eax,%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    0xeea(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11d2 <main+0xa2>
xor    %ebx,%ebx
jmp    1175 <main+0x45>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
cmp    %eax,%ebx
jge    11d2 <main+0xa2>
test   %eax,%eax
jle    1160 <main+0x30>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
jl     1160 <main+0x30>
mov    $0x1,%ebp
jmp    11ba <main+0x8a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %ebx,%ebx
cmove  %ecx,%edi
cmp    %eax,%ebp
cmove  %ecx,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%eax
cmp    %eax,%ebp
jge    1160 <main+0x30>
add    $0xffffffff,%eax
mov    $0x2a,%ecx
mov    $0x2a,%edi
cmp    %eax,%ebx
je     11a0 <main+0x70>
mov    $0x20,%edi
jmp    11a0 <main+0x70>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Inserisci le dimensioni del lato del quadrato: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"*\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 ([48 x i8], [48 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)
store i32 0, i32* %3
br label %7
7: ; preds = %42, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %45
11: ; preds = %7
store i32 0, i32* %4
br label %12
12: ; preds = %37, %11
%13 = load i32, i32* %4
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %40
16: ; preds = %12
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 0
br i1 %18, label %32, label %19
19: ; preds = %16
%20 = load i32, i32* %4
%21 = load i32, i32* %2
%22 = sub nsw i32 %21, 1
%23 = icmp eq i32 %20, %22
br i1 %23, label %32, label %24
24: ; preds = %19
%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, %19, %16
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
34: ; preds = %27
%35 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
br label %37
37: ; preds = %36
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %12
40: ; preds = %12
%41 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %42
42: ; preds = %40
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %7
45: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [48 x i8] c"Inserisci le dimensioni del lato del quadrato: \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 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 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %34
7: ; preds = %0, %29
%8 = phi i32 [ %32, %29 ], [ %5, %0 ]
%9 = phi i32 [ %31, %29 ], [ 0, %0 ]
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %29
11: ; preds = %7
%12 = icmp eq i32 %9, 0
%13 = call i32 @putchar(i32 42)
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %29
16: ; preds = %11, %16
%17 = phi i32 [ %27, %16 ], [ %14, %11 ]
%18 = phi i32 [ %26, %16 ], [ 1, %11 ]
%19 = add nsw i32 %17, -1
%20 = icmp eq i32 %18, %19
%21 = select i1 %20, i1 true, i1 %12
%22 = icmp eq i32 %9, %19
%23 = select i1 %21, i1 true, i1 %22
%24 = select i1 %23, i32 42, i32 32
%25 = call i32 @putchar(i32 %24)
%26 = add nuw nsw i32 %18, 1
%27 = load i32, i32* %1
%28 = icmp slt i32 %26, %27
br i1 %28, label %16, label %29
29: ; preds = %16, %11, %7
%30 = call i32 @putchar(i32 10)
%31 = add nuw nsw i32 %9, 1
%32 = load i32, i32* %1
%33 = icmp slt i32 %31, %32
br i1 %33, label %7, label %34
34: ; preds = %29, %0
ret i32 0
}