#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__ fnmatch(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void test_1(void) {
  if (0 != fnmatch("a", "a", 0)) {
    fprintf(stderr, "test failed!\n");
  }
  if (0 == fnmatch("a", "b", 0)) {
    fprintf(stderr, "test failed!\n");
  }
  if (0 != fnmatch("[a-d]", "a", 0)) {
    fprintf(stderr, "test failed!\n");
  }
  if (0 == fnmatch("[^A-Zb-z0-9]", "a", 0)) {
    fprintf(stderr, "test failed!\n");
  }
}


x86 assembly (clang, -O0):
<test_1>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rsi
xor    %edx,%edx
mov    %rsi,%rdi
call   1030 <fnmatch@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1158 <test_1+0x38>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
lea    0xeaf(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xea1(%rip),%rdi
lea    0xeaa(%rip),%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1190 <test_1+0x70>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe7b(%rip),%rdi
lea    0xe62(%rip),%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11c8 <test_1+0xa8>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe49(%rip),%rdi
lea    0xe2a(%rip),%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1200 <test_1+0xe0>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    0xe07(%rip),%rsi
call   1040 <fprintf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_1>:
push   %rax
lea    0xed8(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
test   %rax,%rax
je     114c <test_1+0x2c>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xead(%rip),%rdi
lea    0xeb6(%rip),%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
test   %rax,%rax
jne    117b <test_1+0x5b>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe90(%rip),%rdi
lea    0xe77(%rip),%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
test   %rax,%rax
je     11aa <test_1+0x8a>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe67(%rip),%rdi
lea    0xe48(%rip),%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
test   %rax,%rax
je     11c6 <test_1+0xa6>
pop    %rax
ret
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
pop    %rax
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@stderr = global i32 0
@.str.1 = [14 x i8] c"test failed!\0A\00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [6 x i8] c"[a-d]\00"
@.str.4 = [13 x i8] c"[^A-Zb-z0-9]\00"
define void @test_1() {
%1 = call i64 @fnmatch(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = icmp ne i64 0, %1
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %3, %0
%7 = call i64 @fnmatch(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 0)
%8 = icmp eq i64 0, %7
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %9, %6
%13 = call i64 @fnmatch(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0)
%14 = icmp ne i64 0, %13
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %12
%19 = call i64 @fnmatch(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0)
%20 = icmp eq i64 0, %19
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@stderr = global i32 0
@.str.1 = [14 x i8] c"test failed!\0A\00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [6 x i8] c"[a-d]\00"
@.str.4 = [13 x i8] c"[^A-Zb-z0-9]\00"
define void @test_1() {
%1 = tail call i64 @fnmatch(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = icmp eq i64 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %3, %0
%7 = tail call i64 @fnmatch(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %9, %6
%13 = tail call i64 @fnmatch(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %12
%19 = tail call i64 @fnmatch(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
ret void
}