#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);
double getNearestExpCov(double argCov, double *expCovMulti) {
  int index;
  double difference, minDiff = 1000000.0, resultExpCov = 0.0;
  for (index = 0; index < 2; index++) {
    if (expCovMulti[index] == -1)
      break;
    difference = fabs(argCov - expCovMulti[index]);
    if (difference < minDiff) {
      minDiff = difference;
      resultExpCov = expCovMulti[index];
    }
  }
  return resultExpCov;
}


x86 assembly (clang, -O0):
<getNearestExpCov>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  0xeeb(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    11c2 <getNearestExpCov+0xc2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xec0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    115d <getNearestExpCov+0x5d>
jp     115d <getNearestExpCov+0x5d>
jmp    11c2 <getNearestExpCov+0xc2>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xe9a(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11af <getNearestExpCov+0xaf>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11b4 <getNearestExpCov+0xb4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <getNearestExpCov+0x29>
movsd  -0x30(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNearestExpCov>:
movsd  (%rdi),%xmm3
xorpd  %xmm1,%xmm1
ucomisd 0xef0(%rip),%xmm3
jne    1119 <getNearestExpCov+0x19>
jp     1119 <getNearestExpCov+0x19>
movapd %xmm1,%xmm0
ret
movapd %xmm0,%xmm2
subsd  %xmm3,%xmm2
andpd  0xee7(%rip),%xmm2
movapd %xmm2,%xmm1
cmpltsd 0xed2(%rip),%xmm1
andpd  %xmm3,%xmm1
movsd  0x8(%rdi),%xmm3
ucomisd 0xeb9(%rip),%xmm3
jne    114b <getNearestExpCov+0x4b>
jnp    1114 <getNearestExpCov+0x14>
minsd  0xeb5(%rip),%xmm2
subsd  %xmm3,%xmm0
andpd  0xeb1(%rip),%xmm0
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm3
andnpd %xmm1,%xmm0
orpd   %xmm3,%xmm0
movapd %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @getNearestExpCov(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %3
store double* %1, double** %4
store double 1.000000e+06, double* %7
store double 0.000000e+00, double* %8
store i32 0, i32* %5
br label %9
9: ; preds = %40, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %43
12: ; preds = %9
%13 = load double*, double** %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = fcmp oeq double %17, -1.000000e+00
br i1 %18, label %19, label %20
19: ; preds = %12
br label %43
20: ; preds = %12
%21 = load double, double* %3
%22 = load double*, double** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %22, i64 %24
%26 = load double, double* %25
%27 = fsub double %21, %26
%28 = call double @llvm.fabs.f64(double %27)
store double %28, double* %6
%29 = load double, double* %6
%30 = load double, double* %7
%31 = fcmp olt double %29, %30
br i1 %31, label %32, label %39
32: ; preds = %20
%33 = load double, double* %6
store double %33, double* %7
%34 = load double*, double** %4
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
store double %38, double* %8
br label %39
39: ; preds = %32, %20
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %9
43: ; preds = %19, %9
%44 = load double, double* %8
ret double %44
}

LLVM IR (-O2):
define double @getNearestExpCov(double %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = fcmp oeq double %3, -1.000000e+00
br i1 %4, label %19, label %5
5: ; preds = %2
%6 = fsub double %0, %3
%7 = tail call double @llvm.fabs.f64(double %6)
%8 = fcmp olt double %7, 1.000000e+06
%9 = select i1 %8, double %3, double 0.000000e+00
%10 = getelementptr inbounds double, double* %1, i64 1
%11 = load double, double* %10
%12 = fcmp oeq double %11, -1.000000e+00
br i1 %12, label %19, label %13
13: ; preds = %5
%14 = select i1 %8, double %7, double 1.000000e+06
%15 = fsub double %0, %11
%16 = tail call double @llvm.fabs.f64(double %15)
%17 = fcmp olt double %16, %14
%18 = select i1 %17, double %11, double %9
br label %19
19: ; preds = %13, %5, %2
%20 = phi double [ 0.000000e+00, %2 ], [ %9, %5 ], [ %18, %13 ]
ret double %20
}