void LF_GBS_drift(double *r, double *v, int N, double dt) {
  int i;
  for (i = 0; i < 3 * N; i++) {
    r[i] += dt * v[i];
  }
}


x86 assembly (clang, -O0):
<LF_GBS_drift>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
imul   $0x3,-0x14(%rbp),%ecx
cmp    %ecx,%eax
jge    1164 <LF_GBS_drift+0x64>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    111b <LF_GBS_drift+0x1b>
pop    %rbp
ret

x86 assembly (clang, -O2):
<LF_GBS_drift>:
test   %edx,%edx
jle    127f <LF_GBS_drift+0x17f>
lea    (%rdx,%rdx,2),%eax
cmp    $0x2,%eax
mov    $0x1,%r9d
cmovge %eax,%r9d
cmp    $0x4,%r9d
jb     1130 <LF_GBS_drift+0x30>
lea    (%rsi,%r9,8),%rax
cmp    %rdi,%rax
jbe    1197 <LF_GBS_drift+0x97>
lea    (%rdi,%r9,8),%rax
cmp    %rsi,%rax
jbe    1197 <LF_GBS_drift+0x97>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
test   $0x1,%r9b
je     1155 <LF_GBS_drift+0x55>
movsd  (%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rdi,%rcx,8),%xmm1
movsd  %xmm1,(%rdi,%rcx,8)
or     $0x1,%rcx
add    %r9,%rax
je     127f <LF_GBS_drift+0x17f>
xchg   %ax,%ax
movsd  (%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rdi,%rcx,8),%xmm1
movsd  %xmm1,(%rdi,%rcx,8)
movsd  0x8(%rsi,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rdi,%rcx,8),%xmm1
movsd  %xmm1,0x8(%rdi,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%r9
jne    1160 <LF_GBS_drift+0x60>
jmp    127f <LF_GBS_drift+0x17f>
mov    %r9d,%ecx
and    $0x7ffffffc,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rcx),%rax
mov    %rax,%r8
shr    $0x2,%r8
add    $0x1,%r8
test   %rax,%rax
je     1280 <LF_GBS_drift+0x180>
mov    %r8,%rax
and    $0xfffffffffffffffe,%rax
xor    %edx,%edx
nopl   0x0(%rax)
movupd (%rsi,%rdx,8),%xmm2
movupd 0x10(%rsi,%rdx,8),%xmm3
mulpd  %xmm1,%xmm2
movupd (%rdi,%rdx,8),%xmm4
addpd  %xmm2,%xmm4
movupd 0x10(%rdi,%rdx,8),%xmm2
movupd 0x20(%rdi,%rdx,8),%xmm5
movupd 0x30(%rdi,%rdx,8),%xmm6
mulpd  %xmm1,%xmm3
addpd  %xmm2,%xmm3
movupd %xmm4,(%rdi,%rdx,8)
movupd %xmm3,0x10(%rdi,%rdx,8)
movupd 0x20(%rsi,%rdx,8),%xmm2
movupd 0x30(%rsi,%rdx,8),%xmm3
mulpd  %xmm1,%xmm2
addpd  %xmm5,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm6,%xmm3
movupd %xmm2,0x20(%rdi,%rdx,8)
movupd %xmm3,0x30(%rdi,%rdx,8)
add    $0x8,%rdx
add    $0xfffffffffffffffe,%rax
jne    11d0 <LF_GBS_drift+0xd0>
test   $0x1,%r8b
je     1276 <LF_GBS_drift+0x176>
movupd (%rsi,%rdx,8),%xmm2
movupd 0x10(%rsi,%rdx,8),%xmm3
movupd (%rdi,%rdx,8),%xmm4
movupd 0x10(%rdi,%rdx,8),%xmm5
mulpd  %xmm1,%xmm2
addpd  %xmm4,%xmm2
mulpd  %xmm1,%xmm3
addpd  %xmm5,%xmm3
movupd %xmm2,(%rdi,%rdx,8)
movupd %xmm3,0x10(%rdi,%rdx,8)
cmp    %r9,%rcx
jne    1132 <LF_GBS_drift+0x32>
ret
xor    %edx,%edx
test   $0x1,%r8b
jne    1245 <LF_GBS_drift+0x145>
jmp    1276 <LF_GBS_drift+0x176>

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

