#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 InterpretLocaleValue(char const *, char **);
double pow(double, int);
char tolower(int);
double SiPrefixToDouble(const char *string, const double interval) {
  char *q;
  double scale, value;
  value = InterpretLocaleValue(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 <InterpretLocaleValue@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>:
sub    $0x28,%rsp
movsd  %xmm0,0x20(%rsp)
lea    0x18(%rsp),%rsi
call   1030 <InterpretLocaleValue@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rsp),%rax
cmpb   $0x0,(%rax)
je     1180 <SiPrefixToDouble+0x50>
movzbl 0x1(%rax),%edi
call   1040 <tolower@plt>
xor    %ecx,%ecx
cmp    $0x69,%al
sete   %cl
lea    0xea5(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x18(%rsp),%rax
movzbl (%rax),%edi
jmp    1190 <SiPrefixToDouble+0x60>
movsd  0xe78(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
call   1040 <tolower@plt>
movsbl %al,%eax
add    $0xffffffdb,%eax
cmp    $0x55,%eax
ja     1252 <SiPrefixToDouble+0x122>
lea    0xe75(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
movsd  0x8(%rsp),%xmm0
jmp    *%rax
movsd  0x10(%rsp),%xmm0
xor    %edi,%edi
call   1050 <pow@plt>
mulsd  0x20(%rsp),%xmm0
divsd  0xe33(%rip),%xmm0
jmp    1242 <SiPrefixToDouble+0x112>
movsd  0x10(%rsp),%xmm0
mov    $0x6,%edi
jmp    123d <SiPrefixToDouble+0x10d>
movsd  0x10(%rsp),%xmm0
mov    $0x3,%edi
jmp    123d <SiPrefixToDouble+0x10d>
movsd  0x10(%rsp),%xmm0
mov    $0x1,%edi
jmp    123d <SiPrefixToDouble+0x10d>
movsd  0x10(%rsp),%xmm0
mov    $0x2,%edi
jmp    123d <SiPrefixToDouble+0x10d>
movsd  0x10(%rsp),%xmm0
mov    $0x5,%edi
jmp    123d <SiPrefixToDouble+0x10d>
movsd  0x10(%rsp),%xmm0
mov    $0x4,%edi
jmp    123d <SiPrefixToDouble+0x10d>
movsd  0x10(%rsp),%xmm0
mov    $0x8,%edi
jmp    123d <SiPrefixToDouble+0x10d>
movsd  0x10(%rsp),%xmm0
mov    $0x7,%edi
call   1050 <pow@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
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 @InterpretLocaleValue(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 @InterpretLocaleValue(i8* %0, i8** %3)
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %19, 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 = 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** %3
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
br label %19
19: ; preds = %9, %2
%20 = phi i32 [ 0, %2 ], [ %18, %9 ]
%21 = phi double [ 1.000000e+03, %2 ], [ %15, %9 ]
%22 = call signext i8 @tolower(i32 %20)
%23 = sext i8 %22 to i32
switch i32 %23, label %53 [
i32 37, label %24
i32 107, label %29
i32 109, label %32
i32 103, label %35
i32 116, label %38
i32 112, label %41
i32 101, label %44
i32 122, label %47
i32 121, label %50
]
24: ; preds = %19
%25 = call double @pow(double %21, i32 0)
%26 = fmul double %25, %1
%27 = fdiv double %26, 1.000000e+02
%28 = fmul double %5, %27
br label %53
29: ; preds = %19
%30 = call double @pow(double %21, i32 1)
%31 = fmul double %5, %30
br label %53
32: ; preds = %19
%33 = call double @pow(double %21, i32 2)
%34 = fmul double %5, %33
br label %53
35: ; preds = %19
%36 = call double @pow(double %21, i32 3)
%37 = fmul double %5, %36
br label %53
38: ; preds = %19
%39 = call double @pow(double %21, i32 4)
%40 = fmul double %5, %39
br label %53
41: ; preds = %19
%42 = call double @pow(double %21, i32 5)
%43 = fmul double %5, %42
br label %53
44: ; preds = %19
%45 = call double @pow(double %21, i32 6)
%46 = fmul double %5, %45
br label %53
47: ; preds = %19
%48 = call double @pow(double %21, i32 7)
%49 = fmul double %5, %48
br label %53
50: ; preds = %19
%51 = call double @pow(double %21, i32 8)
%52 = fmul double %5, %51
br label %53
53: ; preds = %19, %50, %47, %44, %41, %38, %35, %32, %29, %24
%54 = phi double [ %5, %19 ], [ %52, %50 ], [ %49, %47 ], [ %46, %44 ], [ %43, %41 ], [ %40, %38 ], [ %37, %35 ], [ %34, %32 ], [ %31, %29 ], [ %28, %24 ]
ret double %54
}