#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 REG_NOSUB;
scalar_t__ regcomp(int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char const *, size_t, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int match(const char *string, char *pattern, int ignore_case) {
  int status;
  regex_t re;
  if (ignore_case) {
    if (regcomp(&re, pattern, REG_EXTENDED | REG_ICASE | REG_NOSUB) != 0) {
      return 0;
    }
  } else if (regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB) != 0) {
    return 0;
  }
  status = regexec(&re, string, (size_t)0, NULL, 0);
  regfree(&re);
  if (status != 0) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1190 <match+0x60>
mov    -0x18(%rbp),%rsi
mov    0x2e78(%rip),%rax
mov    (%rax),%edx
mov    0x2e87(%rip),%rax
or     (%rax),%edx
mov    0x2e6e(%rip),%rax
or     (%rax),%edx
lea    -0x24(%rbp),%rdi
call   1040 <regcomp@plt>
cmp    $0x0,%rax
je     118b <match+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    120a <match+0xda>
jmp    11ca <match+0x9a>
mov    -0x18(%rbp),%rsi
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
mov    0x2e34(%rip),%rax
or     (%rax),%edx
lea    -0x24(%rbp),%rdi
call   1040 <regcomp@plt>
cmp    $0x0,%rax
je     11c5 <match+0x95>
movl   $0x0,-0x4(%rbp)
jmp    120a <match+0xda>
jmp    11ca <match+0x9a>
mov    -0x10(%rbp),%rsi
lea    -0x24(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
mov    %rcx,%rdx
call   1050 <regexec@plt>
mov    %eax,-0x20(%rbp)
lea    -0x24(%rbp),%rdi
call   1030 <regfree@plt>
cmpl   $0x0,-0x20(%rbp)
je     1203 <match+0xd3>
movl   $0x0,-0x4(%rbp)
jmp    120a <match+0xda>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%eax
mov    %rdi,%rbx
mov    0x2e90(%rip),%rcx
mov    (%rcx),%edx
test   %eax,%eax
je     114f <match+0x1f>
mov    0x2e9b(%rip),%rax
or     (%rax),%edx
mov    0x2e82(%rip),%rax
or     (%rax),%edx
lea    0x4(%rsp),%rdi
call   1040 <regcomp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1194 <match+0x64>
lea    0x4(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <regexec@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <regfree@plt>
xor    %eax,%eax
test   %ebx,%ebx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@REG_EXTENDED = global i32 0
@REG_ICASE = global i32 0
@REG_NOSUB = global i32 0
define i32 @match(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = load i32, i32* @REG_EXTENDED
%15 = load i32, i32* @REG_ICASE
%16 = or i32 %14, %15
%17 = load i32, i32* @REG_NOSUB
%18 = or i32 %16, %17
%19 = call i64 @regcomp(i32* %9, i8* %13, i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %12
store i32 0, i32* %4
br label %40
22: ; preds = %12
br label %32
23: ; preds = %3
%24 = load i8*, i8** %6
%25 = load i32, i32* @REG_EXTENDED
%26 = load i32, i32* @REG_NOSUB
%27 = or i32 %25, %26
%28 = call i64 @regcomp(i32* %9, i8* %24, i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %23
store i32 0, i32* %4
br label %40
31: ; preds = %23
br label %32
32: ; preds = %31, %22
%33 = load i8*, i8** %5
%34 = call i32 @regexec(i32* %9, i8* %33, i64 0, i32* null, i32 0)
store i32 %34, i32* %8
%35 = call i32 @regfree(i32* %9)
%36 = load i32, i32* %8
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %32
store i32 0, i32* %4
br label %40
39: ; preds = %32
store i32 1, i32* %4
br label %40
40: ; preds = %39, %38, %30, %21
%41 = load i32, i32* %4
ret i32 %41
}

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