#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 */
scalar_t__ global_compile_as_re(char const *, int /*<<< orphan*/ *);
scalar_t__ regexec(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/,
                   int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int global_matches(const char globals[], const char file[]) {
  int matches;
  regex_t re;
  matches = 0;
  if (global_compile_as_re(globals, &re) == 0) {
    if (regexec(&re, file, 0, NULL, 0) == 0) {
      matches = 1;
    }
  }
  regfree(&re);
  return matches;
}


x86 assembly (clang, -O0):
<global_matches>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <global_compile_as_re@plt>
cmp    $0x0,%rax
jne    118b <global_matches+0x5b>
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   1050 <regexec@plt>
cmp    $0x0,%rax
jne    1186 <global_matches+0x56>
movl   $0x1,-0x14(%rbp)
jmp    118b <global_matches+0x5b>
lea    -0x18(%rbp),%rdi
call   1040 <regfree@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<global_matches>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
lea    0x4(%rsp),%rsi
call   1030 <global_compile_as_re@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1164 <global_matches+0x34>
lea    0x4(%rsp),%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <regexec@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
lea    0x4(%rsp),%rdi
call   1040 <regfree@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @global_matches(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%7 = load i8*, i8** %3
%8 = call i64 @global_compile_as_re(i8* %7, i32* %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i64 @regexec(i32* %6, i8* %11, i32 0, i32* null, i32 0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1, i32* %5
br label %15
15: ; preds = %14, %10
br label %16
16: ; preds = %15, %2
%17 = call i32 @regfree(i32* %6)
%18 = load i32, i32* %5
ret i32 %18
}

LLVM IR (-O2):
define i32 @global_matches(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i64 @global_compile_as_re(i8* %0, i32* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = call i64 @regexec(i32* %3, i8* %1, i32 0, i32* null, i32 0)
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
br label %11
11: ; preds = %7, %2
%12 = phi i32 [ 0, %2 ], [ %10, %7 ]
%13 = call i32 @regfree(i32* %3)
ret i32 %12
}