#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*/ regmatch_t;
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int /*<<< orphan*/ ERROR_APPLICATION_FAILED(char *, char const *, char *,
                                            char const *);
int REG_NOMATCH;
int regexec(int /*<<< orphan*/ *, char const *, int, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int executeRegex(regex_t *regex, const char *regexString,
                 const char *testString, regmatch_t *capturingGroups,
                 int capturingGroupsSize) {
  int reti =
      regexec(regex, testString, capturingGroupsSize, capturingGroups, 0);
  if (reti && (reti != REG_NOMATCH)) {
    ERROR_APPLICATION_FAILED("regex", regexString, "string", testString);
  }
  return reti;
}


x86 assembly (clang, -O0):
<executeRegex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rcx
xor    %r8d,%r8d
call   1040 <regexec@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     118d <executeRegex+0x6d>
mov    -0x28(%rbp),%eax
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%eax
je     118d <executeRegex+0x6d>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rcx
lea    0xe7f(%rip),%rdi
lea    0xe7e(%rip),%rdx
call   1030 <ERROR_APPLICATION_FAILED@plt>
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executeRegex>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdx,%rsi
mov    %r8d,%edx
xor    %r8d,%r8d
call   1040 <regexec@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1162 <executeRegex+0x42>
mov    0x2ea3(%rip),%rax
cmp    (%rax),%ebp
je     1162 <executeRegex+0x42>
lea    0xeb0(%rip),%rdi
lea    0xeaf(%rip),%rdx
mov    %r14,%rsi
mov    %rbx,%rcx
call   1030 <ERROR_APPLICATION_FAILED@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@REG_NOMATCH = global i32 0
@.str = [6 x i8] c"regex\00"
@.str.1 = [7 x i8] c"string\00"
define i32 @executeRegex(i32* %0, i8* %1, i8* %2, i32* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32* %3, i32** %9
store i32 %4, i32* %10
%12 = load i32*, i32** %6
%13 = load i8*, i8** %8
%14 = load i32, i32* %10
%15 = load i32*, i32** %9
%16 = call i32 @regexec(i32* %12, i8* %13, i32 %14, i32* %15, i32 0)
store i32 %16, i32* %11
%17 = load i32, i32* %11
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %5
%20 = load i32, i32* %11
%21 = load i32, i32* @REG_NOMATCH
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i8*, i8** %7
%25 = load i8*, i8** %8
%26 = call i32 @ERROR_APPLICATION_FAILED(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %23, %19, %5
%28 = load i32, i32* %11
ret i32 %28
}

LLVM IR (-O2):
@REG_NOMATCH = global i32 0
@.str = [6 x i8] c"regex\00"
@.str.1 = [7 x i8] c"string\00"
define i32 @executeRegex(i32* %0, i8* %1, i8* %2, i32* %3, i32 %4) {
%6 = tail call i32 @regexec(i32* %0, i8* %2, i32 %4, i32* %3, i32 0)
%7 = icmp eq i32 %6, 0
%8 = load i32, i32* @REG_NOMATCH
%9 = icmp eq i32 %6, %8
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %13, label %11
11: ; preds = %5
%12 = tail call i32 @ERROR_APPLICATION_FAILED(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %13
13: ; preds = %11, %5
ret i32 %6
}