#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 */
scalar_t__ DEV_BSIZE;
int sscanf(char *, char *, double *, char *, char *);
long long llbytes_by_prefix(char *s) {
  char mult, junk;
  int nconv;
  double num;
  long long result;
  nconv = sscanf(s, "%lf%c%c", &num, &mult, &junk);
  if (nconv == 0 || nconv == 3)
    return -1;
  if (nconv == 1) {
    result = (long long)num;
    return result < 0 ? -1 : result;
  }
  switch (mult) {
  case 'b':
    result = (long long)(num * (float)DEV_BSIZE);
    break;
  case 'k':
    result = (long long)(num * (float)1024);
    break;
  case 'K':
    result = (long long)((num * (float)1024) * sizeof(long long));
    break;
  case 'm':
    result = (long long)(num * (float)1048576);
    break;
  case 'M':
    result = (long long)((num * (float)1048576) * sizeof(long long));
    break;
  case 'g':
    result = (long long)(num * (float)1073741824);
    break;
  case 'G':
    result = (long long)((num * (float)1073741824) * sizeof(long long));
    break;
  default:
    return -1;
  }
  if (result < 0)
    return -1;
  return result;
}


x86 assembly (clang, -O0):
<llbytes_by_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xf95(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x11(%rbp),%rcx
lea    -0x12(%rbp),%r8
call   1030 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     114f <llbytes_by_prefix+0x3f>
cmpl   $0x3,-0x18(%rbp)
jne    115c <llbytes_by_prefix+0x4c>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    12e4 <llbytes_by_prefix+0x1d4>
cmpl   $0x1,-0x18(%rbp)
jne    11a0 <llbytes_by_prefix+0x90>
cvttsd2si -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    118b <llbytes_by_prefix+0x7b>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    1193 <llbytes_by_prefix+0x83>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12e4 <llbytes_by_prefix+0x1d4>
movsbl -0x11(%rbp),%eax
add    $0xffffffb9,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x26,%eax
ja     12b7 <llbytes_by_prefix+0x1a7>
mov    -0x38(%rbp),%rax
lea    0xe5f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x20(%rbp),%xmm0
mov    0x2e12(%rip),%rax
cvtsi2ssq (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c4 <llbytes_by_prefix+0x1b4>
movsd  0xe1f(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c4 <llbytes_by_prefix+0x1b4>
movsd  0xe04(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xddf(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c4 <llbytes_by_prefix+0x1b4>
movsd  0xdd5(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c4 <llbytes_by_prefix+0x1b4>
movsd  0xdba(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xd9d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c4 <llbytes_by_prefix+0x1b4>
movsd  0xd8b(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c4 <llbytes_by_prefix+0x1b4>
movsd  0xd70(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xd5b(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c4 <llbytes_by_prefix+0x1b4>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    12e4 <llbytes_by_prefix+0x1d4>
cmpq   $0x0,-0x28(%rbp)
jge    12dc <llbytes_by_prefix+0x1cc>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    12e4 <llbytes_by_prefix+0x1d4>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<llbytes_by_prefix>:
sub    $0x18,%rsp
lea    0xfa1(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x7(%rsp),%rcx
lea    0x17(%rsp),%r8
call   1030 <sscanf@plt>
mov    %eax,%ecx
mov    $0xffffffffffffffff,%rax
test   %ecx,%ecx
je     120c <llbytes_by_prefix+0xfc>
cmp    $0x3,%ecx
je     120c <llbytes_by_prefix+0xfc>
cmp    $0x1,%ecx
jne    115a <llbytes_by_prefix+0x4a>
cvttsd2si 0x8(%rsp),%rcx
jmp    11fe <llbytes_by_prefix+0xee>
movsbl 0x7(%rsp),%ecx
add    $0xffffffb9,%ecx
cmp    $0x26,%ecx
ja     120c <llbytes_by_prefix+0xfc>
lea    0xeae(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
movsd  0x8(%rsp),%xmm0
mulsd  0xe77(%rip),%xmm0
jmp    11a9 <llbytes_by_prefix+0x99>
movsd  0x8(%rsp),%xmm0
mulsd  0xe7f(%rip),%xmm0
jmp    11a9 <llbytes_by_prefix+0x99>
movsd  0x8(%rsp),%xmm0
mulsd  0xe67(%rip),%xmm0
mulsd  0xe57(%rip),%xmm0
jmp    11f9 <llbytes_by_prefix+0xe9>
mov    0x2e2e(%rip),%rax
cvtsi2ssq (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0x8(%rsp),%xmm0
jmp    11f9 <llbytes_by_prefix+0xe9>
movsd  0x8(%rsp),%xmm0
mulsd  0xe27(%rip),%xmm0
jmp    11f9 <llbytes_by_prefix+0xe9>
movsd  0x8(%rsp),%xmm0
mulsd  0xe2f(%rip),%xmm0
jmp    11f9 <llbytes_by_prefix+0xe9>
movsd  0x8(%rsp),%xmm0
mulsd  0xe17(%rip),%xmm0
cvttsd2si %xmm0,%rcx
test   %rcx,%rcx
mov    $0xffffffffffffffff,%rax
cmovns %rcx,%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%lf%c%c\00"
@DEV_BSIZE = global i64 0
define i64 @llbytes_by_prefix(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
%7 = alloca double
%8 = alloca i64
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i32 @sscanf(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %7, i8* %4, i8* %5)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %1
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 3
br i1 %15, label %16, label %17
16: ; preds = %13, %1
store i64 -1, i64* %2
br label %74
17: ; preds = %13
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load double, double* %7
%22 = fptosi double %21 to i64
store i64 %22, i64* %8
%23 = load i64, i64* %8
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
br label %28
26: ; preds = %20
%27 = load i64, i64* %8
br label %28
28: ; preds = %26, %25
%29 = phi i64 [ -1, %25 ], [ %27, %26 ]
store i64 %29, i64* %2
br label %74
30: ; preds = %17
%31 = load i8, i8* %4
%32 = sext i8 %31 to i32
switch i32 %32, label %67 [
i32 98, label %33
i32 107, label %40
i32 75, label %44
i32 109, label %49
i32 77, label %53
i32 103, label %58
i32 71, label %62
]
33: ; preds = %30
%34 = load double, double* %7
%35 = load i64, i64* @DEV_BSIZE
%36 = sitofp i64 %35 to float
%37 = fpext float %36 to double
%38 = fmul double %34, %37
%39 = fptosi double %38 to i64
store i64 %39, i64* %8
br label %68
40: ; preds = %30
%41 = load double, double* %7
%42 = fmul double %41, 1.024000e+03
%43 = fptosi double %42 to i64
store i64 %43, i64* %8
br label %68
44: ; preds = %30
%45 = load double, double* %7
%46 = fmul double %45, 1.024000e+03
%47 = fmul double %46, 8.000000e+00
%48 = fptosi double %47 to i64
store i64 %48, i64* %8
br label %68
49: ; preds = %30
%50 = load double, double* %7
%51 = fmul double %50, 0x4130000000000000
%52 = fptosi double %51 to i64
store i64 %52, i64* %8
br label %68
53: ; preds = %30
%54 = load double, double* %7
%55 = fmul double %54, 0x4130000000000000
%56 = fmul double %55, 8.000000e+00
%57 = fptosi double %56 to i64
store i64 %57, i64* %8
br label %68
58: ; preds = %30
%59 = load double, double* %7
%60 = fmul double %59, 0x41D0000000000000
%61 = fptosi double %60 to i64
store i64 %61, i64* %8
br label %68
62: ; preds = %30
%63 = load double, double* %7
%64 = fmul double %63, 0x41D0000000000000
%65 = fmul double %64, 8.000000e+00
%66 = fptosi double %65 to i64
store i64 %66, i64* %8
br label %68
67: ; preds = %30
store i64 -1, i64* %2
br label %74
68: ; preds = %62, %58, %53, %49, %44, %40, %33
%69 = load i64, i64* %8
%70 = icmp slt i64 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %68
store i64 -1, i64* %2
br label %74
72: ; preds = %68
%73 = load i64, i64* %8
store i64 %73, i64* %2
br label %74
74: ; preds = %72, %71, %67, %28, %16
%75 = load i64, i64* %2
ret i64 %75
}

LLVM IR (-O2):
@.str = [8 x i8] c"%lf%c%c\00"
@DEV_BSIZE = global i64 0
define i64 @llbytes_by_prefix(i8* nocapture %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca double
%5 = bitcast double* %4 to i8*
%6 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double* %4, i8* %2, i8* %3)
switch i32 %6, label %12 [
i32 3, label %47
i32 0, label %47
i32 1, label %7
]
7: ; preds = %1
%8 = load double, double* %4
%9 = fptosi double %8 to i64
%10 = icmp sgt i64 %9, -1
%11 = select i1 %10, i64 %9, i64 -1
br label %47
12: ; preds = %1
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
switch i32 %14, label %47 [
i32 98, label %15
i32 107, label %21
i32 75, label %24
i32 109, label %28
i32 77, label %31
i32 103, label %35
i32 71, label %38
]
15: ; preds = %12
%16 = load double, double* %4
%17 = load i64, i64* @DEV_BSIZE
%18 = sitofp i64 %17 to float
%19 = fpext float %18 to double
%20 = fmul double %16, %19
br label %42
21: ; preds = %12
%22 = load double, double* %4
%23 = fmul double %22, 1.024000e+03
br label %42
24: ; preds = %12
%25 = load double, double* %4
%26 = fmul double %25, 1.024000e+03
%27 = fmul double %26, 8.000000e+00
br label %42
28: ; preds = %12
%29 = load double, double* %4
%30 = fmul double %29, 0x4130000000000000
br label %42
31: ; preds = %12
%32 = load double, double* %4
%33 = fmul double %32, 0x4130000000000000
%34 = fmul double %33, 8.000000e+00
br label %42
35: ; preds = %12
%36 = load double, double* %4
%37 = fmul double %36, 0x41D0000000000000
br label %42
38: ; preds = %12
%39 = load double, double* %4
%40 = fmul double %39, 0x41D0000000000000
%41 = fmul double %40, 8.000000e+00
br label %42
42: ; preds = %38, %35, %31, %28, %24, %21, %15
%43 = phi double [ %41, %38 ], [ %37, %35 ], [ %34, %31 ], [ %30, %28 ], [ %27, %24 ], [ %23, %21 ], [ %20, %15 ]
%44 = fptosi double %43 to i64
%45 = icmp sgt i64 %44, -1
%46 = select i1 %45, i64 %44, i64 -1
br label %47
47: ; preds = %42, %12, %1, %1, %7
%48 = phi i64 [ %11, %7 ], [ -1, %1 ], [ -1, %1 ], [ -1, %12 ], [ %46, %42 ]
ret i64 %48
}