#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 GCAzimuth(double, double, double, double);
double GCDistance(double, double, double, double);
double atof(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ printf(char *, double, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc < 5) {
    fprintf(stderr, "Usage: %s %s\n", "geo_test", "lat1 lon1 lat2 lon2");
    return (-1);
  }
  double from_latitude = atof(argv[1]);
  double from_longitude = atof(argv[2]);
  double to_latitude = atof(argv[3]);
  double to_longitude = atof(argv[4]);
  printf("Lat: %f  Lon: %f -> ", from_latitude, from_longitude);
  printf("Lat: %f  Lon: %f\n", to_latitude, to_longitude);
  printf("\tdist: %f\n",
         GCDistance(from_latitude, from_longitude, to_latitude, to_longitude));
  printf("\tazimuth: %f\n",
         GCAzimuth(from_latitude, from_longitude, to_latitude, to_longitude));
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    119f <main+0x4f>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
lea    0xe87(%rip),%rdx
lea    0xe89(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    126c <main+0x11c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe33(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xe30(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
call   1030 <GCDistance@plt>
lea    0xe1b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
call   1070 <GCAzimuth@plt>
lea    0xdff(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
cmp    $0x4,%edi
jg     1187 <main+0x37>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
lea    0xe9d(%rip),%rdx
lea    0xe9f(%rip),%rcx
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    124e <main+0xfe>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x18(%rsp)
mov    0x10(%rbx),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x18(%rbx),%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x20(%rbx),%rdi
call   1040 <atof@plt>
movsd  %xmm0,(%rsp)
lea    0xe5f(%rip),%rdi
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xe5a(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm3
call   1030 <GCDistance@plt>
lea    0xe37(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm3
call   1070 <GCAzimuth@plt>
lea    0xe18(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [14 x i8] c"Usage: %s %s\0A\00"
@.str.1 = [9 x i8] c"geo_test\00"
@.str.2 = [20 x i8] c"lat1 lon1 lat2 lon2\00"
@.str.3 = [21 x i8] c"Lat: %f Lon: %f -> \00"
@.str.4 = [18 x i8] c"Lat: %f Lon: %f\0A\00"
@.str.5 = [11 x i8] c"\09dist: %f\0A\00"
@.str.6 = [14 x i8] c"\09azimuth: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 5
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %50
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call double @atof(i8* %18)
store double %19, double* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call double @atof(i8* %22)
store double %23, double* %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
%27 = call double @atof(i8* %26)
store double %27, double* %8
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 4
%30 = load i8*, i8** %29
%31 = call double @atof(i8* %30)
store double %31, double* %9
%32 = load double, double* %6
%33 = load double, double* %7
%34 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %32, double %33)
%35 = load double, double* %8
%36 = load double, double* %9
%37 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %35, double %36)
%38 = load double, double* %6
%39 = load double, double* %7
%40 = load double, double* %8
%41 = load double, double* %9
%42 = call double @GCDistance(double %38, double %39, double %40, double %41)
%43 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), double %42)
%44 = load double, double* %6
%45 = load double, double* %7
%46 = load double, double* %8
%47 = load double, double* %9
%48 = call double @GCAzimuth(double %44, double %45, double %46, double %47)
%49 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %48)
store i32 0, i32* %3
br label %50
50: ; preds = %15, %12
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [14 x i8] c"Usage: %s %s\0A\00"
@.str.1 = [9 x i8] c"geo_test\00"
@.str.2 = [20 x i8] c"lat1 lon1 lat2 lon2\00"
@.str.3 = [21 x i8] c"Lat: %f Lon: %f -> \00"
@.str.4 = [18 x i8] c"Lat: %f Lon: %f\0A\00"
@.str.5 = [11 x i8] c"\09dist: %f\0A\00"
@.str.6 = [14 x i8] c"\09azimuth: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 5
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %26
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call double @atof(i8* %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call double @atof(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call double @atof(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 4
%18 = load i8*, i8** %17
%19 = tail call double @atof(i8* %18)
%20 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %10, double %13)
%21 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), double %16, double %19)
%22 = tail call double @GCDistance(double %10, double %13, double %16, double %19)
%23 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), double %22)
%24 = tail call double @GCAzimuth(double %10, double %13, double %16, double %19)
%25 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), double %24)
br label %26
26: ; preds = %7, %4
%27 = phi i32 [ -1, %4 ], [ 0, %7 ]
ret i32 %27
}