#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 < i - 1; j++) {
      putchar(' ');
    }
    n = 2 * (level - i) + 1;
    for (k = 0; k < n; k++) {
      printf("%d", i % 10);
    }
    for (j = 0; j < i - 1; 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    0xea3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1272 <main+0x132>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11df <main+0x9f>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11b6 <main+0x76>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    122a <main+0xea>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f5 <main+0xb5>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    125a <main+0x11a>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1231 <main+0xf1>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a3 <main+0x63>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1254 <main+0x114>
mov    $0x1,%r15d
lea    0xea6(%rip),%r13
xor    %r12d,%r12d
jmp    11c2 <main+0x82>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r15),%ecx
mov    0x4(%rsp),%eax
add    $0x1,%r12d
cmp    %eax,%r15d
mov    %ecx,%r15d
jge    1254 <main+0x114>
cmp    $0x2,%r15d
jb     11e3 <main+0xa3>
mov    %r12d,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11d0 <main+0x90>
mov    0x4(%rsp),%eax
sub    %r15d,%eax
lea    (%rax,%rax,1),%ebx
add    $0x1,%ebx
test   %ebx,%ebx
jle    1225 <main+0xe5>
mov    %r15d,%eax
mov    $0xcccccccd,%ecx
imul   %rcx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %r15d,%ebp
sub    %eax,%ebp
xor    %r14d,%r14d
nopl   (%rax)
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r14d
cmp    %ebx,%r14d
jl     1210 <main+0xd0>
mov    %r12d,%ebx
cmp    $0x2,%r15d
jb     11a0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1240 <main+0x100>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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