#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 fabs(double);
int earth_radius2datum(double re_major, double re_minor) {
  static double major[20] = {6378206.4, 6378249.145, 6377397.155,  6378157.5,
                             6378388.0, 6378135.0,   6377276.3452, 6378145.0,
                             6378137.0, 6377563.396, 6377304.063,  6377340.189,
                             6378137.0, 6378155.0,   6378160.0,    6378245.0,
                             6378270.0, 6378166.0,   6378150.0,    6370997.0};
  static double minor[20] = {
      6356583.8,      6356514.86955,  6356078.96284,  6356772.2,
      6356911.94613,  6356750.519915, 6356075.4133,   6356759.769356,
      6356752.31414,  6356256.91,     6356103.039,    6356034.448,
      6356752.314245, 6356773.3205,   6356774.719,    6356863.0188,
      6356794.343479, 6356784.283666, 6356768.337303, 6370997.0};
  int major_index = 0, minor_index = 0;
  for (major_index = 0; major_index < 20; major_index++) {
    if ((fabs(major[major_index] - re_major) < 0.1 ? 1 : 0)) {
      for (minor_index = 0; minor_index < 20; minor_index++) {
        if ((fabs(minor[minor_index] - re_minor) < 0.1 ? 1 : 0)) {
          if ((fabs(major_index - minor_index) < 0.1 ? 1 : 0)) {
            return major_index;
          }
        }
      }
    }
  }
  if ((fabs(major[minor_index] - re_major) < 0.1 ? 1 : 0)) {
    return minor_index;
  }
  return (-1);
}


