#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  scalar_t__ rm_so;
  scalar_t__ rm_eo;
};
typedef TYPE_1__ regmatch_t;
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int /*<<< orphan*/ REG_EXTENDED;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int regcomp(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char const *, int, TYPE_1__ *,
            int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char const *);
int check_regex(const char *regex, const char *line, regmatch_t match[10]) {
  regex_t preg;
  int retval = 0;
  if (!regex || !line) {
    return (0);
  }
  if ((retval = regcomp(&preg, regex, REG_EXTENDED))) {
    char err_buf[512];
    regerror(retval, &preg, err_buf, 512);
    fprintf(stderr, "ondir: regcomp failed, %s\n", err_buf);
    return 0;
  }
  retval = regexec(&preg, line, 10, match, 0);
  regfree(&preg);
  return retval == 0 && match[0].rm_so == 0 && match[0].rm_eo == strlen(line);
}


x86 assembly (clang, -O0):
<check_regex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1194 <check_regex+0x34>
cmpq   $0x0,-0x18(%rbp)
jne    11a0 <check_regex+0x40>
movl   $0x0,-0x4(%rbp)
jmp    128b <check_regex+0x12b>
mov    -0x10(%rbp),%rsi
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
lea    -0x24(%rbp),%rdi
call   1050 <regcomp@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
je     1202 <check_regex+0xa2>
mov    -0x28(%rbp),%edi
lea    -0x230(%rbp),%rdx
lea    -0x24(%rbp),%rsi
mov    $0x200,%ecx
call   1070 <regerror@plt>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    -0x230(%rbp),%rdx
lea    0xe0f(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    128b <check_regex+0x12b>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%rdi
mov    $0xa,%edx
xor    %r8d,%r8d
call   1080 <regexec@plt>
mov    %eax,-0x28(%rbp)
lea    -0x24(%rbp),%rdi
call   1030 <regfree@plt>
xor    %eax,%eax
cmpl   $0x0,-0x28(%rbp)
mov    %al,-0x231(%rbp)
jne    127d <check_regex+0x11d>
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x231(%rbp)
jne    127d <check_regex+0x11d>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x240(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x240(%rbp),%rax
cmp    %rcx,%rax
sete   %al
mov    %al,-0x231(%rbp)
mov    -0x231(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_regex>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x210,%rsp
xor    %ebp,%ebp
test   %rdi,%rdi
je     121e <check_regex+0xbe>
mov    %rsi,%rbx
test   %rsi,%rsi
je     121e <check_regex+0xbe>
mov    %rdx,%r14
mov    %rdi,%rsi
mov    0x2e45(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rdi
call   1050 <regcomp@plt>
test   %eax,%eax
je     11d6 <check_regex+0x76>
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rdx
mov    $0x200,%ecx
call   1070 <regerror@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe34(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
jmp    121e <check_regex+0xbe>
lea    0xc(%rsp),%r15
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1080 <regexec@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1030 <regfree@plt>
test   %r12d,%r12d
jne    121e <check_regex+0xbe>
cmpq   $0x0,(%r14)
jne    121e <check_regex+0xbe>
mov    0x8(%r14),%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %ebp,%ebp
cmp    %rax,%r14
sete   %bpl
mov    %ebp,%eax
add    $0x210,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i64, i64 }
@REG_EXTENDED = global i32 0
@stderr = global i32 0
@.str = [27 x i8] c"ondir: regcomp failed, %s\0A\00"
define i32 @check_regex(i8* %0, i8* %1, %struct.TYPE_4__* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca %struct.TYPE_4__*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [512 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store %struct.TYPE_4__* %2, %struct.TYPE_4__** %7
store i32 0, i32* %9
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %13, %3
store i32 0, i32* %4
br label %53
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = load i32, i32* @REG_EXTENDED
%20 = call i32 @regcomp(i32* %8, i8* %18, i32 %19)
store i32 %20, i32* %9
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %17
%23 = load i32, i32* %9
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%25 = call i32 @regerror(i32 %23, i32* %8, i8* %24, i32 512)
%26 = load i32, i32* @stderr
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %27)
store i32 0, i32* %4
br label %53
29: ; preds = %17
%30 = load i8*, i8** %6
%31 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%32 = call i32 @regexec(i32* %8, i8* %30, i32 10, %struct.TYPE_4__* %31, i32 0)
store i32 %32, i32* %9
%33 = call i32 @regfree(i32* %8)
%34 = load i32, i32* %9
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %50
36: ; preds = %29
%37 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%38 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i64 0
%39 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %38, i32 0, i32 0
%40 = load i64, i64* %39
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %50
42: ; preds = %36
%43 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%44 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %43, i64 0
%45 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %44, i32 0, i32 1
%46 = load i64, i64* %45
%47 = load i8*, i8** %6
%48 = call i64 @strlen(i8* %47)
%49 = icmp eq i64 %46, %48
br label %50
50: ; preds = %42, %36, %29
%51 = phi i1 [ false, %36 ], [ false, %29 ], [ %49, %42 ]
%52 = zext i1 %51 to i32
store i32 %52, i32* %4
br label %53
53: ; preds = %50, %22, %16
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i64, i64 }
@REG_EXTENDED = global i32 0
@stderr = global i32 0
@.str = [27 x i8] c"ondir: regcomp failed, %s\0A\00"
define i32 @check_regex(i8* %0, i8* %1, %struct.TYPE_4__* %2) {
%4 = alloca i32
%5 = alloca [512 x i8]
%6 = bitcast i32* %4 to i8*
%7 = icmp ne i8* %0, null
%8 = icmp ne i8* %1, null
%9 = and i1 %7, %8
br i1 %9, label %10, label %33
10: ; preds = %3
%11 = load i32, i32* @REG_EXTENDED
%12 = call i32 @regcomp(i32* %4, i8* %0, i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %10
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%16 = call i32 @regerror(i32 %12, i32* %4, i8* %15, i32 512)
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %33
19: ; preds = %10
%20 = call i32 @regexec(i32* %4, i8* %1, i32 10, %struct.TYPE_4__* %2, i32 0)
%21 = call i32 @regfree(i32* %4)
%22 = icmp eq i32 %20, 0
br i1 %22, label %23, label %33
23: ; preds = %19
%24 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %2, i64 0, i32 0
%25 = load i64, i64* %24
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %23
%28 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %2, i64 0, i32 1
%29 = load i64, i64* %28
%30 = call i64 @strlen(i8* %1)
%31 = icmp eq i64 %29, %30
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %19, %23, %27, %3, %14
%34 = phi i32 [ 0, %14 ], [ 0, %3 ], [ 0, %23 ], [ 0, %19 ], [ %32, %27 ]
ret i32 %34
}