#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_host_filter(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int test_get_host_filter(char *host, char *user, char *match, int out) {
  char *filter;
  int result = 0;
  printf("   get_host_filter( '%s', '%s', '%s', %i ) ", host, user, match, out);
  filter = get_host_filter(host, user);
  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_host_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <get_host_filter@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x30(%rbp)
jne    11cd <test_get_host_filter+0x8d>
cmpq   $0x0,-0x20(%rbp)
jne    11c1 <test_get_host_filter+0x81>
movl   $0x1,-0x34(%rbp)
jmp    11c8 <test_get_host_filter+0x88>
movl   $0x0,-0x34(%rbp)
jmp    1204 <test_get_host_filter+0xc4>
cmpq   $0x0,-0x20(%rbp)
je     11ff <test_get_host_filter+0xbf>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f6 <test_get_host_filter+0xb6>
movl   $0x1,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    1204 <test_get_host_filter+0xc4>
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    122a <test_get_host_filter+0xea>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123f <test_get_host_filter+0xff>
lea    0xe0d(%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_host_filter>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r15,%rcx
mov    %r14d,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1070 <get_host_filter@plt>
mov    %rax,%rbp
lea    0xe9a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rax
or     %r15,%rax
sete   %bl
test   %rbp,%rbp
je     11c8 <test_get_host_filter+0x78>
test   %r15,%r15
je     11c8 <test_get_host_filter+0x78>
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    0xe63(%rip),%rax
lea    0xe54(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [44 x i8] c" get_host_filter( '%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_host_filter(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i8* %2, i32 %3)
%6 = tail call i8* @get_host_filter(i8* %0, i8* %1)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = icmp eq i8* %6, null
%9 = icmp eq i8* %2, null
%10 = or i1 %8, %9
%11 = and i1 %8, %9
br i1 %10, label %16, label %12
12: ; preds = %4
%13 = tail call i64 @strcmp(i8* %6, i8* %2)
%14 = icmp eq i64 %13, 0
%15 = tail call i32 @free(i8* %6)
br label %16
16: ; preds = %4, %12
%17 = phi i1 [ %14, %12 ], [ %11, %4 ]
%18 = zext i1 %17 to i32
%19 = icmp eq i32 %18, %3
%20 = select i1 %19, 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)
%21 = xor i1 %19, true
%22 = zext i1 %21 to i32
%23 = tail call i32 @puts(i8* dereferenceable(1) %20)
ret i32 %22
}