#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*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n = 0, i = 0, j = 0;
  puts("生成一个正方形");
  printf("正方形有几层: ");
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      putchar('*');
    }
    putchar('\n');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9f(%rip),%rdi
call   1050 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11e2 <main+0xa2>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ca <main+0x8a>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a6 <main+0x66>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1193 <main+0x53>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb8(%rip),%rdi
call   1050 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11c5 <main+0x85>
mov    $0x1,%ebx
jmp    11a7 <main+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%ecx
mov    0x4(%rsp),%eax
cmp    %eax,%ebx
mov    %ecx,%ebx
jge    11c5 <main+0x85>
test   %eax,%eax
jle    1190 <main+0x50>
xor    %ebp,%ebp
nopl   (%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     11b0 <main+0x70>
jmp    1190 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"\E7\94\9F\E6\88\90\E4\B8\80\E4\B8\AA\E6\AD\A3\E6\96\B9\E5\BD\A2\00"
@.str.1 = [21 x i8] c"\E6\AD\A3\E6\96\B9\E5\BD\A2\E6\9C\89\E5\87\A0\E5\B1\82: \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %8
8: ; preds = %24, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %27
12: ; preds = %8
store i32 1, i32* %4
br label %13
13: ; preds = %19, %12
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = call i32 @putchar(i8 signext 42)
br label %19
19: ; preds = %17
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %13
22: ; preds = %13
%23 = call i32 @putchar(i8 signext 10)
br label %24
24: ; preds = %22
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %8
27: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"\E7\94\9F\E6\88\90\E4\B8\80\E4\B8\AA\E6\AD\A3\E6\96\B9\E5\BD\A2\00"
@.str.1 = [21 x i8] c"\E6\AD\A3\E6\96\B9\E5\BD\A2\E6\9C\89\E5\87\A0\E5\B1\82: \00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %23, label %8
8: ; preds = %0, %18
%9 = phi i32 [ %21, %18 ], [ %6, %0 ]
%10 = phi i32 [ %20, %18 ], [ 1, %0 ]
%11 = icmp slt i32 %9, 1
br i1 %11, label %18, label %12
12: ; preds = %8, %12
%13 = phi i32 [ %15, %12 ], [ 1, %8 ]
%14 = call i32 @putchar(i8 signext 42)
%15 = add nuw nsw i32 %13, 1
%16 = load i32, i32* %1
%17 = icmp slt i32 %13, %16
br i1 %17, label %12, label %18
18: ; preds = %12, %8
%19 = call i32 @putchar(i8 signext 10)
%20 = add nuw nsw i32 %10, 1
%21 = load i32, i32* %1
%22 = icmp slt i32 %10, %21
br i1 %22, label %8, label %23
23: ; preds = %18, %0
ret i32 0
}