void bcon_calc_g(double prim[(9)], double ucon[(4)], double ucov[(4)],
                 double ncov[(4)], double bcon[(4)]) {
  static double Bcon[(4)];
  double u_dot_B;
  double gamma;
  int i;
  Bcon[0] = 0.;
  for (i = 1; i < (4); i++)
    Bcon[i] = -ncov[0] * prim[5 + i - 1];
  u_dot_B = 0.;
  for (i = 0; i < (4); i++)
    u_dot_B += ucov[i] * Bcon[i];
  gamma = -ucon[0] * ncov[0];
  for (i = 0; i < (4); i++)
    bcon[i] = (Bcon[i] + ucon[i] * u_dot_B) / gamma;
}


x86 assembly (clang, -O0):
<bcon_calc_g>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,0x2f0d(%rip)
movl   $0x1,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    1186 <bcon_calc_g+0x86>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x3c(%rbp),%ecx
add    $0x5,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
movslq -0x3c(%rbp),%rcx
lea    0x2ebd(%rip),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    112a <bcon_calc_g+0x2a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    11dc <bcon_calc_g+0xdc>
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x3c(%rbp),%rcx
lea    0x2e79(%rip),%rax
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1195 <bcon_calc_g+0x95>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x20(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    1263 <bcon_calc_g+0x163>
movslq -0x3c(%rbp),%rcx
lea    0x2e0c(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    120f <bcon_calc_g+0x10f>
pop    %rbp
ret

x86 assembly (clang, -O2):
<bcon_calc_g>:
movsd  (%rcx),%xmm5
movapd 0xef4(%rip),%xmm0
movapd %xmm5,%xmm1
xorpd  %xmm0,%xmm1
movsd  0x28(%rdi),%xmm3
mulsd  %xmm1,%xmm3
movsd  0x30(%rdi),%xmm2
mulsd  %xmm1,%xmm2
mulsd  0x38(%rdi),%xmm1
xorpd  %xmm8,%xmm8
movsd  (%rdx),%xmm4
mulsd  %xmm8,%xmm4
addsd  %xmm8,%xmm4
movsd  0x8(%rdx),%xmm7
mulsd  %xmm3,%xmm7
addsd  %xmm4,%xmm7
movsd  0x10(%rdx),%xmm6
mulsd  %xmm2,%xmm6
addsd  %xmm7,%xmm6
movsd  0x18(%rdx),%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm6,%xmm4
movsd  (%rsi),%xmm6
xorpd  %xmm6,%xmm0
mulsd  %xmm5,%xmm0
mulsd  %xmm4,%xmm6
addsd  %xmm8,%xmm6
divsd  %xmm0,%xmm6
movsd  %xmm6,(%r8)
movsd  0x8(%rsi),%xmm5
mulsd  %xmm4,%xmm5
addsd  %xmm3,%xmm5
divsd  %xmm0,%xmm5
movsd  %xmm5,0x8(%r8)
movsd  0x10(%rsi),%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm2,%xmm3
divsd  %xmm0,%xmm3
movsd  %xmm3,0x10(%r8)
mulsd  0x18(%rsi),%xmm4
addsd  %xmm1,%xmm4
divsd  %xmm0,%xmm4
movsd  %xmm4,0x18(%r8)
ret

LLVM IR (-O0):
@bcon_calc_g.Bcon = internal global [4 x double] zeroinitializer
define void @bcon_calc_g(double* %0, double* %1, double* %2, double* %3, double* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
store double 0.000000e+00, double* getelementptr inbounds ([4 x double], [4 x double]* @bcon_calc_g.Bcon, i64 0, i64 0)
store i32 1, i32* %13
br label %14
14: ; preds = %33, %5
%15 = load i32, i32* %13
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %36
17: ; preds = %14
%18 = load double*, double** %9
%19 = getelementptr inbounds double, double* %18, i64 0
%20 = load double, double* %19
%21 = fneg double %20
%22 = load double*, double** %6
%23 = load i32, i32* %13
%24 = add nsw i32 5, %23
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %22, i64 %26
%28 = load double, double* %27
%29 = fmul double %21, %28
%30 = load i32, i32* %13
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [4 x double], [4 x double]* @bcon_calc_g.Bcon, i64 0, i64 %31
store double %29, double* %32
br label %33
33: ; preds = %17
%34 = load i32, i32* %13
%35 = add nsw i32 %34, 1
store i32 %35, i32* %13
br label %14
36: ; preds = %14
store double 0.000000e+00, double* %11
store i32 0, i32* %13
br label %37
37: ; preds = %52, %36
%38 = load i32, i32* %13
%39 = icmp slt i32 %38, 4
br i1 %39, label %40, label %55
40: ; preds = %37
%41 = load double*, double** %8
%42 = load i32, i32* %13
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
%45 = load double, double* %44
%46 = load i32, i32* %13
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [4 x double], [4 x double]* @bcon_calc_g.Bcon, i64 0, i64 %47
%49 = load double, double* %48
%50 = load double, double* %11
%51 = call double @llvm.fmuladd.f64(double %45, double %49, double %50)
store double %51, double* %11
br label %52
52: ; preds = %40
%53 = load i32, i32* %13
%54 = add nsw i32 %53, 1
store i32 %54, i32* %13
br label %37
55: ; preds = %37
%56 = load double*, double** %7
%57 = getelementptr inbounds double, double* %56, i64 0
%58 = load double, double* %57
%59 = fneg double %58
%60 = load double*, double** %9
%61 = getelementptr inbounds double, double* %60, i64 0
%62 = load double, double* %61
%63 = fmul double %59, %62
store double %63, double* %12
store i32 0, i32* %13
br label %64
64: ; preds = %85, %55
%65 = load i32, i32* %13
%66 = icmp slt i32 %65, 4
br i1 %66, label %67, label %88
67: ; preds = %64
%68 = load i32, i32* %13
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [4 x double], [4 x double]* @bcon_calc_g.Bcon, i64 0, i64 %69
%71 = load double, double* %70
%72 = load double*, double** %7
%73 = load i32, i32* %13
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %72, i64 %74
%76 = load double, double* %75
%77 = load double, double* %11
%78 = call double @llvm.fmuladd.f64(double %76, double %77, double %71)
%79 = load double, double* %12
%80 = fdiv double %78, %79
%81 = load double*, double** %10
%82 = load i32, i32* %13
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %81, i64 %83
store double %80, double* %84
br label %85
85: ; preds = %67
%86 = load i32, i32* %13
%87 = add nsw i32 %86, 1
store i32 %87, i32* %13
br label %64
88: ; preds = %64
ret void
}

LLVM IR (-O2):
define void @bcon_calc_g(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture writeonly %4) {
%6 = load double, double* %3
%7 = fneg double %6
%8 = getelementptr inbounds double, double* %0, i64 5
%9 = load double, double* %8
%10 = fmul double %9, %7
%11 = getelementptr inbounds double, double* %0, i64 6
%12 = load double, double* %11
%13 = fmul double %12, %7
%14 = getelementptr inbounds double, double* %0, i64 7
%15 = load double, double* %14
%16 = fmul double %15, %7
%17 = load double, double* %2
%18 = tail call double @llvm.fmuladd.f64(double %17, double 0.000000e+00, double 0.000000e+00)
%19 = getelementptr inbounds double, double* %2, i64 1
%20 = load double, double* %19
%21 = tail call double @llvm.fmuladd.f64(double %20, double %10, double %18)
%22 = getelementptr inbounds double, double* %2, i64 2
%23 = load double, double* %22
%24 = tail call double @llvm.fmuladd.f64(double %23, double %13, double %21)
%25 = getelementptr inbounds double, double* %2, i64 3
%26 = load double, double* %25
%27 = tail call double @llvm.fmuladd.f64(double %26, double %16, double %24)
%28 = load double, double* %1
%29 = fneg double %28
%30 = fmul double %6, %29
%31 = tail call double @llvm.fmuladd.f64(double %28, double %27, double 0.000000e+00)
%32 = fdiv double %31, %30
store double %32, double* %4
%33 = getelementptr inbounds double, double* %1, i64 1
%34 = load double, double* %33
%35 = tail call double @llvm.fmuladd.f64(double %34, double %27, double %10)
%36 = fdiv double %35, %30
%37 = getelementptr inbounds double, double* %4, i64 1
store double %36, double* %37
%38 = getelementptr inbounds double, double* %1, i64 2
%39 = load double, double* %38
%40 = tail call double @llvm.fmuladd.f64(double %39, double %27, double %13)
%41 = fdiv double %40, %30
%42 = getelementptr inbounds double, double* %4, i64 2
store double %41, double* %42
%43 = getelementptr inbounds double, double* %1, i64 3
%44 = load double, double* %43
%45 = tail call double @llvm.fmuladd.f64(double %44, double %27, double %16)
%46 = fdiv double %45, %30
%47 = getelementptr inbounds double, double* %4, i64 3
store double %46, double* %47
ret void
}