#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 */
typedef int /*<<< orphan*/ array;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void nizhiArray() {
  int array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  int end = sizeof(array) / 4 - 1;
  int start = 0;
  int *p = array;
  while (start < end) {
    int temp = *(p + start);
    *(p + start) = *(p + end);
    *(p + end) = temp;
    start++;
    end--;
  }
  for (int i = 0; i < sizeof(array) / 4; i++) {
    printf("%d\n", array[i]);
  }
}


x86 assembly (clang, -O0):
<nizhiArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x30(%rbp),%rdi
lea    0xecd(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0x9,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11a8 <nizhiArray+0x88>
mov    -0x40(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x40(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x44(%rbp),%edx
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    1153 <nizhiArray+0x33>
movl   $0x0,-0x48(%rbp)
movslq -0x48(%rbp),%rax
cmp    $0xa,%rax
jae    11df <nizhiArray+0xbf>
movslq -0x48(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11af <nizhiArray+0x8f>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nizhiArray>:
push   %rbx
sub    $0x30,%rsp
movaps 0xee4(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0xef9(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xedd(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0xa,(%rsp)
movl   $0x1,0x24(%rsp)
mov    $0x8,%eax
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x4(%rsp,%rcx,4),%edx
mov    (%rsp,%rax,4),%esi
mov    %esi,-0x4(%rsp,%rcx,4)
mov    %edx,(%rsp,%rax,4)
add    $0xffffffffffffffff,%rax
lea    0x1(%rcx),%rdx
cmp    %rax,%rcx
mov    %rdx,%rcx
jb     1160 <nizhiArray+0x50>
mov    (%rsp),%esi
lea    0xea0(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
add    $0x30,%rsp
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.nizhiArray.array = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [4 x i8] c"%d\0A\00"
define void @nizhiArray() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = bitcast [10 x i32]* %1 to i8*
store i32 9, i32* %2
store i32 0, i32* %3
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
store i32* %8, i32** %4
br label %9
9: ; preds = %13, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %37
13: ; preds = %9
%14 = load i32*, i32** %4
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
store i32 %18, i32* %5
%19 = load i32*, i32** %4
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = load i32*, i32** %4
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
store i32 %23, i32* %27
%28 = load i32, i32* %5
%29 = load i32*, i32** %4
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 %28, i32* %32
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
%35 = load i32, i32* %2
%36 = add nsw i32 %35, -1
store i32 %36, i32* %2
br label %9
37: ; preds = %9
store i32 0, i32* %6
br label %38
38: ; preds = %48, %37
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = icmp ult i64 %40, 10
br i1 %41, label %42, label %51
42: ; preds = %38
%43 = load i32, i32* %6
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %42
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %38
51: ; preds = %38
ret void
}

LLVM IR (-O2):
@__const.nizhiArray.array = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
@.str = [4 x i8] c"%d\0A\00"
define void @nizhiArray() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
store i32 10, i32* %3
store i32 1, i32* %4
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 8, %0 ], [ %15, %5 ]
%7 = phi i64 [ 1, %0 ], [ %14, %5 ]
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %7
%9 = load i32, i32* %8
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %6
%11 = load i32, i32* %10
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %7
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %6
store i32 %11, i32* %12
store i32 %9, i32* %13
%14 = add nuw nsw i64 %7, 1
%15 = add nsw i64 %6, -1
%16 = icmp ult i64 %14, %15
br i1 %16, label %5, label %17
17: ; preds = %5
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%19 = load i32, i32* %18
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%22 = load i32, i32* %21
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%25 = load i32, i32* %24
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%28 = load i32, i32* %27
%29 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%31 = load i32, i32* %30
%32 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%34 = load i32, i32* %33
%35 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%37 = load i32, i32* %36
%38 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%40 = load i32, i32* %39
%41 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%43 = load i32, i32* %42
%44 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%46 = load i32, i32* %45
%47 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %46)
ret void
}