#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 /*<<< orphan*/ acos(double);
double cos(double);
double fabs(int /*<<< orphan*/);
double rl_to_rls(double, double, double, double);
double sin(double);
void usvs_to_uv(double us, double vs, double phi, double rla, double polphi,
                double pollam, double *u, double *v) {
  double zpolphi, zpollam, zrla, zphi, pollamd, zrlas, zarg, zbeta;
  zpolphi = polphi * (3.14159265358979323846 / 180.);
  zpollam = pollam * (3.14159265358979323846 / 180.);
  zrla = rla * (3.14159265358979323846 / 180.);
  zphi = phi * (3.14159265358979323846 / 180.);
  pollamd = pollam;
  if (pollamd < 0.0)
    pollamd += 360.0;
  zrlas = rl_to_rls(phi, rla, polphi, pollam) * (3.14159265358979323846 / 180.);
  zarg = -sin(zpolphi) * sin(zrla - zpollam) * sin(zrlas) -
         cos(zrla - zpollam) * cos(zrlas);
  if (zarg > 1.0)
    zarg = 1.0;
  if (zarg < -1.0)
    zarg = -1.0;
  zbeta = fabs(acos(zarg));
  if ((-(rla - (pollamd - 180.0)) < 0) && (-(rla - (pollamd - 180.0)) >= -180))
    zbeta = -zbeta;
  *u = us * cos(zbeta) - vs * sin(zbeta);
  *v = us * sin(zbeta) + vs * cos(zbeta);
}


