#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 cos(float);
float pow(float, double);
int sin(float);
int tan(float);
double shift(float thetao, float phio, float sr) {
  float a, b, c, d1, d2, x, dval = 0.0f, theta, phi;
  float pi = 3.1415927;
  theta = thetao * pi / (sr / 2.);
  phi = phio * pi / (sr / 2.);
  a = cos(theta) * tan(phi) + sin(theta);
  b = 2. * tan(phi);
  c = cos(theta) * tan(phi) - sin(theta);
  x = pow(b, 2.) - 4. * a * c;
  d1 = (-b + pow(x, .5)) / (2. * a);
  d2 = (-b - pow(x, .5)) / (2. * a);
  if (((d1 < 0) ? (-d1) : (d1)) < 1.)
    dval = -d1;
  if (((d2 < 0) ? (-d2) : (d2)) < 1.)
    dval = -d2;
  return ((double)dval);
}


x86 assembly (clang, -O0):
<shift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  0xeb9(%rip),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe75(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe45(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x2c(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,-0x4c(%rbp)
movss  -0x30(%rbp),%xmm0
call   1040 <tan@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x48(%rbp)
movss  -0x2c(%rbp),%xmm0
call   1030 <sin@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
add    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x30(%rbp),%xmm0
call   1040 <tan@plt>
cvtsi2sd %eax,%xmm1
movsd  0xde2(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x2c(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,-0x44(%rbp)
movss  -0x30(%rbp),%xmm0
call   1040 <tan@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x40(%rbp)
movss  -0x2c(%rbp),%xmm0
call   1030 <sin@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
sub    %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
movsd  0xd8c(%rip),%xmm1
call   1060 <pow@plt>
cvtss2sd %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xd82(%rip),%xmm0
mulsd  %xmm2,%xmm0
movss  -0x18(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x24(%rbp),%xmm0
movsd  0xd21(%rip),%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x3c(%rbp),%xmm0
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xcf3(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x24(%rbp),%xmm0
movsd  0xcc6(%rip),%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x38(%rbp),%xmm0
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xc98(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    13a2 <shift+0x262>
movss  -0x1c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x50(%rbp)
jmp    13ac <shift+0x26c>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x50(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xc5b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    13de <shift+0x29e>
movss  -0x1c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x20(%rbp),%xmm0
jbe    1407 <shift+0x2c7>
movss  -0x20(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x54(%rbp)
jmp    1411 <shift+0x2d1>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
movss  -0x54(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xbf6(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1443 <shift+0x303>
movss  -0x20(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shift>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
movss  0xeb2(%rip),%xmm3
mulss  %xmm3,%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm2,%xmm2
mulsd  0xea6(%rip),%xmm2
divsd  %xmm2,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
mulss  %xmm3,%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
movss  %xmm1,(%rsp)
call   1050 <cos@plt>
mov    %eax,%ebx
movss  (%rsp),%xmm0
call   1040 <tan@plt>
mov    %eax,%ebp
imul   %ebx,%ebp
movss  0x10(%rsp),%xmm0
call   1030 <sin@plt>
add    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x30(%rsp)
movss  (%rsp),%xmm0
call   1040 <tan@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm0
cvtsd2ss %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movss  0x10(%rsp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ebx
movss  (%rsp),%xmm0
call   1040 <tan@plt>
mov    %eax,%ebp
imul   %ebx,%ebp
movss  0x10(%rsp),%xmm0
call   1030 <sin@plt>
sub    %eax,%ebp
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
movss  %xmm0,(%rsp)
movsd  0xe00(%rip),%xmm1
movaps 0x40(%rsp),%xmm0
call   1060 <pow@plt>
cvtss2sd %xmm0,%xmm0
movss  0x30(%rsp),%xmm1
xorps  %xmm3,%xmm3
cvtss2sd %xmm1,%xmm3
movaps %xmm3,0x10(%rsp)
movss  (%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xdd7(%rip),%xmm2
mulsd  %xmm3,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
movss  %xmm0,0x2c(%rsp)
movaps 0x40(%rsp),%xmm2
xorps  0xdba(%rip),%xmm2
movaps %xmm2,(%rsp)
movsd  0xd96(%rip),%xmm1
call   1060 <pow@plt>
movaps %xmm0,0x30(%rsp)
movapd 0x10(%rsp),%xmm0
addsd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movss  0x2c(%rsp),%xmm0
movsd  0xd6e(%rip),%xmm1
call   1060 <pow@plt>
movapd 0xd79(%rip),%xmm3
movaps (%rsp),%xmm1
unpcklps 0x30(%rsp),%xmm1
unpcklps 0x40(%rsp),%xmm0
subps  %xmm0,%xmm1
cvtps2pd %xmm1,%xmm0
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm1,%xmm1
divpd  %xmm1,%xmm0
cvtpd2ps %xmm0,%xmm0
xorpd  %xmm1,%xmm1
movapd %xmm0,%xmm2
cmpltps %xmm1,%xmm2
xorpd  %xmm0,%xmm3
movapd %xmm3,%xmm1
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
cmpltps 0xd3b(%rip),%xmm2
01
unpcklps %xmm2,%xmm2
movmskpd %xmm2,%eax
test   $0x2,%al
jne    130a <shift+0x1ca>
xorpd  %xmm0,%xmm0
test   $0x1,%al
je     1313 <shift+0x1d3>
jmp    1317 <shift+0x1d7>
pshufd $0x55,%xmm3,%xmm0
test   $0x1,%al
jne    1317 <shift+0x1d7>
movdqa %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define double @shift(float %0, float %1, float %2) {
%4 = fmul float %0, 0x400921FB60000000
%5 = fpext float %4 to double
%6 = fpext float %2 to double
%7 = fmul double %6, 5.000000e-01
%8 = fdiv double %5, %7
%9 = fptrunc double %8 to float
%10 = fmul float %1, 0x400921FB60000000
%11 = fpext float %10 to double
%12 = fdiv double %11, %7
%13 = fptrunc double %12 to float
%14 = tail call i32 @cos(float %9)
%15 = tail call i32 @tan(float %13)
%16 = mul nsw i32 %15, %14
%17 = tail call i32 @sin(float %9)
%18 = add nsw i32 %16, %17
%19 = sitofp i32 %18 to float
%20 = tail call i32 @tan(float %13)
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 2.000000e+00
%23 = fptrunc double %22 to float
%24 = tail call i32 @cos(float %9)
%25 = tail call i32 @tan(float %13)
%26 = mul nsw i32 %25, %24
%27 = tail call i32 @sin(float %9)
%28 = sub nsw i32 %26, %27
%29 = sitofp i32 %28 to float
%30 = tail call float @pow(float %23, double 2.000000e+00)
%31 = fpext float %30 to double
%32 = fpext float %19 to double
%33 = fpext float %29 to double
%34 = fmul double %32, -4.000000e+00
%35 = tail call double @llvm.fmuladd.f64(double %34, double %33, double %31)
%36 = fptrunc double %35 to float
%37 = fneg float %23
%38 = tail call float @pow(float %36, double 5.000000e-01)
%39 = fmul double %32, 2.000000e+00
%40 = tail call float @pow(float %36, double 5.000000e-01)
%41 = insertelement <2 x float> poison, float %37, i64 0
%42 = insertelement <2 x float> %41, float %38, i64 1
%43 = insertelement <2 x float> poison, float %40, i64 0
%44 = insertelement <2 x float> %43, float %23, i64 1
%45 = fsub <2 x float> %42, %44
%46 = fpext <2 x float> %45 to <2 x double>
%47 = insertelement <2 x double> poison, double %39, i64 0
%48 = shufflevector <2 x double> %47, <2 x double> poison, <2 x i32> zeroinitializer
%49 = fdiv <2 x double> %46, %48
%50 = fptrunc <2 x double> %49 to <2 x float>
%51 = fcmp olt <2 x float> %50, zeroinitializer
%52 = fneg <2 x float> %50
%53 = select <2 x i1> %51, <2 x float> %52, <2 x float> %50
%54 = fcmp olt <2 x float> %53, <float 1.000000e+00, float 1.000000e+00>
%55 = extractelement <2 x i1> %54, i64 1
%56 = extractelement <2 x float> %52, i64 1
%57 = select i1 %55, float %56, float 0.000000e+00
%58 = extractelement <2 x i1> %54, i64 0
%59 = extractelement <2 x float> %52, i64 0
%60 = select i1 %58, float %59, float %57
%61 = fpext float %60 to double
ret double %61
}