#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 atan(int);
double cos(double);
double sin(double);
double sqrt(double);
int tan(double);
void lonlat2geovec(float lon, float lat, float *v) {
  double Re = 6378.137;
  double f = 1 / 298.257223563;
  double rlon, rlat, phi, R;
  rlon = (double)(lon * 3.141592653589793 / 180.0);
  rlat = (double)(lat * 3.141592653589793 / 180.0);
  phi = atan(tan(rlat) * (1 - f) * (1 - f));
  R = Re * (1.0 - f) / sqrt(1.0 - (2.0 - f) * f * (cos(phi) * cos(phi)));
  *v = (float)(R * cos(phi) * cos(rlon));
  *(v + 1) = (float)(R * cos(phi) * sin(rlon));
  *(v + 2) = (float)(R * sin(phi));
}


x86 assembly (clang, -O0):
<lonlat2geovec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  0xeb7(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe84(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe70(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe5e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe4a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <tan@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe1b(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe0a(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <atan@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xde6(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xdd8(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1060 <cos@plt>
movsd  -0x80(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm2,%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd74(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lonlat2geovec>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
cvtss2sd %xmm0,%xmm0
movsd  0xe9c(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe98(%rip),%xmm3
divsd  %xmm3,%xmm0
movsd  %xmm0,0x18(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  %xmm2,%xmm0
divsd  %xmm3,%xmm0
call   1050 <tan@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe73(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <atan@plt>
movsd  %xmm0,0x8(%rsp)
call   1060 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  (%rsp),%xmm0
mulsd  0xe42(%rip),%xmm0
addsd  0xe42(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11ee <lonlat2geovec+0x9e>
sqrtsd %xmm0,%xmm0
jmp    11f3 <lonlat2geovec+0xa3>
call   1070 <sqrt@plt>
movsd  0xe2d(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  0x10(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x10(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  (%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @lonlat2geovec(float %0, float %1, float* %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store float %0, float* %4
store float %1, float* %5
store float* %2, float** %6
store double 0x40B8EA23126E978D, double* %7
store double 0x3F6B775A84F3E128, double* %8
%13 = load float, float* %4
%14 = fpext float %13 to double
%15 = fmul double %14, 0x400921FB54442D18
%16 = fdiv double %15, 1.800000e+02
store double %16, double* %9
%17 = load float, float* %5
%18 = fpext float %17 to double
%19 = fmul double %18, 0x400921FB54442D18
%20 = fdiv double %19, 1.800000e+02
store double %20, double* %10
%21 = load double, double* %10
%22 = call i32 @tan(double %21)
%23 = sitofp i32 %22 to double
%24 = load double, double* %8
%25 = fsub double 1.000000e+00, %24
%26 = fmul double %23, %25
%27 = load double, double* %8
%28 = fsub double 1.000000e+00, %27
%29 = fmul double %26, %28
%30 = fptosi double %29 to i32
%31 = call double @atan(i32 %30)
store double %31, double* %11
%32 = load double, double* %7
%33 = load double, double* %8
%34 = fsub double 1.000000e+00, %33
%35 = fmul double %32, %34
%36 = load double, double* %8
%37 = fsub double 2.000000e+00, %36
%38 = load double, double* %8
%39 = fmul double %37, %38
%40 = load double, double* %11
%41 = call double @cos(double %40)
%42 = load double, double* %11
%43 = call double @cos(double %42)
%44 = fmul double %41, %43
%45 = fneg double %39
%46 = call double @llvm.fmuladd.f64(double %45, double %44, double 1.000000e+00)
%47 = call double @sqrt(double %46)
%48 = fdiv double %35, %47
store double %48, double* %12
%49 = load double, double* %12
%50 = load double, double* %11
%51 = call double @cos(double %50)
%52 = fmul double %49, %51
%53 = load double, double* %9
%54 = call double @cos(double %53)
%55 = fmul double %52, %54
%56 = fptrunc double %55 to float
%57 = load float*, float** %6
store float %56, float* %57
%58 = load double, double* %12
%59 = load double, double* %11
%60 = call double @cos(double %59)
%61 = fmul double %58, %60
%62 = load double, double* %9
%63 = call double @sin(double %62)
%64 = fmul double %61, %63
%65 = fptrunc double %64 to float
%66 = load float*, float** %6
%67 = getelementptr inbounds float, float* %66, i64 1
store float %65, float* %67
%68 = load double, double* %12
%69 = load double, double* %11
%70 = call double @sin(double %69)
%71 = fmul double %68, %70
%72 = fptrunc double %71 to float
%73 = load float*, float** %6
%74 = getelementptr inbounds float, float* %73, i64 2
store float %72, float* %74
ret void
}

LLVM IR (-O2):
define void @lonlat2geovec(float %0, float %1, float* nocapture writeonly %2) {
%4 = fpext float %0 to double
%5 = fmul double %4, 0x400921FB54442D18
%6 = fdiv double %5, 1.800000e+02
%7 = fpext float %1 to double
%8 = fmul double %7, 0x400921FB54442D18
%9 = fdiv double %8, 1.800000e+02
%10 = tail call i32 @tan(double %9)
%11 = sitofp i32 %10 to double
%12 = fmul double %11, 0x3FEFE488A57B0C1F
%13 = fmul double %12, 0x3FEFE488A57B0C1F
%14 = fptosi double %13 to i32
%15 = tail call double @atan(i32 %14)
%16 = tail call double @cos(double %15)
%17 = tail call double @cos(double %15)
%18 = fmul double %16, %17
%19 = tail call double @llvm.fmuladd.f64(double %18, double 0xBF7B6B90F1FE94F0, double 1.000000e+00)
%20 = tail call double @sqrt(double %19)
%21 = fdiv double 0x40B8D4C097AA975C, %20
%22 = tail call double @cos(double %15)
%23 = fmul double %21, %22
%24 = tail call double @cos(double %6)
%25 = fmul double %23, %24
%26 = fptrunc double %25 to float
store float %26, float* %2
%27 = tail call double @cos(double %15)
%28 = fmul double %21, %27
%29 = tail call double @sin(double %6)
%30 = fmul double %28, %29
%31 = fptrunc double %30 to float
%32 = getelementptr inbounds float, float* %2, i64 1
store float %31, float* %32
%33 = tail call double @sin(double %15)
%34 = fmul double %21, %33
%35 = fptrunc double %34 to float
%36 = getelementptr inbounds float, float* %2, i64 2
store float %35, float* %36
ret void
}