#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*/ logDebug(char *, char const *);
scalar_t__ strstr(char const *, char *);
int testFile(void *context, const char *filename, const char *realname,
             char *reserved, unsigned int reserved_size, char *vir_info,
             unsigned int vi_size) {
  logDebug("The Sample plugin is scanning file %s", filename);
  int result = 0;
  if (strstr(filename, "clean.exe")) {
    result = 1;
  } else if (strstr(filename, "eicar.com")) {
    result = 2;
  } else if (strstr(filename, "eicar.tmp")) {
    result = 2;
  } else if (strstr(filename, "eicar.zip")) {
    result = 2;
  } else if (strstr(filename, "eicarpwd.zip")) {
    result = 4;
  } else if (strstr(filename, "empty.file")) {
    result = 1;
  } else if (strstr(filename, "huge.file")) {
    result = 1;
  } else if (strstr(filename, "nonexisting.file")) {
    result = 0;
  }
  return result;
}


x86 assembly (clang, -O0):
<testFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1040 <logDebug@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1180 <testFile+0x60>
movl   $0x1,-0x34(%rbp)
jmp    12a8 <testFile+0x188>
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     11a6 <testFile+0x86>
movl   $0x2,-0x34(%rbp)
jmp    12a3 <testFile+0x183>
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     11cc <testFile+0xac>
movl   $0x2,-0x34(%rbp)
jmp    129e <testFile+0x17e>
mov    -0x10(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     11f2 <testFile+0xd2>
movl   $0x2,-0x34(%rbp)
jmp    1299 <testFile+0x179>
mov    -0x10(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1218 <testFile+0xf8>
movl   $0x4,-0x34(%rbp)
jmp    1294 <testFile+0x174>
mov    -0x10(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     123e <testFile+0x11e>
movl   $0x1,-0x34(%rbp)
jmp    128f <testFile+0x16f>
mov    -0x10(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1264 <testFile+0x144>
movl   $0x1,-0x34(%rbp)
jmp    128a <testFile+0x16a>
mov    -0x10(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1030 <strstr@plt>
cmp    $0x0,%rax
je     1285 <testFile+0x165>
movl   $0x0,-0x34(%rbp)
jmp    128a <testFile+0x16a>
jmp    128f <testFile+0x16f>
jmp    1294 <testFile+0x174>
jmp    1299 <testFile+0x179>
jmp    129e <testFile+0x17e>
jmp    12a3 <testFile+0x183>
jmp    12a8 <testFile+0x188>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testFile>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0xed3(%rip),%rdi
call   1040 <logDebug@plt>
lea    0xeed(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
je     114d <testFile+0x2d>
mov    $0x1,%ebp
jmp    11a7 <testFile+0x87>
lea    0xedc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
mov    $0x2,%ebp
test   %rax,%rax
jne    11a7 <testFile+0x87>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
jne    11a7 <testFile+0x87>
lea    0xec3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
jne    11a7 <testFile+0x87>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
mov    $0x4,%ebp
test   %rax,%rax
je     11b0 <testFile+0x90>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
test   %rax,%rax
jne    1146 <testFile+0x26>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    11a7 <testFile+0x87>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
xor    %ebp,%ebp
jmp    11a7 <testFile+0x87>

LLVM IR (-O0):
@.str = [38 x i8] c"The Sample plugin is scanning file %s\00"
@.str.1 = [10 x i8] c"clean.exe\00"
@.str.2 = [10 x i8] c"eicar.com\00"
@.str.3 = [10 x i8] c"eicar.tmp\00"
@.str.4 = [10 x i8] c"eicar.zip\00"
@.str.5 = [13 x i8] c"eicarpwd.zip\00"
@.str.6 = [11 x i8] c"empty.file\00"
@.str.7 = [10 x i8] c"huge.file\00"
@.str.8 = [17 x i8] c"nonexisting.file\00"
define i32 @testFile(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4, i8* %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i8* %5, i8** %13
store i32 %6, i32* %14
%16 = load i8*, i8** %9
%17 = call i32 @logDebug(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 0, i32* %15
%18 = load i8*, i8** %9
%19 = call i64 @strstr(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %7
store i32 1, i32* %15
br label %64
22: ; preds = %7
%23 = load i8*, i8** %9
%24 = call i64 @strstr(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 2, i32* %15
br label %63
27: ; preds = %22
%28 = load i8*, i8** %9
%29 = call i64 @strstr(i8* %28, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 2, i32* %15
br label %62
32: ; preds = %27
%33 = load i8*, i8** %9
%34 = call i64 @strstr(i8* %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 2, i32* %15
br label %61
37: ; preds = %32
%38 = load i8*, i8** %9
%39 = call i64 @strstr(i8* %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 4, i32* %15
br label %60
42: ; preds = %37
%43 = load i8*, i8** %9
%44 = call i64 @strstr(i8* %43, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
store i32 1, i32* %15
br label %59
47: ; preds = %42
%48 = load i8*, i8** %9
%49 = call i64 @strstr(i8* %48, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %47
store i32 1, i32* %15
br label %58
52: ; preds = %47
%53 = load i8*, i8** %9
%54 = call i64 @strstr(i8* %53, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %52
store i32 0, i32* %15
br label %57
57: ; preds = %56, %52
br label %58
58: ; preds = %57, %51
br label %59
59: ; preds = %58, %46
br label %60
60: ; preds = %59, %41
br label %61
61: ; preds = %60, %36
br label %62
62: ; preds = %61, %31
br label %63
63: ; preds = %62, %26
br label %64
64: ; preds = %63, %21
%65 = load i32, i32* %15
ret i32 %65
}

LLVM IR (-O2):
@.str = [38 x i8] c"The Sample plugin is scanning file %s\00"
@.str.1 = [10 x i8] c"clean.exe\00"
@.str.2 = [10 x i8] c"eicar.com\00"
@.str.3 = [10 x i8] c"eicar.tmp\00"
@.str.4 = [10 x i8] c"eicar.zip\00"
@.str.5 = [13 x i8] c"eicarpwd.zip\00"
@.str.6 = [11 x i8] c"empty.file\00"
@.str.7 = [10 x i8] c"huge.file\00"
@.str.8 = [17 x i8] c"nonexisting.file\00"
define i32 @testFile(i8* nocapture readnone %0, i8* %1, i8* nocapture readnone %2, i8* nocapture readnone %3, i32 %4, i8* nocapture readnone %5, i32 %6) {
%8 = tail call i32 @logDebug(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %1)
%9 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %31
11: ; preds = %7
%12 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %31
14: ; preds = %11
%15 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %14
%18 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %31
20: ; preds = %17
%21 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %31
31: ; preds = %29, %26, %23, %20, %17, %14, %11, %7
%32 = phi i32 [ 1, %7 ], [ 2, %11 ], [ 2, %14 ], [ 2, %17 ], [ 4, %20 ], [ 1, %23 ], [ 1, %26 ], [ 0, %29 ]
ret i32 %32
}