#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*/ strcasecmp(char const *, char *);
int parse_unit_factor(const char *end, unsigned long *val) {
  if (!*end)
    return 1;
  else if (!strcasecmp(end, "k")) {
    *val *= 1024;
    return 1;
  } else if (!strcasecmp(end, "m")) {
    *val *= 1024 * 1024;
    return 1;
  } else if (!strcasecmp(end, "g")) {
    *val *= 1024 * 1024 * 1024;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_unit_factor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1139 <parse_unit_factor+0x29>
movl   $0x1,-0x4(%rbp)
jmp    11e8 <parse_unit_factor+0xd8>
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    116c <parse_unit_factor+0x5c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
shl    $0xa,%rcx
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11e8 <parse_unit_factor+0xd8>
mov    -0x10(%rbp),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    119f <parse_unit_factor+0x8f>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
shl    $0x14,%rcx
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11e8 <parse_unit_factor+0xd8>
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11d2 <parse_unit_factor+0xc2>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
shl    $0x1e,%rcx
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11e8 <parse_unit_factor+0xd8>
jmp    11d7 <parse_unit_factor+0xc7>
jmp    11dc <parse_unit_factor+0xcc>
jmp    11e1 <parse_unit_factor+0xd1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_unit_factor>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%eax
cmpb   $0x0,(%rdi)
je     1179 <parse_unit_factor+0x69>
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xed5(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1165 <parse_unit_factor+0x55>
lea    0xec7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     116c <parse_unit_factor+0x5c>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    1179 <parse_unit_factor+0x69>
mov    $0x1e,%ecx
jmp    1171 <parse_unit_factor+0x61>
mov    $0xa,%ecx
jmp    1171 <parse_unit_factor+0x61>
mov    $0x14,%ecx
shlq   %cl,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"k\00"
@.str.1 = [2 x i8] c"m\00"
@.str.2 = [2 x i8] c"g\00"
define i32 @parse_unit_factor(i8* nocapture %0, i64* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %2
%6 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %5
%9 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @strcasecmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11, %8, %5
%15 = phi i64 [ 10, %5 ], [ 20, %8 ], [ 30, %11 ]
%16 = load i64, i64* %1
%17 = shl i64 %16, %15
store i64 %17, i64* %1
br label %18
18: ; preds = %14, %11, %2
%19 = phi i32 [ 1, %2 ], [ 0, %11 ], [ 1, %14 ]
ret i32 %19
}