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

/* Variables and functions */
int bruteforceFile(char *, int /*<<< orphan*/ *);
scalar_t__ fileExists(char *);
int /*<<< orphan*/ prnlog(char *);
int _testBruteforce() {
  int errors = 0;
  if (true) {
    prnlog("[+] Testing crack from dumpfile...");
    uint16_t keytable[128] = {0};
    if (fileExists("iclass_dump.bin")) {
      errors |= bruteforceFile("iclass_dump.bin", keytable);
    } else if (fileExists("loclass/iclass_dump.bin")) {
      errors |= bruteforceFile("loclass/iclass_dump.bin", keytable);
    } else if (fileExists("client/loclass/iclass_dump.bin")) {
      errors |= bruteforceFile("client/loclass/iclass_dump.bin", keytable);
    } else {
      prnlog("Error: The file iclass_dump.bin was not found!");
    }
  }
  return errors;
}


x86 assembly (clang, -O0):
<_testBruteforce>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <prnlog@plt>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
lea    0xeba(%rip),%rdi
call   1040 <fileExists@plt>
cmp    $0x0,%rax
je     11a5 <_testBruteforce+0x65>
lea    -0x210(%rbp),%rsi
lea    0xe9d(%rip),%rdi
call   1060 <bruteforceFile@plt>
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1223 <_testBruteforce+0xe3>
lea    0xe7e(%rip),%rdi
call   1040 <fileExists@plt>
cmp    $0x0,%rax
je     11d9 <_testBruteforce+0x99>
lea    -0x210(%rbp),%rsi
lea    0xe61(%rip),%rdi
call   1060 <bruteforceFile@plt>
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121e <_testBruteforce+0xde>
lea    0xe43(%rip),%rdi
call   1040 <fileExists@plt>
cmp    $0x0,%rax
je     120d <_testBruteforce+0xcd>
lea    -0x210(%rbp),%rsi
lea    0xe26(%rip),%rdi
call   1060 <bruteforceFile@plt>
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1219 <_testBruteforce+0xd9>
lea    0xe2e(%rip),%rdi
call   1030 <prnlog@plt>
jmp    121e <_testBruteforce+0xde>
jmp    1223 <_testBruteforce+0xe3>
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_testBruteforce>:
sub    $0x208,%rsp
lea    0xeb2(%rip),%rdi
call   1030 <prnlog@plt>
mov    %rsp,%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xec9(%rip),%rdi
call   1040 <fileExists@plt>
test   %rax,%rax
je     117c <_testBruteforce+0x3c>
lea    0xeb8(%rip),%rdi
jmp    11ae <_testBruteforce+0x6e>
lea    0xea7(%rip),%rdi
call   1040 <fileExists@plt>
test   %rax,%rax
je     1196 <_testBruteforce+0x56>
lea    0xe96(%rip),%rdi
jmp    11ae <_testBruteforce+0x6e>
lea    0xe86(%rip),%rdi
call   1040 <fileExists@plt>
test   %rax,%rax
je     11be <_testBruteforce+0x7e>
lea    0xe75(%rip),%rdi
mov    %rsp,%rsi
call   1060 <bruteforceFile@plt>
add    $0x208,%rsp
ret
lea    0xe7d(%rip),%rdi
call   1030 <prnlog@plt>
xor    %eax,%eax
add    $0x208,%rsp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"[+] Testing crack from dumpfile...\00"
@.str.1 = [16 x i8] c"iclass_dump.bin\00"
@.str.2 = [24 x i8] c"loclass/iclass_dump.bin\00"
@.str.3 = [31 x i8] c"client/loclass/iclass_dump.bin\00"
@.str.4 = [47 x i8] c"Error: The file iclass_dump.bin was not found!\00"
define i32 @_testBruteforce() {
%1 = alloca i32
%2 = alloca [128 x i32]
store i32 0, i32* %1
%3 = call i32 @prnlog(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [128 x i32]* %2 to i8*
%5 = call i64 @fileExists(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = getelementptr inbounds [128 x i32], [128 x i32]* %2, i64 0, i64 0
%9 = call i32 @bruteforceFile(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%10 = load i32, i32* %1
%11 = or i32 %10, %9
store i32 %11, i32* %1
br label %32
12: ; preds = %0
%13 = call i64 @fileExists(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = getelementptr inbounds [128 x i32], [128 x i32]* %2, i64 0, i64 0
%17 = call i32 @bruteforceFile(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32* %16)
%18 = load i32, i32* %1
%19 = or i32 %18, %17
store i32 %19, i32* %1
br label %31
20: ; preds = %12
%21 = call i64 @fileExists(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = getelementptr inbounds [128 x i32], [128 x i32]* %2, i64 0, i64 0
%25 = call i32 @bruteforceFile(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32* %24)
%26 = load i32, i32* %1
%27 = or i32 %26, %25
store i32 %27, i32* %1
br label %30
28: ; preds = %20
%29 = call i32 @prnlog(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %28, %23
br label %31
31: ; preds = %30, %15
br label %32
32: ; preds = %31, %7
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [35 x i8] c"[+] Testing crack from dumpfile...\00"
@.str.1 = [16 x i8] c"iclass_dump.bin\00"
@.str.2 = [24 x i8] c"loclass/iclass_dump.bin\00"
@.str.3 = [31 x i8] c"client/loclass/iclass_dump.bin\00"
@.str.4 = [47 x i8] c"Error: The file iclass_dump.bin was not found!\00"
define i32 @_testBruteforce() {
%1 = alloca [128 x i32]
%2 = tail call i32 @prnlog(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%3 = bitcast [128 x i32]* %1 to i8*
%4 = tail call i64 @fileExists(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = getelementptr inbounds [128 x i32], [128 x i32]* %1, i64 0, i64 0
%8 = call i32 @bruteforceFile(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32* %7)
br label %23
9: ; preds = %0
%10 = tail call i64 @fileExists(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = getelementptr inbounds [128 x i32], [128 x i32]* %1, i64 0, i64 0
%14 = call i32 @bruteforceFile(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32* %13)
br label %23
15: ; preds = %9
%16 = tail call i64 @fileExists(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = getelementptr inbounds [128 x i32], [128 x i32]* %1, i64 0, i64 0
%20 = call i32 @bruteforceFile(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32* %19)
br label %23
21: ; preds = %15
%22 = tail call i32 @prnlog(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %12, %21, %18, %6
%24 = phi i32 [ %8, %6 ], [ %14, %12 ], [ %20, %18 ], [ 0, %21 ]
ret i32 %24
}