#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 */
long atol(char *);
scalar_t__ strcmp(char *, char *);
long strlen(char *);
long ConvertBufferSize_atol(char *bufsize_desc) {
  long bufsize_desc_len;
  bufsize_desc_len = strlen(bufsize_desc);
  if (bufsize_desc_len > 2 &&
      strcmp(bufsize_desc + bufsize_desc_len - 2, "GB") == 0)
    return atol(bufsize_desc) * 1024 * 1024 * 1024;
  else if (bufsize_desc_len > 2 &&
           strcmp(bufsize_desc + bufsize_desc_len - 2, "MB") == 0)
    return atol(bufsize_desc) * 1024 * 1024;
  else if (bufsize_desc_len > 2 &&
           strcmp(bufsize_desc + bufsize_desc_len - 2, "KB") == 0)
    return atol(bufsize_desc) * 1024;
  else if (bufsize_desc_len > 1 &&
           strcmp(bufsize_desc + bufsize_desc_len - 1, "B") == 0)
    return atol(bufsize_desc);
  else
    return atol(bufsize_desc);
}


x86 assembly (clang, -O0):
<ConvertBufferSize_atol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x2,-0x18(%rbp)
jle    1194 <ConvertBufferSize_atol+0x64>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xe99(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1194 <ConvertBufferSize_atol+0x64>
mov    -0x10(%rbp),%rdi
call   1050 <atol@plt>
shl    $0xa,%rax
shl    $0xa,%rax
shl    $0xa,%rax
mov    %rax,-0x8(%rbp)
jmp    126a <ConvertBufferSize_atol+0x13a>
cmpq   $0x2,-0x18(%rbp)
jle    11db <ConvertBufferSize_atol+0xab>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11db <ConvertBufferSize_atol+0xab>
mov    -0x10(%rbp),%rdi
call   1050 <atol@plt>
shl    $0xa,%rax
shl    $0xa,%rax
mov    %rax,-0x8(%rbp)
jmp    126a <ConvertBufferSize_atol+0x13a>
cmpq   $0x2,-0x18(%rbp)
jle    121e <ConvertBufferSize_atol+0xee>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
add    $0xfffffffffffffffe,%rdi
lea    0xe0d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    121e <ConvertBufferSize_atol+0xee>
mov    -0x10(%rbp),%rdi
call   1050 <atol@plt>
shl    $0xa,%rax
mov    %rax,-0x8(%rbp)
jmp    126a <ConvertBufferSize_atol+0x13a>
cmpq   $0x1,-0x18(%rbp)
jle    125d <ConvertBufferSize_atol+0x12d>
mov    -0x10(%rbp),%rdi
add    -0x18(%rbp),%rdi
add    $0xffffffffffffffff,%rdi
lea    0xdc5(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    125d <ConvertBufferSize_atol+0x12d>
mov    -0x10(%rbp),%rdi
call   1050 <atol@plt>
mov    %rax,-0x8(%rbp)
jmp    126a <ConvertBufferSize_atol+0x13a>
mov    -0x10(%rbp),%rdi
call   1050 <atol@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConvertBufferSize_atol>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %rax,%rbx
cmp    $0x3,%rax
jl     1198 <ConvertBufferSize_atol+0x68>
lea    (%r14,%rbx,1),%r15
add    $0xfffffffffffffffe,%r15
lea    0xeab(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c2 <ConvertBufferSize_atol+0x92>
lea    0xe9a(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d0 <ConvertBufferSize_atol+0xa0>
lea    0xe89(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    119e <ConvertBufferSize_atol+0x6e>
mov    %r14,%rdi
call   1050 <atol@plt>
shl    $0xa,%rax
jmp    11dc <ConvertBufferSize_atol+0xac>
cmp    $0x2,%rbx
jne    11b5 <ConvertBufferSize_atol+0x85>
lea    (%r14,%rbx,1),%rdi
add    $0xffffffffffffffff,%rdi
lea    0xe54(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <atol@plt>
mov    %r14,%rdi
call   1050 <atol@plt>
shl    $0x1e,%rax
jmp    11dc <ConvertBufferSize_atol+0xac>
mov    %r14,%rdi
call   1050 <atol@plt>
shl    $0x14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"GB\00"
@.str.1 = [3 x i8] c"MB\00"
@.str.2 = [3 x i8] c"KB\00"
@.str.3 = [2 x i8] c"B\00"
define i64 @ConvertBufferSize_atol(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strlen(i8* %5)
store i64 %6, i64* %4
%7 = load i64, i64* %4
%8 = icmp sgt i64 %7, 2
br i1 %8, label %9, label %22
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i64, i64* %4
%12 = getelementptr inbounds i8, i8* %10, i64 %11
%13 = getelementptr inbounds i8, i8* %12, i64 -2
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %9
%17 = load i8*, i8** %3
%18 = call i64 @atol(i8* %17)
%19 = mul nsw i64 %18, 1024
%20 = mul nsw i64 %19, 1024
%21 = mul nsw i64 %20, 1024
store i64 %21, i64* %2
br label %67
22: ; preds = %9, %1
%23 = load i64, i64* %4
%24 = icmp sgt i64 %23, 2
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load i8*, i8** %3
%27 = load i64, i64* %4
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 -2
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %25
%33 = load i8*, i8** %3
%34 = call i64 @atol(i8* %33)
%35 = mul nsw i64 %34, 1024
%36 = mul nsw i64 %35, 1024
store i64 %36, i64* %2
br label %67
37: ; preds = %25, %22
%38 = load i64, i64* %4
%39 = icmp sgt i64 %38, 2
br i1 %39, label %40, label %51
40: ; preds = %37
%41 = load i8*, i8** %3
%42 = load i64, i64* %4
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = getelementptr inbounds i8, i8* %43, i64 -2
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %40
%48 = load i8*, i8** %3
%49 = call i64 @atol(i8* %48)
%50 = mul nsw i64 %49, 1024
store i64 %50, i64* %2
br label %67
51: ; preds = %40, %37
%52 = load i64, i64* %4
%53 = icmp sgt i64 %52, 1
br i1 %53, label %54, label %64
54: ; preds = %51
%55 = load i8*, i8** %3
%56 = load i64, i64* %4
%57 = getelementptr inbounds i8, i8* %55, i64 %56
%58 = getelementptr inbounds i8, i8* %57, i64 -1
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %54
%62 = load i8*, i8** %3
%63 = call i64 @atol(i8* %62)
store i64 %63, i64* %2
br label %67
64: ; preds = %54, %51
%65 = load i8*, i8** %3
%66 = call i64 @atol(i8* %65)
store i64 %66, i64* %2
br label %67
67: ; preds = %64, %61, %47, %32, %16
%68 = load i64, i64* %2
ret i64 %68
}

LLVM IR (-O2):
@.str = [3 x i8] c"GB\00"
@.str.1 = [3 x i8] c"MB\00"
@.str.2 = [3 x i8] c"KB\00"
@.str.3 = [2 x i8] c"B\00"
define i64 @ConvertBufferSize_atol(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp sgt i64 %2, 2
br i1 %3, label %4, label %24
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 %2
%6 = getelementptr inbounds i8, i8* %5, i64 -2
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = tail call i64 @atol(i8* %0)
%11 = shl nsw i64 %10, 30
br label %35
12: ; preds = %4
%13 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = tail call i64 @atol(i8* %0)
%17 = shl nsw i64 %16, 20
br label %35
18: ; preds = %12
%19 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = tail call i64 @atol(i8* %0)
%23 = shl nsw i64 %22, 10
br label %35
24: ; preds = %1
%25 = icmp eq i64 %2, 2
br i1 %25, label %26, label %33
26: ; preds = %18, %24
%27 = getelementptr inbounds i8, i8* %0, i64 %2
%28 = getelementptr inbounds i8, i8* %27, i64 -1
%29 = tail call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = tail call i64 @atol(i8* %0)
br label %35
33: ; preds = %26, %24
%34 = tail call i64 @atol(i8* %0)
br label %35
35: ; preds = %33, %31, %21, %15, %9
%36 = phi i64 [ %11, %9 ], [ %17, %15 ], [ %23, %21 ], [ %32, %31 ], [ %34, %33 ]
ret i64 %36
}