#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*/ FNM_NOESCAPE;
char *basename(char *);
scalar_t__ fnmatch(char *, char const *const, int /*<<< orphan*/);
char *strdup(char const *);
int check_name(const char *file_name, const char *const *parms, int parm_pos) {
  char *basec;
  char *basen;
  basec = strdup(file_name);
  basen = basename(basec);
  if (fnmatch(basen, parms[parm_pos + 1], FNM_NOESCAPE) == 0) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<check_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <basename@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    0x2e7f(%rip),%rax
mov    (%rax),%edx
call   1030 <fnmatch@plt>
cmp    $0x0,%rax
jne    1196 <check_name+0x66>
movl   $0x1,-0x4(%rbp)
jmp    119d <check_name+0x6d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_name>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
call   1050 <strdup@plt>
mov    %rax,%rdi
call   1040 <basename@plt>
movslq %ebx,%rcx
mov    0x8(%r14,%rcx,8),%rsi
mov    0x2ea3(%rip),%rcx
mov    (%rcx),%edx
mov    %rax,%rdi
call   1030 <fnmatch@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@FNM_NOESCAPE = global i32 0
define i32 @check_name(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
%11 = call i8* @strdup(i8* %10)
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = call i8* @basename(i8* %12)
store i8* %13, i8** %9
%14 = load i8*, i8** %9
%15 = load i8**, i8*** %6
%16 = load i32, i32* %7
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %15, i64 %18
%20 = load i8*, i8** %19
%21 = load i32, i32* @FNM_NOESCAPE
%22 = call i64 @fnmatch(i8* %14, i8* %20, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %3
store i32 1, i32* %4
br label %26
25: ; preds = %3
store i32 0, i32* %4
br label %26
26: ; preds = %25, %24
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@FNM_NOESCAPE = global i32 0
define i32 @check_name(i8* nocapture %0, i8** nocapture %1, i32 %2) {
%4 = tail call i8* @strdup(i8* %0)
%5 = tail call i8* @basename(i8* %4)
%6 = add nsw i32 %2, 1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = load i32, i32* @FNM_NOESCAPE
%11 = tail call i64 @fnmatch(i8* %5, i8* %9, i32 %10)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
ret i32 %13
}