#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int ndb_getDebugLevel();
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int wildcardfit(char *, char *);
int ndb_osdep_matchFilename(const char *mask, const char *name) {
  int result = 0;
  char *p;
  char lowerMask[260];
  char lowerName[260];
  strcpy(lowerMask, (char *)mask);
  strcpy(lowerName, (char *)name);
  for (p = lowerMask; *p != '\0'; p++) {
    if (*p == '\\')
      *p = '/';
  }
  for (p = lowerName; *p != '\0'; p++) {
    if (*p == '\\')
      *p = '/';
  }
  if ((ndb_getDebugLevel() >= 7) && (strcmp(lowerMask, "*") != 0)) {
    fprintf(stdout, "ndb_osdep_matchFilename: before: mask '%s', file '%s'\n",
            mask, name);
    fprintf(stdout, "ndb_osdep_matchFilename: after:  mask '%s', file '%s'\n",
            lowerMask, lowerName);
    fprintf(stdout,
            "ndb_osdep_matchFilename: testing mask '%s' against file '%s' -> ",
            lowerMask, lowerName);
    fflush(stdout);
  }
  result = wildcardfit(lowerMask, lowerName);
  if ((ndb_getDebugLevel() >= 7) && (strcmp(mask, "*") != 0)) {
    fprintf(stdout, "%d\n", result);
    fflush(stdout);
  }
  return result;
}


