#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int snoopy_filterregistry_callById(int, char *, char *);
int snoopy_filterregistry_getCount();
char *snoopy_filterregistry_getName(int);
int /*<<< orphan*/ snprintf(char *, int, char *);
scalar_t__ strcmp(char *, char *);
void snoopy_debug_test_all_filters() {
  char *message = NULL;
  char *itemName = NULL;
  char *itemArgs = NULL;
  int itemResult;
  int fCount;
  int i;
  message = malloc(16383 + 1);
  snprintf(message, 16383, "bad message here");
  fCount = snoopy_filterregistry_getCount();
  for (i = 0; i < fCount; i++) {
    itemName = snoopy_filterregistry_getName(i);
    printf("Filter %19s: ", itemName);
    if (strcmp(itemName, "exclude_spawns_of") == 0) {
      itemArgs = "asdf,bsdf";
    } else if (strcmp(itemName, "exclude_uid") == 0) {
      itemArgs = "0";
    } else if (strcmp(itemName, "only_root") == 0) {
      itemArgs = "";
    } else if (strcmp(itemName, "only_uid") == 0) {
      itemArgs = "0";
    } else {
      itemArgs = "";
    }
    itemResult = snoopy_filterregistry_callById(i, message, itemArgs);
    if (1 == itemResult) {
      printf("PASS");
    } else {
      printf("DROP");
    }
    printf("\n");
  }
  free(message);
}


