#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 */
scalar_t__ memcmp(char const *, char *, size_t);
unsigned char CFilterFilter(void *arg, int level, const char *key,
                            size_t key_length, const char *existing_value,
                            size_t value_length, char **new_value,
                            size_t *new_value_length,
                            unsigned char *value_changed) {
  if (key_length == 3) {
    if (memcmp(key, "bar", key_length) == 0) {
      return 1;
    } else if (memcmp(key, "baz", key_length) == 0) {
      *value_changed = 1;
      *new_value = "newbazvalue";
      *new_value_length = 11;
      return 0;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<CFilterFilter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
cmpq   $0x3,-0x28(%rbp)
jne    11be <CFilterFilter+0xae>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xeab(%rip),%rsi
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    116d <CFilterFilter+0x5d>
movb   $0x1,-0x1(%rbp)
jmp    11c2 <CFilterFilter+0xb2>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe88(%rip),%rsi
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    11b4 <CFilterFilter+0xa4>
mov    0x20(%rbp),%rax
movb   $0x1,(%rax)
mov    0x10(%rbp),%rax
lea    0xe6b(%rip),%rcx
mov    %rcx,(%rax)
mov    0x18(%rbp),%rax
movq   $0xb,(%rax)
movb   $0x0,-0x1(%rbp)
jmp    11c2 <CFilterFilter+0xb2>
jmp    11b9 <CFilterFilter+0xa9>
jmp    11be <CFilterFilter+0xae>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CFilterFilter>:
push   %rbx
cmp    $0x3,%rcx
jne    116f <CFilterFilter+0x5f>
mov    %rdx,%rbx
lea    0xedf(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <memcmp@plt>
test   %rax,%rax
je     1173 <CFilterFilter+0x63>
lea    0xeca(%rip),%rsi
mov    $0x3,%edx
mov    %rbx,%rdi
call   1030 <memcmp@plt>
test   %rax,%rax
jne    116f <CFilterFilter+0x5f>
mov    0x20(%rsp),%rax
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%rdx
movb   $0x1,(%rax)
lea    0xea3(%rip),%rax
mov    %rax,(%rdx)
movq   $0xb,(%rcx)
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"bar\00"
@.str.1 = [4 x i8] c"baz\00"
@.str.2 = [12 x i8] c"newbazvalue\00"
define zeroext i8 @CFilterFilter(i8* %0, i32 %1, i8* %2, i64 %3, i8* %4, i64 %5, i8** %6, i64* %7, i8* %8) {
%10 = alloca i8
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i64
%17 = alloca i8**
%18 = alloca i64*
%19 = alloca i8*
store i8* %0, i8** %11
store i32 %1, i32* %12
store i8* %2, i8** %13
store i64 %3, i64* %14
store i8* %4, i8** %15
store i64 %5, i64* %16
store i8** %6, i8*** %17
store i64* %7, i64** %18
store i8* %8, i8** %19
%20 = load i64, i64* %14
%21 = icmp eq i64 %20, 3
br i1 %21, label %22, label %39
22: ; preds = %9
%23 = load i8*, i8** %13
%24 = load i64, i64* %14
%25 = call i64 @memcmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
store i8 1, i8* %10
br label %40
28: ; preds = %22
%29 = load i8*, i8** %13
%30 = load i64, i64* %14
%31 = call i64 @memcmp(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %28
%34 = load i8*, i8** %19
store i8 1, i8* %34
%35 = load i8**, i8*** %17
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %35
%36 = load i64*, i64** %18
store i64 11, i64* %36
store i8 0, i8* %10
br label %40
37: ; preds = %28
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38, %9
store i8 0, i8* %10
br label %40
40: ; preds = %39, %33, %27
%41 = load i8, i8* %10
ret i8 %41
}

LLVM IR (-O2):
@.str = [4 x i8] c"bar\00"
@.str.1 = [4 x i8] c"baz\00"
@.str.2 = [12 x i8] c"newbazvalue\00"
define zeroext i8 @CFilterFilter(i8* nocapture readnone %0, i32 %1, i8* %2, i64 %3, i8* nocapture readnone %4, i64 %5, i8** nocapture writeonly %6, i64* nocapture writeonly %7, i8* nocapture writeonly %8) {
%10 = icmp eq i64 %3, 3
br i1 %10, label %11, label %18
11: ; preds = %9
%12 = tail call i64 @memcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = tail call i64 @memcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %14
store i8 1, i8* %8
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %6
store i64 11, i64* %7
br label %18
18: ; preds = %9, %14, %11, %17
%19 = phi i8 [ 0, %17 ], [ 1, %11 ], [ 0, %14 ], [ 0, %9 ]
ret i8 %19
}