x86 assembly (clang, -O0):
<ndb_osdep_matchFilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x240(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x130(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11e2 <ndb_osdep_matchFilename+0x82>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    11cc <ndb_osdep_matchFilename+0x6c>
mov    -0x20(%rbp),%rax
movb   $0x2f,(%rax)
jmp    11d1 <ndb_osdep_matchFilename+0x71>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11a5 <ndb_osdep_matchFilename+0x45>
lea    -0x240(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     122a <ndb_osdep_matchFilename+0xca>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1214 <ndb_osdep_matchFilename+0xb4>
mov    -0x20(%rbp),%rax
movb   $0x2f,(%rax)
jmp    1219 <ndb_osdep_matchFilename+0xb9>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11ed <ndb_osdep_matchFilename+0x8d>
mov    $0x0,%al
call   1050 <ndb_getDebugLevel@plt>
cmp    $0x7,%eax
jl     12ce <ndb_osdep_matchFilename+0x16e>
lea    -0x130(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12ce <ndb_osdep_matchFilename+0x16e>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xd93(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    -0x240(%rbp),%rcx
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    -0x240(%rbp),%rcx
lea    0xdb7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
lea    -0x130(%rbp),%rdi
lea    -0x240(%rbp),%rsi
call   1040 <wildcardfit@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1050 <ndb_getDebugLevel@plt>
cmp    $0x7,%eax
jl     1336 <ndb_osdep_matchFilename+0x1d6>
mov    -0x8(%rbp),%rdi
lea    0xd01(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1336 <ndb_osdep_matchFilename+0x1d6>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xd90(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    -0x14(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ndb_osdep_matchFilename>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0x110(%rsp),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
jmp    11a7 <ndb_osdep_matchFilename+0x47>
nopw   0x0(%rax,%rax,1)
movb   $0x2f,(%rbx)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x5c,%al
je     11a0 <ndb_osdep_matchFilename+0x40>
test   %al,%al
jne    11a3 <ndb_osdep_matchFilename+0x43>
jmp    11c9 <ndb_osdep_matchFilename+0x69>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x2f,(%r12)
add    $0x1,%r12
movzbl (%r12),%eax
cmp    $0x5c,%al
je     11c0 <ndb_osdep_matchFilename+0x60>
test   %al,%al
jne    11c5 <ndb_osdep_matchFilename+0x65>
xor    %eax,%eax
call   1050 <ndb_getDebugLevel@plt>
cmp    $0x7,%eax
jl     1251 <ndb_osdep_matchFilename+0xf1>
lea    0xe17(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1251 <ndb_osdep_matchFilename+0xf1>
mov    0x2de3(%rip),%rbx
mov    (%rbx),%edi
lea    0xdfc(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe1d(%rip),%rsi
mov    %rsp,%r12
lea    0x110(%rsp),%r15
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe33(%rip),%rsi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%rbx),%edi
call   1080 <fflush@plt>
mov    %rsp,%rdi
lea    0x110(%rsp),%rsi
call   1040 <wildcardfit@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <ndb_getDebugLevel@plt>
cmp    $0x7,%eax
jl     12a5 <ndb_osdep_matchFilename+0x145>
lea    0xd8a(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12a5 <ndb_osdep_matchFilename+0x145>
mov    0x2d56(%rip),%r14
mov    (%r14),%edi
lea    0xe1d(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    (%r14),%edi
call   1080 <fflush@plt>
mov    %ebx,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"*\00"
@stdout = global i32 0
@.str.1 = [55 x i8] c"ndb_osdep_matchFilename: before: mask '%s', file '%s'\0A\00"
@.str.2 = [55 x i8] c"ndb_osdep_matchFilename: after: mask '%s', file '%s'\0A\00"
@.str.3 = [65 x i8] c"ndb_osdep_matchFilename: testing mask '%s' against file '%s' -> \00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @ndb_osdep_matchFilename(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [260 x i8]
%8 = alloca [260 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%9 = getelementptr inbounds [260 x i8], [260 x i8]* %7, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = getelementptr inbounds [260 x i8], [260 x i8]* %8, i64 0, i64 0
%13 = load i8*, i8** %4
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = getelementptr inbounds [260 x i8], [260 x i8]* %7, i64 0, i64 0
store i8* %15, i8** %6
br label %16
16: ; preds = %29, %2
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %16
%22 = load i8*, i8** %6
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 92
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = load i8*, i8** %6
store i8 47, i8* %27
br label %28
28: ; preds = %26, %21
br label %29
29: ; preds = %28
%30 = load i8*, i8** %6
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %6
br label %16
32: ; preds = %16
%33 = getelementptr inbounds [260 x i8], [260 x i8]* %8, i64 0, i64 0
store i8* %33, i8** %6
br label %34
34: ; preds = %47, %32
%35 = load i8*, i8** %6
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %50
39: ; preds = %34
%40 = load i8*, i8** %6
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 92
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = load i8*, i8** %6
store i8 47, i8* %45
br label %46
46: ; preds = %44, %39
br label %47
47: ; preds = %46
%48 = load i8*, i8** %6
%49 = getelementptr inbounds i8, i8* %48, i32 1
store i8* %49, i8** %6
br label %34
50: ; preds = %34
%51 = call i32 (...) @ndb_getDebugLevel()
%52 = icmp sge i32 %51, 7
br i1 %52, label %53, label %72
53: ; preds = %50
%54 = getelementptr inbounds [260 x i8], [260 x i8]* %7, i64 0, i64 0
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %72
57: ; preds = %53
%58 = load i32, i32* @stdout
%59 = load i8*, i8** %3
%60 = load i8*, i8** %4
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8* %59, i8* %60)
%62 = load i32, i32* @stdout
%63 = getelementptr inbounds [260 x i8], [260 x i8]* %7, i64 0, i64 0
%64 = getelementptr inbounds [260 x i8], [260 x i8]* %8, i64 0, i64 0
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %63, i8* %64)
%66 = load i32, i32* @stdout
%67 = getelementptr inbounds [260 x i8], [260 x i8]* %7, i64 0, i64 0
%68 = getelementptr inbounds [260 x i8], [260 x i8]* %8, i64 0, i64 0
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0), i8* %67, i8* %68)
%70 = load i32, i32* @stdout
%71 = call i32 @fflush(i32 %70)
br label %72
72: ; preds = %57, %53, %50
%73 = getelementptr inbounds [260 x i8], [260 x i8]* %7, i64 0, i64 0
%74 = getelementptr inbounds [260 x i8], [260 x i8]* %8, i64 0, i64 0
%75 = call i32 @wildcardfit(i8* %73, i8* %74)
store i32 %75, i32* %5
%76 = call i32 (...) @ndb_getDebugLevel()
%77 = icmp sge i32 %76, 7
br i1 %77, label %78, label %88
78: ; preds = %72
%79 = load i8*, i8** %3
%80 = call i64 @strcmp(i8* %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %88
82: ; preds = %78
%83 = load i32, i32* @stdout
%84 = load i32, i32* %5
%85 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %84)
%86 = load i32, i32* @stdout
%87 = call i32 @fflush(i32 %86)
br label %88
88: ; preds = %82, %78, %72
%89 = load i32, i32* %5
ret i32 %89
}

LLVM IR (-O2):
@.str = [2 x i8] c"*\00"
@stdout = global i32 0
@.str.1 = [55 x i8] c"ndb_osdep_matchFilename: before: mask '%s', file '%s'\0A\00"
@.str.2 = [55 x i8] c"ndb_osdep_matchFilename: after: mask '%s', file '%s'\0A\00"
@.str.3 = [65 x i8] c"ndb_osdep_matchFilename: testing mask '%s' against file '%s' -> \00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @ndb_osdep_matchFilename(i8* %0, i8* %1) {
%3 = alloca [260 x i8]
%4 = alloca [260 x i8]
%5 = getelementptr inbounds [260 x i8], [260 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [260 x i8], [260 x i8]* %4, i64 0, i64 0
%7 = call i32 @strcpy(i8* %5, i8* %0)
%8 = call i32 @strcpy(i8* %6, i8* %1)
br label %9
9: ; preds = %13, %2
%10 = phi i8* [ %5, %2 ], [ %14, %13 ]
%11 = load i8, i8* %10
switch i8 %11, label %13 [
i8 0, label %15
i8 92, label %12
]
12: ; preds = %9
store i8 47, i8* %10
br label %13
13: ; preds = %9, %12
%14 = getelementptr inbounds i8, i8* %10, i64 1
br label %9
15: ; preds = %9, %19
%16 = phi i8* [ %20, %19 ], [ %6, %9 ]
%17 = load i8, i8* %16
switch i8 %17, label %19 [
i8 0, label %21
i8 92, label %18
]
18: ; preds = %15
store i8 47, i8* %16
br label %19
19: ; preds = %15, %18
%20 = getelementptr inbounds i8, i8* %16, i64 1
br label %15
21: ; preds = %15
%22 = call i32 (...) @ndb_getDebugLevel()
%23 = icmp sgt i32 %22, 6
br i1 %23, label %24, label %36
24: ; preds = %21
%25 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %36, label %27
27: ; preds = %24
%28 = load i32, i32* @stdout
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
%30 = load i32, i32* @stdout
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %6)
%32 = load i32, i32* @stdout
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0), i8* %5, i8* %6)
%34 = load i32, i32* @stdout
%35 = call i32 @fflush(i32 %34)
br label %36
36: ; preds = %27, %24, %21
%37 = call i32 @wildcardfit(i8* %5, i8* %6)
%38 = call i32 (...) @ndb_getDebugLevel()
%39 = icmp sgt i32 %38, 6
br i1 %39, label %40, label %48
40: ; preds = %36
%41 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %48, label %43
43: ; preds = %40
%44 = load i32, i32* @stdout
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%46 = load i32, i32* @stdout
%47 = call i32 @fflush(i32 %46)
br label %48
48: ; preds = %43, %40, %36
ret i32 %37
}