#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 */
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int REG_EXTENDED;
int REG_ICASE;
int /*<<< orphan*/ free(char *);
scalar_t__ regcomp(int /*<<< orphan*/ *, char *, int);
scalar_t__ regexec(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/,
                   int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
char *to_regex(char const *);
int global_matches(const char *global, const char *file) {
  char *regex;
  regex_t re;
  regex = to_regex(global);
  if (regcomp(&re, regex, REG_EXTENDED | REG_ICASE) == 0) {
    if (regexec(&re, file, 0, NULL, 0) == 0) {
      regfree(&re);
      free(regex);
      return 1;
    }
  }
  regfree(&re);
  free(regex);
  return 0;
}


x86 assembly (clang, -O0):
<global_matches>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <to_regex@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    0x2e67(%rip),%rax
or     (%rax),%edx
lea    -0x24(%rbp),%rdi
call   1050 <regcomp@plt>
cmp    $0x0,%rax
jne    11da <global_matches+0x8a>
mov    -0x18(%rbp),%rsi
lea    -0x24(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   1070 <regexec@plt>
cmp    $0x0,%rax
jne    11d5 <global_matches+0x85>
lea    -0x24(%rbp),%rdi
call   1040 <regfree@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f3 <global_matches+0xa3>
jmp    11da <global_matches+0x8a>
lea    -0x24(%rbp),%rdi
call   1040 <regfree@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<global_matches>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
call   1060 <to_regex@plt>
mov    %rax,%rbx
mov    0x2e6e(%rip),%rax
mov    0x2e77(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
call   1050 <regcomp@plt>
test   %rax,%rax
jne    11a0 <global_matches+0x50>
lea    0xc(%rsp),%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1070 <regexec@plt>
test   %rax,%rax
je     11bf <global_matches+0x6f>
xor    %ebp,%ebp
lea    0xc(%rsp),%rdi
call   1040 <regfree@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x1,%ebp
jmp    11a2 <global_matches+0x52>

LLVM IR (-O0):
@REG_EXTENDED = global i32 0
@REG_ICASE = global i32 0
define i32 @global_matches(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i8* @to_regex(i8* %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = load i32, i32* @REG_EXTENDED
%12 = load i32, i32* @REG_ICASE
%13 = or i32 %11, %12
%14 = call i64 @regcomp(i32* %7, i8* %10, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = call i64 @regexec(i32* %7, i8* %17, i32 0, i32* null, i32 0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = call i32 @regfree(i32* %7)
%22 = load i8*, i8** %6
%23 = call i32 @free(i8* %22)
store i32 1, i32* %3
br label %29
24: ; preds = %16
br label %25
25: ; preds = %24, %2
%26 = call i32 @regfree(i32* %7)
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
store i32 0, i32* %3
br label %29
29: ; preds = %25, %20
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@REG_EXTENDED = global i32 0
@REG_ICASE = global i32 0
define i32 @global_matches(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i8* @to_regex(i8* %0)
%6 = load i32, i32* @REG_EXTENDED
%7 = load i32, i32* @REG_ICASE
%8 = or i32 %7, %6
%9 = call i64 @regcomp(i32* %3, i8* %5, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i64 @regexec(i32* %3, i8* %1, i32 0, i32* null, i32 0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %11, %2
br label %15
15: ; preds = %11, %14
%16 = phi i32 [ 0, %14 ], [ 1, %11 ]
%17 = call i32 @regfree(i32* %3)
%18 = call i32 @free(i8* %5)
ret i32 %16
}