double dist_ape(int dist) {
  double result;
  if (400 <= dist && dist < 500) {
    result = 0.01;
  } else if (500 <= dist && dist < 600) {
    result = 0.01;
  } else if (600 <= dist && dist < 700) {
    result = 0.77;
  } else if (700 <= dist && dist < 800) {
    result = 0.20;
  } else {
    result = 0.0000000000000001;
  }
  return result;
}


x86 assembly (clang, -O0):
<dist_ape>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    $0x190,%eax
cmp    -0x4(%rbp),%eax
jg     1134 <dist_ape+0x34>
cmpl   $0x1f4,-0x4(%rbp)
jge    1134 <dist_ape+0x34>
movsd  0xeee(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11d7 <dist_ape+0xd7>
mov    $0x1f4,%eax
cmp    -0x4(%rbp),%eax
jg     1161 <dist_ape+0x61>
cmpl   $0x258,-0x4(%rbp)
jge    1161 <dist_ape+0x61>
movsd  0xec1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11d2 <dist_ape+0xd2>
mov    $0x258,%eax
cmp    -0x4(%rbp),%eax
jg     118e <dist_ape+0x8e>
cmpl   $0x2bc,-0x4(%rbp)
jge    118e <dist_ape+0x8e>
movsd  0xe8c(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11cd <dist_ape+0xcd>
mov    $0x2bc,%eax
cmp    -0x4(%rbp),%eax
jg     11bb <dist_ape+0xbb>
cmpl   $0x320,-0x4(%rbp)
jge    11bb <dist_ape+0xbb>
movsd  0xe57(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11c8 <dist_ape+0xc8>
movsd  0xe3d(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11cd <dist_ape+0xcd>
jmp    11d2 <dist_ape+0xd2>
jmp    11d7 <dist_ape+0xd7>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<dist_ape>:
lea    -0x190(%rdi),%eax
cmp    $0xc8,%eax
jae    1116 <dist_ape+0x16>
movsd  0xeeb(%rip),%xmm0
ret
lea    -0x258(%rdi),%eax
cmp    $0x64,%eax
jae    112a <dist_ape+0x2a>
movsd  0xedf(%rip),%xmm0
ret
add    $0xfffffd44,%edi
xor    %eax,%eax
cmp    $0x64,%edi
setb   %al
lea    0xed1(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
ret

LLVM IR (-O0):
define double @dist_ape(i32 %0) {
%2 = alloca i32
%3 = alloca double
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp sle i32 400, %4
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 500
br i1 %8, label %9, label %10
9: ; preds = %6
store double 1.000000e-02, double* %3
br label %35
10: ; preds = %6, %1
%11 = load i32, i32* %2
%12 = icmp sle i32 500, %11
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* %2
%15 = icmp slt i32 %14, 600
br i1 %15, label %16, label %17
16: ; preds = %13
store double 1.000000e-02, double* %3
br label %34
17: ; preds = %13, %10
%18 = load i32, i32* %2
%19 = icmp sle i32 600, %18
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 700
br i1 %22, label %23, label %24
23: ; preds = %20
store double 7.700000e-01, double* %3
br label %33
24: ; preds = %20, %17
%25 = load i32, i32* %2
%26 = icmp sle i32 700, %25
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32, i32* %2
%29 = icmp slt i32 %28, 800
br i1 %29, label %30, label %31
30: ; preds = %27
store double 2.000000e-01, double* %3
br label %32
31: ; preds = %27, %24
store double 0x3C9CD2B297D889BC, double* %3
br label %32
32: ; preds = %31, %30
br label %33
33: ; preds = %32, %23
br label %34
34: ; preds = %33, %16
br label %35
35: ; preds = %34, %9
%36 = load double, double* %3
ret double %36
}

LLVM IR (-O2):
define double @dist_ape(i32 %0) {
%2 = add i32 %0, -400
%3 = icmp ult i32 %2, 200
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = add i32 %0, -600
%6 = icmp ult i32 %5, 100
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = add i32 %0, -700
%9 = icmp ult i32 %8, 100
%10 = select i1 %9, double 2.000000e-01, double 0x3C9CD2B297D889BC
br label %11
11: ; preds = %7, %4, %1
%12 = phi double [ 1.000000e-02, %1 ], [ 7.700000e-01, %4 ], [ %10, %7 ]
ret double %12
}