double shiftRDdouble(double zIn, double z[], int N) {
  int i;
  double zOut;
  zOut = z[0];
  for (i = 0; i < N - 1; i++) {
    z[i] = z[i + 1];
  }
  z[N - 1] = zIn;
  return (zOut);
}


x86 assembly (clang, -O0):
<shiftRDdouble>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1162 <shiftRDdouble+0x62>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1124 <shiftRDdouble+0x24>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<shiftRDdouble>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movaps %xmm0,%xmm1
movsd  (%rdi),%xmm0
lea    -0x1(%rsi),%ebp
cmp    $0x2,%esi
jl     1152 <shiftRDdouble+0x42>
lea    0x8(%rbx),%rsi
mov    %ebp,%edx
shl    $0x3,%rdx
mov    %rbx,%rdi
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1030 <memmove@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
movslq %ebp,%rax
movsd  %xmm1,(%rbx,%rax,8)
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define double @shiftRDdouble(double %0, double* nocapture %1, i32 %2) {
%4 = load double, double* %1
%5 = add i32 %2, -1
%6 = icmp sgt i32 %2, 1
br i1 %6, label %7, label %13
7: ; preds = %3
%8 = bitcast double* %1 to i8*
%9 = getelementptr double, double* %1, i64 1
%10 = bitcast double* %9 to i8*
%11 = zext i32 %5 to i64
%12 = shl nuw nsw i64 %11, 3
br label %13
13: ; preds = %7, %3
%14 = sext i32 %5 to i64
%15 = getelementptr inbounds double, double* %1, i64 %14
store double %0, double* %15
ret double %4
}