#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 asin(double);
double cos(double);
double sin(double);
double phirot_to_phi(double phirot, double lamrot, double polphi,
                     double polgam) {
  double zsinpol, zcospol;
  double zphirot, zlamrot, zarg;
  double zgam;
  zsinpol = sin((3.14159265358979323846 / 180.) * polphi);
  zcospol = cos((3.14159265358979323846 / 180.) * polphi);
  zphirot = (3.14159265358979323846 / 180.) * phirot;
  if (lamrot > 180.0)
    lamrot -= 360.0;
  zlamrot = (3.14159265358979323846 / 180.) * lamrot;
  if (polgam > 0) {
    zgam = (3.14159265358979323846 / 180.) * polgam;
    zarg = zsinpol * sin(zphirot) +
           zcospol * cos(zphirot) *
               (cos(zlamrot) * cos(zgam) - sin(zgam) * sin(zlamrot));
  } else
    zarg = zcospol * cos(zphirot) * cos(zlamrot) + zsinpol * sin(zphirot);
  return ((180. / 3.14159265358979323846) * asin(zarg));
}


x86 assembly (clang, -O0):
<phirot_to_phi>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  0xeb1(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xe9a(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe83(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe64(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11bc <phirot_to_phi+0x8c>
movsd  -0x10(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe44(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12c7 <phirot_to_phi+0x197>
movsd  0xe20(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x80(%rbp),%xmm4
movsd  -0x78(%rbp),%xmm3
movsd  -0x70(%rbp),%xmm5
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm6
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm6,%xmm4
movq   %xmm4,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm4
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    134a <phirot_to_phi+0x21a>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0xa0(%rbp),%xmm1
ff
movsd  -0x98(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <asin@plt>
cvtsi2sd %eax,%xmm1
movsd  0xcb8(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<phirot_to_phi>:
sub    $0x48,%rsp
movsd  %xmm3,0x8(%rsp)
movaps %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
movapd %xmm2,%xmm0
mulsd  0xeaf(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1030 <sin@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xe85(%rip),%xmm4
movsd  0x18(%rsp),%xmm2
mulsd  %xmm4,%xmm2
movsd  0xe7b(%rip),%xmm0
movapd 0x20(%rsp),%xmm3
addsd  %xmm3,%xmm0
movsd  0xe71(%rip),%xmm1
cmpltsd %xmm3,%xmm1
andpd  %xmm1,%xmm0
andnpd %xmm3,%xmm1
orpd   %xmm0,%xmm1
mulsd  %xmm4,%xmm1
movapd %xmm1,0x20(%rsp)
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm3
ucomisd %xmm0,%xmm3
movsd  %xmm2,0x18(%rsp)
jbe    1277 <phirot_to_phi+0x147>
movapd %xmm3,%xmm1
mulsd  0xe20(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm2,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <cos@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movaps 0x20(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x20(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0x10(%rsp),%xmm1
movsd  0x30(%rsp),%xmm0
mulsd  0x40(%rsp),%xmm0
jmp    12c5 <phirot_to_phi+0x195>
movapd %xmm2,%xmm0
call   1050 <cos@plt>
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movaps 0x20(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x30(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm1,%xmm0
call   1040 <asin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd3b(%rip),%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @phirot_to_phi(double %0, double %1, double %2, double %3) {
%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* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%15 = load double, double* %7
%16 = fmul double 0x3F91DF46A2529D39, %15
%17 = call double @sin(double %16)
store double %17, double* %9
%18 = load double, double* %7
%19 = fmul double 0x3F91DF46A2529D39, %18
%20 = call double @cos(double %19)
store double %20, double* %10
%21 = load double, double* %5
%22 = fmul double 0x3F91DF46A2529D39, %21
store double %22, double* %11
%23 = load double, double* %6
%24 = fcmp ogt double %23, 1.800000e+02
br i1 %24, label %25, label %28
25: ; preds = %4
%26 = load double, double* %6
%27 = fsub double %26, 3.600000e+02
store double %27, double* %6
br label %28
28: ; preds = %25, %4
%29 = load double, double* %6
%30 = fmul double 0x3F91DF46A2529D39, %29
store double %30, double* %12
%31 = load double, double* %8
%32 = fcmp ogt double %31, 0.000000e+00
br i1 %32, label %33, label %56
33: ; preds = %28
%34 = load double, double* %8
%35 = fmul double 0x3F91DF46A2529D39, %34
store double %35, double* %14
%36 = load double, double* %9
%37 = load double, double* %11
%38 = call double @sin(double %37)
%39 = load double, double* %10
%40 = load double, double* %11
%41 = call double @cos(double %40)
%42 = fmul double %39, %41
%43 = load double, double* %12
%44 = call double @cos(double %43)
%45 = load double, double* %14
%46 = call double @cos(double %45)
%47 = load double, double* %14
%48 = call double @sin(double %47)
%49 = load double, double* %12
%50 = call double @sin(double %49)
%51 = fmul double %48, %50
%52 = fneg double %51
%53 = call double @llvm.fmuladd.f64(double %44, double %46, double %52)
%54 = fmul double %42, %53
%55 = call double @llvm.fmuladd.f64(double %36, double %38, double %54)
store double %55, double* %13
br label %68
56: ; preds = %28
%57 = load double, double* %10
%58 = load double, double* %11
%59 = call double @cos(double %58)
%60 = fmul double %57, %59
%61 = load double, double* %12
%62 = call double @cos(double %61)
%63 = load double, double* %9
%64 = load double, double* %11
%65 = call double @sin(double %64)
%66 = fmul double %63, %65
%67 = call double @llvm.fmuladd.f64(double %60, double %62, double %66)
store double %67, double* %13
br label %68
68: ; preds = %56, %33
%69 = load double, double* %13
%70 = call i32 @asin(double %69)
%71 = sitofp i32 %70 to double
%72 = fmul double 0x404CA5DC1A63C1F8, %71
ret double %72
}

LLVM IR (-O2):
define double @phirot_to_phi(double %0, double %1, double %2, double %3) {
%5 = fmul double %2, 0x3F91DF46A2529D39
%6 = tail call double @sin(double %5)
%7 = tail call double @cos(double %5)
%8 = fmul double %0, 0x3F91DF46A2529D39
%9 = fcmp ogt double %1, 1.800000e+02
%10 = fadd double %1, -3.600000e+02
%11 = select i1 %9, double %10, double %1
%12 = fmul double %11, 0x3F91DF46A2529D39
%13 = fcmp ogt double %3, 0.000000e+00
br i1 %13, label %14, label %28
14: ; preds = %4
%15 = fmul double %3, 0x3F91DF46A2529D39
%16 = tail call double @sin(double %8)
%17 = tail call double @cos(double %8)
%18 = fmul double %7, %17
%19 = tail call double @cos(double %12)
%20 = tail call double @cos(double %15)
%21 = tail call double @sin(double %15)
%22 = tail call double @sin(double %12)
%23 = fneg double %21
%24 = fmul double %22, %23
%25 = tail call double @llvm.fmuladd.f64(double %19, double %20, double %24)
%26 = fmul double %18, %25
%27 = tail call double @llvm.fmuladd.f64(double %6, double %16, double %26)
br label %35
28: ; preds = %4
%29 = tail call double @cos(double %8)
%30 = fmul double %7, %29
%31 = tail call double @cos(double %12)
%32 = tail call double @sin(double %8)
%33 = fmul double %6, %32
%34 = tail call double @llvm.fmuladd.f64(double %30, double %31, double %33)
br label %35
35: ; preds = %28, %14
%36 = phi double [ %27, %14 ], [ %34, %28 ]
%37 = tail call i32 @asin(double %36)
%38 = sitofp i32 %37 to double
%39 = fmul double %38, 0x404CA5DC1A63C1F8
ret double %39
}