#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_NOSUB;
scalar_t__ nullstr(char const *);
scalar_t__ regcomp(int /*<<< orphan*/ *, char const *, int);
int regexec(int /*<<< orphan*/ *, char const *, size_t, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int match(const char *string, const char *pattern) {
  int status = 0;
  regex_t re;
  if (nullstr(string) || nullstr(pattern)) {
    return 0;
  }
  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    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <nullstr@plt>
cmp    $0x0,%rax
jne    117d <match+0x3d>
mov    -0x18(%rbp),%rdi
call   1060 <nullstr@plt>
cmp    $0x0,%rax
je     1189 <match+0x49>
movl   $0x0,-0x4(%rbp)
jmp    11fe <match+0xbe>
mov    -0x18(%rbp),%rsi
mov    0x2e44(%rip),%rax
mov    (%rax),%edx
mov    0x2e43(%rip),%rax
or     (%rax),%edx
lea    -0x20(%rbp),%rdi
call   1040 <regcomp@plt>
cmp    $0x0,%rax
je     11be <match+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    11fe <match+0xbe>
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
mov    %rcx,%rdx
call   1050 <regexec@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <regfree@plt>
cmpl   $0x0,-0x1c(%rbp)
je     11f7 <match+0xb7>
movl   $0x0,-0x4(%rbp)
jmp    11fe <match+0xbe>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
call   1060 <nullstr@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    11b2 <match+0x72>
mov    %r15,%rdi
call   1060 <nullstr@plt>
test   %rax,%rax
jne    11b2 <match+0x72>
mov    0x2e6b(%rip),%rax
mov    0x2e6c(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0x4(%rsp),%rdi
mov    %r15,%rsi
call   1040 <regcomp@plt>
test   %rax,%rax
jne    11b2 <match+0x72>
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <regexec@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <regfree@plt>
xor    %ebx,%ebx
test   %ebp,%ebp
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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