#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*/ add_random(int, double, int, int);
double atof(char *);
int atoi(char *);
int /*<<< orphan*/ basic();
char *bloom_version();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perf_loop(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strncmp(char *, char *, int);
int main(int argc, char **argv) {
  (void)printf("testing libbloom...\n");
  if (argc == 4 && !strncmp(argv[1], "-p", 2)) {
    perf_loop(atoi(argv[2]), atoi(argv[3]));
    exit(0);
  }
  if (!strncmp(argv[1], "-c", 2)) {
    switch (argc) {
    case 5:
      add_random(atoi(argv[2]), atof(argv[3]), atoi(argv[4]), 0);
      break;
    case 6:
      add_random(atoi(argv[2]), atof(argv[3]), atoi(argv[4]), atoi(argv[5]));
      break;
    default:
      printf("-c ENTRIES ERROR COUNT [CACHE_SIZE]\n");
    }
    exit(0);
  }
  basic();
  add_random(100, 0.001, 300, 0);
  int i;
  for (i = 0; i < 10; i++) {
    add_random(1000000, 0.001, 1000000, 0);
  }
  perf_loop(10000000, 10000000);
  printf("\nBrought to you by libbloom-%s\n", bloom_version());
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
cmpl   $0x4,-0x8(%rbp)
jne    120e <main+0x7e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe50(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    120e <main+0x7e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%esi
call   1070 <perf_loop@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe03(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1305 <main+0x175>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x5,%eax
je     1255 <main+0xc5>
jmp    1244 <main+0xb4>
mov    -0x1c(%rbp),%eax
sub    $0x6,%eax
je     129a <main+0x10a>
jmp    12f0 <main+0x160>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1090 <atoi@plt>
mov    -0x2c(%rbp),%edi
movsd  -0x28(%rbp),%xmm0
mov    %eax,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
jmp    12fe <main+0x16e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atof@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1090 <atoi@plt>
mov    -0x3c(%rbp),%edi
movsd  -0x38(%rbp),%xmm0
mov    -0x30(%rbp),%esi
mov    %eax,%edx
call   1030 <add_random@plt>
jmp    12fe <main+0x16e>
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   10b0 <basic@plt>
mov    $0x64,%edi
movsd  0xce7(%rip),%xmm0
mov    $0x12c,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    135a <main+0x1ca>
mov    $0xf4240,%esi
movsd  0xcbd(%rip),%xmm0
xor    %edx,%edx
mov    %esi,%edi
call   1030 <add_random@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    132c <main+0x19c>
mov    $0x989680,%esi
mov    %esi,%edi
call   1070 <perf_loop@plt>
mov    $0x0,%al
call   1060 <bloom_version@plt>
mov    %rax,%rsi
lea    0xcd1(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe7a(%rip),%rdi
call   1050 <puts@plt>
cmp    $0x4,%ebp
jne    11db <main+0x3b>
mov    0x8(%rbx),%rdi
lea    0xe3f(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1383 <main+0x1e3>
mov    0x8(%rbx),%rdi
lea    0xe25(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     1344 <main+0x1a4>
xor    %eax,%eax
call   10c0 <basic@plt>
movsd  0xdf9(%rip),%xmm0
mov    $0x64,%edi
mov    $0x12c,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0xf4240,%edi
movsd  0xddb(%rip),%xmm0
mov    $0xf4240,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0xf4240,%edi
movsd  0xdc2(%rip),%xmm0
mov    $0xf4240,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0xf4240,%edi
movsd  0xda9(%rip),%xmm0
mov    $0xf4240,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0xf4240,%edi
movsd  0xd90(%rip),%xmm0
mov    $0xf4240,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0xf4240,%edi
movsd  0xd77(%rip),%xmm0
mov    $0xf4240,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0xf4240,%edi
movsd  0xd5e(%rip),%xmm0
mov    $0xf4240,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0xf4240,%edi
movsd  0xd45(%rip),%xmm0
mov    $0xf4240,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0xf4240,%edi
movsd  0xd2c(%rip),%xmm0
mov    $0xf4240,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0xf4240,%edi
movsd  0xd13(%rip),%xmm0
mov    $0xf4240,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0xf4240,%edi
movsd  0xcfa(%rip),%xmm0
mov    $0xf4240,%esi
xor    %edx,%edx
call   1030 <add_random@plt>
mov    $0x989680,%edi
mov    $0x989680,%esi
call   1080 <perf_loop@plt>
xor    %eax,%eax
call   1070 <bloom_version@plt>
lea    0xcdf(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
cmp    $0x6,%ebp
je     13a7 <main+0x207>
cmp    $0x5,%ebp
jne    13ef <main+0x24f>
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
call   1060 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x20(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %ebp,%edi
movsd  0x8(%rsp),%xmm0
mov    %eax,%esi
xor    %edx,%edx
jmp    13e3 <main+0x243>
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1080 <perf_loop@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    0x10(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%rbx),%rdi
call   1060 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x20(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebp
mov    0x28(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %r14d,%edi
movsd  0x8(%rsp),%xmm0
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <add_random@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xc4c(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"testing libbloom...\0A\00"
@.str.1 = [3 x i8] c"-p\00"
@.str.2 = [3 x i8] c"-c\00"
@.str.3 = [37 x i8] c"-c ENTRIES ERROR COUNT [CACHE_SIZE]\0A\00"
@.str.4 = [32 x i8] c"\0ABrought to you by libbloom-%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 4
br i1 %9, label %10, label %27
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strncmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%15 = icmp ne i32 %14, 0
br i1 %15, label %27, label %16
16: ; preds = %10
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 3
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
%25 = call i32 @perf_loop(i32 %20, i32 %24)
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %10, %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @strncmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%32 = icmp ne i32 %31, 0
br i1 %32, label %71, label %33
33: ; preds = %27
%34 = load i32, i32* %4
switch i32 %34, label %67 [
i32 5, label %35
i32 6, label %49
]
35: ; preds = %33
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call double @atof(i8* %42)
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 4
%46 = load i8*, i8** %45
%47 = call i32 @atoi(i8* %46)
%48 = call i32 @add_random(i32 %39, double %43, i32 %47, i32 0)
br label %69
49: ; preds = %33
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 2
%52 = load i8*, i8** %51
%53 = call i32 @atoi(i8* %52)
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 3
%56 = load i8*, i8** %55
%57 = call double @atof(i8* %56)
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 4
%60 = load i8*, i8** %59
%61 = call i32 @atoi(i8* %60)
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 5
%64 = load i8*, i8** %63
%65 = call i32 @atoi(i8* %64)
%66 = call i32 @add_random(i32 %53, double %57, i32 %61, i32 %65)
br label %69
67: ; preds = %33
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br label %69
69: ; preds = %67, %49, %35
%70 = call i32 @exit(i32 0)
unreachable
71: ; preds = %27
%72 = call i32 (...) @basic()
%73 = call i32 @add_random(i32 100, double 1.000000e-03, i32 300, i32 0)
store i32 0, i32* %6
br label %74
74: ; preds = %79, %71
%75 = load i32, i32* %6
%76 = icmp slt i32 %75, 10
br i1 %76, label %77, label %82
77: ; preds = %74
%78 = call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
br label %79
79: ; preds = %77
%80 = load i32, i32* %6
%81 = add nsw i32 %80, 1
store i32 %81, i32* %6
br label %74
82: ; preds = %74
%83 = call i32 @perf_loop(i32 10000000, i32 10000000)
%84 = call i8* (...) @bloom_version()
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %84)
%86 = load i32, i32* %3
ret i32 %86
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"-p\00"
@.str.2 = [3 x i8] c"-c\00"
@.str.4 = [32 x i8] c"\0ABrought to you by libbloom-%s\0A\00"
@str = [20 x i8] c"testing libbloom...\00"
@str.5 = [36 x i8] c"-c ENTRIES ERROR COUNT [CACHE_SIZE]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = icmp eq i32 %0, 4
br i1 %4, label %5, label %19
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @strncmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %5
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = tail call i32 @perf_loop(i32 %13, i32 %16)
%18 = tail call i32 @exit(i32 0)
unreachable
19: ; preds = %5, %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i32 @strncmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %54
24: ; preds = %19
switch i32 %0, label %50 [
i32 5, label %25
i32 6, label %36
]
25: ; preds = %24
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = tail call i32 @atoi(i8* %27)
%29 = getelementptr inbounds i8*, i8** %1, i64 3
%30 = load i8*, i8** %29
%31 = tail call double @atof(i8* %30)
%32 = getelementptr inbounds i8*, i8** %1, i64 4
%33 = load i8*, i8** %32
%34 = tail call i32 @atoi(i8* %33)
%35 = tail call i32 @add_random(i32 %28, double %31, i32 %34, i32 0)
br label %52
36: ; preds = %24
%37 = getelementptr inbounds i8*, i8** %1, i64 2
%38 = load i8*, i8** %37
%39 = tail call i32 @atoi(i8* %38)
%40 = getelementptr inbounds i8*, i8** %1, i64 3
%41 = load i8*, i8** %40
%42 = tail call double @atof(i8* %41)
%43 = getelementptr inbounds i8*, i8** %1, i64 4
%44 = load i8*, i8** %43
%45 = tail call i32 @atoi(i8* %44)
%46 = getelementptr inbounds i8*, i8** %1, i64 5
%47 = load i8*, i8** %46
%48 = tail call i32 @atoi(i8* %47)
%49 = tail call i32 @add_random(i32 %39, double %42, i32 %45, i32 %48)
br label %52
50: ; preds = %24
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.5, i64 0, i64 0))
br label %52
52: ; preds = %50, %36, %25
%53 = tail call i32 @exit(i32 0)
unreachable
54: ; preds = %19
%55 = tail call i32 (...) @basic()
%56 = tail call i32 @add_random(i32 100, double 1.000000e-03, i32 300, i32 0)
%57 = tail call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
%58 = tail call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
%59 = tail call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
%60 = tail call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
%61 = tail call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
%62 = tail call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
%63 = tail call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
%64 = tail call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
%65 = tail call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
%66 = tail call i32 @add_random(i32 1000000, double 1.000000e-03, i32 1000000, i32 0)
%67 = tail call i32 @perf_loop(i32 10000000, i32 10000000)
%68 = tail call i8* (...) @bloom_version()
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %68)
ret i32 0
}