#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 norm(double const *, int);
extern double geodist(const double *rs, const double *rr, double *e) {
  double r;
  int i;
  if (norm(rs, 3) < 6378137.0) {
    return -1.0;
  }
  for (i = 0; i < 3; ++i) {
    e[i] = rs[i] - rr[i];
  }
  r = norm(e, 3);
  for (i = 0; i < 3; ++i) {
    e[i] /= r;
  }
  return r + 7.2921151467E-5 * (rs[0] * rr[1] - rs[1] * rr[0]) / 299792458.0;
}


x86 assembly (clang, -O0):
<geodist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1030 <norm@plt>
movaps %xmm0,%xmm1
movsd  0xec3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1159 <geodist+0x49>
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1253 <geodist+0x143>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    119f <geodist+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1160 <geodist+0x50>
mov    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1030 <norm@plt>
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    11ec <geodist+0xdc>
movsd  -0x28(%rbp),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b9 <geodist+0xa9>
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm3
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  0xdd6(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xdc2(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geodist>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x3,%esi
call   1030 <norm@plt>
movsd  0xed8(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1143 <geodist+0x33>
movsd  0xec2(%rip),%xmm0
jmp    11d4 <geodist+0xc4>
movsd  (%r15),%xmm0
subsd  (%r14),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x8(%r15),%xmm0
subsd  0x8(%r14),%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x10(%r15),%xmm0
subsd  0x10(%r14),%xmm0
movsd  %xmm0,0x10(%rbx)
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <norm@plt>
movapd %xmm0,%xmm1
movupd (%rbx),%xmm0
movapd %xmm1,%xmm2
unpcklpd %xmm1,%xmm2
divpd  %xmm2,%xmm0
movupd %xmm0,(%rbx)
movsd  0x10(%rbx),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rbx)
movsd  (%r15),%xmm0
movsd  (%r14),%xmm2
mulsd  0x8(%r15),%xmm2
mulsd  0x8(%r14),%xmm0
subsd  %xmm2,%xmm0
mulsd  0xe48(%rip),%xmm0
divsd  0xe48(%rip),%xmm0
addsd  %xmm1,%xmm0
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define double @geodist(double* %0, double* nocapture %1, double* %2) {
%4 = tail call double @norm(double* %0, i32 3)
%5 = fcmp olt double %4, 0x415854A640000000
br i1 %5, label %41, label %6
6: ; preds = %3
%7 = load double, double* %0
%8 = load double, double* %1
%9 = fsub double %7, %8
store double %9, double* %2
%10 = getelementptr inbounds double, double* %0, i64 1
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %1, i64 1
%13 = load double, double* %12
%14 = fsub double %11, %13
%15 = getelementptr inbounds double, double* %2, i64 1
store double %14, double* %15
%16 = getelementptr inbounds double, double* %0, i64 2
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %1, i64 2
%19 = load double, double* %18
%20 = fsub double %17, %19
%21 = getelementptr inbounds double, double* %2, i64 2
store double %20, double* %21
%22 = tail call double @norm(double* %2, i32 3)
%23 = bitcast double* %2 to <2 x double>*
%24 = load <2 x double>, <2 x double>* %23
%25 = insertelement <2 x double> poison, double %22, i64 0
%26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> zeroinitializer
%27 = fdiv <2 x double> %24, %26
%28 = bitcast double* %2 to <2 x double>*
store <2 x double> %27, <2 x double>* %28
%29 = load double, double* %21
%30 = fdiv double %29, %22
store double %30, double* %21
%31 = load double, double* %0
%32 = load double, double* %12
%33 = load double, double* %10
%34 = load double, double* %1
%35 = fneg double %33
%36 = fmul double %34, %35
%37 = tail call double @llvm.fmuladd.f64(double %31, double %32, double %36)
%38 = fmul double %37, 0x3F131DA7D7CB8D5B
%39 = fdiv double %38, 0x41B1DE784A000000
%40 = fadd double %22, %39
br label %41
41: ; preds = %3, %6
%42 = phi double [ %40, %6 ], [ -1.000000e+00, %3 ]
ret double %42
}