double shift(thetao, phio, sr)
float thetao, phio, sr;
{
  float a, b, c, d1, d2, x, dval, 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    $0x80,%rsp
movsd  %xmm2,-0x70(%rbp)
movaps %xmm0,%xmm2
movsd  -0x70(%rbp),%xmm0
cvtsd2ss %xmm2,%xmm2
cvtsd2ss %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm0
movss  %xmm2,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  0xea5(%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  0xe61(%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  0xe31(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <tan@plt>
movsd  %xmm0,-0x68(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <sin@plt>
movsd  -0x68(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <tan@plt>
movaps %xmm0,%xmm1
movsd  0xdb5(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <tan@plt>
movsd  %xmm0,-0x58(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <sin@plt>
movsd  -0x58(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd2e(%rip),%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xd25(%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
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcbc(%rip),%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xc92(%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
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc5d(%rip),%xmm1
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xc33(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    1407 <shift+0x2c7>
movss  -0x1c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x74(%rbp)
jmp    1411 <shift+0x2d1>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x74(%rbp)
movss  -0x74(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xbf6(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1443 <shift+0x303>
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    146c <shift+0x32c>
movss  -0x20(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x78(%rbp)
jmp    1476 <shift+0x336>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
movss  -0x78(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xb91(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    14a8 <shift+0x368>
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    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shift>:
sub    $0x38,%rsp
cvtsd2ss %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm2
movss  0xea8(%rip),%xmm3
mulss  %xmm3,%xmm0
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm2,%xmm2
mulsd  0xe9c(%rip),%xmm2
divsd  %xmm2,%xmm0
cvtsd2ss %xmm0,%xmm0
mulss  %xmm3,%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
movss  %xmm1,(%rsp)
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rsp)
call   1040 <tan@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1040 <tan@plt>
addsd  %xmm0,%xmm0
cvtsd2ss %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  (%rsp),%xmm0
call   1040 <tan@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  (%rsp),%xmm1
mulsd  0x30(%rsp),%xmm1
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movaps 0x10(%rsp),%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
mulsd  %xmm1,%xmm1
movss  0x20(%rsp),%xmm2
cvtss2sd %xmm2,%xmm4
movsd  %xmm4,0x8(%rsp)
cvtss2sd %xmm0,%xmm0
movsd  0xdad(%rip),%xmm2
mulsd  %xmm4,%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
movaps %xmm3,%xmm2
xorps  0xda0(%rip),%xmm2
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
movsd  %xmm1,(%rsp)
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xd6a(%rip),%xmm1
call   1060 <pow@plt>
addsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0xd35(%rip),%xmm1
call   1060 <pow@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
divsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movaps %xmm0,%xmm1
movaps 0xd28(%rip),%xmm4
xorps  %xmm4,%xmm1
xorps  %xmm2,%xmm2
movaps %xmm0,%xmm3
cmpltss %xmm2,%xmm3
andps  %xmm3,%xmm1
andnps %xmm0,%xmm3
orps   %xmm1,%xmm3
cmpltss 0xcec(%rip),%xmm3
andps  %xmm3,%xmm0
andnps 0x20(%rsp),%xmm3
orps   %xmm0,%xmm3
xorps  %xmm4,%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
add    $0x38,%rsp
ret

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

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