#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 *, char *);
scalar_t__ strlen(char *);
char *strupper(char *);
int getCompression(char *str) {
  char *upstr = strupper(str);
  if (!strcmp(upstr, "AUTO") || !strcmp(upstr, "BEST") || !strcmp(upstr, "-1"))
    return -1;
  if (!strcmp(upstr, "NONE") || !strcmp(upstr, "0"))
    return 0;
  if (!strcmp(upstr, "APLIB") || !strcmp(upstr, "1"))
    return 1;
  if (!strcmp(upstr, "LZ4W") || !strcmp(upstr, "2") || !strcmp(upstr, "FAST"))
    return 2;
  if (strlen(upstr) > 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<getCompression>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strupper@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1194 <getCompression+0x64>
mov    -0x18(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1194 <getCompression+0x64>
mov    -0x18(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11a0 <getCompression+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    1299 <getCompression+0x169>
mov    -0x18(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     11d2 <getCompression+0xa2>
mov    -0x18(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11de <getCompression+0xae>
movl   $0x0,-0x4(%rbp)
jmp    1299 <getCompression+0x169>
mov    -0x18(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1210 <getCompression+0xe0>
mov    -0x18(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    121c <getCompression+0xec>
movl   $0x1,-0x4(%rbp)
jmp    1299 <getCompression+0x169>
mov    -0x18(%rbp),%rdi
lea    0xdf3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1267 <getCompression+0x137>
mov    -0x18(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     1267 <getCompression+0x137>
mov    -0x18(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1273 <getCompression+0x143>
movl   $0x2,-0x4(%rbp)
jmp    1299 <getCompression+0x169>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jle    1292 <getCompression+0x162>
movl   $0xffffffff,-0x4(%rbp)
jmp    1299 <getCompression+0x169>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCompression>:
push   %rbp
push   %rbx
push   %rax
call   1050 <strupper@plt>
mov    %rax,%rbx
lea    0xebe(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
je     122d <getCompression+0xfd>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122d <getCompression+0xfd>
lea    0xe95(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122d <getCompression+0xfd>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     122d <getCompression+0xfd>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122d <getCompression+0xfd>
lea    0xe5c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     122d <getCompression+0xfd>
lea    0xe3b(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122d <getCompression+0xfd>
lea    0xe37(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    $0x2,%ebp
test   %eax,%eax
je     122d <getCompression+0xfd>
lea    0xe24(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122d <getCompression+0xfd>
lea    0xe13(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122d <getCompression+0xfd>
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %ebp,%ebp
test   %rax,%rax
setg   %bpl
neg    %ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"AUTO\00"
@.str.1 = [5 x i8] c"BEST\00"
@.str.2 = [3 x i8] c"-1\00"
@.str.3 = [5 x i8] c"NONE\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [6 x i8] c"APLIB\00"
@.str.6 = [2 x i8] c"1\00"
@.str.7 = [5 x i8] c"LZ4W\00"
@.str.8 = [2 x i8] c"2\00"
@.str.9 = [5 x i8] c"FAST\00"
define i32 @getCompression(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @strupper(i8* %5)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %14, %10, %1
store i32 -1, i32* %2
br label %56
19: ; preds = %14
%20 = load i8*, i8** %4
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i8*, i8** %4
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23, %19
store i32 0, i32* %2
br label %56
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i8*, i8** %4
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %37, label %36
36: ; preds = %32, %28
store i32 1, i32* %2
br label %56
37: ; preds = %32
%38 = load i8*, i8** %4
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %49
41: ; preds = %37
%42 = load i8*, i8** %4
%43 = call i32 @strcmp(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = load i8*, i8** %4
%47 = call i32 @strcmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %45, %41, %37
store i32 2, i32* %2
br label %56
50: ; preds = %45
%51 = load i8*, i8** %4
%52 = call i64 @strlen(i8* %51)
%53 = icmp sgt i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %50
store i32 -1, i32* %2
br label %56
55: ; preds = %50
store i32 0, i32* %2
br label %56
56: ; preds = %55, %54, %49, %36, %27, %18
%57 = load i32, i32* %2
ret i32 %57
}

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