#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 atan(double);
int /*<<< orphan*/ cos(double);
double fabs(double);
double pow(int /*<<< orphan*/, int);
int /*<<< orphan*/ sin(double);
double sqrt(double);
double tan(double);
void geodetic2geocentric(double phi, double h, double *latrad, double *r) {
  double cosphi2, sinphi2, A2, B2, c;
  A2 = 6378.1370 * 6378.1370;
  B2 = 6356.752314 * 6356.752314;
  cosphi2 = pow(cos(phi), 2);
  sinphi2 = pow(sin(phi), 2);
  c = h * sqrt(A2 * cosphi2 + B2 * sinphi2);
  *r = sqrt(h * h + 2 * c +
            (A2 * A2 * cosphi2 + B2 * B2 * sinphi2) /
                (A2 * cosphi2 + B2 * sinphi2));
  if (fabs(phi - M_PI / 2.0) < 0.00001)
    *latrad = phi;
  else {
    *latrad = atan((c + B2) / (c + A2) * tan(phi));
  }
}


x86 assembly (clang, -O0):
<geodetic2geocentric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  0xe96(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe81(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1060 <cos@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  0xdf0(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm3
movsd  -0x40(%rbp),%xmm2
mulsd  -0x40(%rbp),%xmm2
mulsd  -0x30(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm3
mulsd  -0x30(%rbp),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x8(%rbp),%xmm1
mov    0x2d60(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xd74(%rip),%xmm2
divsd  %xmm2,%xmm0
subsd  %xmm0,%xmm1
movaps 0xd7d(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd51(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    12cb <geodetic2geocentric+0x16b>
movsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    130b <geodetic2geocentric+0x1ab>
movsd  -0x48(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <tan@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <atan@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geodetic2geocentric>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  %xmm1,0x20(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1060 <cos@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1070 <pow@plt>
movapd %xmm0,%xmm2
movsd  0xe4e(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0xe4a(%rip),%xmm4
mulsd  (%rsp),%xmm4
addsd  %xmm0,%xmm4
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm4
jb     11d7 <geodetic2geocentric+0x77>
sqrtsd %xmm4,%xmm3
jmp    1200 <geodetic2geocentric+0xa0>
movapd %xmm4,%xmm0
movsd  %xmm2,0x18(%rsp)
movsd  %xmm4,0x10(%rsp)
call   1080 <sqrt@plt>
xorpd  %xmm5,%xmm5
movsd  0x10(%rsp),%xmm4
movsd  0x18(%rsp),%xmm2
movapd %xmm0,%xmm3
movsd  0x20(%rsp),%xmm1
mulsd  %xmm1,%xmm3
movapd %xmm3,%xmm0
addsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm1
mulsd  0xdf2(%rip),%xmm2
addsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
mulsd  0xde9(%rip),%xmm0
addsd  %xmm2,%xmm0
divsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm5,%xmm0
jb     1247 <geodetic2geocentric+0xe7>
sqrtsd %xmm0,%xmm0
jmp    1256 <geodetic2geocentric+0xf6>
movsd  %xmm3,(%rsp)
call   1080 <sqrt@plt>
movsd  (%rsp),%xmm3
movsd  0x8(%rsp),%xmm2
movsd  %xmm0,(%rbx)
mov    0x2d81(%rip),%rax
movsd  (%rax),%xmm0
mulsd  0xdad(%rip),%xmm0
addsd  %xmm2,%xmm0
andpd  0xdb1(%rip),%xmm0
movsd  0xda1(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     12c1 <geodetic2geocentric+0x161>
movsd  0xd6b(%rip),%xmm0
addsd  %xmm3,%xmm0
addsd  0xd67(%rip),%xmm3
divsd  %xmm3,%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm2,%xmm0
call   1050 <tan@plt>
mulsd  (%rsp),%xmm0
call   1040 <atan@plt>
movapd %xmm0,%xmm2
movsd  %xmm2,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define void @geodetic2geocentric(double %0, double %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double %0, double* %5
store double %1, double* %6
store double* %2, double** %7
store double* %3, double** %8
store double 0x418365E5BCB9E518, double* %11
store double 0x418344A75FDA33EE, double* %12
%14 = load double, double* %5
%15 = call i32 @cos(double %14)
%16 = call double @pow(i32 %15, i32 2)
store double %16, double* %9
%17 = load double, double* %5
%18 = call i32 @sin(double %17)
%19 = call double @pow(i32 %18, i32 2)
store double %19, double* %10
%20 = load double, double* %6
%21 = load double, double* %11
%22 = load double, double* %9
%23 = load double, double* %12
%24 = load double, double* %10
%25 = fmul double %23, %24
%26 = call double @llvm.fmuladd.f64(double %21, double %22, double %25)
%27 = call double @sqrt(double %26)
%28 = fmul double %20, %27
store double %28, double* %13
%29 = load double, double* %6
%30 = load double, double* %6
%31 = load double, double* %13
%32 = fmul double 2.000000e+00, %31
%33 = call double @llvm.fmuladd.f64(double %29, double %30, double %32)
%34 = load double, double* %11
%35 = load double, double* %11
%36 = fmul double %34, %35
%37 = load double, double* %9
%38 = load double, double* %12
%39 = load double, double* %12
%40 = fmul double %38, %39
%41 = load double, double* %10
%42 = fmul double %40, %41
%43 = call double @llvm.fmuladd.f64(double %36, double %37, double %42)
%44 = load double, double* %11
%45 = load double, double* %9
%46 = load double, double* %12
%47 = load double, double* %10
%48 = fmul double %46, %47
%49 = call double @llvm.fmuladd.f64(double %44, double %45, double %48)
%50 = fdiv double %43, %49
%51 = fadd double %33, %50
%52 = call double @sqrt(double %51)
%53 = load double*, double** %8
store double %52, double* %53
%54 = load double, double* %5
%55 = load double, double* @M_PI
%56 = fdiv double %55, 2.000000e+00
%57 = fsub double %54, %56
%58 = call double @llvm.fabs.f64(double %57)
%59 = fcmp olt double %58, 1.000000e-05
br i1 %59, label %60, label %63
60: ; preds = %4
%61 = load double, double* %5
%62 = load double*, double** %7
store double %61, double* %62
br label %76
63: ; preds = %4
%64 = load double, double* %13
%65 = load double, double* %12
%66 = fadd double %64, %65
%67 = load double, double* %13
%68 = load double, double* %11
%69 = fadd double %67, %68
%70 = fdiv double %66, %69
%71 = load double, double* %5
%72 = call double @tan(double %71)
%73 = fmul double %70, %72
%74 = call double @atan(double %73)
%75 = load double*, double** %7
store double %74, double* %75
br label %76
76: ; preds = %63, %60
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define void @geodetic2geocentric(double %0, double %1, double* nocapture writeonly %2, double* nocapture writeonly %3) {
%5 = tail call i32 @cos(double %0)
%6 = tail call double @pow(i32 %5, i32 2)
%7 = tail call i32 @sin(double %0)
%8 = tail call double @pow(i32 %7, i32 2)
%9 = fmul double %8, 0x418344A75FDA33EE
%10 = tail call double @llvm.fmuladd.f64(double %6, double 0x418365E5BCB9E518, double %9)
%11 = tail call double @sqrt(double %10)
%12 = fmul double %11, %1
%13 = fmul double %12, 2.000000e+00
%14 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %13)
%15 = fmul double %8, 0x43173434192BDD38
%16 = tail call double @llvm.fmuladd.f64(double %6, double 0x4317848A918ADE01, double %15)
%17 = fdiv double %16, %10
%18 = fadd double %17, %14
%19 = tail call double @sqrt(double %18)
store double %19, double* %3
%20 = load double, double* @M_PI
%21 = fmul double %20, 5.000000e-01
%22 = fsub double %0, %21
%23 = tail call double @llvm.fabs.f64(double %22)
%24 = fcmp olt double %23, 1.000000e-05
br i1 %24, label %32, label %25
25: ; preds = %4
%26 = fadd double %12, 0x418344A75FDA33EE
%27 = fadd double %12, 0x418365E5BCB9E518
%28 = fdiv double %26, %27
%29 = tail call double @tan(double %0)
%30 = fmul double %28, %29
%31 = tail call double @atan(double %30)
br label %32
32: ; preds = %4, %25
%33 = phi double [ %31, %25 ], [ %0, %4 ]
store double %33, double* %2
ret void
}