#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*/ strcmp(char const *, char *);
int get_multiplier(const char *str) {
  if (!str)
    return 1;
  while (*str == ' ' || *str == '\t')
    str += 1;
  if (!strcmp(str, "KiB"))
    return 1024;
  if (!strcmp(str, "MiB"))
    return 1024 * 1024;
  if (!strcmp(str, "GiB"))
    return 1024 * 1024 * 1024;
  return -1;
}


x86 assembly (clang, -O0):
<get_multiplier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <get_multiplier+0x23>
movl   $0x1,-0x4(%rbp)
jmp    11f4 <get_multiplier+0xe4>
jmp    1138 <get_multiplier+0x28>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x11(%rbp)
je     115d <get_multiplier+0x4d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    116d <get_multiplier+0x5d>
jmp    117e <get_multiplier+0x6e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1138 <get_multiplier+0x28>
mov    -0x10(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11a3 <get_multiplier+0x93>
movl   $0x400,-0x4(%rbp)
jmp    11f4 <get_multiplier+0xe4>
mov    -0x10(%rbp),%rdi
lea    0xe56(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11c8 <get_multiplier+0xb8>
movl   $0x100000,-0x4(%rbp)
jmp    11f4 <get_multiplier+0xe4>
mov    -0x10(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11ed <get_multiplier+0xdd>
movl   $0x40000000,-0x4(%rbp)
jmp    11f4 <get_multiplier+0xe4>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_multiplier>:
push   %rbx
test   %rdi,%rdi
je     116f <get_multiplier+0x5f>
mov    %rdi,%rbx
jmp    1124 <get_multiplier+0x14>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x20,%al
je     1120 <get_multiplier+0x10>
cmp    $0x9,%al
je     1120 <get_multiplier+0x10>
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1176 <get_multiplier+0x66>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     117d <get_multiplier+0x6d>
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
neg    %eax
sbb    %eax,%eax
or     $0x40000000,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x400,%eax
pop    %rbx
ret
mov    $0x100000,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"KiB\00"
@.str.1 = [4 x i8] c"MiB\00"
@.str.2 = [4 x i8] c"GiB\00"
define i32 @get_multiplier(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %1
store i32 1, i32* %2
br label %39
7: ; preds = %1
br label %8
8: ; preds = %20, %7
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 32
br i1 %12, label %18, label %13
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 9
br label %18
18: ; preds = %13, %8
%19 = phi i1 [ true, %8 ], [ %17, %13 ]
br i1 %19, label %20, label %23
20: ; preds = %18
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %3
br label %8
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i32 1024, i32* %2
br label %39
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %28
store i32 1048576, i32* %2
br label %39
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = call i32 @strcmp(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp ne i32 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %33
store i32 1073741824, i32* %2
br label %39
38: ; preds = %33
store i32 -1, i32* %2
br label %39
39: ; preds = %38, %37, %32, %27, %6
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@.str = [4 x i8] c"KiB\00"
@.str.1 = [4 x i8] c"MiB\00"
@.str.2 = [4 x i8] c"GiB\00"
define i32 @get_multiplier(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %18, label %3
3: ; preds = %1, %6
%4 = phi i8* [ %7, %6 ], [ %0, %1 ]
%5 = load i8, i8* %4
switch i8 %5, label %8 [
i8 32, label %6
i8 9, label %6
]
6: ; preds = %3, %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
8: ; preds = %3
%9 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %8
%12 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i32 1073741824, i32 -1
br label %18
18: ; preds = %14, %11, %8, %1
%19 = phi i32 [ 1, %1 ], [ 1024, %8 ], [ 1048576, %11 ], [ %17, %14 ]
ret i32 %19
}