#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);
int main(void) {
  int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  int *p = a, *q = &a[9], temp;
  while (p < q) {
    temp = *p;
    *p++ = *q;
    *q-- = temp;
  }
  for (p = a; p < a + 10; p++)
    printf("%d ", *p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rax
add    $0x24,%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    119f <main+0x7f>
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%ecx
mov    -0x38(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x38(%rbp)
mov    %ecx,(%rax)
mov    -0x44(%rbp),%ecx
mov    -0x40(%rbp),%rax
mov    %rax,%rdx
add    $0xfffffffffffffffc,%rdx
mov    %rdx,-0x40(%rbp)
mov    %ecx,(%rax)
jmp    1158 <main+0x38>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
lea    -0x30(%rbp),%rcx
add    $0x28,%rcx
cmp    %rcx,%rax
jae    11df <main+0xbf>
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
jmp    11a7 <main+0x87>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps 0xee0(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0xef5(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x20(%rsp),%rax
movl   $0xa,(%rsp)
movl   $0x1,0x24(%rsp)
lea    0x8(%rsp),%rcx
cs nopw 0x0(%rax,%rax,1)
nop
mov    -0x4(%rcx),%edx
mov    (%rax),%esi
mov    %esi,-0x4(%rcx)
mov    %edx,(%rax)
add    $0xfffffffffffffffc,%rax
lea    0x4(%rcx),%rdx
cmp    %rax,%rcx
mov    %rdx,%rcx
jb     1160 <main+0x50>
mov    %rsp,%rbx
lea    0x28(%rsp),%r15
lea    0xe9f(%rip),%r14
nopl   0x0(%rax)
mov    (%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x4,%rbx
cmp    %r15,%rbx
jb     1190 <main+0x80>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.a = [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 \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i32]* %2 to i8*
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
store i32* %7, i32** %3
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 9
store i32* %8, i32** %4
br label %9
9: ; preds = %13, %0
%10 = load i32*, i32** %3
%11 = load i32*, i32** %4
%12 = icmp ult i32* %10, %11
br i1 %12, label %13, label %23
13: ; preds = %9
%14 = load i32*, i32** %3
%15 = load i32, i32* %14
store i32 %15, i32* %5
%16 = load i32*, i32** %4
%17 = load i32, i32* %16
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i32 1
store i32* %19, i32** %3
store i32 %17, i32* %18
%20 = load i32, i32* %5
%21 = load i32*, i32** %4
%22 = getelementptr inbounds i32, i32* %21, i32 -1
store i32* %22, i32** %4
store i32 %20, i32* %21
br label %9
23: ; preds = %9
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
store i32* %24, i32** %3
br label %25
25: ; preds = %34, %23
%26 = load i32*, i32** %3
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%28 = getelementptr inbounds i32, i32* %27, i64 10
%29 = icmp ult i32* %26, %28
br i1 %29, label %30, label %37
30: ; preds = %25
%31 = load i32*, i32** %3
%32 = load i32, i32* %31
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %30
%35 = load i32*, i32** %3
%36 = getelementptr inbounds i32, i32* %35, i32 1
store i32* %36, i32** %3
br label %25
37: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [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 \00"
define i32 @main() {
%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
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
store i32 10, i32* %3
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
store i32 1, i32* %4
br label %9
7: ; preds = %9
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 10
br label %17
9: ; preds = %0, %9
%10 = phi i32* [ %6, %0 ], [ %15, %9 ]
%11 = phi i32* [ %5, %0 ], [ %14, %9 ]
%12 = load i32, i32* %11
%13 = load i32, i32* %10
%14 = getelementptr inbounds i32, i32* %11, i64 1
store i32 %13, i32* %11
%15 = getelementptr inbounds i32, i32* %10, i64 -1
store i32 %12, i32* %10
%16 = icmp ult i32* %14, %15
br i1 %16, label %9, label %7
17: ; preds = %7, %17
%18 = phi i32* [ %3, %7 ], [ %21, %17 ]
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds i32, i32* %18, i64 1
%22 = icmp ult i32* %21, %8
br i1 %22, label %17, label %23
23: ; preds = %17
ret i32 0
}