#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*/ get_longitude_latitude(char *, double *, double *, char *);
int /*<<< orphan*/ sm_err_reset(char *);
int /*<<< orphan*/ sm_n_putfield(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, double);
populate_zip_distance(char *this_zip_code, char *that_zip_code) {
  double compute_distance();
  double this_longitude, this_latitude;
  double that_longitude, that_latitude;
  char buffer[50];
  if (!get_longitude_latitude(this_zip_code, &this_longitude, &this_latitude,
                              "..\\lib\\search_z.rnd")) {
    sm_err_reset("Cannot get_longitude_latitude()");
    return 0;
  }
  if (!get_longitude_latitude(that_zip_code, &that_longitude, &that_latitude,
                              "..\\lib\\search_z.rnd")) {
    sm_err_reset("Cannot get_longitude_latitude()");
    return 0;
  }
  sprintf(buffer, "%.0lf",
          compute_distance(this_longitude, this_latitude, that_longitude,
                           that_latitude));
  sm_n_putfield("zip_distance", buffer);
  return 0;
}


x86 assembly (clang, -O0):
<populate_zip_distance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    0xe8a(%rip),%rcx
call   1070 <get_longitude_latitude@plt>
cmp    $0x0,%eax
jne    119c <populate_zip_distance+0x4c>
lea    0xe89(%rip),%rdi
call   1040 <sm_err_reset@plt>
movl   $0x0,-0x4(%rbp)
jmp    121f <populate_zip_distance+0xcf>
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    0xe51(%rip),%rcx
call   1070 <get_longitude_latitude@plt>
cmp    $0x0,%eax
jne    11d5 <populate_zip_distance+0x85>
lea    0xe50(%rip),%rdi
call   1040 <sm_err_reset@plt>
movl   $0x0,-0x4(%rbp)
jmp    121f <populate_zip_distance+0xcf>
lea    -0x70(%rbp),%rax
mov    %rax,-0x78(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
mov    $0x4,%al
call   1050 <compute_distance@plt>
mov    -0x78(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe27(%rip),%rdi
call   1030 <sm_n_putfield@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<populate_zip_distance>:
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
lea    0xea1(%rip),%rcx
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1070 <get_longitude_latitude@plt>
test   %eax,%eax
je     11d0 <populate_zip_distance+0x80>
lea    0xe87(%rip),%rcx
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1070 <get_longitude_latitude@plt>
test   %eax,%eax
je     11d0 <populate_zip_distance+0x80>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm3
mov    $0x4,%al
call   1050 <compute_distance@plt>
lea    0xe82(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0xe74(%rip),%rdi
mov    %rbx,%rsi
call   1030 <sm_n_putfield@plt>
jmp    11dc <populate_zip_distance+0x8c>
lea    0xe3d(%rip),%rdi
call   1040 <sm_err_reset@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"..\\lib\\search_z.rnd\00"
@.str.1 = [32 x i8] c"Cannot get_longitude_latitude()\00"
@.str.2 = [6 x i8] c"%.0lf\00"
@.str.3 = [13 x i8] c"zip_distance\00"
define i32 @populate_zip_distance(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca [50 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = load i8*, i8** %4
%12 = call i32 @get_longitude_latitude(i8* %11, double* %6, double* %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = call i32 @sm_err_reset(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %32
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = call i32 @get_longitude_latitude(i8* %17, double* %8, double* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = call i32 @sm_err_reset(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %32
22: ; preds = %16
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%24 = load double, double* %6
%25 = load double, double* %7
%26 = load double, double* %8
%27 = load double, double* %9
%28 = call double (double, double, double, double, ...) bitcast (double (...)* @compute_distance to double (double, double, double, double, ...)*)(double %24, double %25, double %26, double %27)
%29 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %28)
%30 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%31 = call i32 @sm_n_putfield(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %30)
store i32 0, i32* %3
br label %32
32: ; preds = %22, %20, %14
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [20 x i8] c"..\\lib\\search_z.rnd\00"
@.str.1 = [32 x i8] c"Cannot get_longitude_latitude()\00"
@.str.2 = [6 x i8] c"%.0lf\00"
@.str.3 = [13 x i8] c"zip_distance\00"
define i32 @populate_zip_distance(i8* %0, i8* %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca [50 x i8]
%8 = bitcast double* %3 to i8*
%9 = bitcast double* %4 to i8*
%10 = bitcast double* %5 to i8*
%11 = bitcast double* %6 to i8*
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
%13 = call i32 @get_longitude_latitude(i8* %0, double* %3, double* %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @sm_err_reset(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %30
17: ; preds = %2
%18 = call i32 @get_longitude_latitude(i8* %1, double* %5, double* %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @sm_err_reset(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %30
22: ; preds = %17
%23 = load double, double* %3
%24 = load double, double* %4
%25 = load double, double* %5
%26 = load double, double* %6
%27 = call double (double, double, double, double, ...) bitcast (double (...)* @compute_distance to double (double, double, double, double, ...)*)(double %23, double %24, double %25, double %26)
%28 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = call i32 @sm_n_putfield(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %12)
br label %30
30: ; preds = %22, %20, %15
ret i32 0
}