#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_ICASE;
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int string_has_highlight_regex_compiled(char const *, int /*<<< orphan*/ *);
scalar_t__ string_regcomp(int /*<<< orphan*/ *, char const *, int);
int string_has_highlight_regex(const char *string, const char *regex) {
  regex_t reg;
  int rc;
  if (!string || !regex || !regex[0])
    return 0;
  if (string_regcomp(&reg, regex, REG_EXTENDED | REG_ICASE) != 0)
    return 0;
  rc = string_has_highlight_regex_compiled(string, &reg);
  regfree(&reg);
  return rc;
}


x86 assembly (clang, -O0):
<string_has_highlight_regex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1163 <string_has_highlight_regex+0x33>
cmpq   $0x0,-0x18(%rbp)
je     1163 <string_has_highlight_regex+0x33>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116f <string_has_highlight_regex+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    11c3 <string_has_highlight_regex+0x93>
mov    -0x18(%rbp),%rsi
mov    0x2e5e(%rip),%rax
mov    (%rax),%edx
mov    0x2e65(%rip),%rax
or     (%rax),%edx
lea    -0x1c(%rbp),%rdi
call   1030 <string_regcomp@plt>
cmp    $0x0,%rax
je     11a4 <string_has_highlight_regex+0x74>
movl   $0x0,-0x4(%rbp)
jmp    11c3 <string_has_highlight_regex+0x93>
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <string_has_highlight_regex_compiled@plt>
mov    %eax,-0x20(%rbp)
lea    -0x1c(%rbp),%rdi
call   1040 <regfree@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_has_highlight_regex>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebp,%ebp
test   %rdi,%rdi
je     1187 <string_has_highlight_regex+0x57>
test   %rsi,%rsi
je     1187 <string_has_highlight_regex+0x57>
cmpb   $0x0,(%rsi)
je     1187 <string_has_highlight_regex+0x57>
mov    %rdi,%rbx
mov    0x2e85(%rip),%rax
mov    0x2e8e(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0xc(%rsp),%rdi
call   1030 <string_regcomp@plt>
test   %rax,%rax
jne    1187 <string_has_highlight_regex+0x57>
lea    0xc(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <string_has_highlight_regex_compiled@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <regfree@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@REG_EXTENDED = global i32 0
@REG_ICASE = global i32 0
define i32 @string_has_highlight_regex(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 = icmp ne i8* %8, null
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %13, %10, %2
store i32 0, i32* %3
br label %32
19: ; preds = %13
%20 = load i8*, i8** %5
%21 = load i32, i32* @REG_EXTENDED
%22 = load i32, i32* @REG_ICASE
%23 = or i32 %21, %22
%24 = call i64 @string_regcomp(i32* %6, i8* %20, i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %19
store i32 0, i32* %3
br label %32
27: ; preds = %19
%28 = load i8*, i8** %4
%29 = call i32 @string_has_highlight_regex_compiled(i8* %28, i32* %6)
store i32 %29, i32* %7
%30 = call i32 @regfree(i32* %6)
%31 = load i32, i32* %7
store i32 %31, i32* %3
br label %32
32: ; preds = %27, %26, %18
%33 = load i32, i32* %3
ret i32 %33
}

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