LLVM IR (-O2):
define void @LF_GBS_drift(double* nocapture %0, double* nocapture %1, i32 %2, double %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %122
6: ; preds = %4
%7 = mul i32 %2, 3
%8 = call i32 @llvm.smax.i32(i32 %7, i32 1)
%9 = zext i32 %8 to i64
%10 = icmp ult i32 %8, 4
br i1 %10, label %91, label %11
11: ; preds = %6
%12 = getelementptr double, double* %0, i64 %9
%13 = getelementptr double, double* %1, i64 %9
%14 = icmp ugt double* %13, %0
%15 = icmp ugt double* %12, %1
%16 = and i1 %14, %15
br i1 %16, label %91, label %17
17: ; preds = %11
%18 = and i64 %9, 2147483644
%19 = insertelement <2 x double> poison, double %3, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = insertelement <2 x double> poison, double %3, i64 0
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> zeroinitializer
%23 = add nsw i64 %18, -4
%24 = lshr exact i64 %23, 2
%25 = add nuw nsw i64 %24, 1
%26 = and i64 %25, 1
%27 = icmp eq i64 %23, 0
br i1 %27, label %69, label %28
28: ; preds = %17
%29 = and i64 %25, 9223372036854775806
br label %30
30: ; preds = %30, %28
%31 = phi i64 [ 0, %28 ], [ %66, %30 ]
%32 = phi i64 [ 0, %28 ], [ %67, %30 ]
%33 = getelementptr inbounds double, double* %1, i64 %31
%34 = bitcast double* %33 to <2 x double>*
%35 = load <2 x double>, <2 x double>* %34
%36 = getelementptr inbounds double, double* %33, i64 2
%37 = bitcast double* %36 to <2 x double>*
%38 = load <2 x double>, <2 x double>* %37
%39 = getelementptr inbounds double, double* %0, i64 %31
%40 = bitcast double* %39 to <2 x double>*
%41 = load <2 x double>, <2 x double>* %40
%42 = getelementptr inbounds double, double* %39, i64 2
%43 = bitcast double* %42 to <2 x double>*
%44 = load <2 x double>, <2 x double>* %43
%45 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> %35, <2 x double> %41)
%46 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> %38, <2 x double> %44)
%47 = bitcast double* %39 to <2 x double>*
store <2 x double> %45, <2 x double>* %47
%48 = bitcast double* %42 to <2 x double>*
store <2 x double> %46, <2 x double>* %48
%49 = or i64 %31, 4
%50 = getelementptr inbounds double, double* %1, i64 %49
%51 = bitcast double* %50 to <2 x double>*
%52 = load <2 x double>, <2 x double>* %51
%53 = getelementptr inbounds double, double* %50, i64 2
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = getelementptr inbounds double, double* %0, i64 %49
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = getelementptr inbounds double, double* %56, i64 2
%60 = bitcast double* %59 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> %52, <2 x double> %58)
%63 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> %55, <2 x double> %61)
%64 = bitcast double* %56 to <2 x double>*
store <2 x double> %62, <2 x double>* %64
%65 = bitcast double* %59 to <2 x double>*
store <2 x double> %63, <2 x double>* %65
%66 = add nuw i64 %31, 8
%67 = add i64 %32, 2
%68 = icmp eq i64 %67, %29
br i1 %68, label %69, label %30
69: ; preds = %30, %17
%70 = phi i64 [ 0, %17 ], [ %66, %30 ]
%71 = icmp eq i64 %26, 0
br i1 %71, label %89, label %72
72: ; preds = %69
%73 = getelementptr inbounds double, double* %1, i64 %70
%74 = bitcast double* %73 to <2 x double>*
%75 = load <2 x double>, <2 x double>* %74
%76 = getelementptr inbounds double, double* %73, i64 2
%77 = bitcast double* %76 to <2 x double>*
%78 = load <2 x double>, <2 x double>* %77
%79 = getelementptr inbounds double, double* %0, i64 %70
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = getelementptr inbounds double, double* %79, i64 2
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %20, <2 x double> %75, <2 x double> %81)
%86 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> %78, <2 x double> %84)
%87 = bitcast double* %79 to <2 x double>*
store <2 x double> %85, <2 x double>* %87
%88 = bitcast double* %82 to <2 x double>*
store <2 x double> %86, <2 x double>* %88
br label %89
89: ; preds = %69, %72
%90 = icmp eq i64 %18, %9
br i1 %90, label %122, label %91
91: ; preds = %11, %6, %89
%92 = phi i64 [ 0, %11 ], [ 0, %6 ], [ %18, %89 ]
%93 = xor i64 %92, -1
%94 = and i64 %9, 1
%95 = icmp eq i64 %94, 0
br i1 %95, label %103, label %96
96: ; preds = %91
%97 = getelementptr inbounds double, double* %1, i64 %92
%98 = load double, double* %97
%99 = getelementptr inbounds double, double* %0, i64 %92
%100 = load double, double* %99
%101 = tail call double @llvm.fmuladd.f64(double %3, double %98, double %100)
store double %101, double* %99
%102 = or i64 %92, 1
br label %103
103: ; preds = %96, %91
%104 = phi i64 [ %92, %91 ], [ %102, %96 ]
%105 = sub nsw i64 0, %9
%106 = icmp eq i64 %93, %105
br i1 %106, label %122, label %107
107: ; preds = %103, %107
%108 = phi i64 [ %120, %107 ], [ %104, %103 ]
%109 = getelementptr inbounds double, double* %1, i64 %108
%110 = load double, double* %109
%111 = getelementptr inbounds double, double* %0, i64 %108
%112 = load double, double* %111
%113 = tail call double @llvm.fmuladd.f64(double %3, double %110, double %112)
store double %113, double* %111
%114 = add nuw nsw i64 %108, 1
%115 = getelementptr inbounds double, double* %1, i64 %114
%116 = load double, double* %115
%117 = getelementptr inbounds double, double* %0, i64 %114
%118 = load double, double* %117
%119 = tail call double @llvm.fmuladd.f64(double %3, double %116, double %118)
store double %119, double* %117
%120 = add nuw nsw i64 %108, 2
%121 = icmp eq i64 %120, %9
br i1 %121, label %122, label %107
122: ; preds = %103, %107, %89, %4
ret void
}