#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;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int regcomp(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char const *, size_t, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int match(const char *string, char *pattern) {
  int status;
  regex_t re;
  char error[256];
  if ((status = regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB)) != 0) {
    regerror(status, &re, error, sizeof error);
    (fprintf(stderr, "regcomp failed: %s\n", error), exit(1));
  }
  status = regexec(&re, string, (size_t)0, NULL, 0);
  regfree(&re);
  return status;
}


x86 assembly (clang, -O0):
<match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    0x2e52(%rip),%rax
mov    (%rax),%edx
mov    0x2e59(%rip),%rax
or     (%rax),%edx
lea    -0x18(%rbp),%rdi
call   1040 <regcomp@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11dc <match+0x7c>
mov    -0x14(%rbp),%edi
lea    -0x120(%rbp),%rdx
lea    -0x18(%rbp),%rsi
mov    $0x100,%ecx
call   1060 <regerror@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    -0x120(%rbp),%rdx
lea    0xe33(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rsi
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
mov    %rcx,%rdx
call   1070 <regexec@plt>
mov    %eax,-0x14(%rbp)
lea    -0x18(%rbp),%rdi
call   1030 <regfree@plt>
mov    -0x14(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %rdi,%r14
mov    0x2e5b(%rip),%rax
mov    0x2e64(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0xc(%rsp),%rdi
call   1040 <regcomp@plt>
test   %eax,%eax
jne    11bd <match+0x5d>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1070 <regexec@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <regfree@plt>
mov    %ebp,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rdx
mov    $0x100,%ecx
call   1060 <regerror@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    0xe1a(%rip),%rsi
mov    %rbx,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"regcomp failed: %s\0A\00"
define i32 @match(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [256 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = load i32, i32* @REG_EXTENDED
%10 = load i32, i32* @REG_NOSUB
%11 = or i32 %9, %10
%12 = call i32 @regcomp(i32* %6, i8* %8, i32 %11)
store i32 %12, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load i32, i32* %5
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%17 = call i32 @regerror(i32 %15, i32* %6, i8* %16, i32 256)
%18 = load i32, i32* @stderr
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i8*, i8** %3
%24 = call i32 @regexec(i32* %6, i8* %23, i64 0, i32* null, i32 0)
store i32 %24, i32* %5
%25 = call i32 @regfree(i32* %6)
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"regcomp failed: %s\0A\00"
define i32 @match(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @REG_EXTENDED
%8 = load i32, i32* @REG_NOSUB
%9 = or i32 %8, %7
%10 = call i32 @regcomp(i32* %3, i8* %1, i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = call i32 @regerror(i32 %10, i32* %3, i8* %6, i32 256)
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %6)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = call i32 @regexec(i32* %3, i8* %0, i64 0, i32* null, i32 0)
%19 = call i32 @regfree(i32* %3)
ret i32 %18
}