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


x86 assembly (clang, -O0):
<bytes_by_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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 <bytes_by_prefix+0x3f>
cmpl   $0x3,-0x18(%rbp)
jne    115b <bytes_by_prefix+0x4b>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c2 <bytes_by_prefix+0x1b2>
cmpl   $0x1,-0x18(%rbp)
jne    1195 <bytes_by_prefix+0x85>
cvttss2si -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1184 <bytes_by_prefix+0x74>
mov    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    118a <bytes_by_prefix+0x7a>
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12c2 <bytes_by_prefix+0x1b2>
movsbl -0x11(%rbp),%eax
add    $0xffffffb9,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x26,%eax
ja     129a <bytes_by_prefix+0x18a>
mov    -0x30(%rbp),%rax
lea    0xe5a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x1c(%rbp),%xmm0
mov    0x2e1d(%rip),%rax
cvtsi2ssq (%rax),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
jmp    12a6 <bytes_by_prefix+0x196>
movss  0xe24(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
jmp    12a6 <bytes_by_prefix+0x196>
movss  0xe0b(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  0xdf2(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
jmp    12a6 <bytes_by_prefix+0x196>
movss  0xde2(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
jmp    12a6 <bytes_by_prefix+0x196>
movss  0xdc9(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  0xdb4(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
jmp    12a6 <bytes_by_prefix+0x196>
movss  0xda0(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
jmp    12a6 <bytes_by_prefix+0x196>
movss  0xd87(%rip),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  0xd76(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
jmp    12a6 <bytes_by_prefix+0x196>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c2 <bytes_by_prefix+0x1b2>
cmpl   $0x0,-0x20(%rbp)
jge    12bc <bytes_by_prefix+0x1ac>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c2 <bytes_by_prefix+0x1b2>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bytes_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    $0xffffffff,%eax
test   %ecx,%ecx
je     11f3 <bytes_by_prefix+0xe3>
cmp    $0x3,%ecx
je     11f3 <bytes_by_prefix+0xe3>
cmp    $0x1,%ecx
jne    1151 <bytes_by_prefix+0x41>
cvttss2si (%rsp),%ecx
jmp    11e9 <bytes_by_prefix+0xd9>
movsbl 0x6(%rsp),%ecx
add    $0xffffffb9,%ecx
cmp    $0x26,%ecx
ja     11f3 <bytes_by_prefix+0xe3>
lea    0xea7(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
movss  (%rsp),%xmm0
mulss  0xe81(%rip),%xmm0
jmp    119d <bytes_by_prefix+0x8d>
movss  (%rsp),%xmm0
mulss  0xe7e(%rip),%xmm0
jmp    119d <bytes_by_prefix+0x8d>
movss  (%rsp),%xmm0
mulss  0xe6b(%rip),%xmm0
mulss  0xe5f(%rip),%xmm0
jmp    11e5 <bytes_by_prefix+0xd5>
mov    0x2e3a(%rip),%rax
cvtsi2ssq (%rax),%xmm0
mulss  (%rsp),%xmm0
jmp    11e5 <bytes_by_prefix+0xd5>
movss  (%rsp),%xmm0
mulss  0xe39(%rip),%xmm0
jmp    11e5 <bytes_by_prefix+0xd5>
movss  (%rsp),%xmm0
mulss  0xe36(%rip),%xmm0
jmp    11e5 <bytes_by_prefix+0xd5>
movss  (%rsp),%xmm0
mulss  0xe23(%rip),%xmm0
cvttss2si %xmm0,%ecx
test   %ecx,%ecx
mov    $0xffffffff,%eax
cmovns %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%f%c%c\00"
@DEV_BSIZE = global i64 0
define i32 @bytes_by_prefix(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8
%6 = alloca i32
%7 = alloca float
%8 = alloca i32
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 i32 -1, i32* %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 i32
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
br label %28
26: ; preds = %20
%27 = load i32, i32* %8
br label %28
28: ; preds = %26, %25
%29 = phi i32 [ -1, %25 ], [ %27, %26 ]
store i32 %29, i32* %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 i32
store i32 %38, i32* %8
br label %67
39: ; preds = %30
%40 = load float, float* %7
%41 = fmul float %40, 1.024000e+03
%42 = fptosi float %41 to i32
store i32 %42, i32* %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 i32
store i32 %47, i32* %8
br label %67
48: ; preds = %30
%49 = load float, float* %7
%50 = fmul float %49, 0x4130000000000000
%51 = fptosi float %50 to i32
store i32 %51, i32* %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 i32
store i32 %56, i32* %8
br label %67
57: ; preds = %30
%58 = load float, float* %7
%59 = fmul float %58, 0x41D0000000000000
%60 = fptosi float %59 to i32
store i32 %60, i32* %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 i32
store i32 %65, i32* %8
br label %67
66: ; preds = %30
store i32 -1, i32* %2
br label %73
67: ; preds = %61, %57, %52, %48, %43, %39, %33
%68 = load i32, i32* %8
%69 = icmp slt i32 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %67
store i32 -1, i32* %2
br label %73
71: ; preds = %67
%72 = load i32, i32* %8
store i32 %72, i32* %2
br label %73
73: ; preds = %71, %70, %66, %28, %16
%74 = load i32, i32* %2
ret i32 %74
}

LLVM IR (-O2):
@.str = [7 x i8] c"%f%c%c\00"
@DEV_BSIZE = global i64 0
define i32 @bytes_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 i32
%10 = icmp sgt i32 %9, -1
%11 = select i1 %10, i32 %9, i32 -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 i32
%44 = icmp sgt i32 %43, -1
%45 = select i1 %44, i32 %43, i32 -1
br label %46
46: ; preds = %41, %12, %1, %1, %7
%47 = phi i32 [ %11, %7 ], [ -1, %1 ], [ -1, %1 ], [ -1, %12 ], [ %45, %41 ]
ret i32 %47
}