double xpow10(int e) {
  double result = 1.0;
  static const double table[] = {10.0,    100.0,    1000.0,
                                 10000.0, 100000.0, 1000000.0};
  static const int size = sizeof(table) / sizeof(table[0]);
  if (e > 0) {
    if (e > size) {
      result = table[size - 1];
      for (e = e - size; e; e--)
        result *= (double)10.0;
    } else
      result = table[e - 1];
  }
  return result;
}


x86 assembly (clang, -O0):
<xpow10>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movsd  0xef1(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    118c <xpow10+0x8c>
cmpl   $0x6,-0x4(%rbp)
jle    116d <xpow10+0x6d>
movsd  0xf08(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x6,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1168 <xpow10+0x68>
movsd  0xeb8(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    113e <xpow10+0x3e>
jmp    1187 <xpow10+0x87>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0xe93(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    118c <xpow10+0x8c>
movsd  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<xpow10>:
test   %edi,%edi
jle    1143 <xpow10+0x43>
cmp    $0x7,%edi
jb     114c <xpow10+0x4c>
lea    -0x6(%rdi),%eax
add    $0xfffffff9,%edi
mov    %eax,%ecx
and    $0x7,%ecx
je     115c <xpow10+0x5c>
xor    %edx,%edx
movsd  0xee8(%rip),%xmm0
movsd  0xee8(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
mulsd  %xmm1,%xmm0
add    $0x1,%edx
cmp    %edx,%ecx
jne    1130 <xpow10+0x30>
sub    %edx,%eax
cmp    $0x7,%edi
jae    1169 <xpow10+0x69>
ret
movsd  0xeb5(%rip),%xmm0
ret
add    $0xffffffff,%edi
lea    0xeca(%rip),%rax
movsd  (%rax,%rdi,8),%xmm0
ret
movsd  0xea4(%rip),%xmm0
cmp    $0x7,%edi
jb     1142 <xpow10+0x42>
movsd  0xe9f(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
add    $0xfffffff8,%eax
jne    1180 <xpow10+0x80>
jmp    1142 <xpow10+0x42>

LLVM IR (-O0):
@xpow10.table = internal constant [6 x double] [double 1.000000e+01, double 1.000000e+02, double 1.000000e+03, double 1.000000e+04, double 1.000000e+05, double 1.000000e+06]
@xpow10.size = internal constant i32 6
define double @xpow10(i32 %0) {
%2 = alloca i32
%3 = alloca double
store i32 %0, i32* %2
store double 1.000000e+00, double* %3
%4 = load i32, i32* %2
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %30
6: ; preds = %1
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 6
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load double, double* getelementptr inbounds ([6 x double], [6 x double]* @xpow10.table, i64 0, i64 5)
store double %10, double* %3
%11 = load i32, i32* %2
%12 = sub nsw i32 %11, 6
store i32 %12, i32* %2
br label %13
13: ; preds = %19, %9
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load double, double* %3
%18 = fmul double %17, 1.000000e+01
store double %18, double* %3
br label %19
19: ; preds = %16
%20 = load i32, i32* %2
%21 = add nsw i32 %20, -1
store i32 %21, i32* %2
br label %13
22: ; preds = %13
br label %29
23: ; preds = %6
%24 = load i32, i32* %2
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [6 x double], [6 x double]* @xpow10.table, i64 0, i64 %26
%28 = load double, double* %27
store double %28, double* %3
br label %29
29: ; preds = %23, %22
br label %30
30: ; preds = %29, %1
%31 = load double, double* %3
ret double %31
}

LLVM IR (-O2):
@xpow10.table = internal unnamed_addr constant [6 x double] [double 1.000000e+01, double 1.000000e+02, double 1.000000e+03, double 1.000000e+04, double 1.000000e+05, double 1.000000e+06]
define double @xpow10(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %41
3: ; preds = %1
%4 = icmp ugt i32 %0, 6
br i1 %4, label %5, label %36
5: ; preds = %3
%6 = add i32 %0, -6
%7 = add i32 %0, -7
%8 = and i32 %6, 7
%9 = icmp eq i32 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %5, %10
%11 = phi double [ %14, %10 ], [ 1.000000e+06, %5 ]
%12 = phi i32 [ %15, %10 ], [ %6, %5 ]
%13 = phi i32 [ %16, %10 ], [ 0, %5 ]
%14 = fmul double %11, 1.000000e+01
%15 = add nsw i32 %12, -1
%16 = add i32 %13, 1
%17 = icmp eq i32 %16, %8
br i1 %17, label %18, label %10
18: ; preds = %10, %5
%19 = phi double [ undef, %5 ], [ %14, %10 ]
%20 = phi double [ 1.000000e+06, %5 ], [ %14, %10 ]
%21 = phi i32 [ %6, %5 ], [ %15, %10 ]
%22 = icmp ult i32 %7, 7
br i1 %22, label %41, label %23
23: ; preds = %18, %23
%24 = phi double [ %33, %23 ], [ %20, %18 ]
%25 = phi i32 [ %34, %23 ], [ %21, %18 ]
%26 = fmul double %24, 1.000000e+01
%27 = fmul double %26, 1.000000e+01
%28 = fmul double %27, 1.000000e+01
%29 = fmul double %28, 1.000000e+01
%30 = fmul double %29, 1.000000e+01
%31 = fmul double %30, 1.000000e+01
%32 = fmul double %31, 1.000000e+01
%33 = fmul double %32, 1.000000e+01
%34 = add nsw i32 %25, -8
%35 = icmp eq i32 %34, 0
br i1 %35, label %41, label %23
36: ; preds = %3
%37 = add nsw i32 %0, -1
%38 = zext i32 %37 to i64
%39 = getelementptr inbounds [6 x double], [6 x double]* @xpow10.table, i64 0, i64 %38
%40 = load double, double* %39
br label %41
41: ; preds = %18, %23, %36, %1
%42 = phi double [ %40, %36 ], [ 1.000000e+00, %1 ], [ %19, %18 ], [ %33, %23 ]
ret double %42
}