int stub_math_exponent(double value) {
  double tmp = value < 0.0 ? -value : value;
  int exp = 0;
  while (tmp < 1.0 && tmp > 0.0 && --exp > -99)
    tmp *= 10;
  while (tmp >= 10.0 && ++exp < 99)
    tmp /= 10;
  return exp;
}


x86 assembly (clang, -O0):
<stub_math_exponent>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    113d <stub_math_exponent+0x3d>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1147 <stub_math_exponent+0x47>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
movsd  0xe9e(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
mov    %al,-0x21(%rbp)
jbe    1199 <stub_math_exponent+0x99>
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x21(%rbp)
jbe    1199 <stub_math_exponent+0x99>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0xffffff9d,%eax
setg   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11a9 <stub_math_exponent+0xa9>
jmp    11c0 <stub_math_exponent+0xc0>
movsd  0xe57(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1158 <stub_math_exponent+0x58>
jmp    11c5 <stub_math_exponent+0xc5>
movsd  -0x10(%rbp),%xmm0
xor    %eax,%eax
movsd  0xe34(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x22(%rbp)
jb     11f3 <stub_math_exponent+0xf3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x63,%eax
setl   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    1203 <stub_math_exponent+0x103>
jmp    121e <stub_math_exponent+0x11e>
movsd  -0x10(%rbp),%xmm0
movsd  0xdf8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    11c5 <stub_math_exponent+0xc5>
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<stub_math_exponent>:
movapd 0xef8(%rip),%xmm3
xorpd  %xmm0,%xmm3
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm1
cmpltsd %xmm2,%xmm1
andpd  %xmm1,%xmm3
andnpd %xmm0,%xmm1
orpd   %xmm3,%xmm1
xor    %eax,%eax
movsd  0xee1(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    119d <stub_math_exponent+0x9d>
ucomisd %xmm2,%xmm1
jbe    119d <stub_math_exponent+0x9d>
mov    $0xffffffff,%eax
movsd  0xed0(%rip),%xmm2
xorpd  %xmm3,%xmm3
nopl   0x0(%rax)
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    119d <stub_math_exponent+0x9d>
ucomisd %xmm3,%xmm1
jbe    119d <stub_math_exponent+0x9d>
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    119a <stub_math_exponent+0x9a>
ucomisd %xmm3,%xmm1
jbe    119a <stub_math_exponent+0x9a>
lea    0x1(%rax),%ecx
cmp    $0xffffffa1,%ecx
jl     11c6 <stub_math_exponent+0xc6>
mulsd  %xmm2,%xmm1
add    $0xfffffffd,%eax
ucomisd %xmm1,%xmm0
jbe    118b <stub_math_exponent+0x8b>
ucomisd %xmm3,%xmm1
ja     1150 <stub_math_exponent+0x50>
add    $0x1,%eax
ucomisd 0xe82(%rip),%xmm1
jae    11a7 <stub_math_exponent+0xa7>
jmp    11d5 <stub_math_exponent+0xd5>
add    $0xffffffff,%eax
ucomisd 0xe73(%rip),%xmm1
jb     11d5 <stub_math_exponent+0xd5>
movsd  0xe69(%rip),%xmm0
nop
mov    %eax,%ecx
lea    0x1(%rcx),%eax
divsd  %xmm0,%xmm1
cmp    $0x61,%ecx
jg     11d5 <stub_math_exponent+0xd5>
ucomisd %xmm0,%xmm1
jae    11b0 <stub_math_exponent+0xb0>
jmp    11d5 <stub_math_exponent+0xd5>
mov    $0xffffff9d,%eax
ucomisd 0xe45(%rip),%xmm1
jae    11a7 <stub_math_exponent+0xa7>
ret

LLVM IR (-O0):
define i32 @stub_math_exponent(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %2
%5 = load double, double* %2
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load double, double* %2
%9 = fneg double %8
br label %12
10: ; preds = %1
%11 = load double, double* %2
br label %12
12: ; preds = %10, %7
%13 = phi double [ %9, %7 ], [ %11, %10 ]
store double %13, double* %3
store i32 0, i32* %4
br label %14
14: ; preds = %26, %12
%15 = load double, double* %3
%16 = fcmp olt double %15, 1.000000e+00
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load double, double* %3
%19 = fcmp ogt double %18, 0.000000e+00
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i32, i32* %4
%22 = add nsw i32 %21, -1
store i32 %22, i32* %4
%23 = icmp sgt i32 %22, -99
br label %24
24: ; preds = %20, %17, %14
%25 = phi i1 [ false, %17 ], [ false, %14 ], [ %23, %20 ]
br i1 %25, label %26, label %29
26: ; preds = %24
%27 = load double, double* %3
%28 = fmul double %27, 1.000000e+01
store double %28, double* %3
br label %14
29: ; preds = %24
br label %30
30: ; preds = %39, %29
%31 = load double, double* %3
%32 = fcmp oge double %31, 1.000000e+01
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
%36 = icmp slt i32 %35, 99
br label %37
37: ; preds = %33, %30
%38 = phi i1 [ false, %30 ], [ %36, %33 ]
br i1 %38, label %39, label %42
39: ; preds = %37
%40 = load double, double* %3
%41 = fdiv double %40, 1.000000e+01
store double %41, double* %3
br label %30
42: ; preds = %37
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
define i32 @stub_math_exponent(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, 1.000000e+00
%6 = fcmp ogt double %4, 0.000000e+00
%7 = and i1 %5, %6
br i1 %7, label %8, label %32
8: ; preds = %1, %23
%9 = phi i32 [ %21, %23 ], [ 0, %1 ]
%10 = phi double [ %24, %23 ], [ %4, %1 ]
%11 = fmul double %10, 1.000000e+01
%12 = fcmp olt double %11, 1.000000e+00
%13 = fcmp ogt double %11, 0.000000e+00
%14 = and i1 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %8
%16 = fmul double %11, 1.000000e+01
%17 = fcmp olt double %16, 1.000000e+00
%18 = fcmp ogt double %16, 0.000000e+00
%19 = and i1 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %15
%21 = add nsw i32 %9, -3
%22 = icmp sgt i32 %9, -96
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = fmul double %16, 1.000000e+01
%25 = fcmp olt double %24, 1.000000e+00
%26 = fcmp ogt double %24, 0.000000e+00
%27 = and i1 %25, %26
br i1 %27, label %8, label %32
28: ; preds = %15
%29 = add nsw i32 %9, -2
br label %32
30: ; preds = %8
%31 = add nsw i32 %9, -1
br label %32
32: ; preds = %28, %30, %23, %20, %1
%33 = phi double [ %4, %1 ], [ %16, %28 ], [ %11, %30 ], [ %24, %23 ], [ %16, %20 ]
%34 = phi i32 [ 0, %1 ], [ %29, %28 ], [ %31, %30 ], [ %21, %23 ], [ -99, %20 ]
%35 = fcmp ult double %33, 1.000000e+01
br i1 %35, label %44, label %36
36: ; preds = %32, %36
%37 = phi i32 [ %39, %36 ], [ %34, %32 ]
%38 = phi double [ %41, %36 ], [ %33, %32 ]
%39 = add nsw i32 %37, 1
%40 = icmp sgt i32 %37, 97
%41 = fdiv double %38, 1.000000e+01
%42 = fcmp ult double %41, 1.000000e+01
%43 = select i1 %40, i1 true, i1 %42
br i1 %43, label %44, label %36
44: ; preds = %36, %32
%45 = phi i32 [ %34, %32 ], [ %39, %36 ]
ret i32 %45
}