#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 lato;
  int I;
  int k;
  printf("\n          Programma che tramite l'uso del carattere * disegna un "
         "quadrato");
  do {
    printf("\n inserire il lato del quadrato(1-20):     ");
    scanf("%d", &lato);
  } while ((lato < 0) || (lato > 20));
  I = 0;
  while (I < lato) {
    printf("*");
    k = 1;
    while (k < lato - 1) {
      if ((I = 0) || (I = (lato - 1))) {
        printf("*");
      } else {
        printf(" ");
      }
      k++;
    }
    printf("*");
    printf("\n");
    I++;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
call   1030 <printf@plt>
lea    0xf29(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
jl     1170 <main+0x50>
cmpl   $0x14,-0x8(%rbp)
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    113b <main+0x1b>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1226 <main+0x106>
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1200 <main+0xe0>
movl   $0x0,-0xc(%rbp)
xor    %eax,%eax
test   $0x1,%al
jne    11d5 <main+0xb5>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     11e6 <main+0xc6>
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
jmp    11f2 <main+0xd2>
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a1 <main+0x81>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1182 <main+0x62>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
lea    0xf01(%rip),%r14
lea    0xf26(%rip),%r15
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x14,%eax
ja     1160 <main+0x30>
test   %eax,%eax
je     11f5 <main+0xc5>
xor    %ebx,%ebx
jmp    11ad <main+0x7d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    0x4(%rsp),%ebx
jge    11f5 <main+0xc5>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%eax
cmp    $0x3,%eax
jl     1190 <main+0x60>
add    $0xffffffff,%eax
mov    $0x1,%ebp
jmp    11e3 <main+0xb3>
nopw   0x0(%rax,%rax,1)
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%ebp
jge    1190 <main+0x60>
mov    %eax,%ebx
mov    $0x20,%edi
test   %eax,%eax
je     11d0 <main+0xa0>
mov    $0x2a,%edi
jmp    11d0 <main+0xa0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [75 x i8] c"\0A Programma che tramite l'uso del carattere * disegna un quadrato\00"
@.str.1 = [44 x i8] c"\0A inserire il lato del quadrato(1-20): \00"
@.str.2 = [3 x i8] c"%d\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 ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %15, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 20
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ true, %9 ], [ %14, %12 ]
br i1 %16, label %6, label %17
17: ; preds = %15
store i32 0, i32* %3
br label %18
18: ; preds = %41, %17
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %46
22: ; preds = %18
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %4
br label %24
24: ; preds = %38, %22
%25 = load i32, i32* %4
%26 = load i32, i32* %2
%27 = sub nsw i32 %26, 1
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %41
29: ; preds = %24
store i32 0, i32* %3
br i1 false, label %34, label %30
30: ; preds = %29
%31 = load i32, i32* %2
%32 = sub nsw i32 %31, 1
store i32 %32, i32* %3
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30, %29
%35 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %38
36: ; preds = %30
%37 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %38
38: ; preds = %36, %34
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %24
41: ; preds = %24
%42 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %18
46: ; preds = %18
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [75 x i8] c"\0A Programma che tramite l'uso del carattere * disegna un quadrato\00"
@.str.1 = [44 x i8] c"\0A inserire il lato del quadrato(1-20): \00"
@.str.2 = [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 ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %4, %0
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp ugt i32 %7, 20
br i1 %8, label %4, label %9
9: ; preds = %4
%10 = icmp eq i32 %7, 0
br i1 %10, label %35, label %11
11: ; preds = %9, %28
%12 = phi i32 [ %32, %28 ], [ 0, %9 ]
%13 = call i32 @putchar(i32 42)
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 2
br i1 %15, label %16, label %28
16: ; preds = %11
%17 = add nsw i32 %14, -1
br label %18
18: ; preds = %16, %18
%19 = phi i32 [ %26, %18 ], [ %17, %16 ]
%20 = phi i32 [ %24, %18 ], [ 1, %16 ]
%21 = icmp eq i32 %19, 0
%22 = select i1 %21, i32 32, i32 42
%23 = call i32 @putchar(i32 %22)
%24 = add nuw nsw i32 %20, 1
%25 = load i32, i32* %1
%26 = add nsw i32 %25, -1
%27 = icmp slt i32 %24, %26
br i1 %27, label %18, label %28
28: ; preds = %18, %11
%29 = phi i32 [ %12, %11 ], [ %19, %18 ]
%30 = call i32 @putchar(i32 42)
%31 = call i32 @putchar(i32 10)
%32 = add nsw i32 %29, 1
%33 = load i32, i32* %1
%34 = icmp slt i32 %32, %33
br i1 %34, label %11, label %35
35: ; preds = %28, %9
ret i32 0
}