#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int sqrt(double);
void calc_vc(double Bx, double *Ka, double *Bc, double enth, double *vc,
             int LR) {
  int sgn = Bx > 0 ? LR : -LR;
  double eta = sgn * sqrt(enth);
  double K2 = Ka[0] * Ka[0] + Ka[1] * Ka[1] + Ka[2] * Ka[2];
  double KB = Ka[0] * Bx + Ka[1] * Bc[1] + Ka[2] * Bc[2];
  vc[0] = Ka[0] - Bx * (1.0 - K2) / (eta - KB);
  vc[1] = Ka[1] - Bc[1] * (1.0 - K2) / (eta - KB);
  vc[2] = Ka[2] - Bc[2] * (1.0 - K2) / (eta - KB);
}


x86 assembly (clang, -O0):
<calc_vc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %ecx,-0x2c(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    114e <calc_vc+0x3e>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1156 <calc_vc+0x46>
xor    %eax,%eax
sub    -0x2c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sqrt@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x8(%rbp),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xddf(%rip),%xmm2
subsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  -0x38(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  0xda2(%rip),%xmm2
subsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  -0x38(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm1
movsd  0xd64(%rip),%xmm2
subsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  -0x38(%rbp),%xmm2
subsd  -0x48(%rbp),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_vc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
mov    %ecx,%ebp
neg    %ebp
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
mov    %rdx,%r14
movaps %xmm1,%xmm0
mov    %rsi,%r15
mov    %rdi,%rbx
cmova  %ecx,%ebp
call   1030 <sqrt@plt>
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  (%rbx),%xmm1
movsd  0x8(%rbx),%xmm2
movapd %xmm2,%xmm3
mulsd  %xmm2,%xmm3
movapd %xmm1,%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm3,%xmm4
movsd  0x10(%rbx),%xmm3
movapd %xmm3,%xmm5
mulsd  %xmm3,%xmm5
addsd  %xmm4,%xmm5
mulsd  0x8(%r15),%xmm2
movapd %xmm1,%xmm4
movsd  (%rsp),%xmm6
mulsd  %xmm6,%xmm4
addsd  %xmm2,%xmm4
mulsd  0x10(%r15),%xmm3
addsd  %xmm4,%xmm3
subsd  %xmm3,%xmm0
movsd  0xe5f(%rip),%xmm2
subsd  %xmm5,%xmm2
movapd %xmm6,%xmm3
mulsd  %xmm2,%xmm3
divsd  %xmm0,%xmm3
subsd  %xmm3,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm1
movsd  0x8(%r15),%xmm3
mulsd  %xmm2,%xmm3
divsd  %xmm0,%xmm3
subsd  %xmm3,%xmm1
movsd  %xmm1,0x8(%r14)
mulsd  0x10(%r15),%xmm2
movsd  0x10(%rbx),%xmm1
divsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,0x10(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @calc_vc(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
%14 = alloca double
%15 = alloca double
%16 = alloca double
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
%17 = load double, double* %7
%18 = fcmp ogt double %17, 0.000000e+00
br i1 %18, label %19, label %21
19: ; preds = %6
%20 = load i32, i32* %12
br label %24
21: ; preds = %6
%22 = load i32, i32* %12
%23 = sub nsw i32 0, %22
br label %24
24: ; preds = %21, %19
%25 = phi i32 [ %20, %19 ], [ %23, %21 ]
store i32 %25, i32* %13
%26 = load i32, i32* %13
%27 = load double, double* %10
%28 = call i32 @sqrt(double %27)
%29 = mul nsw i32 %26, %28
%30 = sitofp i32 %29 to double
store double %30, double* %14
%31 = load double*, double** %8
%32 = getelementptr inbounds double, double* %31, i64 0
%33 = load double, double* %32
%34 = load double*, double** %8
%35 = getelementptr inbounds double, double* %34, i64 0
%36 = load double, double* %35
%37 = load double*, double** %8
%38 = getelementptr inbounds double, double* %37, i64 1
%39 = load double, double* %38
%40 = load double*, double** %8
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = fmul double %39, %42
%44 = call double @llvm.fmuladd.f64(double %33, double %36, double %43)
%45 = load double*, double** %8
%46 = getelementptr inbounds double, double* %45, i64 2
%47 = load double, double* %46
%48 = load double*, double** %8
%49 = getelementptr inbounds double, double* %48, i64 2
%50 = load double, double* %49
%51 = call double @llvm.fmuladd.f64(double %47, double %50, double %44)
store double %51, double* %15
%52 = load double*, double** %8
%53 = getelementptr inbounds double, double* %52, i64 0
%54 = load double, double* %53
%55 = load double, double* %7
%56 = load double*, double** %8
%57 = getelementptr inbounds double, double* %56, i64 1
%58 = load double, double* %57
%59 = load double*, double** %9
%60 = getelementptr inbounds double, double* %59, i64 1
%61 = load double, double* %60
%62 = fmul double %58, %61
%63 = call double @llvm.fmuladd.f64(double %54, double %55, double %62)
%64 = load double*, double** %8
%65 = getelementptr inbounds double, double* %64, i64 2
%66 = load double, double* %65
%67 = load double*, double** %9
%68 = getelementptr inbounds double, double* %67, i64 2
%69 = load double, double* %68
%70 = call double @llvm.fmuladd.f64(double %66, double %69, double %63)
store double %70, double* %16
%71 = load double*, double** %8
%72 = getelementptr inbounds double, double* %71, i64 0
%73 = load double, double* %72
%74 = load double, double* %7
%75 = load double, double* %15
%76 = fsub double 1.000000e+00, %75
%77 = fmul double %74, %76
%78 = load double, double* %14
%79 = load double, double* %16
%80 = fsub double %78, %79
%81 = fdiv double %77, %80
%82 = fsub double %73, %81
%83 = load double*, double** %11
%84 = getelementptr inbounds double, double* %83, i64 0
store double %82, double* %84
%85 = load double*, double** %8
%86 = getelementptr inbounds double, double* %85, i64 1
%87 = load double, double* %86
%88 = load double*, double** %9
%89 = getelementptr inbounds double, double* %88, i64 1
%90 = load double, double* %89
%91 = load double, double* %15
%92 = fsub double 1.000000e+00, %91
%93 = fmul double %90, %92
%94 = load double, double* %14
%95 = load double, double* %16
%96 = fsub double %94, %95
%97 = fdiv double %93, %96
%98 = fsub double %87, %97
%99 = load double*, double** %11
%100 = getelementptr inbounds double, double* %99, i64 1
store double %98, double* %100
%101 = load double*, double** %8
%102 = getelementptr inbounds double, double* %101, i64 2
%103 = load double, double* %102
%104 = load double*, double** %9
%105 = getelementptr inbounds double, double* %104, i64 2
%106 = load double, double* %105
%107 = load double, double* %15
%108 = fsub double 1.000000e+00, %107
%109 = fmul double %106, %108
%110 = load double, double* %14
%111 = load double, double* %16
%112 = fsub double %110, %111
%113 = fdiv double %109, %112
%114 = fsub double %103, %113
%115 = load double*, double** %11
%116 = getelementptr inbounds double, double* %115, i64 2
store double %114, double* %116
ret void
}

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