#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 strcasecmp(char const *, char const *);
int strcmp(char const *, char const *);
size_t strlen(char const *);
int strncasecmp(char const *, char const *, size_t);
int strncmp(char const *, char const *, size_t);
int fnmatch_no_wildcards(char const *pattern, char const *f, int options) {
  if (!(options & (1 << 3)))
    return ((options & (1 << 4)) ? strcasecmp(pattern, f) : strcmp(pattern, f));
  else {
    size_t patlen = strlen(pattern);
    int r = ((options & (1 << 4)) ? strncasecmp(pattern, f, patlen)
                                  : strncmp(pattern, f, patlen));
    if (!r) {
      r = f[patlen];
      if (r == '/')
        r = 0;
    }
    return r;
  }
}


x86 assembly (clang, -O0):
<fnmatch_no_wildcards>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
jne    11b1 <fnmatch_no_wildcards+0x61>
mov    -0x1c(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1196 <fnmatch_no_wildcards+0x46>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x30(%rbp)
jmp    11a6 <fnmatch_no_wildcards+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1235 <fnmatch_no_wildcards+0xe5>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     11e6 <fnmatch_no_wildcards+0x96>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1070 <strncasecmp@plt>
mov    %eax,-0x34(%rbp)
jmp    11fa <fnmatch_no_wildcards+0xaa>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <strncmp@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    122f <fnmatch_no_wildcards+0xdf>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x2f,-0x2c(%rbp)
jne    122a <fnmatch_no_wildcards+0xda>
movl   $0x0,-0x2c(%rbp)
jmp    122f <fnmatch_no_wildcards+0xdf>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fnmatch_no_wildcards>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
test   $0x8,%bpl
jne    1180 <fnmatch_no_wildcards+0x30>
mov    %rbx,%rdi
mov    %r15,%rsi
add    $0x8,%rsp
test   $0x10,%bpl
jne    11a5 <fnmatch_no_wildcards+0x55>
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <strcmp@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
test   $0x10,%bpl
jne    11b0 <fnmatch_no_wildcards+0x60>
call   1040 <strncmp@plt>
test   %eax,%eax
jne    11c8 <fnmatch_no_wildcards+0x78>
jmp    11b9 <fnmatch_no_wildcards+0x69>
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <strcasecmp@plt>
call   1070 <strncasecmp@plt>
test   %eax,%eax
jne    11c8 <fnmatch_no_wildcards+0x78>
movzbl (%r15,%r14,1),%eax
xor    %ecx,%ecx
cmp    $0x2f,%al
cmovne %eax,%ecx
movsbl %cl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fnmatch_no_wildcards(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i32, i32* %7
%11 = and i32 %10, 8
%12 = icmp ne i32 %11, 0
br i1 %12, label %27, label %13
13: ; preds = %3
%14 = load i32, i32* %7
%15 = and i32 %14, 16
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = load i8*, i8** %6
%20 = call i32 @strcasecmp(i8* %18, i8* %19)
br label %25
21: ; preds = %13
%22 = load i8*, i8** %5
%23 = load i8*, i8** %6
%24 = call i32 @strcmp(i8* %22, i8* %23)
br label %25
25: ; preds = %21, %17
%26 = phi i32 [ %20, %17 ], [ %24, %21 ]
store i32 %26, i32* %4
br label %59
27: ; preds = %3
%28 = load i8*, i8** %5
%29 = call i64 @strlen(i8* %28)
store i64 %29, i64* %8
%30 = load i32, i32* %7
%31 = and i32 %30, 16
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %27
%34 = load i8*, i8** %5
%35 = load i8*, i8** %6
%36 = load i64, i64* %8
%37 = call i32 @strncasecmp(i8* %34, i8* %35, i64 %36)
br label %43
38: ; preds = %27
%39 = load i8*, i8** %5
%40 = load i8*, i8** %6
%41 = load i64, i64* %8
%42 = call i32 @strncmp(i8* %39, i8* %40, i64 %41)
br label %43
43: ; preds = %38, %33
%44 = phi i32 [ %37, %33 ], [ %42, %38 ]
store i32 %44, i32* %9
%45 = load i32, i32* %9
%46 = icmp ne i32 %45, 0
br i1 %46, label %57, label %47
47: ; preds = %43
%48 = load i8*, i8** %6
%49 = load i64, i64* %8
%50 = getelementptr inbounds i8, i8* %48, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
store i32 %52, i32* %9
%53 = load i32, i32* %9
%54 = icmp eq i32 %53, 47
br i1 %54, label %55, label %56
55: ; preds = %47
store i32 0, i32* %9
br label %56
56: ; preds = %55, %47
br label %57
57: ; preds = %56, %43
%58 = load i32, i32* %9
store i32 %58, i32* %4
br label %59
59: ; preds = %57, %25
%60 = load i32, i32* %4
ret i32 %60
}

LLVM IR (-O2):
define i32 @fnmatch_no_wildcards(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = and i32 %2, 8
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = and i32 %2, 16
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @strcasecmp(i8* %0, i8* %1)
br label %30
11: ; preds = %6
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
br label %30
13: ; preds = %3
%14 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%15 = and i32 %2, 16
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = tail call i32 @strncasecmp(i8* %0, i8* %1, i64 %14)
br label %21
19: ; preds = %13
%20 = tail call i32 @strncmp(i8* %0, i8* %1, i64 %14)
br label %21
21: ; preds = %19, %17
%22 = phi i32 [ %18, %17 ], [ %20, %19 ]
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = getelementptr inbounds i8, i8* %1, i64 %14
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 47
%28 = select i1 %27, i8 0, i8 %26
%29 = sext i8 %28 to i32
br label %30
30: ; preds = %21, %24, %9, %11
%31 = phi i32 [ %10, %9 ], [ %12, %11 ], [ %22, %21 ], [ %29, %24 ]
ret i32 %31
}