void calc_xi(double *xi, double *x0, double *ki, double c, double dt,
             int num_d) {
  int d;
  for (d = 0; d < num_d; ++d) {
    xi[d] = x0[d] + dt * c * ki[d];
  }
}


x86 assembly (clang, -O0):
<calc_xi>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1177 <calc_xi+0x77>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1124 <calc_xi+0x24>
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_xi>:
test   %ecx,%ecx
jle    12af <calc_xi+0x1af>
mulsd  %xmm1,%xmm0
mov    %ecx,%r8d
cmp    $0x4,%ecx
jae    1187 <calc_xi+0x87>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
test   $0x1,%r8b
je     1139 <calc_xi+0x39>
movsd  (%rdx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rsi,%rcx,8),%xmm1
movsd  %xmm1,(%rdi,%rcx,8)
or     $0x1,%rcx
add    %r8,%rax
je     12af <calc_xi+0x1af>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rdx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rsi,%rcx,8),%xmm1
movsd  %xmm1,(%rdi,%rcx,8)
movsd  0x8(%rdx,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rsi,%rcx,8),%xmm1
movsd  %xmm1,0x8(%rdi,%rcx,8)
add    $0x2,%rcx
cmp    %rcx,%r8
jne    1150 <calc_xi+0x50>
jmp    12af <calc_xi+0x1af>
lea    (%rdi,%r8,8),%rcx
lea    (%rsi,%r8,8),%rax
cmp    %rdi,%rax
seta   %r10b
lea    (%rdx,%r8,8),%rax
cmp    %rsi,%rcx
seta   %r11b
cmp    %rdi,%rax
seta   %al
cmp    %rdx,%rcx
seta   %r9b
xor    %ecx,%ecx
test   %r11b,%r10b
jne    1116 <calc_xi+0x16>
and    %r9b,%al
jne    1116 <calc_xi+0x16>
mov    %r8d,%ecx
and    $0xfffffffc,%ecx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rcx),%rax
mov    %rax,%r9
shr    $0x2,%r9
add    $0x1,%r9
test   %rax,%rax
je     12b0 <calc_xi+0x1b0>
mov    %r9,%r10
and    $0xfffffffffffffffe,%r10
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movupd (%rsi,%rax,8),%xmm2
movupd 0x10(%rsi,%rax,8),%xmm3
movupd (%rdx,%rax,8),%xmm4
movupd 0x10(%rdx,%rax,8),%xmm5
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm1,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,(%rdi,%rax,8)
movupd %xmm5,0x10(%rdi,%rax,8)
movupd 0x20(%rsi,%rax,8),%xmm2
movupd 0x30(%rsi,%rax,8),%xmm3
movupd 0x20(%rdx,%rax,8),%xmm4
movupd 0x30(%rdx,%rax,8),%xmm5
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm1,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,0x20(%rdi,%rax,8)
movupd %xmm5,0x30(%rdi,%rax,8)
add    $0x8,%rax
add    $0xfffffffffffffffe,%r10
jne    1200 <calc_xi+0x100>
test   $0x1,%r9b
je     12a6 <calc_xi+0x1a6>
movupd (%rsi,%rax,8),%xmm2
movupd 0x10(%rsi,%rax,8),%xmm3
movupd (%rdx,%rax,8),%xmm4
movupd 0x10(%rdx,%rax,8),%xmm5
mulpd  %xmm1,%xmm4
addpd  %xmm2,%xmm4
mulpd  %xmm1,%xmm5
addpd  %xmm3,%xmm5
movupd %xmm4,(%rdi,%rax,8)
movupd %xmm5,0x10(%rdi,%rax,8)
cmp    %r8,%rcx
jne    1116 <calc_xi+0x16>
ret
xor    %eax,%eax
test   $0x1,%r9b
jne    1275 <calc_xi+0x175>
jmp    12a6 <calc_xi+0x1a6>

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

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