#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 */
double M_PI;
double atan2(float, float);
float cos(float);
int /*<<< orphan*/ rotateX(int, float, float *, float *, float *);
int /*<<< orphan*/ rotateY(int, float, float *, float *, float *);
float sin(float);
float sqrt(float);
void projection_longlat_xy(float longitude, float latitude, float dlongitude,
                           float dlatitude, float *x, float *y) {
  float xE, yE, zE, r2;
  dlongitude *= 180.0 / M_PI;
  dlatitude *= 180.0 / M_PI;
  yE = sin(latitude);
  xE = cos(latitude) * sin(longitude);
  zE = -cos(latitude) * cos(longitude);
  rotateX(1, dlatitude, &xE, &yE, &zE);
  rotateY(1, -dlongitude, &xE, &yE, &zE);
  r2 = sqrt(zE * zE + xE * xE);
  *y = atan2(r2, yE);
  *y = 0.5 * M_PI - (*y);
  *y *= 180.0 / M_PI;
  *x = atan2(xE, -zE) * 180.0 / M_PI;
}


x86 assembly (clang, -O0):
<projection_longlat_xy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  0xe74(%rip),%xmm1
mov    0x2e55(%rip),%rax
divsd  (%rax),%xmm1
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movsd  0xe4b(%rip),%xmm1
mov    0x2e2c(%rip),%rax
divsd  (%rax),%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
call   1050 <sin@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
call   1060 <cos@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x4(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x38(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
call   1060 <cos@plt>
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x4(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x10(%rbp),%xmm0
mov    $0x1,%edi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1040 <rotateX@plt>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    $0x1,%edi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1080 <rotateY@plt>
movss  -0x2c(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  -0x24(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1070 <sqrt@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
call   1030 <atan2@plt>
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    0x2d17(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xd08(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movsd  0xce4(%rip),%xmm1
mov    0x2cc5(%rip),%rax
divsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
call   1030 <atan2@plt>
movsd  0xc9d(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    0x2c7a(%rip),%rax
divsd  (%rax),%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<projection_longlat_xy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
movaps %xmm1,%xmm4
movss  %xmm1,0x20(%rsp)
movss  %xmm0,0x10(%rsp)
mov    0x2e5e(%rip),%rbp
movsd  0xe6e(%rip),%xmm0
divsd  0x0(%rbp),%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
mulsd  %xmm0,%xmm1
cvtsd2ss %xmm1,%xmm1
movaps %xmm1,0x30(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x1c(%rsp)
movaps %xmm4,%xmm0
call   1050 <sin@plt>
movss  %xmm0,0x14(%rsp)
movss  0x20(%rsp),%xmm0
call   1060 <cos@plt>
movss  %xmm0,0x18(%rsp)
movss  0x10(%rsp),%xmm0
call   1050 <sin@plt>
mulss  0x18(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x20(%rsp),%xmm0
call   1060 <cos@plt>
xorps  0xe05(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movss  0x10(%rsp),%xmm0
call   1060 <cos@plt>
mulss  0x20(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xc(%rsp),%rbx
lea    0x14(%rsp),%r12
lea    0x8(%rsp),%r13
mov    $0x1,%edi
movss  0x1c(%rsp),%xmm0
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1040 <rotateX@plt>
movaps 0x30(%rsp),%xmm0
xorps  0xdb5(%rip),%xmm0
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1080 <rotateY@plt>
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1294 <projection_longlat_xy+0x134>
sqrtss %xmm0,%xmm0
jmp    1299 <projection_longlat_xy+0x139>
call   1070 <sqrt@plt>
movss  0x14(%rsp),%xmm1
call   1030 <atan2@plt>
cvtsd2ss %xmm0,%xmm0
movsd  0x0(%rbp),%xmm1
cvtss2sd %xmm0,%xmm0
movsd  0xd47(%rip),%xmm2
divsd  %xmm1,%xmm2
mulsd  0xd43(%rip),%xmm1
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm2,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r15)
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
xorps  0xd1c(%rip),%xmm1
call   1030 <atan2@plt>
mulsd  0xcff(%rip),%xmm0
divsd  0x0(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @projection_longlat_xy(float %0, float %1, float %2, float %3, float* %4, float* %5) {
%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
store float %0, float* %7
store float %1, float* %8
store float %2, float* %9
store float %3, float* %10
store float* %4, float** %11
store float* %5, float** %12
%17 = load double, double* @M_PI
%18 = fdiv double 1.800000e+02, %17
%19 = load float, float* %9
%20 = fpext float %19 to double
%21 = fmul double %20, %18
%22 = fptrunc double %21 to float
store float %22, float* %9
%23 = load double, double* @M_PI
%24 = fdiv double 1.800000e+02, %23
%25 = load float, float* %10
%26 = fpext float %25 to double
%27 = fmul double %26, %24
%28 = fptrunc double %27 to float
store float %28, float* %10
%29 = load float, float* %8
%30 = call float @sin(float %29)
store float %30, float* %14
%31 = load float, float* %8
%32 = call float @cos(float %31)
%33 = load float, float* %7
%34 = call float @sin(float %33)
%35 = fmul float %32, %34
store float %35, float* %13
%36 = load float, float* %8
%37 = call float @cos(float %36)
%38 = fneg float %37
%39 = load float, float* %7
%40 = call float @cos(float %39)
%41 = fmul float %38, %40
store float %41, float* %15
%42 = load float, float* %10
%43 = call i32 @rotateX(i32 1, float %42, float* %13, float* %14, float* %15)
%44 = load float, float* %9
%45 = fneg float %44
%46 = call i32 @rotateY(i32 1, float %45, float* %13, float* %14, float* %15)
%47 = load float, float* %15
%48 = load float, float* %15
%49 = load float, float* %13
%50 = load float, float* %13
%51 = fmul float %49, %50
%52 = call float @llvm.fmuladd.f32(float %47, float %48, float %51)
%53 = call float @sqrt(float %52)
store float %53, float* %16
%54 = load float, float* %16
%55 = load float, float* %14
%56 = call double @atan2(float %54, float %55)
%57 = fptrunc double %56 to float
%58 = load float*, float** %12
store float %57, float* %58
%59 = load double, double* @M_PI
%60 = load float*, float** %12
%61 = load float, float* %60
%62 = fpext float %61 to double
%63 = fneg double %62
%64 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %59, double %63)
%65 = fptrunc double %64 to float
%66 = load float*, float** %12
store float %65, float* %66
%67 = load double, double* @M_PI
%68 = fdiv double 1.800000e+02, %67
%69 = load float*, float** %12
%70 = load float, float* %69
%71 = fpext float %70 to double
%72 = fmul double %71, %68
%73 = fptrunc double %72 to float
store float %73, float* %69
%74 = load float, float* %13
%75 = load float, float* %15
%76 = fneg float %75
%77 = call double @atan2(float %74, float %76)
%78 = fmul double %77, 1.800000e+02
%79 = load double, double* @M_PI
%80 = fdiv double %78, %79
%81 = fptrunc double %80 to float
%82 = load float*, float** %11
store float %81, float* %82
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @projection_longlat_xy(float %0, float %1, float %2, float %3, float* nocapture writeonly %4, float* nocapture writeonly %5) {
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = bitcast float* %7 to i8*
%11 = bitcast float* %8 to i8*
%12 = bitcast float* %9 to i8*
%13 = load double, double* @M_PI
%14 = fdiv double 1.800000e+02, %13
%15 = fpext float %2 to double
%16 = fmul double %14, %15
%17 = fptrunc double %16 to float
%18 = fpext float %3 to double
%19 = fmul double %14, %18
%20 = fptrunc double %19 to float
%21 = tail call float @sin(float %1)
store float %21, float* %8
%22 = tail call float @cos(float %1)
%23 = tail call float @sin(float %0)
%24 = fmul float %22, %23
store float %24, float* %7
%25 = tail call float @cos(float %1)
%26 = fneg float %25
%27 = tail call float @cos(float %0)
%28 = fmul float %27, %26
store float %28, float* %9
%29 = call i32 @rotateX(i32 1, float %20, float* %7, float* %8, float* %9)
%30 = fneg float %17
%31 = call i32 @rotateY(i32 1, float %30, float* %7, float* %8, float* %9)
%32 = load float, float* %9
%33 = load float, float* %7
%34 = fmul float %33, %33
%35 = call float @llvm.fmuladd.f32(float %32, float %32, float %34)
%36 = call float @sqrt(float %35)
%37 = load float, float* %8
%38 = call double @atan2(float %36, float %37)
%39 = fptrunc double %38 to float
%40 = load double, double* @M_PI
%41 = fpext float %39 to double
%42 = fneg double %41
%43 = call double @llvm.fmuladd.f64(double %40, double 5.000000e-01, double %42)
%44 = fptrunc double %43 to float
%45 = fdiv double 1.800000e+02, %40
%46 = fpext float %44 to double
%47 = fmul double %45, %46
%48 = fptrunc double %47 to float
store float %48, float* %5
%49 = load float, float* %7
%50 = load float, float* %9
%51 = fneg float %50
%52 = call double @atan2(float %49, float %51)
%53 = fmul double %52, 1.800000e+02
%54 = load double, double* @M_PI
%55 = fdiv double %53, %54
%56 = fptrunc double %55 to float
store float %56, float* %4
ret void
}