#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 cos(double const);
int sin(double const);
int sqrt(int);
void wgsllh2ecef(const double llh[3], double ecef[3]) {
  double d = (sqrt(2 * (1 / 298.257223563) -
                   (1 / 298.257223563) * (1 / 298.257223563))) *
             sin(llh[0]);
  double N = 6378137.0 / sqrt(1. - d * d);
  ecef[0] = (N + llh[2]) * cos(llh[0]) * cos(llh[1]);
  ecef[1] = (N + llh[2]) * cos(llh[0]) * sin(llh[1]);
  ecef[2] = ((1 - (sqrt(2 * (1 / 298.257223563) -
                        (1 / 298.257223563) * (1 / 298.257223563))) *
                      (sqrt(2 * (1 / 298.257223563) -
                            (1 / 298.257223563) * (1 / 298.257223563)))) *
                 N +
             llh[2]) *
            sin(llh[0]);
}


x86 assembly (clang, -O0):
<wgsllh2ecef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %edi,%edi
call   1050 <sqrt@plt>
mov    %eax,-0x54(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe73(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe52(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
movsd  -0x38(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
xor    %edi,%edi
call   1050 <sqrt@plt>
mov    %eax,-0x2c(%rbp)
xor    %edi,%edi
call   1050 <sqrt@plt>
mov    -0x2c(%rbp),%ecx
imul   %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  -0x20(%rbp),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wgsllh2ecef>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
call   1050 <sqrt@plt>
mov    %eax,%ebp
movsd  (%rbx),%xmm0
call   1030 <sin@plt>
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm0,%xmm0
movsd  0xe9a(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1050 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe86(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rbx),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rbx),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r14)
movsd  0x10(%rbx),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rbx),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%r14)
xor    %edi,%edi
call   1050 <sqrt@plt>
mov    %eax,%ebp
xor    %edi,%edi
call   1050 <sqrt@plt>
imul   %ebp,%eax
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx),%xmm0
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @wgsllh2ecef(double* nocapture %0, double* nocapture writeonly %1) {
%3 = tail call i32 @sqrt(i32 0)
%4 = load double, double* %0
%5 = tail call i32 @sin(double %4)
%6 = mul nsw i32 %5, %3
%7 = sitofp i32 %6 to double
%8 = fneg double %7
%9 = tail call double @llvm.fmuladd.f64(double %8, double %7, double 1.000000e+00)
%10 = fptosi double %9 to i32
%11 = tail call i32 @sqrt(i32 %10)
%12 = sitofp i32 %11 to double
%13 = fdiv double 0x415854A640000000, %12
%14 = getelementptr inbounds double, double* %0, i64 2
%15 = load double, double* %14
%16 = fadd double %15, %13
%17 = load double, double* %0
%18 = tail call double @cos(double %17)
%19 = fmul double %16, %18
%20 = getelementptr inbounds double, double* %0, i64 1
%21 = load double, double* %20
%22 = tail call double @cos(double %21)
%23 = fmul double %19, %22
store double %23, double* %1
%24 = load double, double* %14
%25 = fadd double %13, %24
%26 = load double, double* %0
%27 = tail call double @cos(double %26)
%28 = fmul double %25, %27
%29 = load double, double* %20
%30 = tail call i32 @sin(double %29)
%31 = sitofp i32 %30 to double
%32 = fmul double %28, %31
%33 = getelementptr inbounds double, double* %1, i64 1
store double %32, double* %33
%34 = tail call i32 @sqrt(i32 0)
%35 = tail call i32 @sqrt(i32 0)
%36 = mul nsw i32 %35, %34
%37 = sub nsw i32 1, %36
%38 = sitofp i32 %37 to double
%39 = load double, double* %14
%40 = tail call double @llvm.fmuladd.f64(double %38, double %13, double %39)
%41 = load double, double* %0
%42 = tail call i32 @sin(double %41)
%43 = sitofp i32 %42 to double
%44 = fmul double %40, %43
%45 = getelementptr inbounds double, double* %1, i64 2
store double %44, double* %45
ret void
}