#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 */
char *malloc(size_t);
scalar_t__ memcmp(char const *const, char *, int);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
size_t strlen(char *);
void CompactionFilterV2Filter(
    void *arg, int level, size_t num_keys, const char *const *keys_list,
    const size_t *keys_list_sizes, const char *const *existing_values_list,
    const size_t *existing_values_list_sizes, char **new_values_list,
    size_t *new_values_list_sizes, unsigned char *to_delete_list) {
  size_t i;
  for (i = 0; i < num_keys; i++) {
    if (existing_values_list_sizes[i] == 2 &&
        memcmp(existing_values_list[i], "gc", 2) == 0) {
      to_delete_list[i] = 1;
    } else if (existing_values_list_sizes[i] == 6 &&
               memcmp(existing_values_list[i], "gc all", 6) == 0) {
      size_t j;
      for (j = 0; j < num_keys; j++) {
        to_delete_list[j] = 1;
      }
      return;
    } else if (existing_values_list_sizes[i] == 6 &&
               memcmp(existing_values_list[i], "change", 6) == 0) {
      size_t len;
      len = strlen("changed");
      new_values_list[i] = malloc(len);
      memcpy(new_values_list[i], "changed", len);
      new_values_list_sizes[i] = len;
    } else {
    }
  }
}


