#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double pow(double, int);
double strtod(char const *, char **);
char tolower(int);
double SiPrefixToDouble(const char *string, const double interval) {
  char *q;
  double scale, value;
  value = strtod(string, &q);
  scale = 1000.0;
  if ((*q != '\0') && (tolower((int)((unsigned char)*(q + 1))) == 'i'))
    scale = 1024.0;
  switch (tolower((int)((unsigned char)*q))) {
  case '%':
    value *= pow(scale, 0) * interval / 100.0;
    break;
  case 'k':
    value *= pow(scale, 1);
    break;
  case 'm':
    value *= pow(scale, 2);
    break;
  case 'g':
    value *= pow(scale, 3);
    break;
  case 't':
    value *= pow(scale, 4);
    break;
  case 'p':
    value *= pow(scale, 5);
    break;
  case 'e':
    value *= pow(scale, 6);
    break;
  case 'z':
    value *= pow(scale, 7);
    break;
  case 'y':
    value *= pow(scale, 8);
    break;
  default:
    break;
  }
  return (value);
}


x86 assembly (clang, -O0):
<SiPrefixToDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xea5(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1196 <SiPrefixToDouble+0x66>
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1040 <tolower@plt>
movsbl %al,%eax
cmp    $0x69,%eax
jne    1196 <SiPrefixToDouble+0x66>
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1040 <tolower@plt>
movsbl %al,%eax
add    $0xffffffdb,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x55,%eax
ja     12e7 <SiPrefixToDouble+0x1b7>
mov    -0x30(%rbp),%rax
lea    0xe56(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x20(%rbp),%xmm0
xor    %edi,%edi
call   1050 <pow@plt>
mulsd  -0x10(%rbp),%xmm0
movsd  0xe2c(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12ec <SiPrefixToDouble+0x1bc>
movsd  -0x20(%rbp),%xmm0
mov    $0x1,%edi
call   1050 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12ec <SiPrefixToDouble+0x1bc>
movsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12ec <SiPrefixToDouble+0x1bc>
movsd  -0x20(%rbp),%xmm0
mov    $0x3,%edi
call   1050 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12ec <SiPrefixToDouble+0x1bc>
movsd  -0x20(%rbp),%xmm0
mov    $0x4,%edi
call   1050 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12ec <SiPrefixToDouble+0x1bc>
movsd  -0x20(%rbp),%xmm0
mov    $0x5,%edi
call   1050 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12ec <SiPrefixToDouble+0x1bc>
movsd  -0x20(%rbp),%xmm0
mov    $0x6,%edi
call   1050 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12ec <SiPrefixToDouble+0x1bc>
movsd  -0x20(%rbp),%xmm0
mov    $0x7,%edi
call   1050 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12ec <SiPrefixToDouble+0x1bc>
movsd  -0x20(%rbp),%xmm0
mov    $0x8,%edi
call   1050 <pow@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12ec <SiPrefixToDouble+0x1bc>
jmp    12ec <SiPrefixToDouble+0x1bc>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SiPrefixToDouble>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm0,0x10(%rsp)
lea    0x18(%rsp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,(%rsp)
mov    0x18(%rsp),%rbx
cmpb   $0x0,(%rbx)
je     117b <SiPrefixToDouble+0x4b>
movzbl 0x1(%rbx),%edi
call   1040 <tolower@plt>
xor    %ecx,%ecx
cmp    $0x69,%al
sete   %cl
lea    0xea5(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movzbl (%rbx),%edi
jmp    118b <SiPrefixToDouble+0x5b>
movsd  0xe7d(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %edi,%edi
call   1040 <tolower@plt>
movsbl %al,%eax
add    $0xffffffdb,%eax
cmp    $0x55,%eax
ja     124a <SiPrefixToDouble+0x11a>
lea    0xe7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
movsd  (%rsp),%xmm0
jmp    *%rax
movsd  0x8(%rsp),%xmm0
xor    %edi,%edi
call   1050 <pow@plt>
mulsd  0x10(%rsp),%xmm0
divsd  0xe39(%rip),%xmm0
jmp    123c <SiPrefixToDouble+0x10c>
movsd  0x8(%rsp),%xmm0
mov    $0x6,%edi
jmp    1237 <SiPrefixToDouble+0x107>
movsd  0x8(%rsp),%xmm0
mov    $0x3,%edi
jmp    1237 <SiPrefixToDouble+0x107>
movsd  0x8(%rsp),%xmm0
mov    $0x1,%edi
jmp    1237 <SiPrefixToDouble+0x107>
movsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
jmp    1237 <SiPrefixToDouble+0x107>
movsd  0x8(%rsp),%xmm0
mov    $0x5,%edi
jmp    1237 <SiPrefixToDouble+0x107>
movsd  0x8(%rsp),%xmm0
mov    $0x4,%edi
jmp    1237 <SiPrefixToDouble+0x107>
movsd  0x8(%rsp),%xmm0
mov    $0x8,%edi
jmp    1237 <SiPrefixToDouble+0x107>
movsd  0x8(%rsp),%xmm0
mov    $0x7,%edi
call   1050 <pow@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @SiPrefixToDouble(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca i8*
%6 = alloca double
%7 = alloca double
store i8* %0, i8** %3
store double %1, double* %4
%8 = load i8*, i8** %3
%9 = call double @strtod(i8* %8, i8** %5)
store double %9, double* %7
store double 1.000000e+03, double* %6
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %23
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = call signext i8 @tolower(i32 %18)
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 105
br i1 %21, label %22, label %23
22: ; preds = %14
store double 1.024000e+03, double* %6
br label %23
23: ; preds = %22, %14, %2
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = call signext i8 @tolower(i32 %26)
%28 = sext i8 %27 to i32
switch i32 %28, label %77 [
i32 37, label %29
i32 107, label %37
i32 109, label %42
i32 103, label %47
i32 116, label %52
i32 112, label %57
i32 101, label %62
i32 122, label %67
i32 121, label %72
]
29: ; preds = %23
%30 = load double, double* %6
%31 = call double @pow(double %30, i32 0)
%32 = load double, double* %4
%33 = fmul double %31, %32
%34 = fdiv double %33, 1.000000e+02
%35 = load double, double* %7
%36 = fmul double %35, %34
store double %36, double* %7
br label %78
37: ; preds = %23
%38 = load double, double* %6
%39 = call double @pow(double %38, i32 1)
%40 = load double, double* %7
%41 = fmul double %40, %39
store double %41, double* %7
br label %78
42: ; preds = %23
%43 = load double, double* %6
%44 = call double @pow(double %43, i32 2)
%45 = load double, double* %7
%46 = fmul double %45, %44
store double %46, double* %7
br label %78
47: ; preds = %23
%48 = load double, double* %6
%49 = call double @pow(double %48, i32 3)
%50 = load double, double* %7
%51 = fmul double %50, %49
store double %51, double* %7
br label %78
52: ; preds = %23
%53 = load double, double* %6
%54 = call double @pow(double %53, i32 4)
%55 = load double, double* %7
%56 = fmul double %55, %54
store double %56, double* %7
br label %78
57: ; preds = %23
%58 = load double, double* %6
%59 = call double @pow(double %58, i32 5)
%60 = load double, double* %7
%61 = fmul double %60, %59
store double %61, double* %7
br label %78
62: ; preds = %23
%63 = load double, double* %6
%64 = call double @pow(double %63, i32 6)
%65 = load double, double* %7
%66 = fmul double %65, %64
store double %66, double* %7
br label %78
67: ; preds = %23
%68 = load double, double* %6
%69 = call double @pow(double %68, i32 7)
%70 = load double, double* %7
%71 = fmul double %70, %69
store double %71, double* %7
br label %78
72: ; preds = %23
%73 = load double, double* %6
%74 = call double @pow(double %73, i32 8)
%75 = load double, double* %7
%76 = fmul double %75, %74
store double %76, double* %7
br label %78
77: ; preds = %23
br label %78
78: ; preds = %77, %72, %67, %62, %57, %52, %47, %42, %37, %29
%79 = load double, double* %7
ret double %79
}

LLVM IR (-O2):
define double @SiPrefixToDouble(i8* %0, double %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call double @strtod(i8* %0, i8** %3)
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = tail call signext i8 @tolower(i32 %12)
%14 = icmp eq i8 %13, 105
%15 = select i1 %14, double 1.024000e+03, double 1.000000e+03
%16 = load i8, i8* %6
%17 = zext i8 %16 to i32
br label %18
18: ; preds = %9, %2
%19 = phi i32 [ 0, %2 ], [ %17, %9 ]
%20 = phi double [ 1.000000e+03, %2 ], [ %15, %9 ]
%21 = tail call signext i8 @tolower(i32 %19)
%22 = sext i8 %21 to i32
switch i32 %22, label %52 [
i32 37, label %23
i32 107, label %28
i32 109, label %31
i32 103, label %34
i32 116, label %37
i32 112, label %40
i32 101, label %43
i32 122, label %46
i32 121, label %49
]
23: ; preds = %18
%24 = tail call double @pow(double %20, i32 0)
%25 = fmul double %24, %1
%26 = fdiv double %25, 1.000000e+02
%27 = fmul double %5, %26
br label %52
28: ; preds = %18
%29 = tail call double @pow(double %20, i32 1)
%30 = fmul double %5, %29
br label %52
31: ; preds = %18
%32 = tail call double @pow(double %20, i32 2)
%33 = fmul double %5, %32
br label %52
34: ; preds = %18
%35 = tail call double @pow(double %20, i32 3)
%36 = fmul double %5, %35
br label %52
37: ; preds = %18
%38 = tail call double @pow(double %20, i32 4)
%39 = fmul double %5, %38
br label %52
40: ; preds = %18
%41 = tail call double @pow(double %20, i32 5)
%42 = fmul double %5, %41
br label %52
43: ; preds = %18
%44 = tail call double @pow(double %20, i32 6)
%45 = fmul double %5, %44
br label %52
46: ; preds = %18
%47 = tail call double @pow(double %20, i32 7)
%48 = fmul double %5, %47
br label %52
49: ; preds = %18
%50 = tail call double @pow(double %20, i32 8)
%51 = fmul double %5, %50
br label %52
52: ; preds = %18, %49, %46, %43, %40, %37, %34, %31, %28, %23
%53 = phi double [ %5, %18 ], [ %51, %49 ], [ %48, %46 ], [ %45, %43 ], [ %42, %40 ], [ %39, %37 ], [ %36, %34 ], [ %33, %31 ], [ %30, %28 ], [ %27, %23 ]
ret double %53
}