#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__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int *a, *p, i = 0;
  int N;
  printf("ÇëÊäÈëÄãÏëÒªµÄÊý×é³¤¶È£º");
  scanf("%d", &N);
  a = (int *)malloc(N * sizeof(int));
  p = a;
  printf("ÇëÉÔºò¡­¡­\n");
  while (++i <= N) {
    *p++ = rand() % 100;
  }
  printf("=========\n");
  printf("µÃ³ö½á¹û\n");
  while (--i > 0) {
    printf("a[%d]=%3d,", N - i + 1, a[N - i]);
    printf("ÄæÐòºóa[%d]=%3d\n", N - i + 1, *(--p));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <scanf@plt>
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmp    -0x20(%rbp),%eax
jg     11d4 <main+0x94>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x18(%rbp)
mov    %edx,(%rax)
jmp    119d <main+0x5d>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jle    1257 <main+0x117>
mov    -0x20(%rbp),%esi
sub    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
sub    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xfffffffffffffffc,%rcx
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rax),%edx
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f0 <main+0xb0>
mov    -0x4(%rbp),%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
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    11e7 <main+0x97>
mov    $0x1,%ebp
mov    %r12,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rbx)
add    $0x4,%rbx
lea    0x1(%rbp),%r14d
cmp    0x4(%rsp),%ebp
mov    %r14d,%ebp
jl     11b0 <main+0x60>
jmp    11f0 <main+0xa0>
mov    $0x1,%r14d
mov    %r12,%rbx
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x2,%r14d
jl     1284 <main+0x134>
lea    0x1(%r14),%r13d
mov    $0x2,%ebp
sub    %r14d,%ebp
movslq %r14d,%rax
mov    $0x1,%r14d
sub    %rax,%r14
add    $0xfffffffffffffffc,%rbx
lea    0xe0e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq 0x4(%rsp),%rax
lea    (%rax,%rbp,1),%esi
add    %r14,%rax
mov    (%r12,%rax,4),%edx
lea    0xdde(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
add    %ebp,%esi
mov    (%rbx),%edx
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%r13d
add    $0x1,%ebp
add    $0x1,%r14
add    $0xfffffffffffffffc,%rbx
cmp    $0x2,%r13d
ja     1240 <main+0xf0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"\C3\87\C3\AB\C3\8A\C3\A4\C3\88\C3\AB\C3\84\C3\A3\C3\8F\C3\AB\C3\92\C2\AA\C2\B5\C3\84\C3\8A\C3\BD\C3\97\C3\A9\C2\B3\C2\A4\C2\B6\C3\88\C2\A3\C2\BA\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"\C3\87\C3\AB\C3\89\C3\94\C2\BA\C3\B2\C2\A1\C2\AD\C2\A1\C2\AD\0A\00"
@.str.3 = [11 x i8] c"=========\0A\00"
@.str.4 = [18 x i8] c"\C2\B5\C3\83\C2\B3\C3\B6\C2\BD\C3\A1\C2\B9\C3\BB\0A\00"
@.str.5 = [11 x i8] c"a[%d]=%3d,\00"
@.str.6 = [23 x i8] c"\C3\84\C3\A6\C3\90\C3\B2\C2\BA\C3\B3a[%d]=%3d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 4
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %2
%14 = load i32*, i32** %2
store i32* %14, i32** %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %21, %0
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
%19 = load i32, i32* %5
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %26
21: ; preds = %16
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 100
%24 = load i32*, i32** %3
%25 = getelementptr inbounds i32, i32* %24, i32 1
store i32* %25, i32** %3
store i32 %23, i32* %24
br label %16
26: ; preds = %16
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %33, %26
%30 = load i32, i32* %4
%31 = add nsw i32 %30, -1
store i32 %31, i32* %4
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %54
33: ; preds = %29
%34 = load i32, i32* %5
%35 = load i32, i32* %4
%36 = sub nsw i32 %34, %35
%37 = add nsw i32 %36, 1
%38 = load i32*, i32** %2
%39 = load i32, i32* %5
%40 = load i32, i32* %4
%41 = sub nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %38, i64 %42
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %37, i32 %44)
%46 = load i32, i32* %5
%47 = load i32, i32* %4
%48 = sub nsw i32 %46, %47
%49 = add nsw i32 %48, 1
%50 = load i32*, i32** %3
%51 = getelementptr inbounds i32, i32* %50, i32 -1
store i32* %51, i32** %3
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %49, i32 %52)
br label %29
54: ; preds = %29
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
@.str = [49 x i8] c"\C3\87\C3\AB\C3\8A\C3\A4\C3\88\C3\AB\C3\84\C3\A3\C3\8F\C3\AB\C3\92\C2\AA\C2\B5\C3\84\C3\8A\C3\BD\C3\97\C3\A9\C2\B3\C2\A4\C2\B6\C3\88\C2\A3\C2\BA\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.5 = [11 x i8] c"a[%d]=%3d,\00"
@.str.6 = [23 x i8] c"\C3\84\C3\A6\C3\90\C3\B2\C2\BA\C3\B3a[%d]=%3d\0A\00"
@str = [21 x i8] c"\C3\87\C3\AB\C3\89\C3\94\C2\BA\C3\B2\C2\A1\C2\AD\C2\A1\C2\AD\00"
@str.7 = [10 x i8] c"=========\00"
@str.8 = [17 x i8] c"\C2\B5\C3\83\C2\B3\C3\B6\C2\BD\C3\A1\C2\B9\C3\BB\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 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 = shl i32 %5, 2
%7 = call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %0, %12
%13 = phi i32 [ %18, %12 ], [ 1, %0 ]
%14 = phi i32* [ %17, %12 ], [ %8, %0 ]
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 100
%17 = getelementptr inbounds i32, i32* %14, i64 1
store i32 %16, i32* %14
%18 = add nuw nsw i32 %13, 1
%19 = load i32, i32* %1
%20 = icmp slt i32 %13, %19
br i1 %20, label %12, label %21
21: ; preds = %12, %0
%22 = phi i32* [ %8, %0 ], [ %17, %12 ]
%23 = phi i32 [ 1, %0 ], [ %18, %12 ]
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.7, i64 0, i64 0))
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
%26 = icmp sgt i32 %23, 1
br i1 %26, label %27, label %45
27: ; preds = %21, %27
%28 = phi i32 [ %30, %27 ], [ %23, %21 ]
%29 = phi i32* [ %41, %27 ], [ %22, %21 ]
%30 = add nsw i32 %28, -1
%31 = load i32, i32* %1
%32 = sub nsw i32 %31, %30
%33 = add nsw i32 %32, 1
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds i32, i32* %8, i64 %34
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %33, i32 %36)
%38 = load i32, i32* %1
%39 = sub nsw i32 2, %28
%40 = add i32 %39, %38
%41 = getelementptr inbounds i32, i32* %29, i64 -1
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i32 %40, i32 %42)
%44 = icmp ugt i32 %28, 2
br i1 %44, label %27, label %45
45: ; preds = %27, %21
ret i32 0
}