#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 */
unsigned long long strtoull(char const *, char **, int /*<<< orphan*/);
unsigned long long parse_num_blocks2(const char *arg, int log_block_size) {
  char *p;
  unsigned long long num;
  num = strtoull(arg, &p, 0);
  if (p[0] && p[1])
    return 0;
  switch (*p) {
  case 'T':
  case 't':
    num <<= 10;
  case 'G':
  case 'g':
    num <<= 10;
  case 'M':
  case 'm':
    num <<= 10;
  case 'K':
  case 'k':
    num >>= log_block_size;
    break;
  case 's':
    num >>= (1 + log_block_size);
    break;
  case '\0':
    break;
  default:
    return 0;
  }
  return num;
}


x86 assembly (clang, -O0):
<parse_num_blocks2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1030 <strtoull@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1160 <parse_num_blocks2+0x50>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1160 <parse_num_blocks2+0x50>
movq   $0x0,-0x8(%rbp)
jmp    127b <parse_num_blocks2+0x16b>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     1261 <parse_num_blocks2+0x151>
jmp    1177 <parse_num_blocks2+0x67>
mov    -0x2c(%rbp),%eax
sub    $0x47,%eax
je     121c <parse_num_blocks2+0x10c>
jmp    1188 <parse_num_blocks2+0x78>
mov    -0x2c(%rbp),%eax
sub    $0x4b,%eax
je     1234 <parse_num_blocks2+0x124>
jmp    1199 <parse_num_blocks2+0x89>
mov    -0x2c(%rbp),%eax
sub    $0x4d,%eax
je     1228 <parse_num_blocks2+0x118>
jmp    11aa <parse_num_blocks2+0x9a>
mov    -0x2c(%rbp),%eax
sub    $0x54,%eax
je     1210 <parse_num_blocks2+0x100>
jmp    11bb <parse_num_blocks2+0xab>
mov    -0x2c(%rbp),%eax
sub    $0x67,%eax
je     121c <parse_num_blocks2+0x10c>
jmp    11cc <parse_num_blocks2+0xbc>
mov    -0x2c(%rbp),%eax
sub    $0x6b,%eax
je     1234 <parse_num_blocks2+0x124>
jmp    11dd <parse_num_blocks2+0xcd>
mov    -0x2c(%rbp),%eax
sub    $0x6d,%eax
je     1228 <parse_num_blocks2+0x118>
jmp    11ee <parse_num_blocks2+0xde>
mov    -0x2c(%rbp),%eax
sub    $0x73,%eax
je     1249 <parse_num_blocks2+0x139>
jmp    11ff <parse_num_blocks2+0xef>
mov    -0x2c(%rbp),%eax
sub    $0x74,%eax
jne    1266 <parse_num_blocks2+0x156>
jmp    1210 <parse_num_blocks2+0x100>
mov    -0x28(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,%ecx
shr    %cl,%rax
mov    %rax,-0x28(%rbp)
jmp    1273 <parse_num_blocks2+0x163>
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,%ecx
shr    %cl,%rax
mov    %rax,-0x28(%rbp)
jmp    1273 <parse_num_blocks2+0x163>
jmp    1273 <parse_num_blocks2+0x163>
movq   $0x0,-0x8(%rbp)
jmp    127b <parse_num_blocks2+0x16b>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_num_blocks2>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <strtoull@plt>
mov    0x8(%rsp),%rcx
movsbl (%rcx),%edx
test   %edx,%edx
je     1164 <parse_num_blocks2+0x54>
cmpb   $0x0,0x1(%rcx)
je     1139 <parse_num_blocks2+0x29>
xor    %ecx,%ecx
jmp    1167 <parse_num_blocks2+0x57>
xor    %ecx,%ecx
lea    -0x47(%rdx),%esi
cmp    $0x2d,%esi
ja     1170 <parse_num_blocks2+0x60>
lea    0xeb6(%rip),%rdx
movslq (%rdx,%rsi,4),%rsi
add    %rdx,%rsi
jmp    *%rsi
shl    $0xa,%rax
shl    $0xa,%rax
shl    $0xa,%rax
mov    %ebx,%ecx
shr    %cl,%rax
mov    %rax,%rcx
mov    %rcx,%rax
add    $0x10,%rsp
pop    %rbx
ret
test   %edx,%edx
je     1164 <parse_num_blocks2+0x54>
jmp    1167 <parse_num_blocks2+0x57>
add    $0x1,%bl
jmp    115f <parse_num_blocks2+0x4f>

LLVM IR (-O0):
define i64 @parse_num_blocks2(i8* %0, i32 %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = call i64 @strtoull(i8* %8, i8** %6, i32 0)
store i64 %9, i64* %7
%10 = load i8*, i8** %6
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %15
store i64 0, i64* %3
br label %50
22: ; preds = %15, %2
%23 = load i8*, i8** %6
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
switch i32 %25, label %47 [
i32 84, label %26
i32 116, label %26
i32 71, label %29
i32 103, label %29
i32 77, label %32
i32 109, label %32
i32 75, label %35
i32 107, label %35
i32 115, label %40
i32 0, label %46
]
26: ; preds = %22, %22
%27 = load i64, i64* %7
%28 = shl i64 %27, 10
store i64 %28, i64* %7
br label %29
29: ; preds = %22, %22, %26
%30 = load i64, i64* %7
%31 = shl i64 %30, 10
store i64 %31, i64* %7
br label %32
32: ; preds = %22, %22, %29
%33 = load i64, i64* %7
%34 = shl i64 %33, 10
store i64 %34, i64* %7
br label %35
35: ; preds = %22, %22, %32
%36 = load i32, i32* %5
%37 = load i64, i64* %7
%38 = zext i32 %36 to i64
%39 = lshr i64 %37, %38
store i64 %39, i64* %7
br label %48
40: ; preds = %22
%41 = load i32, i32* %5
%42 = add nsw i32 1, %41
%43 = load i64, i64* %7
%44 = zext i32 %42 to i64
%45 = lshr i64 %43, %44
store i64 %45, i64* %7
br label %48
46: ; preds = %22
br label %48
47: ; preds = %22
store i64 0, i64* %3
br label %50
48: ; preds = %46, %40, %35
%49 = load i64, i64* %7
store i64 %49, i64* %3
br label %50
50: ; preds = %48, %47, %21
%51 = load i64, i64* %3
ret i64 %51
}

LLVM IR (-O2):
define i64 @parse_num_blocks2(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i64 @strtoull(i8* %0, i8** %3, i32 0)
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %31, label %9
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %9
%14 = sext i8 %7 to i32
switch i32 %14, label %33 [
i32 84, label %15
i32 116, label %15
i32 71, label %17
i32 103, label %17
i32 77, label %20
i32 109, label %20
i32 75, label %23
i32 107, label %23
i32 115, label %27
i32 0, label %31
]
15: ; preds = %13, %13
%16 = shl i64 %5, 10
br label %17
17: ; preds = %13, %13, %15
%18 = phi i64 [ %5, %13 ], [ %5, %13 ], [ %16, %15 ]
%19 = shl i64 %18, 10
br label %20
20: ; preds = %13, %13, %17
%21 = phi i64 [ %5, %13 ], [ %5, %13 ], [ %19, %17 ]
%22 = shl i64 %21, 10
br label %23
23: ; preds = %13, %13, %20
%24 = phi i64 [ %5, %13 ], [ %5, %13 ], [ %22, %20 ]
%25 = zext i32 %1 to i64
%26 = lshr i64 %24, %25
br label %31
27: ; preds = %13
%28 = add nsw i32 %1, 1
%29 = zext i32 %28 to i64
%30 = lshr i64 %5, %29
br label %31
31: ; preds = %2, %13, %27, %23
%32 = phi i64 [ %5, %13 ], [ %30, %27 ], [ %26, %23 ], [ %5, %2 ]
br label %33
33: ; preds = %13, %9, %31
%34 = phi i64 [ %32, %31 ], [ 0, %9 ], [ 0, %13 ]
ret i64 %34
}