double hms2d(double hms) {
  int hours, mins, secs;
  double decimals;
  hours = (int)hms;
  decimals = (hms - hours) * 100;
  mins = (int)(decimals + 0.00005);
  secs = (int)((decimals - mins) * 100 + 0.00005);
  return hours + mins / 60.0 + secs / 3600.0;
}


x86 assembly (clang, -O0):
<hms2d>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xee9(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xee0(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  0xeb6(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb2(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
movsd  0xe85(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe68(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<hms2d>:
cvttpd2dq %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm2
subsd  %xmm2,%xmm0
movsd  0xeec(%rip),%xmm3
mulsd  %xmm3,%xmm0
movsd  0xee8(%rip),%xmm4
movapd %xmm0,%xmm1
addsd  %xmm4,%xmm1
cvttpd2dq %xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm4,%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
unpcklpd %xmm0,%xmm1
divpd  0xec0(%rip),%xmm1
addsd  %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @hms2d(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
store double %0, double* %2
%7 = load double, double* %2
%8 = fptosi double %7 to i32
store i32 %8, i32* %3
%9 = load double, double* %2
%10 = load i32, i32* %3
%11 = sitofp i32 %10 to double
%12 = fsub double %9, %11
%13 = fmul double %12, 1.000000e+02
store double %13, double* %6
%14 = load double, double* %6
%15 = fadd double %14, 5.000000e-05
%16 = fptosi double %15 to i32
store i32 %16, i32* %4
%17 = load double, double* %6
%18 = load i32, i32* %4
%19 = sitofp i32 %18 to double
%20 = fsub double %17, %19
%21 = call double @llvm.fmuladd.f64(double %20, double 1.000000e+02, double 5.000000e-05)
%22 = fptosi double %21 to i32
store i32 %22, i32* %5
%23 = load i32, i32* %3
%24 = sitofp i32 %23 to double
%25 = load i32, i32* %4
%26 = sitofp i32 %25 to double
%27 = fdiv double %26, 6.000000e+01
%28 = fadd double %24, %27
%29 = load i32, i32* %5
%30 = sitofp i32 %29 to double
%31 = fdiv double %30, 3.600000e+03
%32 = fadd double %28, %31
ret double %32
}

LLVM IR (-O2):
define double @hms2d(double %0) {
%2 = fptosi double %0 to i32
%3 = sitofp i32 %2 to double
%4 = fsub double %0, %3
%5 = fmul double %4, 1.000000e+02
%6 = fadd double %5, 5.000000e-05
%7 = fptosi double %6 to i32
%8 = sitofp i32 %7 to double
%9 = fsub double %5, %8
%10 = tail call double @llvm.fmuladd.f64(double %9, double 1.000000e+02, double 5.000000e-05)
%11 = fptosi double %10 to i32
%12 = sitofp i32 %11 to double
%13 = insertelement <2 x double> poison, double %8, i64 0
%14 = insertelement <2 x double> %13, double %12, i64 1
%15 = fdiv <2 x double> %14, <double 6.000000e+01, double 3.600000e+03>
%16 = extractelement <2 x double> %15, i64 0
%17 = fadd double %16, %3
%18 = extractelement <2 x double> %15, i64 1
%19 = fadd double %17, %18
ret double %19
}