#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 abs(double);
double acos(double);
int atan(double);
double sqrt(double);
double spherical_angle(const double *v1, const double *v2, const double *v3) {
  double angle;
  double px, py, pz, qx, qy, qz, ddd;
  px = v1[1] * v2[2] - v1[2] * v2[1];
  py = v1[2] * v2[0] - v1[0] * v2[2];
  pz = v1[0] * v2[1] - v1[1] * v2[0];
  qx = v1[1] * v3[2] - v1[2] * v3[1];
  qy = v1[2] * v3[0] - v1[0] * v3[2];
  qz = v1[0] * v3[1] - v1[1] * v3[0];
  ddd = (px * px + py * py + pz * pz) * (qx * qx + qy * qy + qz * qz);
  if (ddd <= 0.0)
    angle = 0.;
  else {
    ddd = (px * qx + py * qy + pz * qz) / sqrt(ddd);
    if (abs(ddd) > 1.) {
      angle = 2. * atan(1.0);
      if (ddd < 0.)
        angle = 4. * atan(1.0);
      else
        angle = 0.;
    } else
      angle = acos(ddd);
  }
  return angle;
}


x86 assembly (clang, -O0):
<spherical_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  0x10(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x50(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x58(%rbp),%xmm0
jb     137c <spherical_angle+0x23c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1462 <spherical_angle+0x322>
movsd  -0x28(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1030 <abs@plt>
cvtsi2sd %eax,%xmm0
movsd  0xc20(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    144e <spherical_angle+0x30e>
movsd  0xc0e(%rip),%xmm0
call   1050 <atan@plt>
cvtsi2sd %eax,%xmm1
movsd  0xc05(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    1441 <spherical_angle+0x301>
movsd  0xbde(%rip),%xmm0
call   1050 <atan@plt>
cvtsi2sd %eax,%xmm1
movsd  0xbdd(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1449 <spherical_angle+0x309>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    145d <spherical_angle+0x31d>
movsd  -0x58(%rbp),%xmm0
call   1040 <acos@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    1462 <spherical_angle+0x322>
movsd  -0x20(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spherical_angle>:
sub    $0x18,%rsp
movsd  (%rsi),%xmm0
movsd  0x8(%rsi),%xmm5
movsd  0x10(%rsi),%xmm1
movhpd 0x8(%rdx),%xmm5
movsd  (%rdi),%xmm2
movsd  0x8(%rdi),%xmm6
movsd  0x10(%rdi),%xmm3
unpcklpd %xmm3,%xmm3
unpcklpd %xmm6,%xmm6
movhpd 0x10(%rdx),%xmm1
movapd %xmm6,%xmm4
mulpd  %xmm1,%xmm4
unpcklpd %xmm2,%xmm2
mulpd  %xmm2,%xmm1
mulpd  %xmm5,%xmm2
mulpd  %xmm3,%xmm5
subpd  %xmm5,%xmm4
movhpd (%rdx),%xmm0
mulpd  %xmm0,%xmm3
subpd  %xmm1,%xmm3
mulpd  %xmm6,%xmm0
subpd  %xmm0,%xmm2
movapd %xmm3,%xmm0
mulpd  %xmm3,%xmm0
movapd %xmm4,%xmm1
mulpd  %xmm4,%xmm1
addpd  %xmm0,%xmm1
movapd %xmm2,%xmm5
mulpd  %xmm2,%xmm5
addpd  %xmm1,%xmm5
movapd %xmm5,%xmm0
unpckhpd %xmm5,%xmm0
mulsd  %xmm5,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    1272 <spherical_angle+0x132>
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movapd %xmm4,%xmm3
unpckhpd %xmm4,%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm1,%xmm3
movapd %xmm2,%xmm4
unpckhpd %xmm2,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm3,%xmm4
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1218 <spherical_angle+0xd8>
sqrtsd %xmm0,%xmm0
jmp    1227 <spherical_angle+0xe7>
movapd %xmm4,(%rsp)
call   1060 <sqrt@plt>
movapd (%rsp),%xmm4
divsd  %xmm0,%xmm4
movapd %xmm4,(%rsp)
movapd %xmm4,%xmm0
call   1030 <abs@plt>
cmp    $0x2,%eax
jl     127b <spherical_angle+0x13b>
movsd  0xdba(%rip),%xmm0
call   1050 <atan@plt>
xorpd  %xmm1,%xmm1
ucomisd (%rsp),%xmm1
jbe    1272 <spherical_angle+0x132>
movsd  0xda2(%rip),%xmm0
call   1050 <atan@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xd96(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret
movaps (%rsp),%xmm0
add    $0x18,%rsp
jmp    1040 <acos@plt>

LLVM IR (-O0):
define double @spherical_angle(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = load double*, double** %5
%19 = getelementptr inbounds double, double* %18, i64 2
%20 = load double, double* %19
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 2
%23 = load double, double* %22
%24 = load double*, double** %5
%25 = getelementptr inbounds double, double* %24, i64 1
%26 = load double, double* %25
%27 = fmul double %23, %26
%28 = fneg double %27
%29 = call double @llvm.fmuladd.f64(double %17, double %20, double %28)
store double %29, double* %8
%30 = load double*, double** %4
%31 = getelementptr inbounds double, double* %30, i64 2
%32 = load double, double* %31
%33 = load double*, double** %5
%34 = getelementptr inbounds double, double* %33, i64 0
%35 = load double, double* %34
%36 = load double*, double** %4
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = load double*, double** %5
%40 = getelementptr inbounds double, double* %39, i64 2
%41 = load double, double* %40
%42 = fmul double %38, %41
%43 = fneg double %42
%44 = call double @llvm.fmuladd.f64(double %32, double %35, double %43)
store double %44, double* %9
%45 = load double*, double** %4
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = load double*, double** %5
%49 = getelementptr inbounds double, double* %48, i64 1
%50 = load double, double* %49
%51 = load double*, double** %4
%52 = getelementptr inbounds double, double* %51, i64 1
%53 = load double, double* %52
%54 = load double*, double** %5
%55 = getelementptr inbounds double, double* %54, i64 0
%56 = load double, double* %55
%57 = fmul double %53, %56
%58 = fneg double %57
%59 = call double @llvm.fmuladd.f64(double %47, double %50, double %58)
store double %59, double* %10
%60 = load double*, double** %4
%61 = getelementptr inbounds double, double* %60, i64 1
%62 = load double, double* %61
%63 = load double*, double** %6
%64 = getelementptr inbounds double, double* %63, i64 2
%65 = load double, double* %64
%66 = load double*, double** %4
%67 = getelementptr inbounds double, double* %66, i64 2
%68 = load double, double* %67
%69 = load double*, double** %6
%70 = getelementptr inbounds double, double* %69, i64 1
%71 = load double, double* %70
%72 = fmul double %68, %71
%73 = fneg double %72
%74 = call double @llvm.fmuladd.f64(double %62, double %65, double %73)
store double %74, double* %11
%75 = load double*, double** %4
%76 = getelementptr inbounds double, double* %75, i64 2
%77 = load double, double* %76
%78 = load double*, double** %6
%79 = getelementptr inbounds double, double* %78, i64 0
%80 = load double, double* %79
%81 = load double*, double** %4
%82 = getelementptr inbounds double, double* %81, i64 0
%83 = load double, double* %82
%84 = load double*, double** %6
%85 = getelementptr inbounds double, double* %84, i64 2
%86 = load double, double* %85
%87 = fmul double %83, %86
%88 = fneg double %87
%89 = call double @llvm.fmuladd.f64(double %77, double %80, double %88)
store double %89, double* %12
%90 = load double*, double** %4
%91 = getelementptr inbounds double, double* %90, i64 0
%92 = load double, double* %91
%93 = load double*, double** %6
%94 = getelementptr inbounds double, double* %93, i64 1
%95 = load double, double* %94
%96 = load double*, double** %4
%97 = getelementptr inbounds double, double* %96, i64 1
%98 = load double, double* %97
%99 = load double*, double** %6
%100 = getelementptr inbounds double, double* %99, i64 0
%101 = load double, double* %100
%102 = fmul double %98, %101
%103 = fneg double %102
%104 = call double @llvm.fmuladd.f64(double %92, double %95, double %103)
store double %104, double* %13
%105 = load double, double* %8
%106 = load double, double* %8
%107 = load double, double* %9
%108 = load double, double* %9
%109 = fmul double %107, %108
%110 = call double @llvm.fmuladd.f64(double %105, double %106, double %109)
%111 = load double, double* %10
%112 = load double, double* %10
%113 = call double @llvm.fmuladd.f64(double %111, double %112, double %110)
%114 = load double, double* %11
%115 = load double, double* %11
%116 = load double, double* %12
%117 = load double, double* %12
%118 = fmul double %116, %117
%119 = call double @llvm.fmuladd.f64(double %114, double %115, double %118)
%120 = load double, double* %13
%121 = load double, double* %13
%122 = call double @llvm.fmuladd.f64(double %120, double %121, double %119)
%123 = fmul double %113, %122
store double %123, double* %14
%124 = load double, double* %14
%125 = fcmp ole double %124, 0.000000e+00
br i1 %125, label %126, label %127
126: ; preds = %3
store double 0.000000e+00, double* %7
br label %160
127: ; preds = %3
%128 = load double, double* %8
%129 = load double, double* %11
%130 = load double, double* %9
%131 = load double, double* %12
%132 = fmul double %130, %131
%133 = call double @llvm.fmuladd.f64(double %128, double %129, double %132)
%134 = load double, double* %10
%135 = load double, double* %13
%136 = call double @llvm.fmuladd.f64(double %134, double %135, double %133)
%137 = load double, double* %14
%138 = call double @sqrt(double %137)
%139 = fdiv double %136, %138
store double %139, double* %14
%140 = load double, double* %14
%141 = call i32 @abs(double %140)
%142 = sitofp i32 %141 to double
%143 = fcmp ogt double %142, 1.000000e+00
br i1 %143, label %144, label %156
144: ; preds = %127
%145 = call i32 @atan(double 1.000000e+00)
%146 = sitofp i32 %145 to double
%147 = fmul double 2.000000e+00, %146
store double %147, double* %7
%148 = load double, double* %14
%149 = fcmp olt double %148, 0.000000e+00
br i1 %149, label %150, label %154
150: ; preds = %144
%151 = call i32 @atan(double 1.000000e+00)
%152 = sitofp i32 %151 to double
%153 = fmul double 4.000000e+00, %152
store double %153, double* %7
br label %155
154: ; preds = %144
store double 0.000000e+00, double* %7
br label %155
155: ; preds = %154, %150
br label %159
156: ; preds = %127
%157 = load double, double* %14
%158 = call double @acos(double %157)
store double %158, double* %7
br label %159
159: ; preds = %156, %155
br label %160
160: ; preds = %159, %126
%161 = load double, double* %7
ret double %161
}

LLVM IR (-O2):
define double @spherical_angle(double* nocapture %0, double* nocapture %1, double* nocapture %2) {
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %1, i64 2
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %0, i64 2
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %1, i64 1
%11 = load double, double* %10
%12 = fneg double %9
%13 = load double, double* %1
%14 = load double, double* %0
%15 = fneg double %14
%16 = fneg double %5
%17 = getelementptr inbounds double, double* %2, i64 2
%18 = load double, double* %17
%19 = getelementptr inbounds double, double* %2, i64 1
%20 = load double, double* %19
%21 = insertelement <2 x double> poison, double %11, i64 0
%22 = insertelement <2 x double> %21, double %20, i64 1
%23 = insertelement <2 x double> poison, double %12, i64 0
%24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> zeroinitializer
%25 = fmul <2 x double> %22, %24
%26 = insertelement <2 x double> poison, double %5, i64 0
%27 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
%28 = insertelement <2 x double> poison, double %7, i64 0
%29 = insertelement <2 x double> %28, double %18, i64 1
%30 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %27, <2 x double> %29, <2 x double> %25)
%31 = load double, double* %2
%32 = insertelement <2 x double> poison, double %15, i64 0
%33 = shufflevector <2 x double> %32, <2 x double> poison, <2 x i32> zeroinitializer
%34 = fmul <2 x double> %29, %33
%35 = insertelement <2 x double> poison, double %9, i64 0
%36 = shufflevector <2 x double> %35, <2 x double> poison, <2 x i32> zeroinitializer
%37 = insertelement <2 x double> poison, double %13, i64 0
%38 = insertelement <2 x double> %37, double %31, i64 1
%39 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %36, <2 x double> %38, <2 x double> %34)
%40 = insertelement <2 x double> poison, double %16, i64 0
%41 = shufflevector <2 x double> %40, <2 x double> poison, <2 x i32> zeroinitializer
%42 = fmul <2 x double> %38, %41
%43 = insertelement <2 x double> poison, double %14, i64 0
%44 = shufflevector <2 x double> %43, <2 x double> poison, <2 x i32> zeroinitializer
%45 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %44, <2 x double> %22, <2 x double> %42)
%46 = fmul <2 x double> %39, %39
%47 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %30, <2 x double> %30, <2 x double> %46)
%48 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %45, <2 x double> %45, <2 x double> %47)
%49 = shufflevector <2 x double> %48, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%50 = fmul <2 x double> %48, %49
%51 = extractelement <2 x double> %50, i64 0
%52 = fcmp ugt double %51, 0.000000e+00
br i1 %52, label %53, label %76
53: ; preds = %3
%54 = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%55 = fmul <2 x double> %39, %54
%56 = extractelement <2 x double> %55, i64 0
%57 = extractelement <2 x double> %30, i64 0
%58 = extractelement <2 x double> %30, i64 1
%59 = tail call double @llvm.fmuladd.f64(double %57, double %58, double %56)
%60 = extractelement <2 x double> %45, i64 0
%61 = extractelement <2 x double> %45, i64 1
%62 = tail call double @llvm.fmuladd.f64(double %60, double %61, double %59)
%63 = tail call double @sqrt(double %51)
%64 = fdiv double %62, %63
%65 = tail call i32 @abs(double %64)
%66 = icmp sgt i32 %65, 1
br i1 %66, label %67, label %74
67: ; preds = %53
%68 = tail call i32 @atan(double 1.000000e+00)
%69 = fcmp olt double %64, 0.000000e+00
br i1 %69, label %70, label %76
70: ; preds = %67
%71 = tail call i32 @atan(double 1.000000e+00)
%72 = sitofp i32 %71 to double
%73 = fmul double %72, 4.000000e+00
br label %76
74: ; preds = %53
%75 = tail call double @acos(double %64)
br label %76
76: ; preds = %67, %3, %74, %70
%77 = phi double [ %73, %70 ], [ %75, %74 ], [ 0.000000e+00, %3 ], [ 0.000000e+00, %67 ]
ret double %77
}