x86 assembly (clang, -O0):
<snoopy_debug_test_all_filters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x4000,%edi
call   1080 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3fff,%esi
lea    0xe42(%rip),%rdx
call   1060 <snprintf@plt>
mov    $0x0,%al
call   1090 <snoopy_filterregistry_getCount@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    131e <snoopy_debug_test_all_filters+0x19e>
mov    -0x24(%rbp),%edi
call   1040 <snoopy_filterregistry_getName@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1228 <snoopy_debug_test_all_filters+0xa8>
lea    0xe12(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12c0 <snoopy_debug_test_all_filters+0x140>
mov    -0x10(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1252 <snoopy_debug_test_all_filters+0xd2>
lea    0xdfe(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12bb <snoopy_debug_test_all_filters+0x13b>
mov    -0x10(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    127c <snoopy_debug_test_all_filters+0xfc>
lea    0xdf4(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12b6 <snoopy_debug_test_all_filters+0x136>
mov    -0x10(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12a6 <snoopy_debug_test_all_filters+0x126>
lea    0xdaa(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12b1 <snoopy_debug_test_all_filters+0x131>
lea    0xdba(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12b6 <snoopy_debug_test_all_filters+0x136>
jmp    12bb <snoopy_debug_test_all_filters+0x13b>
jmp    12c0 <snoopy_debug_test_all_filters+0x140>
mov    -0x24(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10a0 <snoopy_filterregistry_callById@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x1,%eax
cmp    -0x1c(%rbp),%eax
jne    12f4 <snoopy_debug_test_all_filters+0x174>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1302 <snoopy_debug_test_all_filters+0x182>
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d4 <snoopy_debug_test_all_filters+0x54>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<snoopy_debug_test_all_filters>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x4000,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
lea    0xe51(%rip),%rdx
mov    %rax,%rdi
mov    $0x3fff,%esi
call   1070 <snprintf@plt>
xor    %eax,%eax
call   10a0 <snoopy_filterregistry_getCount@plt>
test   %eax,%eax
jle    12b3 <snoopy_debug_test_all_filters+0x123>
mov    %eax,%ebp
lea    0xe5d(%rip),%r14
lea    0xe81(%rip),%r15
xor    %r13d,%r13d
jmp    11fe <snoopy_debug_test_all_filters+0x6e>
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
add    $0x1,%r13d
cmp    %r13d,%ebp
je     12b3 <snoopy_debug_test_all_filters+0x123>
mov    %r13d,%edi
call   1050 <snoopy_filterregistry_getName@plt>
mov    %rax,%r12
lea    0xe01(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
lea    0xdfb(%rip),%rsi
call   1080 <strcmp@plt>
mov    %r14,%rdx
test   %rax,%rax
je     1290 <snoopy_debug_test_all_filters+0x100>
mov    %r12,%rdi
lea    0xe00(%rip),%rsi
call   1080 <strcmp@plt>
lea    0xe00(%rip),%rdx
test   %rax,%rax
je     1290 <snoopy_debug_test_all_filters+0x100>
mov    %r12,%rdi
lea    0xdf3(%rip),%rsi
call   1080 <strcmp@plt>
lea    0xdbc(%rip),%rdx
test   %rax,%rax
je     1290 <snoopy_debug_test_all_filters+0x100>
mov    %r12,%rdi
lea    0xde2(%rip),%rsi
call   1080 <strcmp@plt>
lea    0xdca(%rip),%rdx
test   %rax,%rax
je     1290 <snoopy_debug_test_all_filters+0x100>
lea    0xd95(%rip),%rdx
nopl   0x0(%rax)
mov    %r13d,%edi
mov    %rbx,%rsi
call   10b0 <snoopy_filterregistry_callById@plt>
mov    %r15,%rdi
cmp    $0x1,%eax
je     11e0 <snoopy_debug_test_all_filters+0x50>
lea    0xdb3(%rip),%rdi
jmp    11e0 <snoopy_debug_test_all_filters+0x50>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"bad message here\00"
@.str.1 = [14 x i8] c"Filter %19s: \00"
@.str.2 = [18 x i8] c"exclude_spawns_of\00"
@.str.3 = [10 x i8] c"asdf,bsdf\00"
@.str.4 = [12 x i8] c"exclude_uid\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [10 x i8] c"only_root\00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [9 x i8] c"only_uid\00"
@.str.9 = [5 x i8] c"PASS\00"
@.str.10 = [5 x i8] c"DROP\00"
@.str.11 = [2 x i8] c"\0A\00"
define void @snoopy_debug_test_all_filters() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* null, i8** %1
store i8* null, i8** %2
store i8* null, i8** %3
%7 = call i8* @malloc(i32 16384)
store i8* %7, i8** %1
%8 = load i8*, i8** %1
%9 = call i32 @snprintf(i8* %8, i32 16383, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @snoopy_filterregistry_getCount()
store i32 %10, i32* %5
store i32 0, i32* %6
br label %11
11: ; preds = %56, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %59
15: ; preds = %11
%16 = load i32, i32* %6
%17 = call i8* @snoopy_filterregistry_getName(i32 %16)
store i8* %17, i8** %2
%18 = load i8*, i8** %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %2
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %15
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %43
24: ; preds = %15
%25 = load i8*, i8** %2
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %42
29: ; preds = %24
%30 = load i8*, i8** %2
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %41
34: ; preds = %29
%35 = load i8*, i8** %2
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %40
39: ; preds = %34
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %40
40: ; preds = %39, %38
br label %41
41: ; preds = %40, %33
br label %42
42: ; preds = %41, %28
br label %43
43: ; preds = %42, %23
%44 = load i32, i32* %6
%45 = load i8*, i8** %1
%46 = load i8*, i8** %3
%47 = call i32 @snoopy_filterregistry_callById(i32 %44, i8* %45, i8* %46)
store i32 %47, i32* %4
%48 = load i32, i32* %4
%49 = icmp eq i32 1, %48
br i1 %49, label %50, label %52
50: ; preds = %43
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %54
52: ; preds = %43
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %56
56: ; preds = %54
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %11
59: ; preds = %11
%60 = load i8*, i8** %1
%61 = call i32 @free(i8* %60)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"bad message here\00"
@.str.1 = [14 x i8] c"Filter %19s: \00"
@.str.2 = [18 x i8] c"exclude_spawns_of\00"
@.str.3 = [10 x i8] c"asdf,bsdf\00"
@.str.4 = [12 x i8] c"exclude_uid\00"
@.str.5 = [2 x i8] c"0\00"
@.str.6 = [10 x i8] c"only_root\00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [9 x i8] c"only_uid\00"
@.str.9 = [5 x i8] c"PASS\00"
@.str.10 = [5 x i8] c"DROP\00"
define void @snoopy_debug_test_all_filters() {
%1 = tail call dereferenceable_or_null(16384) i8* @malloc(i32 16384)
%2 = tail call i32 @snprintf(i8* %1, i32 16383, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @snoopy_filterregistry_getCount()
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %30
5: ; preds = %0, %21
%6 = phi i32 [ %28, %21 ], [ 0, %0 ]
%7 = tail call i8* @snoopy_filterregistry_getName(i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %5
%12 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0)
br label %21
21: ; preds = %17, %14, %11, %5
%22 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), %11 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0), %14 ], [ %20, %17 ]
%23 = tail call i32 @snoopy_filterregistry_callById(i32 %6, i8* %1, i8* %22)
%24 = icmp eq i32 %23, 1
%25 = select i1 %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0)
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %25)
%27 = tail call i32 @putchar(i32 10)
%28 = add nuw nsw i32 %6, 1
%29 = icmp eq i32 %28, %3
br i1 %29, label %30, label %5
30: ; preds = %21, %0
%31 = tail call i32 @free(i8* %1)
ret void
}