#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 level = 0;
  int i = 0;
  int j = 0;
  int k = 0;
  int n = 0;
  puts("让我们来画一个金字塔");
  printf("金字塔有几层: ");
  scanf("%d", &level);
  for (i = 1; i <= level; i++) {
    for (j = 0; j < level - i; j++) {
      putchar(' ');
    }
    n = 2 * (i - 1) + 1;
    for (k = 0; k < n; k++) {
      putchar('*');
    }
    for (j = 0; j < level - i; j++) {
      putchar(' ');
    }
    putchar('\n');
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe87(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9a(%rip),%rdi
call   1050 <printf@plt>
lea    0xea3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     125f <main+0x11f>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    11dd <main+0x9d>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b4 <main+0x74>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1217 <main+0xd7>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f3 <main+0xb3>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    1247 <main+0x107>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    121e <main+0xde>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a1 <main+0x61>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xea9(%rip),%rdi
call   1040 <puts@plt>
lea    0xebc(%rip),%rdi
call   1050 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    123c <main+0xfc>
mov    $0x1,%r14d
mov    $0x1,%ebx
jmp    11bf <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%ecx
mov    0xc(%rsp),%eax
add    $0x2,%r14d
cmp    %eax,%ebx
mov    %ecx,%ebx
jge    123c <main+0xfc>
cmp    %ebx,%eax
jle    11e9 <main+0xa9>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0xc(%rsp),%eax
mov    %eax,%ecx
sub    %ebx,%ecx
cmp    %ecx,%ebp
jl     11d0 <main+0x90>
lea    (%rbx,%rbx,1),%ecx
add    $0xffffffff,%ecx
mov    %r14d,%ebp
test   %ecx,%ecx
jle    1213 <main+0xd3>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1200 <main+0xc0>
mov    0xc(%rsp),%eax
cmp    %ebx,%eax
jle    11a0 <main+0x60>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0xc(%rsp),%eax
sub    %ebx,%eax
cmp    %eax,%ebp
jl     1220 <main+0xe0>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"\E8\AE\A9\E6\88\91\E4\BB\AC\E6\9D\A5\E7\94\BB\E4\B8\80\E4\B8\AA\E9\87\91\E5\AD\97\E5\A1\94\00"
@.str.1 = [21 x i8] c"\E9\87\91\E5\AD\97\E5\A1\94\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
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%9 = 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 %10
10: ; preds = %54, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %57
14: ; preds = %10
store i32 0, i32* %4
br label %15
15: ; preds = %23, %14
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = sub nsw i32 %17, %18
%20 = icmp slt i32 %16, %19
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = call i32 @putchar(i8 signext 32)
br label %23
23: ; preds = %21
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %15
26: ; preds = %15
%27 = load i32, i32* %3
%28 = sub nsw i32 %27, 1
%29 = mul nsw i32 2, %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
store i32 0, i32* %5
br label %31
31: ; preds = %37, %26
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = call i32 @putchar(i8 signext 42)
br label %37
37: ; preds = %35
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %31
40: ; preds = %31
store i32 0, i32* %4
br label %41
41: ; preds = %49, %40
%42 = load i32, i32* %4
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = sub nsw i32 %43, %44
%46 = icmp slt i32 %42, %45
br i1 %46, label %47, label %52
47: ; preds = %41
%48 = call i32 @putchar(i8 signext 32)
br label %49
49: ; preds = %47
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %41
52: ; preds = %41
%53 = call i32 @putchar(i8 signext 10)
br label %54
54: ; preds = %52
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %10
57: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"\E8\AE\A9\E6\88\91\E4\BB\AC\E6\9D\A5\E7\94\BB\E4\B8\80\E4\B8\AA\E9\87\91\E5\AD\97\E5\A1\94\00"
@.str.1 = [21 x i8] c"\E9\87\91\E5\AD\97\E5\A1\94\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 ([31 x i8], [31 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 %48, label %8
8: ; preds = %0, %42
%9 = phi i32 [ %45, %42 ], [ %6, %0 ]
%10 = phi i32 [ %47, %42 ], [ 1, %0 ]
%11 = phi i32 [ %44, %42 ], [ 1, %0 ]
%12 = icmp sgt i32 %9, %11
br i1 %12, label %13, label %20
13: ; preds = %8, %13
%14 = phi i32 [ %16, %13 ], [ 0, %8 ]
%15 = call i32 @putchar(i8 signext 32)
%16 = add nuw nsw i32 %14, 1
%17 = load i32, i32* %1
%18 = sub nsw i32 %17, %11
%19 = icmp slt i32 %16, %18
br i1 %19, label %13, label %20
20: ; preds = %13, %8
%21 = phi i32 [ %9, %8 ], [ %17, %13 ]
%22 = shl nuw i32 %11, 1
%23 = add i32 %22, -1
%24 = icmp sgt i32 %23, 0
br i1 %24, label %30, label %27
25: ; preds = %30
%26 = load i32, i32* %1
br label %27
27: ; preds = %25, %20
%28 = phi i32 [ %26, %25 ], [ %21, %20 ]
%29 = icmp sgt i32 %28, %11
br i1 %29, label %35, label %42
30: ; preds = %20, %30
%31 = phi i32 [ %33, %30 ], [ 0, %20 ]
%32 = call i32 @putchar(i8 signext 42)
%33 = add nuw nsw i32 %31, 1
%34 = icmp eq i32 %33, %10
br i1 %34, label %25, label %30
35: ; preds = %27, %35
%36 = phi i32 [ %38, %35 ], [ 0, %27 ]
%37 = call i32 @putchar(i8 signext 32)
%38 = add nuw nsw i32 %36, 1
%39 = load i32, i32* %1
%40 = sub nsw i32 %39, %11
%41 = icmp slt i32 %38, %40
br i1 %41, label %35, label %42
42: ; preds = %35, %27
%43 = call i32 @putchar(i8 signext 10)
%44 = add nuw nsw i32 %11, 1
%45 = load i32, i32* %1
%46 = icmp slt i32 %11, %45
%47 = add nuw i32 %10, 2
br i1 %46, label %8, label %48
48: ; preds = %42, %0
ret i32 0
}