x86 assembly (clang, -O0):
<CompactionFilterV2Filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    12fa <CompactionFilterV2Filter+0x1ba>
mov    0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
cmpq   $0x2,(%rax,%rcx,8)
jne    11d0 <CompactionFilterV2Filter+0x90>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe55(%rip),%rsi
mov    $0x2,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    11d0 <CompactionFilterV2Filter+0x90>
mov    0x28(%rbp),%rax
mov    -0x38(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
jmp    12e4 <CompactionFilterV2Filter+0x1a4>
mov    0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
cmpq   $0x6,(%rax,%rcx,8)
jne    1242 <CompactionFilterV2Filter+0x102>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe0d(%rip),%rsi
mov    $0x6,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    1242 <CompactionFilterV2Filter+0x102>
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    123d <CompactionFilterV2Filter+0xfd>
mov    0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1212 <CompactionFilterV2Filter+0xd2>
jmp    12fa <CompactionFilterV2Filter+0x1ba>
mov    0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
cmpq   $0x6,(%rax,%rcx,8)
jne    12d5 <CompactionFilterV2Filter+0x195>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xda2(%rip),%rsi
mov    $0x6,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    12d5 <CompactionFilterV2Filter+0x195>
lea    0xd8e(%rip),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x48(%rbp),%rdx
lea    0xd56(%rip),%rsi
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rdx
mov    0x20(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    12da <CompactionFilterV2Filter+0x19a>
jmp    12da <CompactionFilterV2Filter+0x19a>
jmp    12df <CompactionFilterV2Filter+0x19f>
jmp    12e4 <CompactionFilterV2Filter+0x1a4>
jmp    12e9 <CompactionFilterV2Filter+0x1a9>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1177 <CompactionFilterV2Filter+0x37>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CompactionFilterV2Filter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     1239 <CompactionFilterV2Filter+0xf9>
mov    %r9,%rbx
mov    %rdx,%r14
mov    0x40(%rsp),%r15
xor    %ebp,%ebp
lea    0xe98(%rip),%r12
lea    0xe94(%rip),%r13
jmp    118d <CompactionFilterV2Filter+0x4d>
mov    0x58(%rsp),%rax
movb   $0x1,(%rax,%rbp,1)
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r14
je     1239 <CompactionFilterV2Filter+0xf9>
mov    (%r15,%rbp,8),%rax
cmp    $0x2,%rax
jne    11b1 <CompactionFilterV2Filter+0x71>
mov    (%rbx,%rbp,8),%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
je     1171 <CompactionFilterV2Filter+0x31>
mov    (%r15,%rbp,8),%rax
cmp    $0x6,%rax
jne    1180 <CompactionFilterV2Filter+0x40>
mov    (%rbx,%rbp,8),%rdi
mov    %r13,%rsi
mov    $0x6,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
je     1227 <CompactionFilterV2Filter+0xe7>
cmpq   $0x6,(%r15,%rbp,8)
jne    1180 <CompactionFilterV2Filter+0x40>
mov    (%rbx,%rbp,8),%rdi
lea    0xe2b(%rip),%rsi
mov    $0x6,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    1180 <CompactionFilterV2Filter+0x40>
mov    $0x7,%edi
call   1060 <malloc@plt>
mov    0x48(%rsp),%rcx
mov    %rax,(%rcx,%rbp,8)
mov    $0x7,%edx
mov    %rax,%rdi
lea    0xe01(%rip),%rsi
call   1050 <memcpy@plt>
mov    0x50(%rsp),%rax
movq   $0x7,(%rax,%rbp,8)
jmp    1180 <CompactionFilterV2Filter+0x40>
mov    0x58(%rsp),%rdi
mov    $0x1,%esi
mov    %r14,%rdx
call   1030 <memset@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"gc\00"
@.str.1 = [7 x i8] c"gc all\00"
@.str.2 = [7 x i8] c"change\00"
@.str.3 = [8 x i8] c"changed\00"
define void @CompactionFilterV2Filter(i8* %0, i32 %1, i64 %2, i8** %3, i64* %4, i8** %5, i64* %6, i8** %7, i64* %8, i8* %9) {
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i64
%14 = alloca i8**
%15 = alloca i64*
%16 = alloca i8**
%17 = alloca i64*
%18 = alloca i8**
%19 = alloca i64*
%20 = alloca i8*
%21 = alloca i64
%22 = alloca i64
%23 = alloca i64
store i8* %0, i8** %11
store i32 %1, i32* %12
store i64 %2, i64* %13
store i8** %3, i8*** %14
store i64* %4, i64** %15
store i8** %5, i8*** %16
store i64* %6, i64** %17
store i8** %7, i8*** %18
store i64* %8, i64** %19
store i8* %9, i8** %20
store i64 0, i64* %21
br label %24
24: ; preds = %105, %10
%25 = load i64, i64* %21
%26 = load i64, i64* %13
%27 = icmp ult i64 %25, %26
br i1 %27, label %28, label %108
28: ; preds = %24
%29 = load i64*, i64** %17
%30 = load i64, i64* %21
%31 = getelementptr inbounds i64, i64* %29, i64 %30
%32 = load i64, i64* %31
%33 = icmp eq i64 %32, 2
br i1 %33, label %34, label %45
34: ; preds = %28
%35 = load i8**, i8*** %16
%36 = load i64, i64* %21
%37 = getelementptr inbounds i8*, i8** %35, i64 %36
%38 = load i8*, i8** %37
%39 = call i64 @memcmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %34
%42 = load i8*, i8** %20
%43 = load i64, i64* %21
%44 = getelementptr inbounds i8, i8* %42, i64 %43
store i8 1, i8* %44
br label %104
45: ; preds = %34, %28
%46 = load i64*, i64** %17
%47 = load i64, i64* %21
%48 = getelementptr inbounds i64, i64* %46, i64 %47
%49 = load i64, i64* %48
%50 = icmp eq i64 %49, 6
br i1 %50, label %51, label %71
51: ; preds = %45
%52 = load i8**, i8*** %16
%53 = load i64, i64* %21
%54 = getelementptr inbounds i8*, i8** %52, i64 %53
%55 = load i8*, i8** %54
%56 = call i64 @memcmp(i8* %55, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %71
58: ; preds = %51
store i64 0, i64* %22
br label %59
59: ; preds = %67, %58
%60 = load i64, i64* %22
%61 = load i64, i64* %13
%62 = icmp ult i64 %60, %61
br i1 %62, label %63, label %70
63: ; preds = %59
%64 = load i8*, i8** %20
%65 = load i64, i64* %22
%66 = getelementptr inbounds i8, i8* %64, i64 %65
store i8 1, i8* %66
br label %67
67: ; preds = %63
%68 = load i64, i64* %22
%69 = add i64 %68, 1
store i64 %69, i64* %22
br label %59
70: ; preds = %59
br label %108
71: ; preds = %51, %45
%72 = load i64*, i64** %17
%73 = load i64, i64* %21
%74 = getelementptr inbounds i64, i64* %72, i64 %73
%75 = load i64, i64* %74
%76 = icmp eq i64 %75, 6
br i1 %76, label %77, label %101
77: ; preds = %71
%78 = load i8**, i8*** %16
%79 = load i64, i64* %21
%80 = getelementptr inbounds i8*, i8** %78, i64 %79
%81 = load i8*, i8** %80
%82 = call i64 @memcmp(i8* %81, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %101
84: ; preds = %77
%85 = call i64 @strlen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i64 %85, i64* %23
%86 = load i64, i64* %23
%87 = call i8* @malloc(i64 %86)
%88 = load i8**, i8*** %18
%89 = load i64, i64* %21
%90 = getelementptr inbounds i8*, i8** %88, i64 %89
store i8* %87, i8** %90
%91 = load i8**, i8*** %18
%92 = load i64, i64* %21
%93 = getelementptr inbounds i8*, i8** %91, i64 %92
%94 = load i8*, i8** %93
%95 = load i64, i64* %23
%96 = call i32 @memcpy(i8* %94, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 %95)
%97 = load i64, i64* %23
%98 = load i64*, i64** %19
%99 = load i64, i64* %21
%100 = getelementptr inbounds i64, i64* %98, i64 %99
store i64 %97, i64* %100
br label %102
101: ; preds = %77, %71
br label %102
102: ; preds = %101, %84
br label %103
103: ; preds = %102
br label %104
104: ; preds = %103, %41
br label %105
105: ; preds = %104
%106 = load i64, i64* %21
%107 = add i64 %106, 1
store i64 %107, i64* %21
br label %24
108: ; preds = %70, %24
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"gc\00"
@.str.1 = [7 x i8] c"gc all\00"
@.str.2 = [7 x i8] c"change\00"
@.str.3 = [8 x i8] c"changed\00"
define void @CompactionFilterV2Filter(i8* nocapture readnone %0, i32 %1, i64 %2, i8** nocapture readnone %3, i64* nocapture readnone %4, i8** nocapture %5, i64* nocapture %6, i8** nocapture writeonly %7, i64* nocapture writeonly %8, i8* nocapture writeonly %9) {
%11 = icmp eq i64 %2, 0
br i1 %11, label %51, label %12
12: ; preds = %10, %48
%13 = phi i64 [ %49, %48 ], [ 0, %10 ]
%14 = getelementptr inbounds i64, i64* %6, i64 %13
%15 = load i64, i64* %14
%16 = icmp eq i64 %15, 2
br i1 %16, label %17, label %26
17: ; preds = %12
%18 = getelementptr inbounds i8*, i8** %5, i64 %13
%19 = load i8*, i8** %18
%20 = tail call i64 @memcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = getelementptr inbounds i8, i8* %9, i64 %13
store i8 1, i8* %23
br label %48
24: ; preds = %17
%25 = load i64, i64* %14
br label %26
26: ; preds = %24, %12
%27 = phi i64 [ %25, %24 ], [ %15, %12 ]
%28 = icmp eq i64 %27, 6
br i1 %28, label %29, label %48
29: ; preds = %26
%30 = getelementptr inbounds i8*, i8** %5, i64 %13
%31 = load i8*, i8** %30
%32 = tail call i64 @memcmp(i8* %31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %29
br label %51
35: ; preds = %29
%36 = load i64, i64* %14
%37 = icmp eq i64 %36, 6
br i1 %37, label %38, label %48
38: ; preds = %35
%39 = getelementptr inbounds i8*, i8** %5, i64 %13
%40 = load i8*, i8** %39
%41 = tail call i64 @memcmp(i8* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %38
%44 = tail call dereferenceable_or_null(7) i8* @malloc(i64 7)
%45 = getelementptr inbounds i8*, i8** %7, i64 %13
store i8* %44, i8** %45
%46 = tail call i32 @memcpy(i8* %44, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i64 7)
%47 = getelementptr inbounds i64, i64* %8, i64 %13
store i64 7, i64* %47
br label %48
48: ; preds = %26, %22, %43, %38, %35
%49 = add nuw i64 %13, 1
%50 = icmp eq i64 %49, %2
br i1 %50, label %51, label %12
51: ; preds = %48, %34, %10
ret void
}