#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 */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ geodist(double, double, double, double, double *);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  double lat1, lon1, lat2, lon2, distance;
  fprintf(stdout, "Computing distances between points on Earth\n");
  lat1 = 37.62;
  lon1 = 122.38;
  lat2 = 33.94;
  lon2 = 118.41;
  if (geodist(lat1, lon1, lat2, lon2, &distance) != 0)
    return 1;
  fprintf(stdout, "SFO: (%+07.2lf,%+07.2lf)\n", lat1, lon1);
  fprintf(stdout, "LAX: (%+07.2lf,%+07.2lf)\n", lat2, lon2);
  fprintf(stdout, "distance=%d\n", (int)distance);
  lat1 = 49.01;
  lon1 = -2.55;
  lat2 = -31.94;
  lon2 = -115.97;
  if (geodist(lat1, lon1, lat2, lon2, &distance) != 0)
    return 1;
  fprintf(stdout, "CDG: (%+07.2lf,%+07.2lf)\n", lat1, lon1);
  fprintf(stdout, "PER: (%+07.2lf,%+07.2lf)\n", lat2, lon2);
  fprintf(stdout, "distance=%d\n", (int)distance);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
lea    0xefa(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeae(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe84(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
lea    -0x38(%rbp),%rdi
call   1030 <geodist@plt>
cmp    $0x0,%rax
je     11b4 <main+0x94>
movl   $0x1,-0x4(%rbp)
jmp    12de <main+0x1be>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe9f(%rip),%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xe98(%rip),%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
cvttsd2si -0x38(%rbp),%edx
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movsd  0xe1e(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe09(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xdf4(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xddf(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
lea    -0x38(%rbp),%rdi
call   1030 <geodist@plt>
cmp    $0x0,%rax
je     1279 <main+0x159>
movl   $0x1,-0x4(%rbp)
jmp    12de <main+0x1be>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe1b(%rip),%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
lea    0xe14(%rip),%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
cvttsd2si -0x38(%rbp),%edx
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2eb5(%rip),%r14
mov    (%r14),%edi
lea    0xf0b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
movsd  0xebc(%rip),%xmm0
movsd  0xebc(%rip),%xmm1
movsd  0xebc(%rip),%xmm2
movsd  0xebc(%rip),%xmm3
mov    %rsp,%rdi
call   1030 <geodist@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    1251 <main+0x131>
mov    (%r14),%edi
lea    0xef1(%rip),%rsi
movsd  0xe7c(%rip),%xmm0
movsd  0xe7c(%rip),%xmm1
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xeea(%rip),%rsi
movsd  0xe6b(%rip),%xmm0
movsd  0xe6b(%rip),%xmm1
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    (%r14),%edi
cvttsd2si (%rsp),%edx
lea    0xede(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
movsd  0xe4e(%rip),%xmm0
movsd  0xe4e(%rip),%xmm1
movsd  0xe4e(%rip),%xmm2
movsd  0xe4e(%rip),%xmm3
mov    %rsp,%rdi
call   1030 <geodist@plt>
test   %rax,%rax
jne    1251 <main+0x131>
mov    (%r14),%edi
lea    0xead(%rip),%rsi
movsd  0xe17(%rip),%xmm0
movsd  0xe17(%rip),%xmm1
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xea6(%rip),%rsi
movsd  0xe06(%rip),%xmm0
movsd  0xe06(%rip),%xmm1
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    (%r14),%edi
cvttsd2si (%rsp),%edx
lea    0xe59(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [45 x i8] c"Computing distances between points on Earth\0A\00"
@.str.1 = [26 x i8] c"SFO: (%+07.2lf,%+07.2lf)\0A\00"
@.str.2 = [26 x i8] c"LAX: (%+07.2lf,%+07.2lf)\0A\00"
@.str.3 = [13 x i8] c"distance=%d\0A\00"
@.str.4 = [26 x i8] c"CDG: (%+07.2lf,%+07.2lf)\0A\00"
@.str.5 = [26 x i8] c"PER: (%+07.2lf,%+07.2lf)\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
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @stdout
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
store double 3.762000e+01, double* %6
store double 1.223800e+02, double* %7
store double 3.394000e+01, double* %8
store double 1.184100e+02, double* %9
%13 = load double, double* %6
%14 = load double, double* %7
%15 = load double, double* %8
%16 = load double, double* %9
%17 = call i64 @geodist(double %13, double %14, double %15, double %16, double* %10)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 1, i32* %3
br label %53
20: ; preds = %2
%21 = load i32, i32* @stdout
%22 = load double, double* %6
%23 = load double, double* %7
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), double %22, double %23)
%25 = load i32, i32* @stdout
%26 = load double, double* %8
%27 = load double, double* %9
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double %26, double %27)
%29 = load i32, i32* @stdout
%30 = load double, double* %10
%31 = fptosi double %30 to i32
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %31)
store double 4.901000e+01, double* %6
store double -2.550000e+00, double* %7
store double -3.194000e+01, double* %8
store double -1.159700e+02, double* %9
%33 = load double, double* %6
%34 = load double, double* %7
%35 = load double, double* %8
%36 = load double, double* %9
%37 = call i64 @geodist(double %33, double %34, double %35, double %36, double* %10)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %20
store i32 1, i32* %3
br label %53
40: ; preds = %20
%41 = load i32, i32* @stdout
%42 = load double, double* %6
%43 = load double, double* %7
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), double %42, double %43)
%45 = load i32, i32* @stdout
%46 = load double, double* %8
%47 = load double, double* %9
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), double %46, double %47)
%49 = load i32, i32* @stdout
%50 = load double, double* %10
%51 = fptosi double %50 to i32
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %51)
store i32 0, i32* %3
br label %53
53: ; preds = %40, %39, %19
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [45 x i8] c"Computing distances between points on Earth\0A\00"
@.str.1 = [26 x i8] c"SFO: (%+07.2lf,%+07.2lf)\0A\00"
@.str.2 = [26 x i8] c"LAX: (%+07.2lf,%+07.2lf)\0A\00"
@.str.3 = [13 x i8] c"distance=%d\0A\00"
@.str.4 = [26 x i8] c"CDG: (%+07.2lf,%+07.2lf)\0A\00"
@.str.5 = [26 x i8] c"PER: (%+07.2lf,%+07.2lf)\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = load i32, i32* @stdout
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%7 = call i64 @geodist(double 3.762000e+01, double 1.223800e+02, double 3.394000e+01, double 1.184100e+02, double* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %29
9: ; preds = %2
%10 = load i32, i32* @stdout
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), double 3.762000e+01, double 1.223800e+02)
%12 = load i32, i32* @stdout
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), double 3.394000e+01, double 1.184100e+02)
%14 = load i32, i32* @stdout
%15 = load double, double* %3
%16 = fptosi double %15 to i32
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = call i64 @geodist(double 4.901000e+01, double -2.550000e+00, double -3.194000e+01, double -1.159700e+02, double* %3)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %9
%21 = load i32, i32* @stdout
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), double 4.901000e+01, double -2.550000e+00)
%23 = load i32, i32* @stdout
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), double -3.194000e+01, double -1.159700e+02)
%25 = load i32, i32* @stdout
%26 = load double, double* %3
%27 = fptosi double %26 to i32
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %9, %2, %20
%30 = phi i32 [ 0, %20 ], [ 1, %2 ], [ 1, %9 ]
ret i32 %30
}