void cdiEncodeTimevalue(int days, int secs, int timeunit, double *timevalue) {
  static int lwarn = 1;
  if (timeunit == 1) {
    *timevalue = days * 86400. + secs;
  } else if (timeunit == 2 || timeunit == 3 || timeunit == 4) {
    *timevalue = days * 1440. + secs / 60.;
  } else if (timeunit == 5 || timeunit == 6 || timeunit == 7 || timeunit == 8) {
    *timevalue = days * 24. + secs / 3600.;
  } else if (timeunit == 9) {
    *timevalue = days + secs / 86400.;
  } else {
    if (lwarn) {
      Warning_(__func__, "timeunit %s unsupported!", tunitNamePtr(timeunit));
      lwarn = 0;
    }
  }
}


x86 assembly (clang, -O0):
<cdiEncodeTimevalue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1166 <cdiEncodeTimevalue+0x46>
cvtsi2sdl -0x4(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xeaf(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    128f <cdiEncodeTimevalue+0x16f>
cmpl   $0x2,-0xc(%rbp)
je     1184 <cdiEncodeTimevalue+0x64>
cmpl   $0x3,-0xc(%rbp)
je     1184 <cdiEncodeTimevalue+0x64>
cmpl   $0x4,-0xc(%rbp)
jne    11b7 <cdiEncodeTimevalue+0x97>
cvtsi2sdl -0x4(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe8a(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xe76(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    128a <cdiEncodeTimevalue+0x16a>
cmpl   $0x5,-0xc(%rbp)
je     11df <cdiEncodeTimevalue+0xbf>
cmpl   $0x6,-0xc(%rbp)
je     11df <cdiEncodeTimevalue+0xbf>
cmpl   $0x7,-0xc(%rbp)
je     11df <cdiEncodeTimevalue+0xbf>
cmpl   $0x8,-0xc(%rbp)
jne    1212 <cdiEncodeTimevalue+0xf2>
cvtsi2sdl -0x4(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe1f(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xe0b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1285 <cdiEncodeTimevalue+0x165>
cmpl   $0x9,-0xc(%rbp)
jne    1243 <cdiEncodeTimevalue+0x123>
cvtsi2sdl -0x4(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xdd2(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1280 <cdiEncodeTimevalue+0x160>
cmpl   $0x0,0x2de6(%rip)
je     127b <cdiEncodeTimevalue+0x15b>
mov    -0xc(%rbp),%edi
mov    $0x0,%al
call   1040 <tunitNamePtr@plt>
mov    %eax,%edx
lea    0xdc5(%rip),%rdi
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   1030 <Warning_@plt>
movl   $0x0,0x2db5(%rip)
jmp    1280 <cdiEncodeTimevalue+0x160>
jmp    1285 <cdiEncodeTimevalue+0x165>
jmp    128a <cdiEncodeTimevalue+0x16a>
jmp    128f <cdiEncodeTimevalue+0x16f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdiEncodeTimevalue>:
push   %rax
lea    -0x2(%rdx),%eax
cmp    $0x3,%eax
jae    1143 <cdiEncodeTimevalue+0x23>
cvtsi2sd %edi,%xmm0
cvtsi2sd %esi,%xmm1
divsd  0xec7(%rip),%xmm1
mulsd  0xec7(%rip),%xmm0
jmp    117a <cdiEncodeTimevalue+0x5a>
cmp    $0x1,%edx
jne    115a <cdiEncodeTimevalue+0x3a>
cvtsi2sd %edi,%xmm0
cvtsi2sd %esi,%xmm1
mulsd  0xeb8(%rip),%xmm0
jmp    117a <cdiEncodeTimevalue+0x5a>
lea    -0x5(%rdx),%eax
cmp    $0x3,%eax
ja     1184 <cdiEncodeTimevalue+0x64>
cvtsi2sd %edi,%xmm0
cvtsi2sd %esi,%xmm1
divsd  0xea6(%rip),%xmm1
mulsd  0xea6(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rcx)
pop    %rax
ret
cmp    $0x9,%edx
jne    11a3 <cdiEncodeTimevalue+0x83>
cvtsi2sd %edi,%xmm0
cvtsi2sd %esi,%xmm1
divsd  0xe77(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rcx)
pop    %rax
ret
cmpb   $0x0,0x2e8a(%rip)
jne    11d3 <cdiEncodeTimevalue+0xb3>
mov    %edx,%edi
xor    %eax,%eax
call   1040 <tunitNamePtr@plt>
lea    0xe6c(%rip),%rdi
lea    0xe78(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <Warning_@plt>
movb   $0x1,0x2e61(%rip)
pop    %rax
ret

LLVM IR (-O0):
@cdiEncodeTimevalue.lwarn = internal global i32 1
@__func__.cdiEncodeTimevalue = [19 x i8] c"cdiEncodeTimevalue\00"
@.str = [25 x i8] c"timeunit %s unsupported!\00"
define void @cdiEncodeTimevalue(i32 %0, i32 %1, i32 %2, double* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store double* %3, double** %8
%9 = load i32, i32* %7
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %18
11: ; preds = %4
%12 = load i32, i32* %5
%13 = sitofp i32 %12 to double
%14 = load i32, i32* %6
%15 = sitofp i32 %14 to double
%16 = call double @llvm.fmuladd.f64(double %13, double 8.640000e+04, double %15)
%17 = load double*, double** %8
store double %16, double* %17
br label %77
18: ; preds = %4
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, 2
br i1 %20, label %27, label %21
21: ; preds = %18
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, 3
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* %7
%26 = icmp eq i32 %25, 4
br i1 %26, label %27, label %35
27: ; preds = %24, %21, %18
%28 = load i32, i32* %5
%29 = sitofp i32 %28 to double
%30 = load i32, i32* %6
%31 = sitofp i32 %30 to double
%32 = fdiv double %31, 6.000000e+01
%33 = call double @llvm.fmuladd.f64(double %29, double 1.440000e+03, double %32)
%34 = load double*, double** %8
store double %33, double* %34
br label %76
35: ; preds = %24
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, 5
br i1 %37, label %47, label %38
38: ; preds = %35
%39 = load i32, i32* %7
%40 = icmp eq i32 %39, 6
br i1 %40, label %47, label %41
41: ; preds = %38
%42 = load i32, i32* %7
%43 = icmp eq i32 %42, 7
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i32, i32* %7
%46 = icmp eq i32 %45, 8
br i1 %46, label %47, label %55
47: ; preds = %44, %41, %38, %35
%48 = load i32, i32* %5
%49 = sitofp i32 %48 to double
%50 = load i32, i32* %6
%51 = sitofp i32 %50 to double
%52 = fdiv double %51, 3.600000e+03
%53 = call double @llvm.fmuladd.f64(double %49, double 2.400000e+01, double %52)
%54 = load double*, double** %8
store double %53, double* %54
br label %75
55: ; preds = %44
%56 = load i32, i32* %7
%57 = icmp eq i32 %56, 9
br i1 %57, label %58, label %66
58: ; preds = %55
%59 = load i32, i32* %5
%60 = sitofp i32 %59 to double
%61 = load i32, i32* %6
%62 = sitofp i32 %61 to double
%63 = fdiv double %62, 8.640000e+04
%64 = fadd double %60, %63
%65 = load double*, double** %8
store double %64, double* %65
br label %74
66: ; preds = %55
%67 = load i32, i32* @cdiEncodeTimevalue.lwarn
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %66
%70 = load i32, i32* %7
%71 = call i32 (i32, ...) bitcast (i32 (...)* @tunitNamePtr to i32 (i32, ...)*)(i32 %70)
%72 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @Warning_ to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__func__.cdiEncodeTimevalue, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %71)
store i32 0, i32* @cdiEncodeTimevalue.lwarn
br label %73
73: ; preds = %69, %66
br label %74
74: ; preds = %73, %58
br label %75
75: ; preds = %74, %47
br label %76
76: ; preds = %75, %27
br label %77
77: ; preds = %76, %11
ret void
}

LLVM IR (-O2):
@cdiEncodeTimevalue.lwarn = internal unnamed_addr global i1 false
@__func__.cdiEncodeTimevalue = [19 x i8] c"cdiEncodeTimevalue\00"
@.str = [25 x i8] c"timeunit %s unsupported!\00"
define void @cdiEncodeTimevalue(i32 %0, i32 %1, i32 %2, double* nocapture writeonly %3) {
switch i32 %2, label %14 [
i32 1, label %5
i32 4, label %9
i32 3, label %9
i32 2, label %9
]
5: ; preds = %4
%6 = sitofp i32 %0 to double
%7 = sitofp i32 %1 to double
%8 = tail call double @llvm.fmuladd.f64(double %6, double 8.640000e+04, double %7)
store double %8, double* %3
br label %34
9: ; preds = %4, %4, %4
%10 = sitofp i32 %0 to double
%11 = sitofp i32 %1 to double
%12 = fdiv double %11, 6.000000e+01
%13 = tail call double @llvm.fmuladd.f64(double %10, double 1.440000e+03, double %12)
store double %13, double* %3
br label %34
14: ; preds = %4
%15 = add i32 %2, -5
%16 = icmp ult i32 %15, 4
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = sitofp i32 %0 to double
%19 = sitofp i32 %1 to double
%20 = fdiv double %19, 3.600000e+03
%21 = tail call double @llvm.fmuladd.f64(double %18, double 2.400000e+01, double %20)
store double %21, double* %3
br label %34
22: ; preds = %14
%23 = icmp eq i32 %2, 9
br i1 %23, label %24, label %29
24: ; preds = %22
%25 = sitofp i32 %0 to double
%26 = sitofp i32 %1 to double
%27 = fdiv double %26, 8.640000e+04
%28 = fadd double %27, %25
store double %28, double* %3
br label %34
29: ; preds = %22
%30 = load i1, i1* @cdiEncodeTimevalue.lwarn
br i1 %30, label %34, label %31
31: ; preds = %29
%32 = tail call i32 (i32, ...) bitcast (i32 (...)* @tunitNamePtr to i32 (i32, ...)*)(i32 %2)
%33 = tail call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @Warning_ to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @__func__.cdiEncodeTimevalue, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %32)
store i1 true, i1* @cdiEncodeTimevalue.lwarn
br label %34
34: ; preds = %9, %24, %31, %29, %17, %5
ret void
}