#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*/ MyExit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int regcomp(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ stderr;
void compile_regex(regex_t *c, char *p[], int n, int CFLAGS) {
  int i;
  char buf[4098];
  for (i = 0; i < n; i++) {
    int ier = regcomp(c + i, p[i], CFLAGS);
    if (ier) {
      regerror(ier, c + i, buf, 4098);
      fprintf(stderr, "regecomp error:  %s (%s)\n", buf, p[i]);
      MyExit(1);
    }
  }
}


x86 assembly (clang, -O0):
<compile_regex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    120d <compile_regex+0xcd>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%edx
call   1030 <regcomp@plt>
mov    %eax,-0x1024(%rbp)
cmpl   $0x0,-0x1024(%rbp)
je     11fa <compile_regex+0xba>
mov    -0x1024(%rbp),%edi
mov    -0x8(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    -0x1020(%rbp),%rdx
mov    $0x1002,%ecx
call   1050 <regerror@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    -0x1020(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe15(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <MyExit@plt>
jmp    11ff <compile_regex+0xbf>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1160 <compile_regex+0x20>
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compile_regex>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
test   %edx,%edx
jle    11cd <compile_regex+0x8d>
mov    %ecx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r13
mov    %edx,%r12d
shl    $0x2,%r12
xor    %r15d,%r15d
jmp    1179 <compile_regex+0x39>
nopw   0x0(%rax,%rax,1)
add    $0x4,%r15
cmp    %r15,%r12
je     11cd <compile_regex+0x8d>
lea    (%r15,%r13,1),%rbp
mov    (%rbx,%r15,2),%rsi
mov    %rbp,%rdi
mov    %r14d,%edx
call   1030 <regcomp@plt>
test   %eax,%eax
je     1170 <compile_regex+0x30>
mov    %eax,%edi
mov    %rbp,%rsi
mov    %rsp,%rbp
mov    %rbp,%rdx
mov    $0x1002,%ecx
call   1050 <regerror@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r15,2),%rcx
lea    0xe47(%rip),%rsi
mov    %rbp,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <MyExit@plt>
jmp    1170 <compile_regex+0x30>
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"regecomp error: %s (%s)\0A\00"
define void @compile_regex(i32* %0, i8** %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [4098 x i8]
%11 = alloca i32
store i32* %0, i32** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %12
12: ; preds = %48, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %51
16: ; preds = %12
%17 = load i32*, i32** %5
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i8**, i8*** %6
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = load i32, i32* %8
%27 = call i32 @regcomp(i32* %20, i8* %25, i32 %26)
store i32 %27, i32* %11
%28 = load i32, i32* %11
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %47
30: ; preds = %16
%31 = load i32, i32* %11
%32 = load i32*, i32** %5
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = getelementptr inbounds [4098 x i8], [4098 x i8]* %10, i64 0, i64 0
%37 = call i32 @regerror(i32 %31, i32* %35, i8* %36, i32 4098)
%38 = load i32, i32* @stderr
%39 = getelementptr inbounds [4098 x i8], [4098 x i8]* %10, i64 0, i64 0
%40 = load i8**, i8*** %6
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %39, i8* %44)
%46 = call i32 @MyExit(i32 1)
br label %47
47: ; preds = %30, %16
br label %48
48: ; preds = %47
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %12
51: ; preds = %12
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"regecomp error: %s (%s)\0A\00"
define void @compile_regex(i32* %0, i8** nocapture %1, i32 %2, i32 %3) {
%5 = alloca [4098 x i8]
%6 = getelementptr inbounds [4098 x i8], [4098 x i8]* %5, i64 0, i64 0
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %26
8: ; preds = %4
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %8, %23
%11 = phi i64 [ 0, %8 ], [ %24, %23 ]
%12 = getelementptr inbounds i32, i32* %0, i64 %11
%13 = getelementptr inbounds i8*, i8** %1, i64 %11
%14 = load i8*, i8** %13
%15 = call i32 @regcomp(i32* %12, i8* %14, i32 %3)
%16 = icmp eq i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %10
%18 = call i32 @regerror(i32 %15, i32* %12, i8* %6, i32 4098)
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %13
%21 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %20)
%22 = call i32 @MyExit(i32 1)
br label %23
23: ; preds = %17, %10
%24 = add nuw nsw i64 %11, 1
%25 = icmp eq i64 %24, %9
br i1 %25, label %26, label %10
26: ; preds = %23, %4
ret void
}