void compute_displacement_from_forces(double *fXYZ, double *charge,
                                      double *dXYZ, int nb_xyz) {
  int idPart;
  for (idPart = 0; idPart < nb_xyz; ++idPart) {
    dXYZ[idPart * 3 + 0] = fXYZ[idPart * 3 + 0] * 0.001 / charge[idPart];
    dXYZ[idPart * 3 + 1] = fXYZ[idPart * 3 + 1] * 0.001 / charge[idPart];
    dXYZ[idPart * 3 + 2] = fXYZ[idPart * 3 + 2] * 0.001 / charge[idPart];
  }
}


x86 assembly (clang, -O0):
<compute_displacement_from_forces>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11e5 <compute_displacement_from_forces+0xe5>
mov    -0x8(%rbp),%rax
imul   $0x3,-0x20(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  0xec4(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x3,-0x20(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
imul   $0x3,-0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xe89(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x3,-0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
imul   $0x3,-0x20(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  0xe4e(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x3,-0x20(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111a <compute_displacement_from_forces+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_displacement_from_forces>:
test   %ecx,%ecx
jle    124a <compute_displacement_from_forces+0x14a>
mov    %ecx,%r8d
cmp    $0x1,%ecx
jne    1117 <compute_displacement_from_forces+0x17>
xor    %ecx,%ecx
jmp    11e4 <compute_displacement_from_forces+0xe4>
lea    0x0(,%r8,8),%rax
lea    (%rax,%rax,2),%rax
lea    (%rdx,%rax,1),%rcx
add    %rdi,%rax
cmp    %rdx,%rax
seta   %r10b
lea    (%rsi,%r8,8),%rax
cmp    %rdi,%rcx
seta   %r11b
cmp    %rdx,%rax
seta   %al
cmp    %rsi,%rcx
seta   %r9b
xor    %ecx,%ecx
test   %r11b,%r10b
jne    11e4 <compute_displacement_from_forces+0xe4>
and    %r9b,%al
jne    11e4 <compute_displacement_from_forces+0xe4>
mov    %r8d,%ecx
and    $0xfffffffe,%ecx
xor    %eax,%eax
movapd 0xe93(%rip),%xmm0
xor    %r9d,%r9d
movupd (%rdi,%rax,1),%xmm1
movupd 0x10(%rdi,%rax,1),%xmm2
movupd 0x20(%rdi,%rax,1),%xmm3
movapd %xmm2,%xmm4
movsd  %xmm1,%xmm4
shufpd $0x1,%xmm3,%xmm1
movsd  %xmm2,%xmm3
mulpd  %xmm0,%xmm4
movupd (%rsi,%r9,8),%xmm2
divpd  %xmm2,%xmm4
mulpd  %xmm0,%xmm1
divpd  %xmm2,%xmm1
mulpd  %xmm0,%xmm3
divpd  %xmm2,%xmm3
movapd %xmm4,%xmm2
unpcklpd %xmm1,%xmm2
unpckhpd %xmm3,%xmm1
shufpd $0x2,%xmm4,%xmm3
movupd %xmm3,0x10(%rdx,%rax,1)
movupd %xmm1,0x20(%rdx,%rax,1)
movupd %xmm2,(%rdx,%rax,1)
add    $0x2,%r9
add    $0x30,%rax
cmp    %r9,%rcx
jne    1170 <compute_displacement_from_forces+0x70>
cmp    %r8,%rcx
je     124a <compute_displacement_from_forces+0x14a>
lea    (%rcx,%rcx,2),%rax
lea    0x10(,%rax,8),%rax
movsd  0xe18(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movsd  -0x10(%rdi,%rax,1),%xmm1
mulsd  %xmm0,%xmm1
divsd  (%rsi,%rcx,8),%xmm1
movsd  %xmm1,-0x10(%rdx,%rax,1)
movsd  -0x8(%rdi,%rax,1),%xmm1
mulsd  %xmm0,%xmm1
divsd  (%rsi,%rcx,8),%xmm1
movsd  %xmm1,-0x8(%rdx,%rax,1)
movsd  (%rdi,%rax,1),%xmm1
mulsd  %xmm0,%xmm1
divsd  (%rsi,%rcx,8),%xmm1
movsd  %xmm1,(%rdx,%rax,1)
add    $0x1,%rcx
add    $0x18,%rax
cmp    %rcx,%r8
jne    1200 <compute_displacement_from_forces+0x100>
ret

LLVM IR (-O0):
define void @compute_displacement_from_forces(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %75, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %8
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %78
14: ; preds = %10
%15 = load double*, double** %5
%16 = load i32, i32* %9
%17 = mul nsw i32 %16, 3
%18 = add nsw i32 %17, 0
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %15, i64 %19
%21 = load double, double* %20
%22 = fmul double %21, 1.000000e-03
%23 = load double*, double** %6
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = fdiv double %22, %27
%29 = load double*, double** %7
%30 = load i32, i32* %9
%31 = mul nsw i32 %30, 3
%32 = add nsw i32 %31, 0
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %29, i64 %33
store double %28, double* %34
%35 = load double*, double** %5
%36 = load i32, i32* %9
%37 = mul nsw i32 %36, 3
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %35, i64 %39
%41 = load double, double* %40
%42 = fmul double %41, 1.000000e-03
%43 = load double*, double** %6
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = fdiv double %42, %47
%49 = load double*, double** %7
%50 = load i32, i32* %9
%51 = mul nsw i32 %50, 3
%52 = add nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %49, i64 %53
store double %48, double* %54
%55 = load double*, double** %5
%56 = load i32, i32* %9
%57 = mul nsw i32 %56, 3
%58 = add nsw i32 %57, 2
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %55, i64 %59
%61 = load double, double* %60
%62 = fmul double %61, 1.000000e-03
%63 = load double*, double** %6
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds double, double* %63, i64 %65
%67 = load double, double* %66
%68 = fdiv double %62, %67
%69 = load double*, double** %7
%70 = load i32, i32* %9
%71 = mul nsw i32 %70, 3
%72 = add nsw i32 %71, 2
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %69, i64 %73
store double %68, double* %74
br label %75
75: ; preds = %14
%76 = load i32, i32* %9
%77 = add nsw i32 %76, 1
store i32 %77, i32* %9
br label %10
78: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @compute_displacement_from_forces(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %78
6: ; preds = %4
%7 = zext i32 %3 to i64
%8 = icmp eq i32 %3, 1
br i1 %8, label %50, label %9
9: ; preds = %6
%10 = mul nuw nsw i64 %7, 3
%11 = getelementptr double, double* %2, i64 %10
%12 = getelementptr double, double* %0, i64 %10
%13 = getelementptr double, double* %1, i64 %7
%14 = icmp ugt double* %12, %2
%15 = icmp ugt double* %11, %0
%16 = and i1 %14, %15
%17 = icmp ugt double* %13, %2
%18 = icmp ugt double* %11, %1
%19 = and i1 %17, %18
%20 = or i1 %16, %19
br i1 %20, label %50, label %21
21: ; preds = %9
%22 = and i64 %7, 4294967294
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %46, %23 ]
%25 = mul nuw nsw i64 %24, 3
%26 = getelementptr inbounds double, double* %0, i64 %25
%27 = bitcast double* %26 to <6 x double>*
%28 = load <6 x double>, <6 x double>* %27
%29 = shufflevector <6 x double> %28, <6 x double> poison, <2 x i32> <i32 0, i32 3>
%30 = shufflevector <6 x double> %28, <6 x double> poison, <2 x i32> <i32 1, i32 4>
%31 = shufflevector <6 x double> %28, <6 x double> poison, <2 x i32> <i32 2, i32 5>
%32 = fmul <2 x double> %29, <double 1.000000e-03, double 1.000000e-03>
%33 = getelementptr inbounds double, double* %1, i64 %24
%34 = bitcast double* %33 to <2 x double>*
%35 = load <2 x double>, <2 x double>* %34
%36 = fdiv <2 x double> %32, %35
%37 = fmul <2 x double> %30, <double 1.000000e-03, double 1.000000e-03>
%38 = fdiv <2 x double> %37, %35
%39 = fmul <2 x double> %31, <double 1.000000e-03, double 1.000000e-03>
%40 = fdiv <2 x double> %39, %35
%41 = getelementptr inbounds double, double* %2, i64 %25
%42 = bitcast double* %41 to <6 x double>*
%43 = shufflevector <2 x double> %36, <2 x double> %38, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
%44 = shufflevector <2 x double> %40, <2 x double> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%45 = shufflevector <4 x double> %43, <4 x double> %44, <6 x i32> <i32 0, i32 2, i32 4, i32 1, i32 3, i32 5>
store <6 x double> %45, <6 x double>* %42
%46 = add nuw i64 %24, 2
%47 = icmp eq i64 %46, %22
br i1 %47, label %48, label %23
48: ; preds = %23
%49 = icmp eq i64 %22, %7
br i1 %49, label %78, label %50
50: ; preds = %9, %6, %48
%51 = phi i64 [ 0, %9 ], [ 0, %6 ], [ %22, %48 ]
br label %52
52: ; preds = %50, %52
%53 = phi i64 [ %76, %52 ], [ %51, %50 ]
%54 = mul nuw nsw i64 %53, 3
%55 = getelementptr inbounds double, double* %0, i64 %54
%56 = load double, double* %55
%57 = fmul double %56, 1.000000e-03
%58 = getelementptr inbounds double, double* %1, i64 %53
%59 = load double, double* %58
%60 = fdiv double %57, %59
%61 = getelementptr inbounds double, double* %2, i64 %54
store double %60, double* %61
%62 = add nuw nsw i64 %54, 1
%63 = getelementptr inbounds double, double* %0, i64 %62
%64 = load double, double* %63
%65 = fmul double %64, 1.000000e-03
%66 = load double, double* %58
%67 = fdiv double %65, %66
%68 = getelementptr inbounds double, double* %2, i64 %62
store double %67, double* %68
%69 = add nuw nsw i64 %54, 2
%70 = getelementptr inbounds double, double* %0, i64 %69
%71 = load double, double* %70
%72 = fmul double %71, 1.000000e-03
%73 = load double, double* %58
%74 = fdiv double %72, %73
%75 = getelementptr inbounds double, double* %2, i64 %69
store double %74, double* %75
%76 = add nuw nsw i64 %53, 1
%77 = icmp eq i64 %76, %7
br i1 %77, label %78, label %52
78: ; preds = %52, %48, %4
ret void
}