#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*/ regmatch_t;
typedef int /*<<< orphan*/ regex_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int REG_NOMATCH;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char *, size_t, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int match(char *str, regex_t *re, FILE *errlog) {
  size_t nmatch = 1;
  regmatch_t pmatch[nmatch];
  int re_err;
  char err_msg[1000];
  if (!(re_err = regexec(re, str, nmatch, pmatch, 0)))
    return 1;
  else if (re_err == REG_NOMATCH)
    return 0;
  else {
    regerror(re_err, re, err_msg, 1000);
    fprintf(errlog, "match(): %s\n", err_msg);
    return 0;
  }
}


x86 assembly (clang, -O0):
<match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
xor    %r8d,%r8d
call   1050 <regexec@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
jne    11a9 <match+0x79>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x434(%rbp)
jmp    1211 <match+0xe1>
mov    -0x3c(%rbp),%eax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%eax
jne    11d1 <match+0xa1>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x434(%rbp)
jmp    1211 <match+0xe1>
mov    -0x3c(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    -0x430(%rbp),%rdx
mov    $0x3e8,%ecx
call   1040 <regerror@plt>
mov    -0x20(%rbp),%rdi
lea    -0x430(%rbp),%rdx
lea    0xe05(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x434(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3f8,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rsp,%rcx
xor    %ebp,%ebp
mov    $0x1,%edx
mov    %rbx,%rdi
xor    %r8d,%r8d
call   1050 <regexec@plt>
test   %eax,%eax
je     1195 <match+0x65>
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%eax
je     119a <match+0x6a>
lea    0x10(%rsp),%r15
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    $0x3e8,%ecx
call   1040 <regerror@plt>
lea    0xe78(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
call   1030 <fprintf@plt>
jmp    119a <match+0x6a>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@REG_NOMATCH = global i32 0
@.str = [13 x i8] c"match(): %s\0A\00"
define i32 @match(i8* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca [1000 x i8]
%13 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i64 1, i64* %8
%14 = load i64, i64* %8
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %9
%16 = alloca i32, i64 %14
store i64 %14, i64* %10
%17 = load i32*, i32** %6
%18 = load i8*, i8** %5
%19 = load i64, i64* %8
%20 = call i32 @regexec(i32* %17, i8* %18, i64 %19, i32* %16, i32 0)
store i32 %20, i32* %11
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %3
store i32 1, i32* %4
store i32 1, i32* %13
br label %36
23: ; preds = %3
%24 = load i32, i32* %11
%25 = load i32, i32* @REG_NOMATCH
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 0, i32* %4
store i32 1, i32* %13
br label %36
28: ; preds = %23
%29 = load i32, i32* %11
%30 = load i32*, i32** %6
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %12, i64 0, i64 0
%32 = call i32 @regerror(i32 %29, i32* %30, i8* %31, i32 1000)
%33 = load i32*, i32** %7
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %12, i64 0, i64 0
%35 = call i32 @fprintf(i32* %33, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %34)
store i32 0, i32* %4
store i32 1, i32* %13
br label %36
36: ; preds = %28, %27, %22
%37 = load i8*, i8** %9
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
@REG_NOMATCH = global i32 0
@.str = [13 x i8] c"match(): %s\0A\00"
define i32 @match(i8* %0, i32* %1, i32* nocapture %2) {
%4 = alloca [1000 x i8]
%5 = alloca i32
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%7 = call i32 @regexec(i32* %1, i8* %0, i64 1, i32* %5, i32 0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %3
%10 = load i32, i32* @REG_NOMATCH
%11 = icmp eq i32 %7, %10
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = call i32 @regerror(i32 %7, i32* %1, i8* %6, i32 1000)
%14 = call i32 @fprintf(i32* %2, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %15
15: ; preds = %9, %3, %12
%16 = phi i32 [ 0, %12 ], [ 1, %3 ], [ 0, %9 ]
ret i32 %16
}