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


x86 assembly (clang, -O0):
<lbytes_by_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xf85(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x11(%rbp),%rcx
lea    -0x12(%rbp),%r8
call   1030 <sscanf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     114f <lbytes_by_prefix+0x3f>
cmpl   $0x3,-0x18(%rbp)
jne    115c <lbytes_by_prefix+0x4c>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    12e0 <lbytes_by_prefix+0x1d0>
cmpl   $0x1,-0x18(%rbp)
jne    11a0 <lbytes_by_prefix+0x90>
cvttss2si -0x1c(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    118b <lbytes_by_prefix+0x7b>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    1193 <lbytes_by_prefix+0x83>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12e0 <lbytes_by_prefix+0x1d0>
movsbl -0x11(%rbp),%eax
add    $0xffffffb9,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x26,%eax
ja     12b3 <lbytes_by_prefix+0x1a3>
mov    -0x38(%rbp),%rax
lea    0xe4f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x1c(%rbp),%xmm0
mov    0x2e12(%rip),%rax
cvtsi2ssq (%rax),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c0 <lbytes_by_prefix+0x1b0>
movss  0xe17(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvttss2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c0 <lbytes_by_prefix+0x1b0>
movss  0xdfc(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  0xde3(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c0 <lbytes_by_prefix+0x1b0>
movss  0xdd1(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvttss2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c0 <lbytes_by_prefix+0x1b0>
movss  0xdb6(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  0xda1(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c0 <lbytes_by_prefix+0x1b0>
movss  0xd8b(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvttss2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c0 <lbytes_by_prefix+0x1b0>
movss  0xd70(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  0xd5f(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
jmp    12c0 <lbytes_by_prefix+0x1b0>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    12e0 <lbytes_by_prefix+0x1d0>
cmpq   $0x0,-0x28(%rbp)
jge    12d8 <lbytes_by_prefix+0x1c8>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    12e0 <lbytes_by_prefix+0x1d0>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lbytes_by_prefix>:
push   %rax
lea    0xf94(%rip),%rsi
mov    %rsp,%rdx
lea    0x6(%rsp),%rcx
lea    0x7(%rsp),%r8
call   1030 <sscanf@plt>
mov    %eax,%ecx
mov    $0xffffffffffffffff,%rax
test   %ecx,%ecx
je     11fb <lbytes_by_prefix+0xeb>
cmp    $0x3,%ecx
je     11fb <lbytes_by_prefix+0xeb>
cmp    $0x1,%ecx
jne    1154 <lbytes_by_prefix+0x44>
cvttss2si (%rsp),%rcx
jmp    11ed <lbytes_by_prefix+0xdd>
movsbl 0x6(%rsp),%ecx
add    $0xffffffb9,%ecx
cmp    $0x26,%ecx
ja     11fb <lbytes_by_prefix+0xeb>
lea    0xea4(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
movss  (%rsp),%xmm0
mulss  0xe7e(%rip),%xmm0
jmp    11a0 <lbytes_by_prefix+0x90>
movss  (%rsp),%xmm0
mulss  0xe7b(%rip),%xmm0
jmp    11a0 <lbytes_by_prefix+0x90>
movss  (%rsp),%xmm0
mulss  0xe68(%rip),%xmm0
mulss  0xe5c(%rip),%xmm0
jmp    11e8 <lbytes_by_prefix+0xd8>
mov    0x2e37(%rip),%rax
cvtsi2ssq (%rax),%xmm0
mulss  (%rsp),%xmm0
jmp    11e8 <lbytes_by_prefix+0xd8>
movss  (%rsp),%xmm0
mulss  0xe36(%rip),%xmm0
jmp    11e8 <lbytes_by_prefix+0xd8>
movss  (%rsp),%xmm0
mulss  0xe33(%rip),%xmm0
jmp    11e8 <lbytes_by_prefix+0xd8>
movss  (%rsp),%xmm0
mulss  0xe20(%rip),%xmm0
cvttss2si %xmm0,%rcx
test   %rcx,%rcx
mov    $0xffffffffffffffff,%rax
cmovns %rcx,%rax
pop    %rcx
ret

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

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