#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 */
typedef int ssize_t;

/* Variables and functions */
size_t strlen(char const *);
size_t strtol(char const *, char **, int);
ssize_t parse_bytes(const char *arg) {
  size_t arg_len = strlen(arg);
  if (arg_len < 2) {
    return -1;
  }
  char *suffix;
  size_t size = strtol(arg, &suffix, 10);
  switch (suffix[0]) {
  case 'm':
  case 'M':
    size *= 1024;
  case 'k':
  case 'K':
    size *= 1024;
  case 'b':
  case 'B':
  default:
    return size;
  }
}


x86 assembly (clang, -O0):
<parse_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x2,-0x18(%rbp)
jae    1150 <parse_bytes+0x30>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f7 <parse_bytes+0xd7>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x42,%eax
je     11eb <parse_bytes+0xcb>
jmp    117e <parse_bytes+0x5e>
mov    -0x2c(%rbp),%eax
sub    $0x4b,%eax
je     11df <parse_bytes+0xbf>
jmp    118f <parse_bytes+0x6f>
mov    -0x2c(%rbp),%eax
sub    $0x4d,%eax
je     11d3 <parse_bytes+0xb3>
jmp    11a0 <parse_bytes+0x80>
mov    -0x2c(%rbp),%eax
sub    $0x62,%eax
je     11eb <parse_bytes+0xcb>
jmp    11b1 <parse_bytes+0x91>
mov    -0x2c(%rbp),%eax
sub    $0x6b,%eax
je     11df <parse_bytes+0xbf>
jmp    11c2 <parse_bytes+0xa2>
mov    -0x2c(%rbp),%eax
sub    $0x6d,%eax
jne    11f0 <parse_bytes+0xd0>
jmp    11d3 <parse_bytes+0xb3>
mov    -0x28(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x28(%rbp)
jmp    11f0 <parse_bytes+0xd0>
mov    -0x28(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_bytes>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
cmp    $0x2,%rcx
jb     1175 <parse_bytes+0x55>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    0x8(%rsp),%rcx
movsbl (%rcx),%ecx
add    $0xffffffb5,%ecx
cmp    $0x22,%ecx
ja     1175 <parse_bytes+0x55>
lea    0xe9c(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
shl    $0xa,%rax
shl    $0xa,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @parse_bytes(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %4
%9 = load i64, i64* %4
%10 = icmp ult i64 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 -1, i32* %2
br label %29
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i64 @strtol(i8* %13, i8** %5, i32 10)
store i64 %14, i64* %6
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %26 [
i32 109, label %19
i32 77, label %19
i32 107, label %22
i32 75, label %22
i32 98, label %25
i32 66, label %25
]
19: ; preds = %12, %12
%20 = load i64, i64* %6
%21 = mul i64 %20, 1024
store i64 %21, i64* %6
br label %22
22: ; preds = %12, %12, %19
%23 = load i64, i64* %6
%24 = mul i64 %23, 1024
store i64 %24, i64* %6
br label %25
25: ; preds = %12, %12, %22
br label %26
26: ; preds = %12, %25
%27 = load i64, i64* %6
%28 = trunc i64 %27 to i32
store i32 %28, i32* %2
br label %29
29: ; preds = %26, %11
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @parse_bytes(i8* %0) {
%2 = alloca i8*
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = icmp ult i64 %3, 2
br i1 %4, label %19, label %5
5: ; preds = %1
%6 = bitcast i8** %2 to i8*
%7 = call i64 @strtol(i8* %0, i8** %2, i32 10)
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %16 [
i32 109, label %11
i32 77, label %11
i32 107, label %13
i32 75, label %13
]
11: ; preds = %5, %5
%12 = shl i64 %7, 10
br label %13
13: ; preds = %5, %5, %11
%14 = phi i64 [ %7, %5 ], [ %7, %5 ], [ %12, %11 ]
%15 = shl i64 %14, 10
br label %16
16: ; preds = %13, %5
%17 = phi i64 [ %7, %5 ], [ %15, %13 ]
%18 = trunc i64 %17 to i32
br label %19
19: ; preds = %1, %16
%20 = phi i32 [ %18, %16 ], [ -1, %1 ]
ret i32 %20
}