#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ LOG_ERR;
int REG_EXTENDED;
int REG_NEWLINE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int regcomp(int /*<<< orphan*/ *, char const *, int);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char const *, char *);
void compile_regex(regex_t *r, const char *regex_text) {
  int status = regcomp(r, regex_text, REG_EXTENDED | REG_NEWLINE);
  if (status != 0) {
    char error_message[0x100];
    regerror(status, r, error_message, 0x100);
    syslog(LOG_ERR, "Regex error compiling '%s': %s\n", regex_text,
           error_message);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<compile_regex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e6e(%rip),%rax
mov    (%rax),%edx
mov    0x2e7d(%rip),%rax
or     (%rax),%edx
call   1030 <regcomp@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11c5 <compile_regex+0x85>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
lea    -0x120(%rbp),%rdx
mov    $0x100,%ecx
call   1040 <regerror@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    0xe4e(%rip),%rsi
call   1050 <syslog@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compile_regex>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e77(%rip),%rax
mov    0x2e88(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
call   1030 <regcomp@plt>
test   %eax,%eax
jne    117a <compile_regex+0x3a>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rsp,%r15
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    $0x100,%ecx
call   1040 <regerror@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <syslog@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@REG_EXTENDED = global i32 0
@REG_NEWLINE = global i32 0
@LOG_ERR = global i32 0
@.str = [32 x i8] c"Regex error compiling '%s': %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @compile_regex(i32* %0, i8* %1) {
%3 = alloca [256 x i8]
%4 = load i32, i32* @REG_EXTENDED
%5 = load i32, i32* @REG_NEWLINE
%6 = or i32 %5, %4
%7 = tail call i32 @regcomp(i32* %0, i8* %1, i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %2
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%11 = call i32 @regerror(i32 %7, i32* %0, i8* %10, i32 256)
%12 = load i32, i32* @LOG_ERR
%13 = call i32 @syslog(i32 %12, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %10)
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
ret void
}