#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 ph_to_phs(double phi, double rla, double polphi, double pollam) {
  double zsinpol, zcospol, zlampol;
  double zphi, zrla, zarg;
  zsinpol = sin((3.14159265358979323846 / 180.) * polphi);
  zcospol = cos((3.14159265358979323846 / 180.) * polphi);
  zlampol = (3.14159265358979323846 / 180.) * pollam;
  zphi = (3.14159265358979323846 / 180.) * phi;
  if (rla > 180.0)
    rla -= 360.0;
  zrla = (3.14159265358979323846 / 180.) * rla;
  zarg = zcospol * cos(zphi) * cos(zrla - zlampol) + zsinpol * sin(zphi);
  return ((180. / 3.14159265358979323846) * asin(zarg));
}


x86 assembly (clang, -O0):
<ph_to_phs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  0xeb4(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xe9d(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe86(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe74(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe55(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11cb <ph_to_phs+0x9b>
movsd  -0x10(%rbp),%xmm0
movsd  0xe4e(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe35(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <asin@plt>
cvtsi2sd %eax,%xmm1
movsd  0xdb5(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ph_to_phs>:
sub    $0x38,%rsp
movsd  %xmm3,0x10(%rsp)
movaps %xmm1,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
movapd %xmm2,%xmm0
mulsd  0xeaf(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <sin@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0xe7f(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0xe75(%rip),%xmm1
movapd 0x20(%rsp),%xmm3
addsd  %xmm3,%xmm1
movsd  0xe6b(%rip),%xmm4
cmpltsd %xmm3,%xmm4
andpd  %xmm4,%xmm1
andnpd %xmm3,%xmm4
orpd   %xmm1,%xmm4
movsd  0x10(%rsp),%xmm1
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm4
subsd  %xmm1,%xmm4
movapd %xmm4,0x20(%rsp)
call   1050 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movaps 0x20(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x30(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm1,%xmm0
call   1040 <asin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xdf4(%rip),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @ph_to_phs(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* %8
%22 = fmul double 0x3F91DF46A2529D39, %21
store double %22, double* %11
%23 = load double, double* %5
%24 = fmul double 0x3F91DF46A2529D39, %23
store double %24, double* %12
%25 = load double, double* %6
%26 = fcmp ogt double %25, 1.800000e+02
br i1 %26, label %27, label %30
27: ; preds = %4
%28 = load double, double* %6
%29 = fsub double %28, 3.600000e+02
store double %29, double* %6
br label %30
30: ; preds = %27, %4
%31 = load double, double* %6
%32 = fmul double 0x3F91DF46A2529D39, %31
store double %32, double* %13
%33 = load double, double* %10
%34 = load double, double* %12
%35 = call double @cos(double %34)
%36 = fmul double %33, %35
%37 = load double, double* %13
%38 = load double, double* %11
%39 = fsub double %37, %38
%40 = call double @cos(double %39)
%41 = load double, double* %9
%42 = load double, double* %12
%43 = call double @sin(double %42)
%44 = fmul double %41, %43
%45 = call double @llvm.fmuladd.f64(double %36, double %40, double %44)
store double %45, double* %14
%46 = load double, double* %14
%47 = call i32 @asin(double %46)
%48 = sitofp i32 %47 to double
%49 = fmul double 0x404CA5DC1A63C1F8, %48
ret double %49
}

LLVM IR (-O2):
define double @ph_to_phs(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 %3, 0x3F91DF46A2529D39
%13 = fmul double %11, 0x3F91DF46A2529D39
%14 = tail call double @cos(double %8)
%15 = fmul double %7, %14
%16 = fsub double %13, %12
%17 = tail call double @cos(double %16)
%18 = tail call double @sin(double %8)
%19 = fmul double %6, %18
%20 = tail call double @llvm.fmuladd.f64(double %15, double %17, double %19)
%21 = tail call i32 @asin(double %20)
%22 = sitofp i32 %21 to double
%23 = fmul double %22, 0x404CA5DC1A63C1F8
ret double %23
}