#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 *get_service_filter(char *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int test_get_service_filter(char *host, char *user, char *tag, char *match,
                            int out) {
  char *filter;
  int result = 0;
  printf("   get_service_filter( '%s', '%s', '%s', '%s', %i ) ", host, user,
         tag, match, out);
  filter = get_service_filter(host, user, tag);
  printf(" = '%s' ", filter);
  if (filter == NULL) {
    if (match == NULL) {
      result = 1;
    } else {
      result = 0;
    }
  } else {
    if (match != NULL) {
      if (strcmp(filter, match) == 0) {
        result = 1;
      }
      free(filter);
    }
  }
  if (result == out) {
    printf(" passed\n");
    return (0);
  }
  printf(" failed\n");
  return (1);
}


x86 assembly (clang, -O0):
<test_get_service_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <get_service_filter@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x38(%rbp)
jne    11da <test_get_service_filter+0x9a>
cmpq   $0x0,-0x28(%rbp)
jne    11ce <test_get_service_filter+0x8e>
movl   $0x1,-0x3c(%rbp)
jmp    11d5 <test_get_service_filter+0x95>
movl   $0x0,-0x3c(%rbp)
jmp    1211 <test_get_service_filter+0xd1>
cmpq   $0x0,-0x28(%rbp)
je     120c <test_get_service_filter+0xcc>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <test_get_service_filter+0xc3>
movl   $0x1,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
jmp    1211 <test_get_service_filter+0xd1>
mov    -0x3c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    1237 <test_get_service_filter+0xf7>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    124c <test_get_service_filter+0x10c>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_get_service_filter>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0xe92(%rip),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14d,%r9d
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1070 <get_service_filter@plt>
mov    %rax,%rbp
lea    0xe99(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rax
or     %r15,%rax
sete   %bl
test   %rbp,%rbp
je     11d2 <test_get_service_filter+0x82>
test   %r15,%r15
je     11d2 <test_get_service_filter+0x82>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
sete   %bl
mov    %rbp,%rdi
call   1030 <free@plt>
movzbl %bl,%eax
xor    %ebx,%ebx
cmp    %r14d,%eax
setne  %bl
lea    0xe62(%rip),%rax
lea    0xe53(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c" get_service_filter( '%s', '%s', '%s', '%s', %i ) \00"
@.str.1 = [9 x i8] c" = '%s' \00"
@.str.2 = [9 x i8] c" passed\0A\00"
@.str.3 = [9 x i8] c" failed\0A\00"
define i32 @test_get_service_filter(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 0, i32* %13
%14 = load i8*, i8** %7
%15 = load i8*, i8** %8
%16 = load i8*, i8** %9
%17 = load i8*, i8** %10
%18 = load i32, i32* %11
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15, i8* %16, i8* %17, i32 %18)
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = load i8*, i8** %9
%23 = call i8* @get_service_filter(i8* %20, i8* %21, i8* %22)
store i8* %23, i8** %12
%24 = load i8*, i8** %12
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i8*, i8** %12
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %34
28: ; preds = %5
%29 = load i8*, i8** %10
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 1, i32* %13
br label %33
32: ; preds = %28
store i32 0, i32* %13
br label %33
33: ; preds = %32, %31
br label %47
34: ; preds = %5
%35 = load i8*, i8** %10
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %46
37: ; preds = %34
%38 = load i8*, i8** %12
%39 = load i8*, i8** %10
%40 = call i64 @strcmp(i8* %38, i8* %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 1, i32* %13
br label %43
43: ; preds = %42, %37
%44 = load i8*, i8** %12
%45 = call i32 @free(i8* %44)
br label %46
46: ; preds = %43, %34
br label %47
47: ; preds = %46, %33
%48 = load i32, i32* %13
%49 = load i32, i32* %11
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %55
53: ; preds = %47
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %6
br label %55
55: ; preds = %53, %51
%56 = load i32, i32* %6
ret i32 %56
}

LLVM IR (-O2):
@.str = [53 x i8] c" get_service_filter( '%s', '%s', '%s', '%s', %i ) \00"
@.str.1 = [9 x i8] c" = '%s' \00"
@str = [8 x i8] c" failed\00"
@str.4 = [8 x i8] c" passed\00"
define i32 @test_get_service_filter(i8* %0, i8* %1, i8* %2, i8* %3, i32 %4) {
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %2, i8* %3, i32 %4)
%7 = tail call i8* @get_service_filter(i8* %0, i8* %1, i8* %2)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = icmp eq i8* %7, null
%10 = icmp eq i8* %3, null
%11 = or i1 %9, %10
%12 = and i1 %9, %10
br i1 %11, label %17, label %13
13: ; preds = %5
%14 = tail call i64 @strcmp(i8* %7, i8* %3)
%15 = icmp eq i64 %14, 0
%16 = tail call i32 @free(i8* %7)
br label %17
17: ; preds = %5, %13
%18 = phi i1 [ %15, %13 ], [ %12, %5 ]
%19 = zext i1 %18 to i32
%20 = icmp eq i32 %19, %4
%21 = select i1 %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0)
%22 = xor i1 %20, true
%23 = zext i1 %22 to i32
%24 = tail call i32 @puts(i8* dereferenceable(1) %21)
ret i32 %23
}