void 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    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <cos@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
call   1030 <sin@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x30(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  0xe61(%rip),%xmm1
addss  -0x34(%rbp),%xmm1
movss  0xe54(%rip),%xmm0
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
call   1050 <sqrt@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
mulss  -0x2c(%rbp),%xmm0
mulss  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movss  -0x34(%rbp),%xmm0
mov    -0x28(%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  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x38(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movss  -0x38(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movss  -0x38(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%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 void @latlon2kmX(float* %0, float* %1, float* %2, float* %3, float* %4) {
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
store float* %0, float** %6
store float* %1, float** %7
store float* %2, float** %8
store float* %3, float** %9
store float* %4, float** %10
%15 = load float*, float** %6
%16 = load float, float* %15
%17 = fpext float %16 to double
%18 = call double @cos(double %17)
%19 = fptrunc double %18 to float
store float %19, float* %11
%20 = load float*, float** %6
%21 = load float, float* %20
%22 = fpext float %21 to double
%23 = call double @sin(double %22)
%24 = fptrunc double %23 to float
store float %24, float* %12
%25 = load float*, float** %10
%26 = load float, float* %25
%27 = load float, float* %12
%28 = fmul float %26, %27
%29 = load float, float* %12
%30 = fmul float %28, %29
store float %30, float* %13
%31 = load float, float* %13
%32 = fadd float 1.000000e+00, %31
%33 = fdiv float 1.000000e+00, %32
%34 = fpext float %33 to double
%35 = call double @sqrt(double %34)
%36 = fptrunc double %35 to float
store float %36, float* %14
%37 = load float*, float** %9
%38 = load float, float* %37
%39 = load float, float* %11
%40 = fmul float %38, %39
%41 = load float, float* %14
%42 = fmul float %40, %41
%43 = load float*, float** %8
store float %42, float* %43
%44 = load float*, float** %9
%45 = load float, float* %44
%46 = fpext float %45 to double
%47 = load float, float* %13
%48 = load float*, float** %10
%49 = load float, float* %48
%50 = fadd float 2.000000e+00, %49
%51 = call float @llvm.fmuladd.f32(float %47, float %50, float 1.000000e+00)
%52 = fpext float %51 to double
%53 = call double @sqrt(double %52)
%54 = fmul double %46, %53
%55 = load float, float* %14
%56 = fpext float %55 to double
%57 = fmul double %54, %56
%58 = load float, float* %14
%59 = fpext float %58 to double
%60 = fmul double %57, %59
%61 = load float, float* %14
%62 = fpext float %61 to double
%63 = fmul double %60, %62
%64 = fptrunc double %63 to float
%65 = load float*, float** %7
store float %64, float* %65
ret void
}

LLVM IR (-O2):
define void @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 void
}