#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*/ fprintf(int /*<<< orphan*/, char *, char const *);
int get_multiplier(char *);
int /*<<< orphan*/ stderr;
long long strtoull(char const *, char **, int /*<<< orphan*/);
long long ubiutils_get_bytes(const char *str) {
  char *endp;
  long long bytes = strtoull(str, &endp, 0);
  if (endp == str || bytes < 0) {
    fprintf(stderr, "incorrect amount of bytes: \"%s\"\n", str);
    return -1;
  }
  if (*endp != '\0') {
    int mult = get_multiplier(endp);
    if (mult == -1) {
      fprintf(stderr,
              "bad size specifier: \"%s\" - "
              "should be 'KiB', 'MiB' or 'GiB'\n",
              endp);
      return -1;
    }
    bytes *= mult;
  }
  return bytes;
}


x86 assembly (clang, -O0):
<ubiutils_get_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoull@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1168 <ubiutils_get_bytes+0x38>
cmpq   $0x0,-0x20(%rbp)
jge    118e <ubiutils_get_bytes+0x5e>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe84(%rip),%rsi
call   1050 <fprintf@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11ef <ubiutils_get_bytes+0xbf>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e7 <ubiutils_get_bytes+0xb7>
mov    -0x18(%rbp),%rdi
call   1030 <get_multiplier@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    11da <ubiutils_get_bytes+0xaa>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe59(%rip),%rsi
call   1050 <fprintf@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11ef <ubiutils_get_bytes+0xbf>
movslq -0x24(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ubiutils_get_bytes>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1040 <strtoull@plt>
mov    0x8(%rsp),%r14
cmp    %rbx,%r14
je     1175 <ubiutils_get_bytes+0x45>
mov    %rax,%r15
test   %rax,%rax
js     1175 <ubiutils_get_bytes+0x45>
cmpb   $0x0,(%r14)
je     11a9 <ubiutils_get_bytes+0x79>
mov    %r14,%rdi
call   1030 <get_multiplier@plt>
cmp    $0xffffffff,%eax
je     118a <ubiutils_get_bytes+0x5a>
cltq
imul   %rax,%r15
jmp    11a9 <ubiutils_get_bytes+0x79>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    %rbx,%rdx
jmp    119d <ubiutils_get_bytes+0x6d>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
mov    $0xffffffffffffffff,%r15
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"incorrect amount of bytes: \22%s\22\0A\00"
@.str.1 = [60 x i8] c"bad size specifier: \22%s\22 - should be 'KiB', 'MiB' or 'GiB'\0A\00"
define i64 @ubiutils_get_bytes(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strtoull(i8* %7, i8** %4, i32 0)
store i64 %8, i64* %5
%9 = load i8*, i8** %4
%10 = load i8*, i8** %3
%11 = icmp eq i8* %9, %10
br i1 %11, label %15, label %12
12: ; preds = %1
%13 = load i64, i64* %5
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12, %1
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %3
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %17)
store i64 -1, i64* %2
br label %40
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %38
24: ; preds = %19
%25 = load i8*, i8** %4
%26 = call i32 @get_multiplier(i8* %25)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %4
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i8* %31)
store i64 -1, i64* %2
br label %40
33: ; preds = %24
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = load i64, i64* %5
%37 = mul nsw i64 %36, %35
store i64 %37, i64* %5
br label %38
38: ; preds = %33, %19
%39 = load i64, i64* %5
store i64 %39, i64* %2
br label %40
40: ; preds = %38, %29, %15
%41 = load i64, i64* %2
ret i64 %41
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"incorrect amount of bytes: \22%s\22\0A\00"
@.str.1 = [60 x i8] c"bad size specifier: \22%s\22 - should be 'KiB', 'MiB' or 'GiB'\0A\00"
define i64 @ubiutils_get_bytes(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i64 @strtoull(i8* %0, i8** %2, i32 0)
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, %0
%7 = icmp slt i64 %4, 0
%8 = select i1 %6, i1 true, i1 %7
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %24
12: ; preds = %1
%13 = load i8, i8* %5
%14 = icmp eq i8 %13, 0
br i1 %14, label %24, label %15
15: ; preds = %12
%16 = tail call i32 @get_multiplier(i8* %5)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %24
21: ; preds = %15
%22 = sext i32 %16 to i64
%23 = mul nsw i64 %4, %22
br label %24
24: ; preds = %12, %21, %18, %9
%25 = phi i64 [ -1, %9 ], [ -1, %18 ], [ %23, %21 ], [ %4, %12 ]
ret i64 %25
}