#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 /*<<< orphan*/ supportsKindOfCompress;

/* Variables and functions */
char *GetSuffix(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int whichKindOfCompressedFile(char *compressedFile) {
  char *supportsKindOfCompress[] = {"rar", "zip", "gz", "tar", "bz2"};
  int NumberOfType =
      sizeof(supportsKindOfCompress) / sizeof(supportsKindOfCompress[0]);
  char *p = NULL;
  int isCompressed = 0;
  p = GetSuffix(compressedFile);
  if (p) {
    int i = 0;
    while (i < NumberOfType) {
      if (!strcmp(supportsKindOfCompress[i], p)) {
        isCompressed = i + 1;
        break;
      }
      i++;
    }
  }
  if (isCompressed == 0) {
    return 0;
  }
  return isCompressed;
}


x86 assembly (clang, -O0):
<whichKindOfCompressedFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xead(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe9f(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe90(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x5,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <GetSuffix@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1200 <whichKindOfCompressedFile+0xd0>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    11fb <whichKindOfCompressedFile+0xcb>
movslq -0x58(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
mov    -0x50(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11ed <whichKindOfCompressedFile+0xbd>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11fb <whichKindOfCompressedFile+0xcb>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11b8 <whichKindOfCompressedFile+0x88>
jmp    1200 <whichKindOfCompressedFile+0xd0>
cmpl   $0x0,-0x54(%rbp)
jne    1216 <whichKindOfCompressedFile+0xe6>
movl   $0x0,-0x4(%rbp)
jmp    121c <whichKindOfCompressedFile+0xec>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<whichKindOfCompressedFile>:
push   %rbx
call   1030 <GetSuffix@plt>
test   %rax,%rax
je     1195 <whichKindOfCompressedFile+0x75>
mov    %rax,%rbx
lea    0xecb(%rip),%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1199 <whichKindOfCompressedFile+0x79>
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11a0 <whichKindOfCompressedFile+0x80>
lea    0xead(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11a7 <whichKindOfCompressedFile+0x87>
lea    0xe9d(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ae <whichKindOfCompressedFile+0x8e>
lea    0xe8e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rcx,%rcx,4),%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"rar\00"
@.str.1 = [4 x i8] c"zip\00"
@.str.2 = [3 x i8] c"gz\00"
@.str.3 = [4 x i8] c"tar\00"
@.str.4 = [4 x i8] c"bz2\00"
define i32 @whichKindOfCompressedFile(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [5 x i8*]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
%9 = bitcast [5 x i8*]* %4 to i8*
%10 = bitcast i8* %9 to [5 x i8*]*
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %10, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %10, i32 0, i32 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %10, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %10, i32 0, i32 3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %10, i32 0, i32 4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8** %15
store i32 5, i32* %5
store i8* null, i8** %6
store i32 0, i32* %7
%16 = load i8*, i8** %3
%17 = call i8* @GetSuffix(i8* %16)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %40
20: ; preds = %1
store i32 0, i32* %8
br label %21
21: ; preds = %36, %20
%22 = load i32, i32* %8
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %39
25: ; preds = %21
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = load i8*, i8** %6
%31 = call i32 @strcmp(i8* %29, i8* %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %25
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %39
36: ; preds = %25
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %21
39: ; preds = %33, %21
br label %40
40: ; preds = %39, %1
%41 = load i32, i32* %7
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %40
store i32 0, i32* %2
br label %46
44: ; preds = %40
%45 = load i32, i32* %7
store i32 %45, i32* %2
br label %46
46: ; preds = %44, %43
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
@.str = [4 x i8] c"rar\00"
@.str.1 = [4 x i8] c"zip\00"
@.str.2 = [3 x i8] c"gz\00"
@.str.3 = [4 x i8] c"tar\00"
@.str.4 = [4 x i8] c"bz2\00"
define i32 @whichKindOfCompressedFile(i8* %0) {
%2 = tail call i8* @GetSuffix(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i32 5, i32 0
br label %20
20: ; preds = %16, %4, %7, %10, %13, %1
%21 = phi i32 [ 0, %1 ], [ 1, %4 ], [ 2, %7 ], [ 3, %10 ], [ 4, %13 ], [ %19, %16 ]
ret i32 %21
}