#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 */
int /*<<< orphan*/ sscanf(char *, char *, double *);
int strlen(char *);
double Scanf_io_size(char *text, int flag) {
  int c;
  double ret = 0.0;
  if (flag & 1)
    ret = -1.0;
  if (text[0] == 0)
    return (ret);
  sscanf(text, "%lf", &ret);
  c = text[strlen(text) - 1];
  if (c == 'k' || c == 'K')
    ret *= 1024.0;
  if (c == 'm' || c == 'M')
    ret *= 1024.0 * 1024.0;
  if (c == 'g' || c == 'G')
    ret *= 1024.0 * 1024.0 * 1024.0;
  if (c == 't' || c == 'T')
    ret *= 1024.0 * 1024.0 * 1024.0 * 1024.0;
  if (c == 'p' || c == 'P')
    ret *= 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0;
  if (c == 'e' || c == 'E')
    ret *= 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0;
  if (c == 's' || c == 'S')
    ret *= 2048.0;
  return (ret);
}


x86 assembly (clang, -O0):
<Scanf_io_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1153 <Scanf_io_size+0x33>
movsd  0xeb2(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1172 <Scanf_io_size+0x52>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12be <Scanf_io_size+0x19e>
mov    -0x10(%rbp),%rdi
lea    0xec3(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x6b,-0x18(%rbp)
je     11be <Scanf_io_size+0x9e>
cmpl   $0x4b,-0x18(%rbp)
jne    11d0 <Scanf_io_size+0xb0>
movsd  0xe42(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x6d,-0x18(%rbp)
je     11e4 <Scanf_io_size+0xc4>
cmpl   $0x4d,-0x18(%rbp)
jne    11f6 <Scanf_io_size+0xd6>
movsd  0xe24(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x67,-0x18(%rbp)
je     120a <Scanf_io_size+0xea>
cmpl   $0x47,-0x18(%rbp)
jne    121c <Scanf_io_size+0xfc>
movsd  0xe06(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x74,-0x18(%rbp)
je     1230 <Scanf_io_size+0x110>
cmpl   $0x54,-0x18(%rbp)
jne    1242 <Scanf_io_size+0x122>
movsd  0xde8(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x70,-0x18(%rbp)
je     1256 <Scanf_io_size+0x136>
cmpl   $0x50,-0x18(%rbp)
jne    1268 <Scanf_io_size+0x148>
movsd  0xdca(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x65,-0x18(%rbp)
je     127c <Scanf_io_size+0x15c>
cmpl   $0x45,-0x18(%rbp)
jne    128e <Scanf_io_size+0x16e>
movsd  0xdac(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x73,-0x18(%rbp)
je     12a2 <Scanf_io_size+0x182>
cmpl   $0x53,-0x18(%rbp)
jne    12b4 <Scanf_io_size+0x194>
movsd  0xd8e(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Scanf_io_size>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xorpd  %xmm0,%xmm0
test   $0x1,%sil
je     113a <Scanf_io_size+0x1a>
movsd  0xec6(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
cmpb   $0x0,(%rbx)
je     11fc <Scanf_io_size+0xdc>
lea    0xf30(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <sscanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
mov    -0x1(%rax,%rbx,1),%al
and    $0xdf,%al
add    $0xbb,%al
cmp    $0xf,%al
ja     1196 <Scanf_io_size+0x76>
movzbl %al,%eax
lea    0xec3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0x8(%rsp),%xmm0
mulsd  0xe7c(%rip),%xmm0
jmp    11fc <Scanf_io_size+0xdc>
movsd  0x8(%rsp),%xmm0
jmp    11fc <Scanf_io_size+0xdc>
movsd  0x8(%rsp),%xmm0
mulsd  0xe7c(%rip),%xmm0
jmp    11fc <Scanf_io_size+0xdc>
movsd  0x8(%rsp),%xmm0
mulsd  0xe7c(%rip),%xmm0
jmp    11fc <Scanf_io_size+0xdc>
movsd  0x8(%rsp),%xmm0
mulsd  0xe64(%rip),%xmm0
jmp    11fc <Scanf_io_size+0xdc>
movsd  0x8(%rsp),%xmm0
mulsd  0xe3c(%rip),%xmm0
jmp    11fc <Scanf_io_size+0xdc>
movsd  0x8(%rsp),%xmm0
mulsd  0xe1c(%rip),%xmm0
jmp    11fc <Scanf_io_size+0xdc>
movsd  0x8(%rsp),%xmm0
mulsd  0xe24(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
define double @Scanf_io_size(i8* %0, i32 %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i8* %0, i8** %4
store i32 %1, i32* %5
store double 0.000000e+00, double* %7
%8 = load i32, i32* %5
%9 = and i32 %8, 1
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store double -1.000000e+00, double* %7
br label %12
12: ; preds = %11, %2
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = load double, double* %7
store double %19, double* %3
br label %95
20: ; preds = %12
%21 = load i8*, i8** %4
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %7)
%23 = load i8*, i8** %4
%24 = load i8*, i8** %4
%25 = call i32 @strlen(i8* %24)
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %23, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 107
br i1 %32, label %36, label %33
33: ; preds = %20
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, 75
br i1 %35, label %36, label %39
36: ; preds = %33, %20
%37 = load double, double* %7
%38 = fmul double %37, 1.024000e+03
store double %38, double* %7
br label %39
39: ; preds = %36, %33
%40 = load i32, i32* %6
%41 = icmp eq i32 %40, 109
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load i32, i32* %6
%44 = icmp eq i32 %43, 77
br i1 %44, label %45, label %48
45: ; preds = %42, %39
%46 = load double, double* %7
%47 = fmul double %46, 0x4130000000000000
store double %47, double* %7
br label %48
48: ; preds = %45, %42
%49 = load i32, i32* %6
%50 = icmp eq i32 %49, 103
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = load i32, i32* %6
%53 = icmp eq i32 %52, 71
br i1 %53, label %54, label %57
54: ; preds = %51, %48
%55 = load double, double* %7
%56 = fmul double %55, 0x41D0000000000000
store double %56, double* %7
br label %57
57: ; preds = %54, %51
%58 = load i32, i32* %6
%59 = icmp eq i32 %58, 116
br i1 %59, label %63, label %60
60: ; preds = %57
%61 = load i32, i32* %6
%62 = icmp eq i32 %61, 84
br i1 %62, label %63, label %66
63: ; preds = %60, %57
%64 = load double, double* %7
%65 = fmul double %64, 0x4270000000000000
store double %65, double* %7
br label %66
66: ; preds = %63, %60
%67 = load i32, i32* %6
%68 = icmp eq i32 %67, 112
br i1 %68, label %72, label %69
69: ; preds = %66
%70 = load i32, i32* %6
%71 = icmp eq i32 %70, 80
br i1 %71, label %72, label %75
72: ; preds = %69, %66
%73 = load double, double* %7
%74 = fmul double %73, 0x4310000000000000
store double %74, double* %7
br label %75
75: ; preds = %72, %69
%76 = load i32, i32* %6
%77 = icmp eq i32 %76, 101
br i1 %77, label %81, label %78
78: ; preds = %75
%79 = load i32, i32* %6
%80 = icmp eq i32 %79, 69
br i1 %80, label %81, label %84
81: ; preds = %78, %75
%82 = load double, double* %7
%83 = fmul double %82, 0x43B0000000000000
store double %83, double* %7
br label %84
84: ; preds = %81, %78
%85 = load i32, i32* %6
%86 = icmp eq i32 %85, 115
br i1 %86, label %90, label %87
87: ; preds = %84
%88 = load i32, i32* %6
%89 = icmp eq i32 %88, 83
br i1 %89, label %90, label %93
90: ; preds = %87, %84
%91 = load double, double* %7
%92 = fmul double %91, 2.048000e+03
store double %92, double* %7
br label %93
93: ; preds = %90, %87
%94 = load double, double* %7
store double %94, double* %3
br label %95
95: ; preds = %93, %18
%96 = load double, double* %3
ret double %96
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
define double @Scanf_io_size(i8* %0, i32 %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
%5 = and i32 %1, 1
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, double 0.000000e+00, double -1.000000e+00
store double %7, double* %3
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %41, label %10
10: ; preds = %2
%11 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %3)
%12 = call i32 @strlen(i8* %0)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = and i8 %16, -33
switch i8 %17, label %18 [
i8 75, label %20
i8 77, label %23
i8 71, label %26
i8 84, label %29
i8 80, label %32
i8 69, label %35
i8 83, label %38
]
18: ; preds = %10
%19 = load double, double* %3
br label %41
20: ; preds = %10
%21 = load double, double* %3
%22 = fmul double %21, 1.024000e+03
br label %41
23: ; preds = %10
%24 = load double, double* %3
%25 = fmul double %24, 0x4130000000000000
br label %41
26: ; preds = %10
%27 = load double, double* %3
%28 = fmul double %27, 0x41D0000000000000
br label %41
29: ; preds = %10
%30 = load double, double* %3
%31 = fmul double %30, 0x4270000000000000
br label %41
32: ; preds = %10
%33 = load double, double* %3
%34 = fmul double %33, 0x4310000000000000
br label %41
35: ; preds = %10
%36 = load double, double* %3
%37 = fmul double %36, 0x43B0000000000000
br label %41
38: ; preds = %10
%39 = load double, double* %3
%40 = fmul double %39, 2.048000e+03
br label %41
41: ; preds = %38, %35, %23, %20, %26, %29, %32, %18, %2
%42 = phi double [ %7, %2 ], [ %19, %18 ], [ %34, %32 ], [ %31, %29 ], [ %28, %26 ], [ %22, %20 ], [ %25, %23 ], [ %37, %35 ], [ %40, %38 ]
ret double %42
}