x86 assembly (clang, -O0):
<earth_radius2datum>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    125e <earth_radius2datum+0x15e>
movslq -0x1c(%rbp),%rcx
lea    0x2ef8(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
subsd  -0x10(%rbp),%xmm1
movaps 0xec7(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xeab(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    116e <earth_radius2datum+0x6e>
mov    $0x1,%al
test   $0x1,%al
jne    117d <earth_radius2datum+0x7d>
jmp    124b <earth_radius2datum+0x14b>
xor    %eax,%eax
test   $0x1,%al
jne    117d <earth_radius2datum+0x7d>
jmp    124b <earth_radius2datum+0x14b>
movl   $0x0,-0x20(%rbp)
cmpl   $0x14,-0x20(%rbp)
jge    1246 <earth_radius2datum+0x146>
movslq -0x20(%rbp),%rcx
lea    0x2f37(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
subsd  -0x18(%rbp),%xmm1
movaps 0xe66(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe4a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11cf <earth_radius2datum+0xcf>
mov    $0x1,%al
test   $0x1,%al
jne    11de <earth_radius2datum+0xde>
jmp    1233 <earth_radius2datum+0x133>
xor    %eax,%eax
test   $0x1,%al
jne    11de <earth_radius2datum+0xde>
jmp    1233 <earth_radius2datum+0x133>
mov    -0x1c(%rbp),%eax
sub    -0x20(%rbp),%eax
cvtsi2sd %eax,%xmm1
movaps 0xe21(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe05(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1214 <earth_radius2datum+0x114>
mov    $0x1,%al
test   $0x1,%al
jne    1223 <earth_radius2datum+0x123>
jmp    122e <earth_radius2datum+0x12e>
xor    %eax,%eax
test   $0x1,%al
jne    1223 <earth_radius2datum+0x123>
jmp    122e <earth_radius2datum+0x12e>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12c0 <earth_radius2datum+0x1c0>
jmp    1233 <earth_radius2datum+0x133>
jmp    1238 <earth_radius2datum+0x138>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1184 <earth_radius2datum+0x84>
jmp    124b <earth_radius2datum+0x14b>
jmp    1250 <earth_radius2datum+0x150>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1123 <earth_radius2datum+0x23>
movslq -0x20(%rbp),%rcx
lea    0x2dc7(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
subsd  -0x10(%rbp),%xmm1
movaps 0xd96(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xd7a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    129f <earth_radius2datum+0x19f>
mov    $0x1,%al
test   $0x1,%al
jne    12ae <earth_radius2datum+0x1ae>
jmp    12b9 <earth_radius2datum+0x1b9>
xor    %eax,%eax
test   $0x1,%al
jne    12ae <earth_radius2datum+0x1ae>
jmp    12b9 <earth_radius2datum+0x1b9>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12c0 <earth_radius2datum+0x1c0>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<earth_radius2datum>:
xor    %eax,%eax
lea    0xf17(%rip),%rcx
movapd 0xeef(%rip),%xmm3
movsd  0xef7(%rip),%xmm2
lea    0xfa0(%rip),%rdx
xor    %esi,%esi
jmp    113f <earth_radius2datum+0x3f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x14,%esi
add    $0x1,%rax
cmp    $0x14,%rax
je     1195 <earth_radius2datum+0x95>
movsd  (%rcx,%rax,8),%xmm4
subsd  %xmm0,%xmm4
andpd  %xmm3,%xmm4
ucomisd %xmm4,%xmm2
jbe    1135 <earth_radius2datum+0x35>
xor    %esi,%esi
mov    %eax,%edi
jmp    1170 <earth_radius2datum+0x70>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%edi
add    $0x8,%rsi
cmp    $0xa0,%rsi
je     1130 <earth_radius2datum+0x30>
movsd  (%rsi,%rdx,1),%xmm4
subsd  %xmm1,%xmm4
andpd  %xmm3,%xmm4
ucomisd %xmm4,%xmm2
jbe    1160 <earth_radius2datum+0x60>
xorps  %xmm4,%xmm4
cvtsi2sd %edi,%xmm4
andpd  %xmm3,%xmm4
ucomisd %xmm4,%xmm2
jbe    1160 <earth_radius2datum+0x60>
ret
mov    %esi,%eax
movsd  (%rcx,%rax,8),%xmm1
subsd  %xmm0,%xmm1
andpd  0xe58(%rip),%xmm1
ucomisd %xmm1,%xmm2
mov    $0xffffffff,%eax
cmova  %esi,%eax
ret

LLVM IR (-O0):
@earth_radius2datum.major = internal global [20 x double] [double 0x415854B79999999A, double 0x415854C24947AE14, double 0x415853ED49EB851F, double 0x415854AB60000000, double 0x415854E500000000, double 0x415854A5C0000000, double 0x415853CF1617C1BE, double 0x415854A840000000, double 0x415854A640000000, double 0x41585416D9581062, double 0x415853D604083127, double 0x415853DF0C189375, double 0x415854A640000000, double 0x415854AAC0000000, double 6.378160e+06, double 0x415854C140000000, double 6.378270e+06, double 0x415854AD80000000, double 6.378150e+06, double 0x41584DAD40000000]
@earth_radius2datum.minor = internal global [20 x double] [double 0x41583F99F3333333, double 0x41583F88B7A6B50B, double 0x41583F1BBD9F2BAA, double 0x41583FC90CCCCCCD, double 0x41583FEBFC8D64D8, double 0x41583FC3A1464990, double 0x41583F1ADA7381D8, double 0x41583FC5F13D20F3, double 0x41583FC4141ADEA9, double 0x41583F483A3D70A4, double 0x41583F21C27EF9DB, double 0x41583F109CAC0831, double 0x41583FC4141C970F, double 0x41583FC95483126F, double 0x41583FC9AE041893, double 0x41583FDFC13404EA, double 0x41583FCE95FB8F58, double 0x41583FCC12279570, double 0x41583FC815965F52, double 0x41584DAD40000000]
define i32 @earth_radius2datum(double %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
store double %0, double* %4
store double %1, double* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %6
br label %8
8: ; preds = %55, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 20
br i1 %10, label %11, label %58
11: ; preds = %8
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [20 x double], [20 x double]* @earth_radius2datum.major, i64 0, i64 %13
%15 = load double, double* %14
%16 = load double, double* %4
%17 = fsub double %15, %16
%18 = call double @llvm.fabs.f64(double %17)
%19 = fcmp olt double %18, 1.000000e-01
br i1 %19, label %20, label %21
20: ; preds = %11
br i1 true, label %22, label %54
21: ; preds = %11
br i1 false, label %22, label %54
22: ; preds = %21, %20
store i32 0, i32* %7
br label %23
23: ; preds = %50, %22
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 20
br i1 %25, label %26, label %53
26: ; preds = %23
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [20 x double], [20 x double]* @earth_radius2datum.minor, i64 0, i64 %28
%30 = load double, double* %29
%31 = load double, double* %5
%32 = fsub double %30, %31
%33 = call double @llvm.fabs.f64(double %32)
%34 = fcmp olt double %33, 1.000000e-01
br i1 %34, label %35, label %36
35: ; preds = %26
br i1 true, label %37, label %49
36: ; preds = %26
br i1 false, label %37, label %49
37: ; preds = %36, %35
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = sub nsw i32 %38, %39
%41 = sitofp i32 %40 to double
%42 = call double @llvm.fabs.f64(double %41)
%43 = fcmp olt double %42, 1.000000e-01
br i1 %43, label %44, label %45
44: ; preds = %37
br i1 true, label %46, label %48
45: ; preds = %37
br i1 false, label %46, label %48
46: ; preds = %45, %44
%47 = load i32, i32* %6
store i32 %47, i32* %3
br label %72
48: ; preds = %45, %44
br label %49
49: ; preds = %48, %36, %35
br label %50
50: ; preds = %49
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %23
53: ; preds = %23
br label %54
54: ; preds = %53, %21, %20
br label %55
55: ; preds = %54
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %8
58: ; preds = %8
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [20 x double], [20 x double]* @earth_radius2datum.major, i64 0, i64 %60
%62 = load double, double* %61
%63 = load double, double* %4
%64 = fsub double %62, %63
%65 = call double @llvm.fabs.f64(double %64)
%66 = fcmp olt double %65, 1.000000e-01
br i1 %66, label %67, label %68
67: ; preds = %58
br i1 true, label %69, label %71
68: ; preds = %58
br i1 false, label %69, label %71
69: ; preds = %68, %67
%70 = load i32, i32* %7
store i32 %70, i32* %3
br label %72
71: ; preds = %68, %67
store i32 -1, i32* %3
br label %72
72: ; preds = %71, %69, %46
%73 = load i32, i32* %3
ret i32 %73
}

LLVM IR (-O2):
@earth_radius2datum.major = internal unnamed_addr constant [20 x double] [double 0x415854B79999999A, double 0x415854C24947AE14, double 0x415853ED49EB851F, double 0x415854AB60000000, double 0x415854E500000000, double 0x415854A5C0000000, double 0x415853CF1617C1BE, double 0x415854A840000000, double 0x415854A640000000, double 0x41585416D9581062, double 0x415853D604083127, double 0x415853DF0C189375, double 0x415854A640000000, double 0x415854AAC0000000, double 6.378160e+06, double 0x415854C140000000, double 6.378270e+06, double 0x415854AD80000000, double 6.378150e+06, double 0x41584DAD40000000]
@earth_radius2datum.minor = internal unnamed_addr constant [20 x double] [double 0x41583F99F3333333, double 0x41583F88B7A6B50B, double 0x41583F1BBD9F2BAA, double 0x41583FC90CCCCCCD, double 0x41583FEBFC8D64D8, double 0x41583FC3A1464990, double 0x41583F1ADA7381D8, double 0x41583FC5F13D20F3, double 0x41583FC4141ADEA9, double 0x41583F483A3D70A4, double 0x41583F21C27EF9DB, double 0x41583F109CAC0831, double 0x41583FC4141C970F, double 0x41583FC95483126F, double 0x41583FC9AE041893, double 0x41583FDFC13404EA, double 0x41583FCE95FB8F58, double 0x41583FCC12279570, double 0x41583FC815965F52, double 0x41584DAD40000000]
define i32 @earth_radius2datum(double %0, double %1) {
br label %3
3: ; preds = %2, %27
%4 = phi i64 [ 0, %2 ], [ %29, %27 ]
%5 = phi i32 [ 0, %2 ], [ %28, %27 ]
%6 = getelementptr inbounds [20 x double], [20 x double]* @earth_radius2datum.major, i64 0, i64 %4
%7 = load double, double* %6
%8 = fsub double %7, %0
%9 = tail call double @llvm.fabs.f64(double %8)
%10 = fcmp olt double %9, 1.000000e-01
br i1 %10, label %11, label %27
11: ; preds = %3, %24
%12 = phi i64 [ %25, %24 ], [ 0, %3 ]
%13 = getelementptr inbounds [20 x double], [20 x double]* @earth_radius2datum.minor, i64 0, i64 %12
%14 = load double, double* %13
%15 = fsub double %14, %1
%16 = tail call double @llvm.fabs.f64(double %15)
%17 = fcmp olt double %16, 1.000000e-01
br i1 %17, label %18, label %24
18: ; preds = %11
%19 = sub nsw i64 %4, %12
%20 = trunc i64 %19 to i32
%21 = sitofp i32 %20 to double
%22 = tail call double @llvm.fabs.f64(double %21)
%23 = fcmp olt double %22, 1.000000e-01
br i1 %23, label %39, label %24
24: ; preds = %11, %18
%25 = add nuw nsw i64 %12, 1
%26 = icmp eq i64 %25, 20
br i1 %26, label %27, label %11
27: ; preds = %24, %3
%28 = phi i32 [ %5, %3 ], [ 20, %24 ]
%29 = add nuw nsw i64 %4, 1
%30 = icmp eq i64 %29, 20
br i1 %30, label %31, label %3
31: ; preds = %27
%32 = zext i32 %28 to i64
%33 = getelementptr inbounds [20 x double], [20 x double]* @earth_radius2datum.major, i64 0, i64 %32
%34 = load double, double* %33
%35 = fsub double %34, %0
%36 = tail call double @llvm.fabs.f64(double %35)
%37 = fcmp olt double %36, 1.000000e-01
%38 = select i1 %37, i32 %28, i32 -1
br label %41
39: ; preds = %18
%40 = trunc i64 %4 to i32
br label %41
41: ; preds = %39, %31
%42 = phi i32 [ %38, %31 ], [ %40, %39 ]
ret i32 %42
}