latlon2kmX(arg, latkm, lonkm, rc, g2) float *arg, *latkm, *lonkm, *rc, *g2;
{
  float cosA, sinA, g2s2, den;
  cosA = cos((*arg));
  sinA = sin((*arg));
  g2s2 = (*g2) * sinA * sinA;
  den = sqrt(((float)(1.0)) / (((float)(1.0)) + g2s2));
  *lonkm = (*rc) * cosA * den;
  *latkm = (*rc) * (sqrt(((float)(1.0)) + g2s2 * (((float)(2.0)) + (*g2)))) *
           den * den * den;
}


x86 assembly (clang, -O0):
<latlon2kmX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <cos@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <sin@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x30(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x38(%rbp),%xmm0
mulss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  0xe61(%rip),%xmm1
addss  -0x3c(%rbp),%xmm1
movss  0xe54(%rip),%xmm0
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <sqrt@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x34(%rbp),%xmm0
mulss  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movss  -0x3c(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movss  0xe06(%rip),%xmm1
addss  (%rax),%xmm1
mulss  %xmm1,%xmm0
movss  0xdf2(%rip),%xmm1
addss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x40(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movss  -0x40(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movss  -0x40(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<latlon2kmX>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r15
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rbx
movss  (%rdi),%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <cos@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
movss  (%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <sin@plt>
cvtsd2ss %xmm0,%xmm0
movss  (%r15),%xmm3
mulss  %xmm0,%xmm3
mulss  %xmm0,%xmm3
movss  0xe67(%rip),%xmm0
movaps %xmm3,%xmm1
addss  %xmm0,%xmm1
divss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11b2 <latlon2kmX+0x72>
sqrtss %xmm0,%xmm2
jmp    11c6 <latlon2kmX+0x86>
movss  %xmm3,0x8(%rsp)
call   1040 <sqrtf@plt>
movss  0x8(%rsp),%xmm3
movaps %xmm0,%xmm2
movss  0x4(%rsp),%xmm0
mulss  0x0(%r13),%xmm0
mulss  %xmm2,%xmm0
movss  %xmm0,(%r12)
movss  0x0(%r13),%xmm0
movss  (%r15),%xmm1
addss  0xe15(%rip),%xmm1
cvtss2sd %xmm0,%xmm4
mulss  %xmm1,%xmm3
addss  0xe01(%rip),%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1215 <latlon2kmX+0xd5>
sqrtsd %xmm0,%xmm0
jmp    1232 <latlon2kmX+0xf2>
movss  %xmm2,0x4(%rsp)
movsd  %xmm4,0x8(%rsp)
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm4
movss  0x4(%rsp),%xmm2
mulsd  %xmm4,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @latlon2kmX(float* %0, float* %1, float* %2, float* %3, float* %4) {
%6 = alloca i32
%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
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
%16 = load float*, float** %7
%17 = load float, float* %16
%18 = fpext float %17 to double
%19 = call double @cos(double %18)
%20 = fptrunc double %19 to float
store float %20, float* %12
%21 = load float*, float** %7
%22 = load float, float* %21
%23 = fpext float %22 to double
%24 = call double @sin(double %23)
%25 = fptrunc double %24 to float
store float %25, float* %13
%26 = load float*, float** %11
%27 = load float, float* %26
%28 = load float, float* %13
%29 = fmul float %27, %28
%30 = load float, float* %13
%31 = fmul float %29, %30
store float %31, float* %14
%32 = load float, float* %14
%33 = fadd float 1.000000e+00, %32
%34 = fdiv float 1.000000e+00, %33
%35 = fpext float %34 to double
%36 = call double @sqrt(double %35)
%37 = fptrunc double %36 to float
store float %37, float* %15
%38 = load float*, float** %10
%39 = load float, float* %38
%40 = load float, float* %12
%41 = fmul float %39, %40
%42 = load float, float* %15
%43 = fmul float %41, %42
%44 = load float*, float** %9
store float %43, float* %44
%45 = load float*, float** %10
%46 = load float, float* %45
%47 = fpext float %46 to double
%48 = load float, float* %14
%49 = load float*, float** %11
%50 = load float, float* %49
%51 = fadd float 2.000000e+00, %50
%52 = call float @llvm.fmuladd.f32(float %48, float %51, float 1.000000e+00)
%53 = fpext float %52 to double
%54 = call double @sqrt(double %53)
%55 = fmul double %47, %54
%56 = load float, float* %15
%57 = fpext float %56 to double
%58 = fmul double %55, %57
%59 = load float, float* %15
%60 = fpext float %59 to double
%61 = fmul double %58, %60
%62 = load float, float* %15
%63 = fpext float %62 to double
%64 = fmul double %61, %63
%65 = fptrunc double %64 to float
%66 = load float*, float** %8
store float %65, float* %66
%67 = load i32, i32* %6
ret i32 %67
}

LLVM IR (-O2):
define i32 @latlon2kmX(float* nocapture %0, float* nocapture writeonly %1, float* nocapture writeonly %2, float* nocapture %3, float* nocapture %4) {
%6 = load float, float* %0
%7 = fpext float %6 to double
%8 = tail call double @cos(double %7)
%9 = fptrunc double %8 to float
%10 = load float, float* %0
%11 = fpext float %10 to double
%12 = tail call double @sin(double %11)
%13 = fptrunc double %12 to float
%14 = load float, float* %4
%15 = fmul float %14, %13
%16 = fmul float %15, %13
%17 = fadd float %16, 1.000000e+00
%18 = fdiv float 1.000000e+00, %17
%19 = tail call float @sqrtf(float %18)
%20 = load float, float* %3
%21 = fmul float %20, %9
%22 = fmul float %19, %21
store float %22, float* %2
%23 = load float, float* %3
%24 = fpext float %23 to double
%25 = load float, float* %4
%26 = fadd float %25, 2.000000e+00
%27 = tail call float @llvm.fmuladd.f32(float %16, float %26, float 1.000000e+00)
%28 = fpext float %27 to double
%29 = tail call double @sqrt(double %28)
%30 = fmul double %29, %24
%31 = fpext float %19 to double
%32 = fmul double %30, %31
%33 = fmul double %32, %31
%34 = fmul double %33, %31
%35 = fptrunc double %34 to float
store float %35, float* %1
ret i32 undef
}