#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*/ free(char *);
char *strdup(char const *);
int /*<<< orphan*/ strupr(char *);
int wildmatch(char *, char *, int);
int wildmatchi(const char *fname, const char *spec, int path) {
  char *s1;
  char *s2;
  int result;
  if ((s1 = strdup(fname)) == NULL)
    return (0);
  if ((s2 = strdup(spec)) == NULL) {
    free(s1);
    return (0);
  }
  strupr(s1);
  strupr(s2);
  result = wildmatch(s1, s2, path);
  free(s1);
  free(s2);
  return (result);
}


x86 assembly (clang, -O0):
<wildmatchi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1176 <wildmatchi+0x36>
movl   $0x0,-0x4(%rbp)
jmp    11df <wildmatchi+0x9f>
mov    -0x18(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11a2 <wildmatchi+0x62>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11df <wildmatchi+0x9f>
mov    -0x28(%rbp),%rdi
call   1050 <strupr@plt>
mov    -0x30(%rbp),%rdi
call   1050 <strupr@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <wildmatch@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wildmatchi>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbp
call   1060 <strdup@plt>
test   %rax,%rax
je     1195 <wildmatchi+0x55>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1060 <strdup@plt>
test   %rax,%rax
je     119a <wildmatchi+0x5a>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <strupr@plt>
mov    %rbp,%rdi
call   1050 <strupr@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1040 <wildmatch@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rbx
jmp    119d <wildmatchi+0x5d>
xor    %r14d,%r14d
jmp    11a5 <wildmatchi+0x65>
xor    %r14d,%r14d
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @wildmatchi(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%11 = load i8*, i8** %5
%12 = call i8* @strdup(i8* %11)
store i8* %12, i8** %8
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 0, i32* %4
br label %36
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = call i8* @strdup(i8* %16)
store i8* %17, i8** %9
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i8*, i8** %8
%21 = call i32 @free(i8* %20)
store i32 0, i32* %4
br label %36
22: ; preds = %15
%23 = load i8*, i8** %8
%24 = call i32 @strupr(i8* %23)
%25 = load i8*, i8** %9
%26 = call i32 @strupr(i8* %25)
%27 = load i8*, i8** %8
%28 = load i8*, i8** %9
%29 = load i32, i32* %7
%30 = call i32 @wildmatch(i8* %27, i8* %28, i32 %29)
store i32 %30, i32* %10
%31 = load i8*, i8** %8
%32 = call i32 @free(i8* %31)
%33 = load i8*, i8** %9
%34 = call i32 @free(i8* %33)
%35 = load i32, i32* %10
store i32 %35, i32* %4
br label %36
36: ; preds = %22, %19, %14
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
define i32 @wildmatchi(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = tail call i8* @strdup(i8* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %18, label %6
6: ; preds = %3
%7 = tail call i8* @strdup(i8* %1)
%8 = icmp eq i8* %7, null
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = tail call i32 @strupr(i8* %4)
%11 = tail call i32 @strupr(i8* %7)
%12 = tail call i32 @wildmatch(i8* %4, i8* %7, i32 %2)
%13 = tail call i32 @free(i8* %4)
br label %14
14: ; preds = %6, %9
%15 = phi i8* [ %7, %9 ], [ %4, %6 ]
%16 = phi i32 [ %12, %9 ], [ 0, %6 ]
%17 = tail call i32 @free(i8* %15)
br label %18
18: ; preds = %14, %3
%19 = phi i32 [ 0, %3 ], [ %16, %14 ]
ret i32 %19
}