#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 EXIT_FAILURE;
int REG_EXTENDED;
int REG_NOSUB;
int regcomp(int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char const *, size_t, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int regex_match(char *pattern, const char *default_string) {
  int status;
  regex_t preg;
  status = regcomp(&preg, pattern, REG_EXTENDED | REG_NOSUB);
  if (status != 0)
    return (EXIT_FAILURE);
  status = regexec(&preg, default_string, (size_t)0, NULL, 0);
  if (status != 0) {
    regfree(&preg);
    return (EXIT_FAILURE);
  }
  regfree(&preg);
  return status;
}


x86 assembly (clang, -O0):
<regex_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
mov    0x2e8c(%rip),%rax
or     (%rax),%edx
lea    -0x20(%rbp),%rdi
call   1040 <regcomp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     117d <regex_match+0x4d>
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ca <regex_match+0x9a>
mov    -0x18(%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)
cmpl   $0x0,-0x1c(%rbp)
je     11bb <regex_match+0x8b>
lea    -0x20(%rbp),%rdi
call   1030 <regfree@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ca <regex_match+0x9a>
lea    -0x20(%rbp),%rdi
call   1030 <regfree@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<regex_match>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    0x2e8f(%rip),%rax
mov    0x2e98(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0x4(%rsp),%rdi
call   1040 <regcomp@plt>
test   %eax,%eax
jne    117f <regex_match+0x4f>
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>
test   %ebx,%ebx
je     1188 <regex_match+0x58>
mov    0x2e52(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@EXIT_FAILURE = global i32 0
define i32 @regex_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
%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* %7, i8* %8, i32 %11)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i32, i32* @EXIT_FAILURE
store i32 %16, i32* %3
br label %28
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = call i32 @regexec(i32* %7, i8* %18, i64 0, i32* null, i32 0)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = call i32 @regfree(i32* %7)
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %3
br label %28
25: ; preds = %17
%26 = call i32 @regfree(i32* %7)
%27 = load i32, i32* %6
store i32 %27, i32* %3
br label %28
28: ; preds = %25, %22, %15
%29 = load i32, i32* %3
ret i32 %29
}

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