#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 */

/* Variables and functions */
scalar_t__ chaz_CC_test_compile(char const *);
int /*<<< orphan*/ chaz_ConfWriter_add_def(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ chaz_ConfWriter_end_module();
int /*<<< orphan*/ chaz_ConfWriter_start_module(char *);
int chaz_HeadCheck_check_header(char *);
void chaz_RegularExpressions_run(void) {
  int has_regex_h = chaz_HeadCheck_check_header("regex.h");
  int has_pcre_h = chaz_HeadCheck_check_header("pcre.h");
  int has_pcreposix_h = chaz_HeadCheck_check_header("pcreposix.h");
  chaz_ConfWriter_start_module("RegularExpressions");
  if (has_pcre_h) {
    chaz_ConfWriter_add_def("HAS_PCRE_H", NULL);
  }
  if (has_pcreposix_h) {
    chaz_ConfWriter_add_def("HAS_PCREPOSIX_H", NULL);
  }
  if (has_regex_h) {
    const char *reg_enhanced_code = "#include <regex.h>"
                                    "\n"
                                    "int main(int argc, char **argv) {"
                                    "\n"
                                    "regex_t re;"
                                    "\n"
                                    "if (regcomp(&re, \"^\", REG_ENHANCED)) {"
                                    "\n"
                                    "return 1;"
                                    "\n"
                                    "}"
                                    "\n"
                                    "return 0;"
                                    "\n"
                                    "}"
                                    "\n";
    if (chaz_CC_test_compile(reg_enhanced_code)) {
      chaz_ConfWriter_add_def("HAS_REG_ENHANCED", NULL);
    }
  }
  chaz_ConfWriter_end_module();
}


x86 assembly (clang, -O0):
<chaz_RegularExpressions_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
mov    %eax,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
mov    %eax,-0x8(%rbp)
lea    0xe92(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
mov    %eax,-0xc(%rbp)
lea    0xe8f(%rip),%rdi
call   1030 <chaz_ConfWriter_start_module@plt>
cmpl   $0x0,-0x8(%rbp)
je     11ab <chaz_RegularExpressions_run+0x5b>
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
cmpl   $0x0,-0xc(%rbp)
je     11c5 <chaz_RegularExpressions_run+0x75>
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
cmpl   $0x0,-0x4(%rbp)
je     1202 <chaz_RegularExpressions_run+0xb2>
lea    0xe73(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <chaz_CC_test_compile@plt>
cmp    $0x0,%rax
je     11fd <chaz_RegularExpressions_run+0xad>
lea    0xed6(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
jmp    1202 <chaz_RegularExpressions_run+0xb2>
mov    $0x0,%al
call   1070 <chaz_ConfWriter_end_module@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chaz_RegularExpressions_run>:
push   %rbp
push   %r14
push   %rbx
lea    0xea5(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
mov    %eax,%r14d
lea    0xe9e(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
mov    %eax,%ebx
lea    0xe97(%rip),%rdi
call   1060 <chaz_HeadCheck_check_header@plt>
mov    %eax,%ebp
lea    0xe95(%rip),%rdi
call   1030 <chaz_ConfWriter_start_module@plt>
test   %ebx,%ebx
je     119d <chaz_RegularExpressions_run+0x4d>
lea    0xe98(%rip),%rdi
xor    %esi,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
test   %ebp,%ebp
je     11af <chaz_RegularExpressions_run+0x5f>
lea    0xe91(%rip),%rdi
xor    %esi,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
test   %r14d,%r14d
je     11d3 <chaz_RegularExpressions_run+0x83>
lea    0xe8e(%rip),%rdi
call   1050 <chaz_CC_test_compile@plt>
test   %rax,%rax
je     11d3 <chaz_RegularExpressions_run+0x83>
lea    0xefe(%rip),%rdi
xor    %esi,%esi
call   1040 <chaz_ConfWriter_add_def@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <chaz_ConfWriter_end_module@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"regex.h\00"
@.str.1 = [7 x i8] c"pcre.h\00"
@.str.2 = [12 x i8] c"pcreposix.h\00"
@.str.3 = [19 x i8] c"RegularExpressions\00"
@.str.4 = [11 x i8] c"HAS_PCRE_H\00"
@.str.5 = [16 x i8] c"HAS_PCREPOSIX_H\00"
@.str.6 = [129 x i8] c"#include <regex.h>\0Aint main(int argc, char **argv) {\0Aregex_t re;\0Aif (regcomp(&re, \22^\22, REG_ENHANCED)) {\0Areturn 1;\0A}\0Areturn 0;\0A}\0A\00"
@.str.7 = [17 x i8] c"HAS_REG_ENHANCED\00"
define void @chaz_RegularExpressions_run() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = call i32 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %5, i32* %1
%6 = call i32 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i32 %6, i32* %2
%7 = call i32 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i32 %7, i32* %3
%8 = call i32 @chaz_ConfWriter_start_module(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32* null)
br label %13
13: ; preds = %11, %0
%14 = load i32, i32* %3
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32* null)
br label %18
18: ; preds = %16, %13
%19 = load i32, i32* %1
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %18
store i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.6, i64 0, i64 0), i8** %4
%22 = load i8*, i8** %4
%23 = call i64 @chaz_CC_test_compile(i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32* null)
br label %27
27: ; preds = %25, %21
br label %28
28: ; preds = %27, %18
%29 = call i32 (...) @chaz_ConfWriter_end_module()
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"regex.h\00"
@.str.1 = [7 x i8] c"pcre.h\00"
@.str.2 = [12 x i8] c"pcreposix.h\00"
@.str.3 = [19 x i8] c"RegularExpressions\00"
@.str.4 = [11 x i8] c"HAS_PCRE_H\00"
@.str.5 = [16 x i8] c"HAS_PCREPOSIX_H\00"
@.str.6 = [129 x i8] c"#include <regex.h>\0Aint main(int argc, char **argv) {\0Aregex_t re;\0Aif (regcomp(&re, \22^\22, REG_ENHANCED)) {\0Areturn 1;\0A}\0Areturn 0;\0A}\0A\00"
@.str.7 = [17 x i8] c"HAS_REG_ENHANCED\00"
define void @chaz_RegularExpressions_run() {
%1 = tail call i32 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @chaz_HeadCheck_check_header(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%4 = tail call i32 @chaz_ConfWriter_start_module(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%5 = icmp eq i32 %2, 0
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32* null)
br label %8
8: ; preds = %6, %0
%9 = icmp eq i32 %3, 0
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32* null)
br label %12
12: ; preds = %10, %8
%13 = icmp eq i32 %1, 0
br i1 %13, label %19, label %14
14: ; preds = %12
%15 = tail call i64 @chaz_CC_test_compile(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.6, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @chaz_ConfWriter_add_def(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i32* null)
br label %19
19: ; preds = %14, %17, %12
%20 = tail call i32 (...) @chaz_ConfWriter_end_module()
ret void
}