void ca_add_radiation_pressure(int n, struct CARandCtx *ctx,
                               const double *hbar_k, const double *nbars,
                               double *f) {
  double hbar_k_nrm = 0.0;
  int i;
  for (i = 0; i < 3; ++i) {
    hbar_k_nrm += ((hbar_k[i]) * (hbar_k[i]));
  }
  hbar_k_nrm = sqrt(hbar_k_nrm);
  for (i = 0; i < n; ++i) {
    add_radiation_pressure_one(ctx, hbar_k, hbar_k_nrm, nbars[i], f + 3 * i);
  }
}


x86 assembly (clang, -O0):
<ca_add_radiation_pressure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    118e <ca_add_radiation_pressure+0x6e>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    114a <ca_add_radiation_pressure+0x2a>
movsd  -0x30(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f0 <ca_add_radiation_pressure+0xd0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x28(%rbp),%rdx
imul   $0x3,-0x34(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    $0x2,%al
call   1030 <add_radiation_pressure_one@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a4 <ca_add_radiation_pressure+0x84>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ca_add_radiation_pressure>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%ebp
movsd  (%rdx),%xmm0
movsd  0x8(%rdx),%xmm1
mulsd  %xmm0,%xmm0
xorpd  %xmm2,%xmm2
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rdx),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm2,%xmm0
jb     1173 <ca_add_radiation_pressure+0x53>
sqrtsd %xmm0,%xmm0
test   %ebp,%ebp
jg     117c <ca_add_radiation_pressure+0x5c>
jmp    11b8 <ca_add_radiation_pressure+0x98>
call   1040 <sqrt@plt>
test   %ebp,%ebp
jle    11b8 <ca_add_radiation_pressure+0x98>
mov    %ebp,%r13d
xor    %ebp,%ebp
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
movsd  (%r14,%rbp,8),%xmm1
mov    %r12,%rdi
mov    %r15,%rsi
movsd  (%rsp),%xmm0
mov    %rbx,%rdx
mov    $0x2,%al
call   1030 <add_radiation_pressure_one@plt>
add    $0x1,%rbp
add    $0x18,%rbx
cmp    %rbp,%r13
jne    1190 <ca_add_radiation_pressure+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.CARandCtx = type opaque
define void @ca_add_radiation_pressure(i32 %0, %struct.CARandCtx* %1, double* %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca %struct.CARandCtx*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca i32
store i32 %0, i32* %6
store %struct.CARandCtx* %1, %struct.CARandCtx** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
store double 0.000000e+00, double* %11
store i32 0, i32* %12
br label %13
13: ; preds = %29, %5
%14 = load i32, i32* %12
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %32
16: ; preds = %13
%17 = load double*, double** %8
%18 = load i32, i32* %12
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = load double*, double** %8
%23 = load i32, i32* %12
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = load double, double* %11
%28 = call double @llvm.fmuladd.f64(double %21, double %26, double %27)
store double %28, double* %11
br label %29
29: ; preds = %16
%30 = load i32, i32* %12
%31 = add nsw i32 %30, 1
store i32 %31, i32* %12
br label %13
32: ; preds = %13
%33 = load double, double* %11
%34 = call double @sqrt(double %33)
store double %34, double* %11
store i32 0, i32* %12
br label %35
35: ; preds = %54, %32
%36 = load i32, i32* %12
%37 = load i32, i32* %6
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %57
39: ; preds = %35
%40 = load %struct.CARandCtx*, %struct.CARandCtx** %7
%41 = load double*, double** %8
%42 = load double, double* %11
%43 = load double*, double** %9
%44 = load i32, i32* %12
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
%47 = load double, double* %46
%48 = load double*, double** %10
%49 = load i32, i32* %12
%50 = mul nsw i32 3, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %48, i64 %51
%53 = call i32 (%struct.CARandCtx*, double*, double, double, double*, ...) bitcast (i32 (...)* @add_radiation_pressure_one to i32 (%struct.CARandCtx*, double*, double, double, double*, ...)*)(%struct.CARandCtx* %40, double* %41, double %42, double %47, double* %52)
br label %54
54: ; preds = %39
%55 = load i32, i32* %12
%56 = add nsw i32 %55, 1
store i32 %56, i32* %12
br label %35
57: ; preds = %35
ret void
}

LLVM IR (-O2):
%struct.CARandCtx = type opaque
define void @ca_add_radiation_pressure(i32 %0, %struct.CARandCtx* %1, double* %2, double* nocapture %3, double* %4) {
%6 = load double, double* %2
%7 = tail call double @llvm.fmuladd.f64(double %6, double %6, double 0.000000e+00)
%8 = getelementptr inbounds double, double* %2, i64 1
%9 = load double, double* %8
%10 = tail call double @llvm.fmuladd.f64(double %9, double %9, double %7)
%11 = getelementptr inbounds double, double* %2, i64 2
%12 = load double, double* %11
%13 = tail call double @llvm.fmuladd.f64(double %12, double %12, double %10)
%14 = tail call double @sqrt(double %13)
%15 = icmp sgt i32 %0, 0
br i1 %15, label %16, label %27
16: ; preds = %5
%17 = zext i32 %0 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %25, %18 ]
%20 = getelementptr inbounds double, double* %3, i64 %19
%21 = load double, double* %20
%22 = mul nuw nsw i64 %19, 3
%23 = getelementptr inbounds double, double* %4, i64 %22
%24 = tail call i32 (%struct.CARandCtx*, double*, double, double, double*, ...) bitcast (i32 (...)* @add_radiation_pressure_one to i32 (%struct.CARandCtx*, double*, double, double, double*, ...)*)(%struct.CARandCtx* %1, double* %2, double %14, double %21, double* %23)
%25 = add nuw nsw i64 %19, 1
%26 = icmp eq i64 %25, %17
br i1 %26, label %27, label %18
27: ; preds = %18, %5
ret void
}