#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 atan2(double, double);
double cos(double);
double fabs(double);
double sin(double);
double rl_to_rls(double phi, double rla, double polphi, double pollam) {
  double zsinpol, zcospol, zlampol;
  double zphi, zrla, zarg1, zarg2;
  zsinpol = sin((3.14159265358979323846 / 180.) * polphi);
  zcospol = cos((3.14159265358979323846 / 180.) * polphi);
  zlampol = (3.14159265358979323846 / 180.) * pollam;
  if (rla > 180.0)
    rla -= 360.0;
  zrla = (3.14159265358979323846 / 180.) * rla;
  zphi = (3.14159265358979323846 / 180.) * phi;
  zarg1 = -sin(zrla - zlampol) * cos(zphi);
  zarg2 = -zsinpol * cos(zphi) * cos(zrla - zlampol) + zcospol * sin(zphi);
  if (fabs(zarg2) < 1.0e-20)
    zarg2 = 1.0e-20;
  return ((180. / 3.14159265358979323846) * atan2(zarg1, zarg2));
}


x86 assembly (clang, -O0):
<rl_to_rls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%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   1040 <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  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe64(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11bc <rl_to_rls+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,-0x48(%rbp)
movsd  0xe32(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x70(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
movaps 0xd77(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd53(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12dc <rl_to_rls+0x1ac>
movsd  0xd41(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
call   1030 <atan2@plt>
cvtsi2sd %eax,%xmm1
movsd  0xd29(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rl_to_rls>:
sub    $0x48,%rsp
movsd  %xmm3,0x8(%rsp)
movaps %xmm1,0x30(%rsp)
movsd  %xmm0,(%rsp)
movapd %xmm2,%xmm0
mulsd  0xeb0(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm1
movsd  0xe80(%rip),%xmm3
mulsd  %xmm3,%xmm1
movsd  0xe7c(%rip),%xmm0
movapd 0x30(%rsp),%xmm4
addsd  %xmm4,%xmm0
movsd  0xe72(%rip),%xmm2
cmpltsd %xmm4,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm4,%xmm2
orpd   %xmm0,%xmm2
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm2
movapd %xmm2,0x20(%rsp)
movsd  (%rsp),%xmm0
mulsd  %xmm3,%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm2,%xmm0
call   1040 <sin@plt>
movapd %xmm0,0x30(%rsp)
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movaps 0x20(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
subsd  %xmm1,%xmm0
movapd 0xdf8(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xdd4(%rip),%xmm2
cmpltsd %xmm2,%xmm1
movapd %xmm1,%xmm3
andnpd %xmm0,%xmm3
andpd  %xmm2,%xmm1
orpd   %xmm3,%xmm1
movapd 0x30(%rsp),%xmm0
xorpd  0xdd9(%rip),%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <atan2@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd9f(%rip),%xmm0
add    $0x48,%rsp
ret

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

LLVM IR (-O2):
define double @rl_to_rls(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 %3, 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 = fmul double %0, 0x3F91DF46A2529D39
%14 = fsub double %12, %8
%15 = tail call double @sin(double %14)
%16 = tail call double @cos(double %13)
%17 = fneg double %6
%18 = tail call double @cos(double %13)
%19 = fmul double %18, %17
%20 = tail call double @cos(double %14)
%21 = tail call double @sin(double %13)
%22 = fmul double %7, %21
%23 = tail call double @llvm.fmuladd.f64(double %19, double %20, double %22)
%24 = tail call double @llvm.fabs.f64(double %23)
%25 = fcmp olt double %24, 0x3BC79CA10C924223
%26 = select i1 %25, double 0x3BC79CA10C924223, double %23
%27 = fneg double %15
%28 = fmul double %16, %27
%29 = tail call i32 @atan2(double %28, double %26)
%30 = sitofp i32 %29 to double
%31 = fmul double %30, 0x404CA5DC1A63C1F8
ret double %31
}