#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 NAN;
double atof(char *);
int /*<<< orphan*/ free(char *);
char *readstring(char const *);
int strlen(char *);
double readnumber(const char *prompt) {
  double val;
  char *ret;
  ret = readstring(prompt);
  if (!ret)
    return NAN;
  val = atof(ret);
  switch (ret[strlen(ret) - 1]) {
  case 'E':
    val *= 1e+18;
    break;
  case 'P':
    val *= 1e+15;
    break;
  case 'T':
    val *= 1e+12;
    break;
  case 'G':
    val *= 1e+09;
    break;
  case 'M':
    val *= 1e+06;
    break;
  case 'k':
    val *= 1e+03;
    break;
  case 'c':
    val *= 1e-02;
    break;
  case 'm':
    val *= 1e-03;
    break;
  case 'u':
    val *= 1e-06;
    break;
  case 'n':
    val *= 1e-09;
    break;
  case 'p':
    val *= 1e-12;
    break;
  case 'f':
    val *= 1e-15;
    break;
  case 'a':
    val *= 1e-18;
    break;
  default:
    break;
  }
  free(ret);
  return val;
}


x86 assembly (clang, -O0):
<readnumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <readstring@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1179 <readnumber+0x39>
mov    0x2e8d(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    130d <readnumber+0x1cd>
mov    -0x20(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    %rdi,-0x30(%rbp)
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
add    $0xffffffff,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffbb,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x30,%eax
ja     12f5 <readnumber+0x1b5>
mov    -0x28(%rbp),%rax
lea    0xea7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0xe8e(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xe6f(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xe50(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xe31(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xe12(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xdf3(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xdd4(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xdb5(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xd96(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xd77(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xd58(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xd39(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
movsd  0xd1a(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12fa <readnumber+0x1ba>
jmp    12fa <readnumber+0x1ba>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readnumber>:
push   %rbx
sub    $0x10,%rsp
call   1060 <readstring@plt>
test   %rax,%rax
je     119e <readnumber+0x5e>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movsbl -0x1(%rax,%rbx,1),%eax
add    $0xffffffbb,%eax
cmp    $0x30,%eax
ja     127b <readnumber+0x13b>
lea    0xee6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0x8(%rsp),%xmm0
mulsd  0xec7(%rip),%xmm0
jmp    1275 <readnumber+0x135>
mov    0x2e53(%rip),%rax
movsd  (%rax),%xmm0
jmp    1289 <readnumber+0x149>
movsd  0x8(%rsp),%xmm0
mulsd  0xe8c(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xe71(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xe76(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xe5b(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xdfb(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xe1b(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xde3(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xe03(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xde3(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xdc3(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xdab(%rip),%xmm0
jmp    1275 <readnumber+0x135>
movsd  0x8(%rsp),%xmm0
mulsd  0xdab(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
define double @readnumber(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca double
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @readstring(i8* %6)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %1
%11 = load double, double* @NAN
store double %11, double* %2
br label %67
12: ; preds = %1
%13 = load i8*, i8** %5
%14 = call double @atof(i8* %13)
store double %14, double* %4
%15 = load i8*, i8** %5
%16 = load i8*, i8** %5
%17 = call i32 @strlen(i8* %16)
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %15, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
switch i32 %22, label %62 [
i32 69, label %23
i32 80, label %26
i32 84, label %29
i32 71, label %32
i32 77, label %35
i32 107, label %38
i32 99, label %41
i32 109, label %44
i32 117, label %47
i32 110, label %50
i32 112, label %53
i32 102, label %56
i32 97, label %59
]
23: ; preds = %12
%24 = load double, double* %4
%25 = fmul double %24, 1.000000e+18
store double %25, double* %4
br label %63
26: ; preds = %12
%27 = load double, double* %4
%28 = fmul double %27, 1.000000e+15
store double %28, double* %4
br label %63
29: ; preds = %12
%30 = load double, double* %4
%31 = fmul double %30, 1.000000e+12
store double %31, double* %4
br label %63
32: ; preds = %12
%33 = load double, double* %4
%34 = fmul double %33, 1.000000e+09
store double %34, double* %4
br label %63
35: ; preds = %12
%36 = load double, double* %4
%37 = fmul double %36, 1.000000e+06
store double %37, double* %4
br label %63
38: ; preds = %12
%39 = load double, double* %4
%40 = fmul double %39, 1.000000e+03
store double %40, double* %4
br label %63
41: ; preds = %12
%42 = load double, double* %4
%43 = fmul double %42, 1.000000e-02
store double %43, double* %4
br label %63
44: ; preds = %12
%45 = load double, double* %4
%46 = fmul double %45, 1.000000e-03
store double %46, double* %4
br label %63
47: ; preds = %12
%48 = load double, double* %4
%49 = fmul double %48, 0x3EB0C6F7A0B5ED8D
store double %49, double* %4
br label %63
50: ; preds = %12
%51 = load double, double* %4
%52 = fmul double %51, 1.000000e-09
store double %52, double* %4
br label %63
53: ; preds = %12
%54 = load double, double* %4
%55 = fmul double %54, 0x3D719799812DEA11
store double %55, double* %4
br label %63
56: ; preds = %12
%57 = load double, double* %4
%58 = fmul double %57, 1.000000e-15
store double %58, double* %4
br label %63
59: ; preds = %12
%60 = load double, double* %4
%61 = fmul double %60, 1.000000e-18
store double %61, double* %4
br label %63
62: ; preds = %12
br label %63
63: ; preds = %62, %59, %56, %53, %50, %47, %44, %41, %38, %35, %32, %29, %26, %23
%64 = load i8*, i8** %5
%65 = call i32 @free(i8* %64)
%66 = load double, double* %4
store double %66, double* %2
br label %67
67: ; preds = %63, %10
%68 = load double, double* %2
ret double %68
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
define double @readnumber(i8* %0) {
%2 = tail call i8* @readstring(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = load double, double* @NAN
br label %43
6: ; preds = %1
%7 = tail call double @atof(i8* %2)
%8 = tail call i32 @strlen(i8* %2)
%9 = add nsw i32 %8, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %2, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
switch i32 %13, label %40 [
i32 69, label %14
i32 80, label %16
i32 84, label %18
i32 71, label %20
i32 77, label %22
i32 107, label %24
i32 99, label %26
i32 109, label %28
i32 117, label %30
i32 110, label %32
i32 112, label %34
i32 102, label %36
i32 97, label %38
]
14: ; preds = %6
%15 = fmul double %7, 1.000000e+18
br label %40
16: ; preds = %6
%17 = fmul double %7, 1.000000e+15
br label %40
18: ; preds = %6
%19 = fmul double %7, 1.000000e+12
br label %40
20: ; preds = %6
%21 = fmul double %7, 1.000000e+09
br label %40
22: ; preds = %6
%23 = fmul double %7, 1.000000e+06
br label %40
24: ; preds = %6
%25 = fmul double %7, 1.000000e+03
br label %40
26: ; preds = %6
%27 = fmul double %7, 1.000000e-02
br label %40
28: ; preds = %6
%29 = fmul double %7, 1.000000e-03
br label %40
30: ; preds = %6
%31 = fmul double %7, 0x3EB0C6F7A0B5ED8D
br label %40
32: ; preds = %6
%33 = fmul double %7, 1.000000e-09
br label %40
34: ; preds = %6
%35 = fmul double %7, 0x3D719799812DEA11
br label %40
36: ; preds = %6
%37 = fmul double %7, 1.000000e-15
br label %40
38: ; preds = %6
%39 = fmul double %7, 1.000000e-18
br label %40
40: ; preds = %6, %38, %36, %34, %32, %30, %28, %26, %24, %22, %20, %18, %16, %14
%41 = phi double [ %7, %6 ], [ %39, %38 ], [ %37, %36 ], [ %35, %34 ], [ %33, %32 ], [ %31, %30 ], [ %29, %28 ], [ %27, %26 ], [ %25, %24 ], [ %23, %22 ], [ %21, %20 ], [ %19, %18 ], [ %17, %16 ], [ %15, %14 ]
%42 = tail call i32 @free(i8* %2)
br label %43
43: ; preds = %40, %4
%44 = phi double [ %41, %40 ], [ %5, %4 ]
ret double %44
}