double recompute_ta(double ref_ta, double time_now) {
  int now = (int)time_now;
  now %= (7 * (24 * 3600));
  if (now > 5 * (24 * 3600))
    return ref_ta * 5;
  now %= (24 * 3600);
  if (now < 8.5 * 3600)
    return ref_ta * 4;
  if (now < 13 * 3600)
    return ref_ta * 0.8;
  if (now < 15 * 3600)
    return ref_ta * 2.5;
  if (now < 19 * 3600)
    return ref_ta * 2;
  if (now < 21 * 3600)
    return ref_ta * 2.2;
  return ref_ta * 4.5;
}


x86 assembly (clang, -O0):
<recompute_ta>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x93a80,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
cmpl   $0x69780,-0x1c(%rbp)
jle    1148 <recompute_ta+0x48>
movsd  0xeff(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1226 <recompute_ta+0x126>
mov    -0x1c(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe9d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1184 <recompute_ta+0x84>
movsd  0xebb(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1226 <recompute_ta+0x126>
cmpl   $0xb6d0,-0x1c(%rbp)
jge    11a8 <recompute_ta+0xa8>
movsd  0xe8f(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1226 <recompute_ta+0x126>
cmpl   $0xd2f0,-0x1c(%rbp)
jge    11cc <recompute_ta+0xcc>
movsd  0xe63(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1226 <recompute_ta+0x126>
cmpl   $0x10b30,-0x1c(%rbp)
jge    11f0 <recompute_ta+0xf0>
movsd  0xe37(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1226 <recompute_ta+0x126>
cmpl   $0x12750,-0x1c(%rbp)
jge    1214 <recompute_ta+0x114>
movsd  0xe0b(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1226 <recompute_ta+0x126>
movsd  0xdec(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<recompute_ta>:
cvttsd2si %xmm1,%eax
cltq
imul   $0x6ef5de4d,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x32,%rcx
add    %edx,%ecx
imul   $0x93a80,%ecx,%ecx
sub    %ecx,%eax
cmp    $0x69780,%eax
jle    1133 <recompute_ta+0x33>
movsd  0xecf(%rip),%xmm1
jmp    11af <recompute_ta+0xaf>
movslq %eax,%rcx
imul   $0xffffffffc22e4507,%rcx,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x10,%ecx
add    %edx,%ecx
imul   $0x15180,%ecx,%ecx
sub    %ecx,%eax
cmp    $0x7788,%eax
jge    1166 <recompute_ta+0x66>
movsd  0xea4(%rip),%xmm1
jmp    11af <recompute_ta+0xaf>
cmp    $0xb6d0,%eax
jae    1177 <recompute_ta+0x77>
movsd  0xe9b(%rip),%xmm1
jmp    11af <recompute_ta+0xaf>
cmp    $0xd2f0,%eax
jae    1188 <recompute_ta+0x88>
movsd  0xe92(%rip),%xmm1
jmp    11af <recompute_ta+0xaf>
cmp    $0x10b30,%eax
jae    1199 <recompute_ta+0x99>
movsd  0xe89(%rip),%xmm1
jmp    11af <recompute_ta+0xaf>
xor    %ecx,%ecx
cmp    $0x12750,%eax
setb   %cl
lea    0xe7e(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @recompute_ta(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %5
%8 = fptosi double %7 to i32
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = srem i32 %9, 604800
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 432000
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load double, double* %4
%15 = fmul double %14, 5.000000e+00
store double %15, double* %3
br label %52
16: ; preds = %2
%17 = load i32, i32* %6
%18 = srem i32 %17, 86400
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = sitofp i32 %19 to double
%21 = fcmp olt double %20, 3.060000e+04
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load double, double* %4
%24 = fmul double %23, 4.000000e+00
store double %24, double* %3
br label %52
25: ; preds = %16
%26 = load i32, i32* %6
%27 = icmp slt i32 %26, 46800
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load double, double* %4
%30 = fmul double %29, 8.000000e-01
store double %30, double* %3
br label %52
31: ; preds = %25
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 54000
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load double, double* %4
%36 = fmul double %35, 2.500000e+00
store double %36, double* %3
br label %52
37: ; preds = %31
%38 = load i32, i32* %6
%39 = icmp slt i32 %38, 68400
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load double, double* %4
%42 = fmul double %41, 2.000000e+00
store double %42, double* %3
br label %52
43: ; preds = %37
%44 = load i32, i32* %6
%45 = icmp slt i32 %44, 75600
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load double, double* %4
%48 = fmul double %47, 2.200000e+00
store double %48, double* %3
br label %52
49: ; preds = %43
%50 = load double, double* %4
%51 = fmul double %50, 4.500000e+00
store double %51, double* %3
br label %52
52: ; preds = %49, %46, %40, %34, %28, %22, %13
%53 = load double, double* %3
ret double %53
}

LLVM IR (-O2):
define double @recompute_ta(double %0, double %1) {
%3 = fptosi double %1 to i32
%4 = srem i32 %3, 604800
%5 = icmp sgt i32 %4, 432000
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = srem i32 %4, 86400
%8 = icmp slt i32 %7, 30600
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = icmp ult i32 %7, 46800
br i1 %10, label %18, label %11
11: ; preds = %9
%12 = icmp ult i32 %7, 54000
br i1 %12, label %18, label %13
13: ; preds = %11
%14 = icmp ult i32 %7, 68400
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = icmp ult i32 %7, 75600
%17 = select i1 %16, double 2.200000e+00, double 4.500000e+00
br label %18
18: ; preds = %15, %13, %11, %9, %6, %2
%19 = phi double [ 5.000000e+00, %2 ], [ 4.000000e+00, %6 ], [ 8.000000e-01, %9 ], [ 2.500000e+00, %11 ], [ 2.000000e+00, %13 ], [ %17, %15 ]
%20 = fmul double %19, %0
ret double %20
}