#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 */
struct timeval {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ build_whitelist();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, long, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ init_whitelist();
int load_whitelist(int /*<<< orphan*/ *);
char *malloc(long);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ show_time(struct timeval, struct timeval);
int /*<<< orphan*/ whitelist_done();
int whitelist_match(char *, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 2)
    return 1;
  FILE *f = fopen("whitelist.wdb", "rb");
  init_whitelist();
  printf("%d,", load_whitelist(f));
  struct timeval tv0, tv01;
  gettimeofday(&tv0, NULL);
  build_whitelist();
  gettimeofday(&tv01, NULL);
  show_time(tv0, tv01);
  fclose(f);
  FILE *f2 = fopen(argv[1], "rb");
  fseek(f2, 0, SEEK_END);
  long p = ftell(f2);
  fseek(f2, 0, SEEK_SET);
  char *x = malloc(p + 1);
  if (fread(x, p, 1, f2) != 1)
    return 2;
  x[p] = 0;
  fclose(f2);
  struct timeval tv1, tv2, diff;
  gettimeofday(&tv1, NULL);
  int rc = whitelist_match(x, "test", 0);
  gettimeofday(&tv2, NULL);
  show_time(tv1, tv2);
  printf("%d\n", rc);
  free(x);
  whitelist_done();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    121c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    1384 <main+0x194>
lea    0xddd(%rip),%rdi
lea    0xde4(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   10c0 <init_whitelist@plt>
mov    -0x18(%rbp),%rdi
call   1110 <load_whitelist@plt>
mov    %eax,%esi
lea    0xdc5(%rip),%rdi
call   1060 <printf@plt>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    $0x0,%al
call   10d0 <build_whitelist@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x20(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1090 <show_time@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd79(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2d3f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10e0 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <ftell@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2d0e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10e0 <fseek@plt>
mov    -0x38(%rbp),%rdi
add    $0x1,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     130f <main+0x11f>
movl   $0x2,-0x4(%rbp)
jmp    1384 <main+0x194>
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
lea    -0x48(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x40(%rbp),%rdi
lea    0xcd9(%rip),%rsi
xor    %edx,%edx
call   1070 <whitelist_match@plt>
mov    %eax,-0x5c(%rbp)
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
mov    -0x48(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1090 <show_time@plt>
mov    -0x5c(%rbp),%esi
lea    0xcb2(%rip),%rdi
call   1060 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   10f0 <whitelist_done@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%eax
cmp    $0x2,%edi
jl     1349 <main+0x159>
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r15
lea    0xdef(%rip),%rdi
lea    0xdf6(%rip),%r14
mov    %r14,%rsi
call   1100 <fopen@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   10c0 <init_whitelist@plt>
mov    %rbx,%rdi
call   1110 <load_whitelist@plt>
lea    0xdd8(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
xor    %eax,%eax
call   10d0 <build_whitelist@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x18(%rsp),%edi
mov    0x10(%rsp),%esi
call   1090 <show_time@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x8(%r15),%rdi
mov    %r14,%rsi
call   1100 <fopen@plt>
mov    %rax,%rbx
mov    0x2d5e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10e0 <fseek@plt>
mov    %rbx,%rdi
call   10a0 <ftell@plt>
mov    %rax,%r15
mov    0x2d30(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10e0 <fseek@plt>
lea    0x1(%r15),%rdi
call   10b0 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    %eax,%ecx
mov    $0x2,%eax
cmp    $0x1,%ecx
jne    1340 <main+0x150>
movb   $0x0,(%r14,%r15,1)
mov    %rbx,%rdi
call   1050 <fclose@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
lea    0xd16(%rip),%rsi
mov    %r14,%rdi
xor    %edx,%edx
call   1070 <whitelist_match@plt>
mov    %eax,%ebx
mov    %rsp,%rdi
xor    %esi,%esi
call   1080 <gettimeofday@plt>
mov    0x8(%rsp),%edi
mov    (%rsp),%esi
call   1090 <show_time@plt>
lea    0xcf2(%rip),%rdi
mov    %ebx,%esi
call   1060 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   10f0 <whitelist_done@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [14 x i8] c"whitelist.wdb\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [4 x i8] c"%d,\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [5 x i8] c"test\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca %struct.timeval
%13 = alloca %struct.timeval
%14 = alloca %struct.timeval
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %19
18: ; preds = %2
store i32 1, i32* %3
br label %76
19: ; preds = %2
%20 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = call i32 (...) @init_whitelist()
%22 = load i32*, i32** %6
%23 = call i32 @load_whitelist(i32* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%26 = call i32 (...) @build_whitelist()
%27 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%31 = load i32, i32* %30
%32 = call i32 @show_time(i32 %29, i32 %31)
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %38, i32** %9
%39 = load i32*, i32** %9
%40 = load i32, i32* @SEEK_END
%41 = call i32 @fseek(i32* %39, i32 0, i32 %40)
%42 = load i32*, i32** %9
%43 = call i64 @ftell(i32* %42)
store i64 %43, i64* %10
%44 = load i32*, i32** %9
%45 = load i32, i32* @SEEK_SET
%46 = call i32 @fseek(i32* %44, i32 0, i32 %45)
%47 = load i64, i64* %10
%48 = add nsw i64 %47, 1
%49 = call i8* @malloc(i64 %48)
store i8* %49, i8** %11
%50 = load i8*, i8** %11
%51 = load i64, i64* %10
%52 = load i32*, i32** %9
%53 = call i32 @fread(i8* %50, i64 %51, i32 1, i32* %52)
%54 = icmp ne i32 %53, 1
br i1 %54, label %55, label %56
55: ; preds = %19
store i32 2, i32* %3
br label %76
56: ; preds = %19
%57 = load i8*, i8** %11
%58 = load i64, i64* %10
%59 = getelementptr inbounds i8, i8* %57, i64 %58
store i8 0, i8* %59
%60 = load i32*, i32** %9
%61 = call i32 @fclose(i32* %60)
%62 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
%63 = load i8*, i8** %11
%64 = call i32 @whitelist_match(i8* %63, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0)
store i32 %64, i32* %15
%65 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%66 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%67 = load i32, i32* %66
%68 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%69 = load i32, i32* %68
%70 = call i32 @show_time(i32 %67, i32 %69)
%71 = load i32, i32* %15
%72 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %71)
%73 = load i8*, i8** %11
%74 = call i32 @free(i8* %73)
%75 = call i32 (...) @whitelist_done()
store i32 0, i32* %3
br label %76
76: ; preds = %56, %55, %18
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [14 x i8] c"whitelist.wdb\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [4 x i8] c"%d,\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [5 x i8] c"test\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = icmp slt i32 %0, 2
br i1 %7, label %54, label %8
8: ; preds = %2
%9 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 (...) @init_whitelist()
%11 = tail call i32 @load_whitelist(i32* %9)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = bitcast %struct.timeval* %3 to i8*
%14 = bitcast %struct.timeval* %4 to i8*
%15 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%16 = tail call i32 (...) @build_whitelist()
%17 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%21 = load i32, i32* %20
%22 = tail call i32 @show_time(i32 %19, i32 %21)
%23 = tail call i32 @fclose(i32* %9)
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* @SEEK_END
%28 = tail call i32 @fseek(i32* %26, i32 0, i32 %27)
%29 = tail call i64 @ftell(i32* %26)
%30 = load i32, i32* @SEEK_SET
%31 = tail call i32 @fseek(i32* %26, i32 0, i32 %30)
%32 = add nsw i64 %29, 1
%33 = tail call i8* @malloc(i64 %32)
%34 = tail call i32 @fread(i8* %33, i64 %29, i32 1, i32* %26)
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %52
36: ; preds = %8
%37 = getelementptr inbounds i8, i8* %33, i64 %29
store i8 0, i8* %37
%38 = tail call i32 @fclose(i32* %26)
%39 = bitcast %struct.timeval* %5 to i8*
%40 = bitcast %struct.timeval* %6 to i8*
%41 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%42 = tail call i32 @whitelist_match(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0)
%43 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%44 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%47 = load i32, i32* %46
%48 = tail call i32 @show_time(i32 %45, i32 %47)
%49 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%50 = tail call i32 @free(i8* %33)
%51 = tail call i32 (...) @whitelist_done()
br label %52
52: ; preds = %8, %36
%53 = phi i32 [ 0, %36 ], [ 2, %8 ]
br label %54
54: ; preds = %2, %52
%55 = phi i32 [ %53, %52 ], [ 1, %2 ]
ret i32 %55
}