void areversep(double *arr, int nm) {
  for (double *p = arr, *q = arr + nm - 1; p < q; ++p, --q) {
    double temp = *p;
    *p = *q;
    *q = temp;
  }
}


x86 assembly (clang, -O0):
<areversep>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    117f <areversep+0x7f>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x20(%rbp)
jmp    112a <areversep+0x2a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<areversep>:
movslq %esi,%rax
lea    (%rdi,%rax,8),%rax
add    $0xfffffffffffffff8,%rax
cmp    %rdi,%rax
jbe    1142 <areversep+0x42>
add    $0x8,%rdi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  -0x8(%rdi),%xmm0
movsd  (%rax),%xmm1
movsd  %xmm1,-0x8(%rdi)
movsd  %xmm0,(%rax)
add    $0xfffffffffffffff8,%rax
lea    0x8(%rdi),%rcx
cmp    %rax,%rdi
mov    %rcx,%rdi
jb     1120 <areversep+0x20>
ret

LLVM IR (-O0):
define void @areversep(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
store double* %0, double** %3
store i32 %1, i32* %4
%8 = load double*, double** %3
store double* %8, double** %5
%9 = load double*, double** %3
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds double, double* %9, i64 %11
%13 = getelementptr inbounds double, double* %12, i64 -1
store double* %13, double** %6
br label %14
14: ; preds = %26, %2
%15 = load double*, double** %5
%16 = load double*, double** %6
%17 = icmp ult double* %15, %16
br i1 %17, label %18, label %31
18: ; preds = %14
%19 = load double*, double** %5
%20 = load double, double* %19
store double %20, double* %7
%21 = load double*, double** %6
%22 = load double, double* %21
%23 = load double*, double** %5
store double %22, double* %23
%24 = load double, double* %7
%25 = load double*, double** %6
store double %24, double* %25
br label %26
26: ; preds = %18
%27 = load double*, double** %5
%28 = getelementptr inbounds double, double* %27, i32 1
store double* %28, double** %5
%29 = load double*, double** %6
%30 = getelementptr inbounds double, double* %29, i32 -1
store double* %30, double** %6
br label %14
31: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @areversep(double* %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds double, double* %0, i64 %3
%5 = getelementptr inbounds double, double* %4, i64 -1
%6 = icmp ugt double* %5, %0
br i1 %6, label %8, label %7
7: ; preds = %8, %2
ret void
8: ; preds = %2, %8
%9 = phi double* [ %14, %8 ], [ %5, %2 ]
%10 = phi double* [ %13, %8 ], [ %0, %2 ]
%11 = load double, double* %10
%12 = load double, double* %9
store double %12, double* %10
store double %11, double* %9
%13 = getelementptr inbounds double, double* %10, i64 1
%14 = getelementptr inbounds double, double* %9, i64 -1
%15 = icmp ult double* %13, %14
br i1 %15, label %8, label %7
}