x86 assembly (clang, -O0):
<usvs_to_uv>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
mov    %rdi,-0x38(%rbp)
mov    %rsi,-0x40(%rbp)
movsd  0xe77(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe65(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe53(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe41(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    11f3 <usvs_to_uv+0xa3>
movsd  0xe1f(%rip),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
call   1030 <rl_to_rls@plt>
movsd  0xdec(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1060 <sin@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
call   1060 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
call   1070 <cos@plt>
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x90(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0x88(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
movsd  0xd21(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1306 <usvs_to_uv+0x1b6>
movsd  0xd0f(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xd0a(%rip),%xmm0
ucomisd -0x78(%rbp),%xmm0
jbe    1326 <usvs_to_uv+0x1d6>
movsd  0xcf7(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
call   1040 <acos@plt>
mov    %eax,%edi
call   1050 <fabs@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  0xcd2(%rip),%xmm2
subsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    13de <usvs_to_uv+0x28e>
movsd  -0x20(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  0xc94(%rip),%xmm2
subsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xc75(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     13de <usvs_to_uv+0x28e>
movsd  -0x80(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
call   1060 <sin@plt>
movsd  -0xd0(%rbp),%xmm1
ff
movsd  -0xc8(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
call   1070 <cos@plt>
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xa8(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usvs_to_uv>:
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x40(%rsp)
movsd  0xe8f(%rip),%xmm6
movapd %xmm4,%xmm0
mulsd  %xmm6,%xmm0
movsd  %xmm0,0x20(%rsp)
movapd %xmm5,%xmm0
mulsd  %xmm6,%xmm0
movapd %xmm3,%xmm1
movapd %xmm3,0x50(%rsp)
mulsd  %xmm6,%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xe61(%rip),%xmm0
addsd  %xmm5,%xmm0
xorpd  %xmm1,%xmm1
movapd %xmm5,%xmm6
cmpltsd %xmm1,%xmm6
andpd  %xmm6,%xmm0
andnpd %xmm5,%xmm6
orpd   %xmm0,%xmm6
movapd %xmm6,0x60(%rsp)
movapd %xmm2,%xmm0
movapd %xmm3,%xmm1
movapd %xmm4,%xmm2
movapd %xmm5,%xmm3
call   1030 <rl_to_rls@plt>
mulsd  0xe19(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
call   1060 <sin@plt>
xorps  0xe31(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <sin@plt>
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,0x48(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x48(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0xda6(%rip),%xmm1
minsd  %xmm0,%xmm1
movsd  0xda2(%rip),%xmm0
maxsd  %xmm1,%xmm0
call   1040 <acos@plt>
mov    %eax,%edi
call   1050 <fabs@plt>
movapd 0x60(%rsp),%xmm2
addsd  0xd8c(%rip),%xmm2
movapd 0x50(%rsp),%xmm1
subsd  %xmm2,%xmm1
movapd 0xd8a(%rip),%xmm3
xorpd  %xmm0,%xmm3
xorpd  %xmm2,%xmm2
cmpnltsd %xmm1,%xmm2
cmpnlesd 0xd6c(%rip),%xmm1
movapd %xmm1,%xmm4
andpd  %xmm0,%xmm4
andnpd %xmm3,%xmm1
orpd   %xmm4,%xmm1
movapd %xmm2,%xmm3
andnpd %xmm1,%xmm3
andpd  %xmm2,%xmm0
orpd   %xmm3,%xmm0
movapd %xmm0,0x10(%rsp)
call   1070 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x10(%rsp),%xmm0
call   1060 <sin@plt>
mulsd  0x38(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x40(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
movaps 0x10(%rsp),%xmm0
call   1060 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movapd 0x10(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x38(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x40(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @usvs_to_uv(double %0, double %1, double %2, double %3, double %4, double %5, double* %6, double* %7) {
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double*
%16 = alloca double*
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store double* %6, double** %15
store double* %7, double** %16
%25 = load double, double* %13
%26 = fmul double %25, 0x3F91DF46A2529D39
store double %26, double* %17
%27 = load double, double* %14
%28 = fmul double %27, 0x3F91DF46A2529D39
store double %28, double* %18
%29 = load double, double* %12
%30 = fmul double %29, 0x3F91DF46A2529D39
store double %30, double* %19
%31 = load double, double* %11
%32 = fmul double %31, 0x3F91DF46A2529D39
store double %32, double* %20
%33 = load double, double* %14
store double %33, double* %21
%34 = load double, double* %21
%35 = fcmp olt double %34, 0.000000e+00
br i1 %35, label %36, label %39
36: ; preds = %8
%37 = load double, double* %21
%38 = fadd double %37, 3.600000e+02
store double %38, double* %21
br label %39
39: ; preds = %36, %8
%40 = load double, double* %11
%41 = load double, double* %12
%42 = load double, double* %13
%43 = load double, double* %14
%44 = call double @rl_to_rls(double %40, double %41, double %42, double %43)
%45 = fmul double %44, 0x3F91DF46A2529D39
store double %45, double* %22
%46 = load double, double* %17
%47 = call double @sin(double %46)
%48 = fneg double %47
%49 = load double, double* %19
%50 = load double, double* %18
%51 = fsub double %49, %50
%52 = call double @sin(double %51)
%53 = fmul double %48, %52
%54 = load double, double* %22
%55 = call double @sin(double %54)
%56 = load double, double* %19
%57 = load double, double* %18
%58 = fsub double %56, %57
%59 = call double @cos(double %58)
%60 = load double, double* %22
%61 = call double @cos(double %60)
%62 = fmul double %59, %61
%63 = fneg double %62
%64 = call double @llvm.fmuladd.f64(double %53, double %55, double %63)
store double %64, double* %23
%65 = load double, double* %23
%66 = fcmp ogt double %65, 1.000000e+00
br i1 %66, label %67, label %68
67: ; preds = %39
store double 1.000000e+00, double* %23
br label %68
68: ; preds = %67, %39
%69 = load double, double* %23
%70 = fcmp olt double %69, -1.000000e+00
br i1 %70, label %71, label %72
71: ; preds = %68
store double -1.000000e+00, double* %23
br label %72
72: ; preds = %71, %68
%73 = load double, double* %23
%74 = call i32 @acos(double %73)
%75 = call double @fabs(i32 %74)
store double %75, double* %24
%76 = load double, double* %12
%77 = load double, double* %21
%78 = fsub double %77, 1.800000e+02
%79 = fsub double %76, %78
%80 = fneg double %79
%81 = fcmp olt double %80, 0.000000e+00
br i1 %81, label %82, label %92
82: ; preds = %72
%83 = load double, double* %12
%84 = load double, double* %21
%85 = fsub double %84, 1.800000e+02
%86 = fsub double %83, %85
%87 = fneg double %86
%88 = fcmp oge double %87, -1.800000e+02
br i1 %88, label %89, label %92
89: ; preds = %82
%90 = load double, double* %24
%91 = fneg double %90
store double %91, double* %24
br label %92
92: ; preds = %89, %82, %72
%93 = load double, double* %9
%94 = load double, double* %24
%95 = call double @cos(double %94)
%96 = load double, double* %10
%97 = load double, double* %24
%98 = call double @sin(double %97)
%99 = fmul double %96, %98
%100 = fneg double %99
%101 = call double @llvm.fmuladd.f64(double %93, double %95, double %100)
%102 = load double*, double** %15
store double %101, double* %102
%103 = load double, double* %9
%104 = load double, double* %24
%105 = call double @sin(double %104)
%106 = load double, double* %10
%107 = load double, double* %24
%108 = call double @cos(double %107)
%109 = fmul double %106, %108
%110 = call double @llvm.fmuladd.f64(double %103, double %105, double %109)
%111 = load double*, double** %16
store double %110, double* %111
ret void
}

LLVM IR (-O2):
define void @usvs_to_uv(double %0, double %1, double %2, double %3, double %4, double %5, double* nocapture writeonly %6, double* nocapture writeonly %7) {
%9 = fmul double %4, 0x3F91DF46A2529D39
%10 = fmul double %5, 0x3F91DF46A2529D39
%11 = fmul double %3, 0x3F91DF46A2529D39
%12 = fcmp olt double %5, 0.000000e+00
%13 = fadd double %5, 3.600000e+02
%14 = select i1 %12, double %13, double %5
%15 = tail call double @rl_to_rls(double %2, double %3, double %4, double %5)
%16 = fmul double %15, 0x3F91DF46A2529D39
%17 = tail call double @sin(double %9)
%18 = fneg double %17
%19 = fsub double %11, %10
%20 = tail call double @sin(double %19)
%21 = fmul double %20, %18
%22 = tail call double @sin(double %16)
%23 = tail call double @cos(double %19)
%24 = tail call double @cos(double %16)
%25 = fneg double %23
%26 = fmul double %24, %25
%27 = tail call double @llvm.fmuladd.f64(double %21, double %22, double %26)
%28 = fcmp ogt double %27, 1.000000e+00
%29 = select i1 %28, double 1.000000e+00, double %27
%30 = fcmp olt double %29, -1.000000e+00
%31 = select i1 %30, double -1.000000e+00, double %29
%32 = tail call i32 @acos(double %31)
%33 = tail call double @fabs(i32 %32)
%34 = fadd double %14, -1.800000e+02
%35 = fsub double %3, %34
%36 = fcmp ule double %35, 0.000000e+00
%37 = fcmp ugt double %35, 1.800000e+02
%38 = or i1 %36, %37
%39 = fneg double %33
%40 = select i1 %38, double %33, double %39
%41 = tail call double @cos(double %40)
%42 = tail call double @sin(double %40)
%43 = fneg double %42
%44 = fmul double %43, %1
%45 = tail call double @llvm.fmuladd.f64(double %0, double %41, double %44)
store double %45, double* %6
%46 = tail call double @sin(double %40)
%47 = tail call double @cos(double %40)
%48 = fmul double %47, %1
%49 = tail call double @llvm.fmuladd.f64(double %0, double %46, double %48)
store double %49, double* %7
ret void
}