double _round_double2(double d) {
  double r = 0.0;
  r = (d - (long)d) * 100.0;
  if ((r - (long)r) > 0.5)
    return ((long)d + (((long)r + 1) / 100.0));
  return ((long)d + ((long)r / 100.0));
}


x86 assembly (clang, -O0):
<_round_double2>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
cvttsd2si -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xedb(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
cvttsd2si -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xeae(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1190 <_round_double2+0x90>
cvttsd2si -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
cvttsd2si -0x18(%rbp),%rax
add    $0x1,%rax
cvtsi2sd %rax,%xmm1
movsd  0xe8a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11bb <_round_double2+0xbb>
cvttsd2si -0x10(%rbp),%rax
cvtsi2sd %rax,%xmm0
cvttsd2si -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xe5a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<_round_double2>:
cvttsd2si %xmm0,%rax
cvtsi2sd %rax,%xmm2
subsd  %xmm2,%xmm0
movsd  0xeea(%rip),%xmm3
mulsd  %xmm3,%xmm0
cvttsd2si %xmm0,%rax
cvtsi2sd %rax,%xmm4
add    $0x1,%rax
cvtsi2sd %rax,%xmm5
subsd  %xmm4,%xmm0
movsd  0xecf(%rip),%xmm1
cmpltsd %xmm0,%xmm1
andpd  %xmm1,%xmm5
andnpd %xmm4,%xmm1
orpd   %xmm5,%xmm1
divsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @_round_double2(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %3
store double 0.000000e+00, double* %4
%5 = load double, double* %3
%6 = load double, double* %3
%7 = fptosi double %6 to i64
%8 = sitofp i64 %7 to double
%9 = fsub double %5, %8
%10 = fmul double %9, 1.000000e+02
store double %10, double* %4
%11 = load double, double* %4
%12 = load double, double* %4
%13 = fptosi double %12 to i64
%14 = sitofp i64 %13 to double
%15 = fsub double %11, %14
%16 = fcmp ogt double %15, 5.000000e-01
br i1 %16, label %17, label %27
17: ; preds = %1
%18 = load double, double* %3
%19 = fptosi double %18 to i64
%20 = sitofp i64 %19 to double
%21 = load double, double* %4
%22 = fptosi double %21 to i64
%23 = add nsw i64 %22, 1
%24 = sitofp i64 %23 to double
%25 = fdiv double %24, 1.000000e+02
%26 = fadd double %20, %25
store double %26, double* %2
br label %36
27: ; preds = %1
%28 = load double, double* %3
%29 = fptosi double %28 to i64
%30 = sitofp i64 %29 to double
%31 = load double, double* %4
%32 = fptosi double %31 to i64
%33 = sitofp i64 %32 to double
%34 = fdiv double %33, 1.000000e+02
%35 = fadd double %30, %34
store double %35, double* %2
br label %36
36: ; preds = %27, %17
%37 = load double, double* %2
ret double %37
}

LLVM IR (-O2):
define double @_round_double2(double %0) {
%2 = fptosi double %0 to i64
%3 = sitofp i64 %2 to double
%4 = fsub double %0, %3
%5 = fmul double %4, 1.000000e+02
%6 = fptosi double %5 to i64
%7 = sitofp i64 %6 to double
%8 = fsub double %5, %7
%9 = fcmp ogt double %8, 5.000000e-01
%10 = add nsw i64 %6, 1
%11 = sitofp i64 %10 to double
%12 = select i1 %9, double %11, double %7
%13 = fdiv double %12, 1.000000e+02
%14 = fadd double %13, %3
ret double %14
}