#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 (major_index == minor_index) {
            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    1225 <earth_radius2datum+0x125>
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    1212 <earth_radius2datum+0x112>
xor    %eax,%eax
test   $0x1,%al
jne    117d <earth_radius2datum+0x7d>
jmp    1212 <earth_radius2datum+0x112>
movl   $0x0,-0x20(%rbp)
cmpl   $0x14,-0x20(%rbp)
jge    120d <earth_radius2datum+0x10d>
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    11fa <earth_radius2datum+0xfa>
xor    %eax,%eax
test   $0x1,%al
jne    11de <earth_radius2datum+0xde>
jmp    11fa <earth_radius2datum+0xfa>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    11f5 <earth_radius2datum+0xf5>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1287 <earth_radius2datum+0x187>
jmp    11fa <earth_radius2datum+0xfa>
jmp    11ff <earth_radius2datum+0xff>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1184 <earth_radius2datum+0x84>
jmp    1212 <earth_radius2datum+0x112>
jmp    1217 <earth_radius2datum+0x117>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1123 <earth_radius2datum+0x23>
movslq -0x20(%rbp),%rcx
lea    0x2e00(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
subsd  -0x10(%rbp),%xmm1
movaps 0xdcf(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xdb3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1266 <earth_radius2datum+0x166>
mov    $0x1,%al
test   $0x1,%al
jne    1275 <earth_radius2datum+0x175>
jmp    1280 <earth_radius2datum+0x180>
xor    %eax,%eax
test   $0x1,%al
jne    1275 <earth_radius2datum+0x175>
jmp    1280 <earth_radius2datum+0x180>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1287 <earth_radius2datum+0x187>
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    1133 <earth_radius2datum+0x33>
mov    $0x14,%esi
add    $0x1,%rax
cmp    $0x14,%rax
je     1190 <earth_radius2datum+0x90>
movsd  (%rcx,%rax,8),%xmm4
subsd  %xmm0,%xmm4
andpd  %xmm3,%xmm4
ucomisd %xmm4,%xmm2
jbe    1129 <earth_radius2datum+0x29>
xor    %esi,%esi
jmp    115a <earth_radius2datum+0x5a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rsi
cmp    $0x14,%rsi
je     1124 <earth_radius2datum+0x24>
movsd  (%rdx,%rsi,8),%xmm4
subsd  %xmm1,%xmm4
andpd  %xmm3,%xmm4
ucomisd %xmm4,%xmm2
jbe    1172 <earth_radius2datum+0x72>
cmp    %rsi,%rax
je     118f <earth_radius2datum+0x8f>
movsd  0x8(%rdx,%rsi,8),%xmm4
subsd  %xmm1,%xmm4
andpd  %xmm3,%xmm4
add    $0x1,%rsi
ucomisd %xmm4,%xmm2
jbe    1150 <earth_radius2datum+0x50>
cmp    %rsi,%rax
jne    1150 <earth_radius2datum+0x50>
ret
mov    %esi,%eax
movsd  (%rcx,%rax,8),%xmm1
subsd  %xmm0,%xmm1
andpd  0xe5d(%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 = %50, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 20
br i1 %10, label %11, label %53
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 %49
21: ; preds = %11
br i1 false, label %22, label %49
22: ; preds = %21, %20
store i32 0, i32* %7
br label %23
23: ; preds = %45, %22
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 20
br i1 %25, label %26, label %48
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 %44
36: ; preds = %26
br i1 false, label %37, label %44
37: ; preds = %36, %35
%38 = load i32, i32* %6
%39 = load i32, i32* %7
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = load i32, i32* %6
store i32 %42, i32* %3
br label %67
43: ; preds = %37
br label %44
44: ; preds = %43, %36, %35
br label %45
45: ; preds = %44
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %23
48: ; preds = %23
br label %49
49: ; preds = %48, %21, %20
br label %50
50: ; preds = %49
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %8
53: ; preds = %8
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [20 x double], [20 x double]* @earth_radius2datum.major, i64 0, i64 %55
%57 = load double, double* %56
%58 = load double, double* %4
%59 = fsub double %57, %58
%60 = call double @llvm.fabs.f64(double %59)
%61 = fcmp olt double %60, 1.000000e-01
br i1 %61, label %62, label %63
62: ; preds = %53
br i1 true, label %64, label %66
63: ; preds = %53
br i1 false, label %64, label %66
64: ; preds = %63, %62
%65 = load i32, i32* %7
store i32 %65, i32* %3
br label %67
66: ; preds = %63, %62
store i32 -1, i32* %3
br label %67
67: ; preds = %66, %64, %41
%68 = load i32, i32* %3
ret i32 %68
}

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, %32
%4 = phi i64 [ 0, %2 ], [ %34, %32 ]
%5 = phi i32 [ 0, %2 ], [ %33, %32 ]
%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 %32
11: ; preds = %3, %29
%12 = phi i64 [ %30, %29 ], [ 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
%18 = icmp eq i64 %4, %12
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %44, label %20
20: ; preds = %11
%21 = or i64 %12, 1
%22 = getelementptr inbounds [20 x double], [20 x double]* @earth_radius2datum.minor, i64 0, i64 %21
%23 = load double, double* %22
%24 = fsub double %23, %1
%25 = tail call double @llvm.fabs.f64(double %24)
%26 = fcmp olt double %25, 1.000000e-01
%27 = icmp eq i64 %4, %21
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %44, label %29
29: ; preds = %20
%30 = add nuw nsw i64 %12, 2
%31 = icmp eq i64 %30, 20
br i1 %31, label %32, label %11
32: ; preds = %29, %3
%33 = phi i32 [ %5, %3 ], [ 20, %29 ]
%34 = add nuw nsw i64 %4, 1
%35 = icmp eq i64 %34, 20
br i1 %35, label %36, label %3
36: ; preds = %32
%37 = zext i32 %33 to i64
%38 = getelementptr inbounds [20 x double], [20 x double]* @earth_radius2datum.major, i64 0, i64 %37
%39 = load double, double* %38
%40 = fsub double %39, %0
%41 = tail call double @llvm.fabs.f64(double %40)
%42 = fcmp olt double %41, 1.000000e-01
%43 = select i1 %42, i32 %33, i32 -1
br label %46
44: ; preds = %20, %11
%45 = trunc i64 %4 to i32
br label %46
46: ; preds = %44, %36
%47 = phi i32 [ %43, %36 ], [ %45, %44 ]
ret i32 %47
}