double SimInf_forward_euler_linear_decay(double phi, int day, int end_t1,
                                         int end_t2, int end_t3, int end_t4,
                                         double beta_t1, double beta_t2,
                                         double beta_t3, double beta_t4) {
  if (day < end_t2) {
    if (day < end_t1) {
      if (end_t1 < end_t4)
        return phi * (1.0 - beta_t1);
      if (day < end_t4) {
        if (end_t4 < end_t3)
          return phi * (1.0 - beta_t4);
        if (day < end_t3)
          return phi * (1.0 - beta_t3);
        return phi * (1.0 - beta_t4);
      }
      return phi * (1.0 - beta_t1);
    }
    return phi * (1.0 - beta_t2);
  }
  if (end_t3 < end_t1 || day < end_t3)
    return phi * (1.0 - beta_t3);
  if (end_t4 < end_t1 || day < end_t4)
    return phi * (1.0 - beta_t4);
  return phi * (1.0 - beta_t1);
}


x86 assembly (clang, -O0):
<SimInf_forward_euler_linear_decay>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movsd  %xmm1,-0x30(%rbp)
movsd  %xmm2,-0x38(%rbp)
movsd  %xmm3,-0x40(%rbp)
movsd  %xmm4,-0x48(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1235 <SimInf_forward_euler_linear_decay+0x135>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1215 <SimInf_forward_euler_linear_decay+0x115>
mov    -0x18(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1171 <SimInf_forward_euler_linear_decay+0x71>
movsd  -0x10(%rbp),%xmm0
movsd  0xea2(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <SimInf_forward_euler_linear_decay+0x1c0>
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11f5 <SimInf_forward_euler_linear_decay+0xf5>
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11a9 <SimInf_forward_euler_linear_decay+0xa9>
movsd  -0x10(%rbp),%xmm0
movsd  0xe6a(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <SimInf_forward_euler_linear_decay+0x1c0>
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11d5 <SimInf_forward_euler_linear_decay+0xd5>
movsd  -0x10(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
subsd  -0x40(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <SimInf_forward_euler_linear_decay+0x1c0>
movsd  -0x10(%rbp),%xmm0
movsd  0xe1e(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <SimInf_forward_euler_linear_decay+0x1c0>
movsd  -0x10(%rbp),%xmm0
movsd  0xdfe(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <SimInf_forward_euler_linear_decay+0x1c0>
movsd  -0x10(%rbp),%xmm0
movsd  0xdde(%rip),%xmm1
subsd  -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <SimInf_forward_euler_linear_decay+0x1c0>
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     124d <SimInf_forward_euler_linear_decay+0x14d>
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    126d <SimInf_forward_euler_linear_decay+0x16d>
movsd  -0x10(%rbp),%xmm0
movsd  0xda6(%rip),%xmm1
subsd  -0x40(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <SimInf_forward_euler_linear_decay+0x1c0>
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     1285 <SimInf_forward_euler_linear_decay+0x185>
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12a5 <SimInf_forward_euler_linear_decay+0x1a5>
movsd  -0x10(%rbp),%xmm0
movsd  0xd6e(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c0 <SimInf_forward_euler_linear_decay+0x1c0>
movsd  -0x10(%rbp),%xmm0
movsd  0xd4e(%rip),%xmm1
subsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<SimInf_forward_euler_linear_decay>:
cmp    %edx,%edi
jge    1129 <SimInf_forward_euler_linear_decay+0x29>
cmp    %esi,%edi
jge    114f <SimInf_forward_euler_linear_decay+0x4f>
movapd %xmm1,%xmm2
cmp    %r8d,%esi
jl     114f <SimInf_forward_euler_linear_decay+0x4f>
cmp    %r8d,%edi
jge    114f <SimInf_forward_euler_linear_decay+0x4f>
cmp    %ecx,%r8d
jl     114b <SimInf_forward_euler_linear_decay+0x4b>
cmp    %ecx,%edi
jl     1123 <SimInf_forward_euler_linear_decay+0x23>
movapd %xmm4,%xmm3
movapd %xmm3,%xmm2
jmp    114f <SimInf_forward_euler_linear_decay+0x4f>
movapd %xmm3,%xmm2
cmp    %esi,%ecx
jl     114f <SimInf_forward_euler_linear_decay+0x4f>
cmp    %ecx,%edi
jl     114f <SimInf_forward_euler_linear_decay+0x4f>
movapd %xmm4,%xmm2
cmp    %r8d,%edi
jl     1142 <SimInf_forward_euler_linear_decay+0x42>
movapd %xmm1,%xmm2
cmp    %esi,%r8d
jl     114b <SimInf_forward_euler_linear_decay+0x4b>
movapd %xmm2,%xmm4
movapd %xmm4,%xmm2
movsd  0xea9(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @SimInf_forward_euler_linear_decay(double %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6, double %7, double %8, double %9) {
%11 = alloca double
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
store double %0, double* %12
store i32 %1, i32* %13
store i32 %2, i32* %14
store i32 %3, i32* %15
store i32 %4, i32* %16
store i32 %5, i32* %17
store double %6, double* %18
store double %7, double* %19
store double %8, double* %20
store double %9, double* %21
%22 = load i32, i32* %13
%23 = load i32, i32* %15
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %75
25: ; preds = %10
%26 = load i32, i32* %13
%27 = load i32, i32* %14
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %70
29: ; preds = %25
%30 = load i32, i32* %14
%31 = load i32, i32* %17
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load double, double* %12
%35 = load double, double* %18
%36 = fsub double 1.000000e+00, %35
%37 = fmul double %34, %36
store double %37, double* %11
br label %106
38: ; preds = %29
%39 = load i32, i32* %13
%40 = load i32, i32* %17
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %65
42: ; preds = %38
%43 = load i32, i32* %17
%44 = load i32, i32* %16
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = load double, double* %12
%48 = load double, double* %21
%49 = fsub double 1.000000e+00, %48
%50 = fmul double %47, %49
store double %50, double* %11
br label %106
51: ; preds = %42
%52 = load i32, i32* %13
%53 = load i32, i32* %16
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %60
55: ; preds = %51
%56 = load double, double* %12
%57 = load double, double* %20
%58 = fsub double 1.000000e+00, %57
%59 = fmul double %56, %58
store double %59, double* %11
br label %106
60: ; preds = %51
%61 = load double, double* %12
%62 = load double, double* %21
%63 = fsub double 1.000000e+00, %62
%64 = fmul double %61, %63
store double %64, double* %11
br label %106
65: ; preds = %38
%66 = load double, double* %12
%67 = load double, double* %18
%68 = fsub double 1.000000e+00, %67
%69 = fmul double %66, %68
store double %69, double* %11
br label %106
70: ; preds = %25
%71 = load double, double* %12
%72 = load double, double* %19
%73 = fsub double 1.000000e+00, %72
%74 = fmul double %71, %73
store double %74, double* %11
br label %106
75: ; preds = %10
%76 = load i32, i32* %16
%77 = load i32, i32* %14
%78 = icmp slt i32 %76, %77
br i1 %78, label %83, label %79
79: ; preds = %75
%80 = load i32, i32* %13
%81 = load i32, i32* %16
%82 = icmp slt i32 %80, %81
br i1 %82, label %83, label %88
83: ; preds = %79, %75
%84 = load double, double* %12
%85 = load double, double* %20
%86 = fsub double 1.000000e+00, %85
%87 = fmul double %84, %86
store double %87, double* %11
br label %106
88: ; preds = %79
%89 = load i32, i32* %17
%90 = load i32, i32* %14
%91 = icmp slt i32 %89, %90
br i1 %91, label %96, label %92
92: ; preds = %88
%93 = load i32, i32* %13
%94 = load i32, i32* %17
%95 = icmp slt i32 %93, %94
br i1 %95, label %96, label %101
96: ; preds = %92, %88
%97 = load double, double* %12
%98 = load double, double* %21
%99 = fsub double 1.000000e+00, %98
%100 = fmul double %97, %99
store double %100, double* %11
br label %106
101: ; preds = %92
%102 = load double, double* %12
%103 = load double, double* %18
%104 = fsub double 1.000000e+00, %103
%105 = fmul double %102, %104
store double %105, double* %11
br label %106
106: ; preds = %101, %96, %83, %70, %65, %60, %55, %46, %33
%107 = load double, double* %11
ret double %107
}

LLVM IR (-O2):
define double @SimInf_forward_euler_linear_decay(double %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double %6, double %7, double %8, double %9) {
%11 = icmp slt i32 %1, %3
br i1 %11, label %12, label %23
12: ; preds = %10
%13 = icmp slt i32 %1, %2
br i1 %13, label %14, label %32
14: ; preds = %12
%15 = icmp sge i32 %2, %5
%16 = icmp slt i32 %1, %5
%17 = and i1 %15, %16
br i1 %17, label %18, label %32
18: ; preds = %14
%19 = icmp slt i32 %5, %4
br i1 %19, label %32, label %20
20: ; preds = %18
%21 = icmp slt i32 %1, %4
%22 = select i1 %21, double %8, double %9
br label %32
23: ; preds = %10
%24 = icmp slt i32 %4, %2
%25 = icmp slt i32 %1, %4
%26 = or i1 %24, %25
br i1 %26, label %32, label %27
27: ; preds = %23
%28 = icmp slt i32 %5, %2
%29 = icmp slt i32 %1, %5
%30 = or i1 %28, %29
%31 = select i1 %30, double %9, double %6
br label %32
32: ; preds = %27, %23, %12, %20, %18, %14
%33 = phi double [ %6, %14 ], [ %9, %18 ], [ %22, %20 ], [ %7, %12 ], [ %8, %23 ], [ %31, %27 ]
%34 = fsub double 1.000000e+00, %33
%35 = fmul double %34, %0
ret double %35
}