void bcon_calc_g(double prim[8], double ucon[4], double ucov[4], double ncov[4],
                 double bcon[4]) {
  double Bcon[4];
  double u_dot_B;
  double gamma;
  int i;
  Bcon[0] = 0.;
  for (i = 1; i < 4; i++)
    Bcon[i] = 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,-0x50(%rbp)
movl   $0x1,-0x64(%rbp)
cmpl   $0x4,-0x64(%rbp)
jge    115e <bcon_calc_g+0x5e>
mov    -0x8(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x5,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x64(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1127 <bcon_calc_g+0x27>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x4,-0x64(%rbp)
jge    11ae <bcon_calc_g+0xae>
mov    -0x18(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x64(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    116d <bcon_calc_g+0x6d>
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,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x4,-0x64(%rbp)
jge    122f <bcon_calc_g+0x12f>
movslq -0x64(%rbp),%rax
movsd  -0x50(%rbp,%rax,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x64(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11e1 <bcon_calc_g+0xe1>
pop    %rbp
ret

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

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