#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*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ wfile_eitherslash(char);
int wfile_wild_match(char *, char *);
int filelist_dir_name_match(char *pattern, char *dirname) {
  int len;
  len = strlen(pattern);
  if (len > 2 && wfile_eitherslash(pattern[len - 2]) &&
      pattern[len - 1] == '*') {
    char tname[512];
    strcpy(tname, pattern);
    tname[len - 2] = '\0';
    return (wfile_wild_match(tname, dirname));
  }
  if (!wfile_wild_match(pattern, dirname))
    return (0);
  return (pattern[len - 1] == '*');
}


x86 assembly (clang, -O0):
<filelist_dir_name_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jle    11db <filelist_dir_name_match+0x9b>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <wfile_eitherslash@plt>
cmp    $0x0,%rax
je     11db <filelist_dir_name_match+0x9b>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2a,%eax
jne    11db <filelist_dir_name_match+0x9b>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
cltq
movb   $0x0,-0x220(%rbp,%rax,1)
lea    -0x220(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <wfile_wild_match@plt>
mov    %eax,-0x4(%rbp)
jmp    121c <filelist_dir_name_match+0xdc>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <wfile_wild_match@plt>
cmp    $0x0,%eax
jne    11fd <filelist_dir_name_match+0xbd>
movl   $0x0,-0x4(%rbp)
jmp    121c <filelist_dir_name_match+0xdc>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2a,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filelist_dir_name_match>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1060 <strlen@plt>
mov    %eax,%r15d
cmp    $0x3,%eax
jl     119e <filelist_dir_name_match+0x5e>
lea    -0x2(%r15),%r12d
movsbl (%rbx,%r12,1),%edi
call   1050 <wfile_eitherslash@plt>
test   %rax,%rax
je     119e <filelist_dir_name_match+0x5e>
lea    -0x1(%r15),%eax
cmpb   $0x2a,(%rbx,%rax,1)
jne    119e <filelist_dir_name_match+0x5e>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
movb   $0x0,(%rsp,%r12,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <wfile_wild_match@plt>
jmp    11be <filelist_dir_name_match+0x7e>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <wfile_wild_match@plt>
test   %eax,%eax
je     11bc <filelist_dir_name_match+0x7c>
movslq %r15d,%rcx
xor    %eax,%eax
cmpb   $0x2a,-0x1(%rcx,%rbx,1)
sete   %al
jmp    11be <filelist_dir_name_match+0x7e>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @filelist_dir_name_match(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 2
br i1 %5, label %6, label %24
6: ; preds = %2
%7 = add nsw i32 %4, -2
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = tail call i64 @wfile_eitherslash(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %24, label %13
13: ; preds = %6
%14 = add nsw i32 %4, -1
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 42
br i1 %18, label %19, label %24
19: ; preds = %13
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%21 = call i32 @strcpy(i8* %20, i8* %0)
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %8
store i8 0, i8* %22
%23 = call i32 @wfile_wild_match(i8* %20, i8* %1)
br label %34
24: ; preds = %13, %6, %2
%25 = tail call i32 @wfile_wild_match(i8* %0, i8* %1)
%26 = icmp eq i32 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %24
%28 = add nsw i32 %4, -1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %0, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 42
%33 = zext i1 %32 to i32
br label %34
34: ; preds = %24, %27, %19
%35 = phi i32 [ %23, %19 ], [ %33, %27 ], [ 0, %24 ]
ret i32 %35
}