double calc_weight(int data_age_in_days) {
  if (data_age_in_days < 28) {
    return 1.0;
  } else if (data_age_in_days < 42) {
    return 0.8;
  } else if (data_age_in_days < 56) {
    return 0.6;
  } else if (data_age_in_days < 70) {
    return 0.4;
  } else if (data_age_in_days < 120) {
    return 0.15;
  }
  return 0;
}


x86 assembly (clang, -O0):
<calc_weight>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
cmpl   $0x1c,-0xc(%rbp)
jge    1123 <calc_weight+0x23>
movsd  0xf07(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11af <calc_weight+0xaf>
cmpl   $0x2a,-0xc(%rbp)
jge    113f <calc_weight+0x3f>
movsd  0xee3(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11af <calc_weight+0xaf>
cmpl   $0x38,-0xc(%rbp)
jge    115b <calc_weight+0x5b>
movsd  0xebf(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11af <calc_weight+0xaf>
cmpl   $0x46,-0xc(%rbp)
jge    1177 <calc_weight+0x77>
movsd  0xe9b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11af <calc_weight+0xaf>
cmpl   $0x78,-0xc(%rbp)
jge    1193 <calc_weight+0x93>
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11af <calc_weight+0xaf>
jmp    1198 <calc_weight+0x98>
jmp    119d <calc_weight+0x9d>
jmp    11a2 <calc_weight+0xa2>
jmp    11a7 <calc_weight+0xa7>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_weight>:
cmp    $0x1c,%edi
jge    110e <calc_weight+0xe>
movsd  0xef3(%rip),%xmm0
ret
cmp    $0x2a,%edi
jae    111c <calc_weight+0x1c>
movsd  0xeed(%rip),%xmm0
ret
cmp    $0x38,%edi
jae    112a <calc_weight+0x2a>
movsd  0xee7(%rip),%xmm0
ret
cmp    $0x46,%edi
jae    1138 <calc_weight+0x38>
movsd  0xee1(%rip),%xmm0
ret
cmp    $0x78,%edi
jb     1141 <calc_weight+0x41>
xorps  %xmm0,%xmm0
ret
movsd  0xed7(%rip),%xmm0
ret

LLVM IR (-O0):
define double @calc_weight(i32 %0) {
%2 = alloca double
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 28
br i1 %5, label %6, label %7
6: ; preds = %1
store double 1.000000e+00, double* %2
br label %28
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 42
br i1 %9, label %10, label %11
10: ; preds = %7
store double 8.000000e-01, double* %2
br label %28
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 56
br i1 %13, label %14, label %15
14: ; preds = %11
store double 6.000000e-01, double* %2
br label %28
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 70
br i1 %17, label %18, label %19
18: ; preds = %15
store double 4.000000e-01, double* %2
br label %28
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 120
br i1 %21, label %22, label %23
22: ; preds = %19
store double 1.500000e-01, double* %2
br label %28
23: ; preds = %19
br label %24
24: ; preds = %23
br label %25
25: ; preds = %24
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26
store double 0.000000e+00, double* %2
br label %28
28: ; preds = %27, %22, %18, %14, %10, %6
%29 = load double, double* %2
ret double %29
}

LLVM IR (-O2):
define double @calc_weight(i32 %0) {
%2 = icmp slt i32 %0, 28
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 42
br i1 %4, label %12, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 56
br i1 %6, label %12, label %7
7: ; preds = %5
%8 = icmp ult i32 %0, 70
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = icmp ult i32 %0, 120
%11 = select i1 %10, double 1.500000e-01, double 0.000000e+00
br label %12
12: ; preds = %9, %7, %5, %3, %1
%13 = phi double [ 1.000000e+00, %1 ], [ 8.000000e-01, %3 ], [ 6.000000e-01, %5 ], [ 4.000000e-01, %7 ], [ %11, %9 ]
ret double %13
}