double parse_multiplier_string(char *str) {
  switch (str[0]) {
  case 'k':
    return 1000;
  case 'K':
    return 1024;
  case 'm':
    return 1000000;
  case 'M':
    return 1048578;
  case 'g':
    return 1000000000;
  case 'G':
    return 1073741824;
  case 't':
    return 1000000000000LL;
  case 'T':
    return 1099511627776LL;
  case 'p':
    return 1000000000000000LL;
  case 'P':
    return 1125899906842624LL;
  case 'e':
    return 1000000000000000000LL;
  case 'E':
    return 1152921504606846976LL;
  }
  return 1;
}


x86 assembly (clang, -O0):
<parse_multiplier_string>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffbb,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x2f,%eax
ja     120d <parse_multiplier_string+0x10d>
mov    -0x18(%rbp),%rax
lea    0xf3c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xf1b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xf01(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xee7(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xecd(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xe99(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xe7f(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xe65(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xe4b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xe31(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xe17(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xdfd(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    121a <parse_multiplier_string+0x11a>
movsd  0xe4b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_multiplier_string>:
movsbl (%rdi),%eax
add    $0xffffffbb,%eax
cmp    $0x2f,%eax
ja     112c <parse_multiplier_string+0x2c>
movsd  0xeed(%rip),%xmm0
lea    0xf4e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xedd(%rip),%xmm0
ret
movsd  0xf2c(%rip),%xmm0
ret
movsd  0xefb(%rip),%xmm0
ret
movsd  0xf12(%rip),%xmm0
ret
movsd  0xef9(%rip),%xmm0
ret
movsd  0xec0(%rip),%xmm0
ret
movsd  0xec7(%rip),%xmm0
ret
movsd  0xea6(%rip),%xmm0
ret
movsd  0xecd(%rip),%xmm0
ret
movsd  0xed4(%rip),%xmm0
ret
movsd  0xe9b(%rip),%xmm0
ret
movsd  0xea2(%rip),%xmm0
ret

LLVM IR (-O0):
define double @parse_multiplier_string(i8* %0) {
%2 = alloca double
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %20 [
i32 107, label %8
i32 75, label %9
i32 109, label %10
i32 77, label %11
i32 103, label %12
i32 71, label %13
i32 116, label %14
i32 84, label %15
i32 112, label %16
i32 80, label %17
i32 101, label %18
i32 69, label %19
]
8: ; preds = %1
store double 1.000000e+03, double* %2
br label %21
9: ; preds = %1
store double 1.024000e+03, double* %2
br label %21
10: ; preds = %1
store double 1.000000e+06, double* %2
br label %21
11: ; preds = %1
store double 0x4130000200000000, double* %2
br label %21
12: ; preds = %1
store double 1.000000e+09, double* %2
br label %21
13: ; preds = %1
store double 0x41D0000000000000, double* %2
br label %21
14: ; preds = %1
store double 1.000000e+12, double* %2
br label %21
15: ; preds = %1
store double 0x4270000000000000, double* %2
br label %21
16: ; preds = %1
store double 1.000000e+15, double* %2
br label %21
17: ; preds = %1
store double 0x4310000000000000, double* %2
br label %21
18: ; preds = %1
store double 1.000000e+18, double* %2
br label %21
19: ; preds = %1
store double 0x43B0000000000000, double* %2
br label %21
20: ; preds = %1
store double 1.000000e+00, double* %2
br label %21
21: ; preds = %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %8
%22 = load double, double* %2
ret double %22
}

LLVM IR (-O2):
define double @parse_multiplier_string(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
switch i32 %3, label %15 [
i32 107, label %16
i32 75, label %4
i32 109, label %5
i32 77, label %6
i32 103, label %7
i32 71, label %8
i32 116, label %9
i32 84, label %10
i32 112, label %11
i32 80, label %12
i32 101, label %13
i32 69, label %14
]
4: ; preds = %1
br label %16
5: ; preds = %1
br label %16
6: ; preds = %1
br label %16
7: ; preds = %1
br label %16
8: ; preds = %1
br label %16
9: ; preds = %1
br label %16
10: ; preds = %1
br label %16
11: ; preds = %1
br label %16
12: ; preds = %1
br label %16
13: ; preds = %1
br label %16
14: ; preds = %1
br label %16
15: ; preds = %1
br label %16
16: ; preds = %1, %15, %14, %13, %12, %11, %10, %9, %8, %7, %6, %5, %4
%17 = phi double [ 1.000000e+00, %15 ], [ 0x43B0000000000000, %14 ], [ 1.000000e+18, %13 ], [ 0x4310000000000000, %12 ], [ 1.000000e+15, %11 ], [ 0x4270000000000000, %10 ], [ 1.000000e+12, %9 ], [ 0x41D0000000000000, %8 ], [ 1.000000e+09, %7 ], [ 0x4130000200000000, %6 ], [ 1.000000e+06, %5 ], [ 1.024000e+03, %4 ], [ 1.000000e+03, %1 ]
ret double %17
}