int round_125_cat(double value) {
  if (value < 0)
    value *= -1;
  if (value < 0.000001)
    return 10;
  while (value > 1000)
    value /= 10;
  while (value < 100)
    value *= 10;
  if (value > 670) {
    return 10;
  } else if (value > 300) {
    return 50;
  } else if (value > 135) {
    return 20;
  } else {
    return 10;
  }
  return 10;
}


x86 assembly (clang, -O0):
<round_125_cat>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1129 <round_125_cat+0x29>
movsd  0xee1(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xed7(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1148 <round_125_cat+0x48>
movl   $0xa,-0x4(%rbp)
jmp    121e <round_125_cat+0x11e>
jmp    114d <round_125_cat+0x4d>
movsd  -0x10(%rbp),%xmm0
movsd  0xeb6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117f <round_125_cat+0x7f>
movsd  -0x10(%rbp),%xmm0
movsd  0xec7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    114d <round_125_cat+0x4d>
jmp    1184 <round_125_cat+0x84>
movsd  0xe8c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11ae <round_125_cat+0xae>
movsd  0xe99(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1184 <round_125_cat+0x84>
movsd  -0x10(%rbp),%xmm0
movsd  0xe65(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d1 <round_125_cat+0xd1>
movl   $0xa,-0x4(%rbp)
jmp    121e <round_125_cat+0x11e>
movsd  -0x10(%rbp),%xmm0
movsd  0xe4a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11f4 <round_125_cat+0xf4>
movl   $0x32,-0x4(%rbp)
jmp    121e <round_125_cat+0x11e>
movsd  -0x10(%rbp),%xmm0
movsd  0xe2f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1217 <round_125_cat+0x117>
movl   $0x14,-0x4(%rbp)
jmp    121e <round_125_cat+0x11e>
movl   $0xa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<round_125_cat>:
movapd 0xef8(%rip),%xmm2
xorpd  %xmm0,%xmm2
xorpd  %xmm3,%xmm3
movapd %xmm0,%xmm1
cmpltsd %xmm3,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
mov    $0xa,%eax
movsd  0xede(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     11b8 <round_125_cat+0xb8>
ucomisd 0xed4(%rip),%xmm1
jbe    116a <round_125_cat+0x6a>
movsd  0xed2(%rip),%xmm0
movsd  0xec2(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
divsd  %xmm0,%xmm1
ucomisd %xmm2,%xmm1
ja     1160 <round_125_cat+0x60>
movsd  0xeb6(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    118a <round_125_cat+0x8a>
movsd  0xea0(%rip),%xmm2
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
ja     1180 <round_125_cat+0x80>
ucomisd 0xe9e(%rip),%xmm1
ja     11b8 <round_125_cat+0xb8>
mov    $0x32,%eax
ucomisd 0xe97(%rip),%xmm1
ja     11b8 <round_125_cat+0xb8>
ucomisd 0xe95(%rip),%xmm1
mov    $0x14,%ecx
mov    $0xa,%eax
cmova  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @round_125_cat(double %0) {
%2 = alloca i32
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp olt double %4, 0.000000e+00
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load double, double* %3
%8 = fmul double %7, -1.000000e+00
store double %8, double* %3
br label %9
9: ; preds = %6, %1
%10 = load double, double* %3
%11 = fcmp olt double %10, 0x3EB0C6F7A0B5ED8D
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 10, i32* %2
br label %40
13: ; preds = %9
br label %14
14: ; preds = %17, %13
%15 = load double, double* %3
%16 = fcmp ogt double %15, 1.000000e+03
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load double, double* %3
%19 = fdiv double %18, 1.000000e+01
store double %19, double* %3
br label %14
20: ; preds = %14
br label %21
21: ; preds = %24, %20
%22 = load double, double* %3
%23 = fcmp olt double %22, 1.000000e+02
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load double, double* %3
%26 = fmul double %25, 1.000000e+01
store double %26, double* %3
br label %21
27: ; preds = %21
%28 = load double, double* %3
%29 = fcmp ogt double %28, 6.700000e+02
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 10, i32* %2
br label %40
31: ; preds = %27
%32 = load double, double* %3
%33 = fcmp ogt double %32, 3.000000e+02
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 50, i32* %2
br label %40
35: ; preds = %31
%36 = load double, double* %3
%37 = fcmp ogt double %36, 1.350000e+02
br i1 %37, label %38, label %39
38: ; preds = %35
store i32 20, i32* %2
br label %40
39: ; preds = %35
store i32 10, i32* %2
br label %40
40: ; preds = %39, %38, %34, %30, %12
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
define i32 @round_125_cat(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
%3 = fneg double %0
%4 = select i1 %2, double %3, double %0
%5 = fcmp olt double %4, 0x3EB0C6F7A0B5ED8D
br i1 %5, label %27, label %6
6: ; preds = %1
%7 = fcmp ogt double %4, 1.000000e+03
br i1 %7, label %11, label %8
8: ; preds = %11, %6
%9 = phi double [ %4, %6 ], [ %13, %11 ]
%10 = fcmp olt double %9, 1.000000e+02
br i1 %10, label %15, label %19
11: ; preds = %6, %11
%12 = phi double [ %13, %11 ], [ %4, %6 ]
%13 = fdiv double %12, 1.000000e+01
%14 = fcmp ogt double %13, 1.000000e+03
br i1 %14, label %11, label %8
15: ; preds = %8, %15
%16 = phi double [ %17, %15 ], [ %9, %8 ]
%17 = fmul double %16, 1.000000e+01
%18 = fcmp olt double %17, 1.000000e+02
br i1 %18, label %15, label %19
19: ; preds = %15, %8
%20 = phi double [ %9, %8 ], [ %17, %15 ]
%21 = fcmp ogt double %20, 6.700000e+02
br i1 %21, label %27, label %22
22: ; preds = %19
%23 = fcmp ogt double %20, 3.000000e+02
br i1 %23, label %27, label %24
24: ; preds = %22
%25 = fcmp ogt double %20, 1.350000e+02
%26 = select i1 %25, i32 20, i32 10
br label %27
27: ; preds = %24, %22, %19, %1
%28 = phi i32 [ 10, %1 ], [ 10, %19 ], [ 50, %22 ], [ %26, %24 ]
ret i32 %28
}