#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 atof(char *);
int strlen(char *);
double atofs(char *f) {
  char last;
  int len;
  double suff = 1.0;
  len = strlen(f);
  last = f[len - 1];
  f[len - 1] = '\0';
  switch (last) {
  case 'g':
  case 'G':
    suff *= 1e3;
  case 'm':
  case 'M':
    suff *= 1e3;
  case 'k':
  case 'K':
    suff *= 1e3;
    suff *= atof(f);
    f[len - 1] = last;
    return suff;
  }
  f[len - 1] = last;
  return atof(f);
}


x86 assembly (clang, -O0):
<atofs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movabs $0x3ff0000000000000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x47,%eax
je     11d4 <atofs+0xb4>
jmp    117f <atofs+0x5f>
mov    -0x24(%rbp),%eax
sub    $0x4b,%eax
je     11f8 <atofs+0xd8>
jmp    1190 <atofs+0x70>
mov    -0x24(%rbp),%eax
sub    $0x4d,%eax
je     11e6 <atofs+0xc6>
jmp    11a1 <atofs+0x81>
mov    -0x24(%rbp),%eax
sub    $0x67,%eax
je     11d4 <atofs+0xb4>
jmp    11b2 <atofs+0x92>
mov    -0x24(%rbp),%eax
sub    $0x6b,%eax
je     11f8 <atofs+0xd8>
jmp    11c3 <atofs+0xa3>
mov    -0x24(%rbp),%eax
sub    $0x6d,%eax
je     11e6 <atofs+0xc6>
jmp    123f <atofs+0x11f>
movsd  0xe24(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe12(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe00(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1260 <atofs+0x140>
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atofs>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
movslq %eax,%r14
movsbl -0x1(%r14,%rbx,1),%ebp
movb   $0x0,-0x1(%r14,%rbx,1)
mov    %ebp,%eax
add    $0xffffffb9,%eax
cmp    $0x26,%eax
ja     11b7 <atofs+0x97>
movabs $0x100000001,%rcx
bt     %rax,%rcx
jb     118d <atofs+0x6d>
movabs $0x1000000010,%rcx
bt     %rax,%rcx
jb     1183 <atofs+0x63>
movabs $0x4000000040,%rcx
bt     %rax,%rcx
jae    11b7 <atofs+0x97>
movsd  0xe87(%rip),%xmm0
jmp    1195 <atofs+0x75>
movsd  0xe75(%rip),%xmm0
jmp    1195 <atofs+0x75>
movsd  0xe7b(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <atof@plt>
mulsd  0x8(%rsp),%xmm0
mov    %bpl,-0x1(%rbx,%r14,1)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %bpl,-0x1(%rbx,%r14,1)
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <atof@plt>

LLVM IR (-O0):
define double @atofs(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca double
store i8* %0, i8** %3
store double 1.000000e+00, double* %6
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %9, i64 %12
%14 = load i8, i8* %13
store i8 %14, i8* %4
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
store i8 0, i8* %19
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
switch i32 %21, label %42 [
i32 103, label %22
i32 71, label %22
i32 109, label %25
i32 77, label %25
i32 107, label %28
i32 75, label %28
]
22: ; preds = %1, %1
%23 = load double, double* %6
%24 = fmul double %23, 1.000000e+03
store double %24, double* %6
br label %25
25: ; preds = %1, %1, %22
%26 = load double, double* %6
%27 = fmul double %26, 1.000000e+03
store double %27, double* %6
br label %28
28: ; preds = %1, %1, %25
%29 = load double, double* %6
%30 = fmul double %29, 1.000000e+03
store double %30, double* %6
%31 = load i8*, i8** %3
%32 = call double @atof(i8* %31)
%33 = load double, double* %6
%34 = fmul double %33, %32
store double %34, double* %6
%35 = load i8, i8* %4
%36 = load i8*, i8** %3
%37 = load i32, i32* %5
%38 = sub nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %36, i64 %39
store i8 %35, i8* %40
%41 = load double, double* %6
store double %41, double* %2
br label %51
42: ; preds = %1
%43 = load i8, i8* %4
%44 = load i8*, i8** %3
%45 = load i32, i32* %5
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %44, i64 %47
store i8 %43, i8* %48
%49 = load i8*, i8** %3
%50 = call double @atof(i8* %49)
store double %50, double* %2
br label %51
51: ; preds = %42, %28
%52 = load double, double* %2
ret double %52
}

LLVM IR (-O2):
define double @atofs(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
store i8 0, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %15 [
i32 103, label %8
i32 71, label %8
i32 109, label %9
i32 77, label %9
i32 107, label %11
i32 75, label %11
]
8: ; preds = %1, %1
br label %9
9: ; preds = %1, %1, %8
%10 = phi double [ 1.000000e+06, %1 ], [ 1.000000e+06, %1 ], [ 1.000000e+09, %8 ]
br label %11
11: ; preds = %1, %1, %9
%12 = phi double [ 1.000000e+03, %1 ], [ 1.000000e+03, %1 ], [ %10, %9 ]
%13 = tail call double @atof(i8* %0)
%14 = fmul double %12, %13
store i8 %6, i8* %5
br label %17
15: ; preds = %1
store i8 %6, i8* %5
%16 = tail call double @atof(i8* %0)
br label %17
17: ; preds = %15, %11
%18 = phi double [ %16, %15 ], [ %14, %11 ]
ret double %18
}