#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n1, i;
  int *array;
  printf("请输入所要创建的一维动态数组的长度：");
  scanf("%d", &n1);
  array = (int *)calloc(n1, sizeof(int));
  for (i = 0; i < n1; i++) {
    printf("%d\t", array[i]);
  }
  printf("\n");
  for (i = 0; i < n1; i++) {
    array[i] = i + 1;
    printf("%d\t", array[i]);
  }
  free(array);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b8 <main+0x78>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1185 <main+0x45>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1211 <main+0xd1>
mov    -0xc(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cd <main+0x8d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%r15
cmpl   $0x0,0xc(%rsp)
jle    11bc <main+0x6c>
lea    0xea3(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11a0 <main+0x50>
mov    $0xa,%edi
call   1040 <putchar@plt>
cmpl   $0x0,0xc(%rsp)
jle    1201 <main+0xb1>
lea    0xe66(%rip),%r14
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%rax),%rbx
mov    %ebx,(%r15,%rax,4)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0xc(%rsp),%rcx
mov    %rbx,%rax
cmp    %rcx,%rbx
jl     11e0 <main+0x90>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [55 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E6\89\80\E8\A6\81\E5\88\9B\E5\BB\BA\E7\9A\84\E4\B8\80\E7\BB\B4\E5\8A\A8\E6\80\81\E6\95\B0\E7\BB\84\E7\9A\84\E9\95\BF\E5\BA\A6\EF\BC\9A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\09\00"
@.str.3 = [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 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 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)
%7 = load i32, i32* %2
%8 = call i64 @calloc(i32 %7, i32 4)
%9 = inttoptr i64 %8 to i32*
store i32* %9, i32** %4
store i32 0, i32* %3
br label %10
10: ; preds = %21, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i32*, i32** %4
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %14
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %10
24: ; preds = %10
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %26
26: ; preds = %43, %24
%27 = load i32, i32* %3
%28 = load i32, i32* %2
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %46
30: ; preds = %26
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
%33 = load i32*, i32** %4
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 %32, i32* %36
%37 = load i32*, i32** %4
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %30
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %26
46: ; preds = %26
%47 = load i32*, i32** %4
%48 = call i32 @free(i32* %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [55 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E6\89\80\E8\A6\81\E5\88\9B\E5\BB\BA\E7\9A\84\E4\B8\80\E7\BB\B4\E5\8A\A8\E6\80\81\E6\95\B0\E7\BB\84\E7\9A\84\E9\95\BF\E5\BA\A6\EF\BC\9A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\09\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 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 = call i64 @calloc(i32 %5, i32 4)
%7 = inttoptr i64 %6 to i32*
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %0, %10
%11 = phi i64 [ %15, %10 ], [ 0, %0 ]
%12 = getelementptr inbounds i32, i32* %7, i64 %11
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i64 %11, 1
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %10, label %19
19: ; preds = %10, %0
%20 = call i32 @putchar(i32 10)
%21 = load i32, i32* %1
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %19, %23
%24 = phi i64 [ %25, %23 ], [ 0, %19 ]
%25 = add nuw nsw i64 %24, 1
%26 = getelementptr inbounds i32, i32* %7, i64 %24
%27 = trunc i64 %25 to i32
store i32 %27, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %1
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %25, %30
br i1 %31, label %23, label %32
32: ; preds = %23, %19
%33 = call i32 @free(i32* %7)
ret i32 0
}