#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__ strcasecmp(char *, char *);
double strtod(char *, char **);
int get_size(unsigned *size, char *str) {
  double sz;
  char *p;
  sz = strtod(str, &p);
  if (p == str)
    return -1;
  if (*p) {
    if (strcasecmp(p, "kb") == 0 || strcasecmp(p, "k") == 0)
      sz *= 1024;
    else if (strcasecmp(p, "mb") == 0 || strcasecmp(p, "m") == 0)
      sz *= 1024 * 1024;
    else if (strcasecmp(p, "mbit") == 0)
      sz *= 1024 * 1024 / 8;
    else if (strcasecmp(p, "kbit") == 0)
      sz *= 1024 / 8;
    else if (strcasecmp(p, "b") != 0)
      return -1;
  }
  *size = sz;
  return 0;
}


x86 assembly (clang, -O0):
<get_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    115c <get_size+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b5 <get_size+0x195>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     12a0 <get_size+0x180>
mov    -0x28(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     119d <get_size+0x7d>
mov    -0x28(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11b4 <get_size+0x94>
movsd  0xe73(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    129b <get_size+0x17b>
mov    -0x28(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     11e8 <get_size+0xc8>
mov    -0x28(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11ff <get_size+0xdf>
movsd  0xe20(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1296 <get_size+0x176>
mov    -0x28(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1230 <get_size+0x110>
movsd  0xde7(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1291 <get_size+0x171>
mov    -0x28(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1261 <get_size+0x141>
movsd  0xdae(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    128c <get_size+0x16c>
mov    -0x28(%rbp),%rdi
lea    0xdb5(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1287 <get_size+0x167>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b5 <get_size+0x195>
jmp    128c <get_size+0x16c>
jmp    1291 <get_size+0x171>
jmp    1296 <get_size+0x176>
jmp    129b <get_size+0x17b>
jmp    12a0 <get_size+0x180>
cvttsd2si -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_size>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %rdi,%r14
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
call   1040 <strtod@plt>
mov    0x10(%rsp),%rbx
mov    $0xffffffff,%r15d
cmp    %rbp,%rbx
je     1221 <get_size+0x101>
cmpb   $0x0,(%rbx)
je     1216 <get_size+0xf6>
movsd  %xmm0,0x8(%rsp)
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11f8 <get_size+0xd8>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11f8 <get_size+0xd8>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1208 <get_size+0xe8>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1208 <get_size+0xe8>
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     122f <get_size+0x10f>
lea    0xe60(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     123f <get_size+0x11f>
lea    0xe3e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
movsd  0x8(%rsp),%xmm0
jne    1221 <get_size+0x101>
jmp    1216 <get_size+0xf6>
movsd  0x8(%rsp),%xmm0
mulsd  0xe12(%rip),%xmm0
jmp    1216 <get_size+0xf6>
movsd  0x8(%rsp),%xmm0
mulsd  0xdfa(%rip),%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,(%r14)
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movsd  0x8(%rsp),%xmm0
mulsd  0xdcb(%rip),%xmm0
jmp    1216 <get_size+0xf6>
movsd  0x8(%rsp),%xmm0
mulsd  0xdb3(%rip),%xmm0
jmp    1216 <get_size+0xf6>

LLVM IR (-O0):
@.str = [3 x i8] c"kb\00"
@.str.1 = [2 x i8] c"k\00"
@.str.2 = [3 x i8] c"mb\00"
@.str.3 = [2 x i8] c"m\00"
@.str.4 = [5 x i8] c"mbit\00"
@.str.5 = [5 x i8] c"kbit\00"
@.str.6 = [2 x i8] c"b\00"
define i32 @get_size(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca double
%7 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call double @strtod(i8* %8, i8** %7)
store double %9, double* %6
%10 = load i8*, i8** %7
%11 = load i8*, i8** %5
%12 = icmp eq i8* %10, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 -1, i32* %3
br label %68
14: ; preds = %2
%15 = load i8*, i8** %7
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %18, label %64
18: ; preds = %14
%19 = load i8*, i8** %7
%20 = call i64 @strcasecmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = load i8*, i8** %7
%24 = call i64 @strcasecmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22, %18
%27 = load double, double* %6
%28 = fmul double %27, 1.024000e+03
store double %28, double* %6
br label %63
29: ; preds = %22
%30 = load i8*, i8** %7
%31 = call i64 @strcasecmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i8*, i8** %7
%35 = call i64 @strcasecmp(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33, %29
%38 = load double, double* %6
%39 = fmul double %38, 0x4130000000000000
store double %39, double* %6
br label %62
40: ; preds = %33
%41 = load i8*, i8** %7
%42 = call i64 @strcasecmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load double, double* %6
%46 = fmul double %45, 1.310720e+05
store double %46, double* %6
br label %61
47: ; preds = %40
%48 = load i8*, i8** %7
%49 = call i64 @strcasecmp(i8* %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load double, double* %6
%53 = fmul double %52, 1.280000e+02
store double %53, double* %6
br label %60
54: ; preds = %47
%55 = load i8*, i8** %7
%56 = call i64 @strcasecmp(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %54
store i32 -1, i32* %3
br label %68
59: ; preds = %54
br label %60
60: ; preds = %59, %51
br label %61
61: ; preds = %60, %44
br label %62
62: ; preds = %61, %37
br label %63
63: ; preds = %62, %26
br label %64
64: ; preds = %63, %14
%65 = load double, double* %6
%66 = fptoui double %65 to i32
%67 = load i32*, i32** %4
store i32 %66, i32* %67
store i32 0, i32* %3
br label %68
68: ; preds = %64, %58, %13
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@.str = [3 x i8] c"kb\00"
@.str.1 = [2 x i8] c"k\00"
@.str.2 = [3 x i8] c"mb\00"
@.str.3 = [2 x i8] c"m\00"
@.str.4 = [5 x i8] c"mbit\00"
@.str.5 = [5 x i8] c"kbit\00"
@.str.6 = [2 x i8] c"b\00"
define i32 @get_size(i32* nocapture writeonly %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call double @strtod(i8* %1, i8** %3)
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, %1
br i1 %7, label %43, label %8
8: ; preds = %2
%9 = load i8, i8* %6
%10 = icmp eq i8 %9, 0
br i1 %10, label %40, label %11
11: ; preds = %8
%12 = tail call i64 @strcasecmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = tail call i64 @strcasecmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14, %11
%18 = fmul double %5, 1.024000e+03
br label %40
19: ; preds = %14
%20 = tail call i64 @strcasecmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = tail call i64 @strcasecmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22, %19
%26 = fmul double %5, 0x4130000000000000
br label %40
27: ; preds = %22
%28 = tail call i64 @strcasecmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = fmul double %5, 1.310720e+05
br label %40
32: ; preds = %27
%33 = tail call i64 @strcasecmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = fmul double %5, 1.280000e+02
br label %40
37: ; preds = %32
%38 = tail call i64 @strcasecmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %17, %30, %37, %35, %25, %8
%41 = phi double [ %18, %17 ], [ %26, %25 ], [ %31, %30 ], [ %36, %35 ], [ %5, %37 ], [ %5, %8 ]
%42 = fptoui double %41 to i32
store i32 %42, i32* %0
br label %43
43: ; preds = %37, %2, %40
%44 = phi i32 [ 0, %40 ], [ -1, %2 ], [ -1, %37 ]
ret i32 %44
}