#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 REG_NOMATCH;
int regexec(int /*<<< orphan*/ *, char const *, size_t, int /*<<< orphan*/ *,
            int);
int regexecs(regex_t *regex, size_t num_regex, const char *string,
             size_t nmatch, regmatch_t pmatch[], int eflags) {
  size_t i;
  int ret = REG_NOMATCH;
  for (i = 0; i < num_regex; i++)
    if (!(ret = regexec(&regex[i], string, nmatch, pmatch, eflags)))
      break;
  return ret;
}


x86 assembly (clang, -O0):
<regexecs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    0x2eb1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    119d <regexecs+0x8d>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1030 <regexec@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
jne    1187 <regexecs+0x77>
jmp    119d <regexecs+0x8d>
jmp    118c <regexecs+0x7c>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1144 <regexecs+0x34>
mov    -0x3c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<regexecs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1164 <regexecs+0x54>
mov    %r9d,%r14d
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14d,%r8d
call   1030 <regexec@plt>
test   %eax,%eax
je     116f <regexecs+0x5f>
add    $0x4,%rbx
add    $0xffffffffffffffff,%rbp
jne    1140 <regexecs+0x30>
jmp    1171 <regexecs+0x61>
mov    0x2e7d(%rip),%rax
mov    (%rax),%eax
jmp    1171 <regexecs+0x61>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@REG_NOMATCH = global i32 0
define i32 @regexecs(i32* %0, i64 %1, i8* %2, i64 %3, i32* %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i64
%14 = alloca i32
store i32* %0, i32** %7
store i64 %1, i64* %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i32* %4, i32** %11
store i32 %5, i32* %12
%15 = load i32, i32* @REG_NOMATCH
store i32 %15, i32* %14
store i64 0, i64* %13
br label %16
16: ; preds = %32, %6
%17 = load i64, i64* %13
%18 = load i64, i64* %8
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = load i32*, i32** %7
%22 = load i64, i64* %13
%23 = getelementptr inbounds i32, i32* %21, i64 %22
%24 = load i8*, i8** %9
%25 = load i64, i64* %10
%26 = load i32*, i32** %11
%27 = load i32, i32* %12
%28 = call i32 @regexec(i32* %23, i8* %24, i64 %25, i32* %26, i32 %27)
store i32 %28, i32* %14
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %20
br label %35
31: ; preds = %20
br label %32
32: ; preds = %31
%33 = load i64, i64* %13
%34 = add i64 %33, 1
store i64 %34, i64* %13
br label %16
35: ; preds = %30, %16
%36 = load i32, i32* %14
ret i32 %36
}

LLVM IR (-O2):
@REG_NOMATCH = global i32 0
define i32 @regexecs(i32* %0, i64 %1, i8* %2, i64 %3, i32* %4, i32 %5) {
%7 = load i32, i32* @REG_NOMATCH
%8 = icmp eq i64 %1, 0
br i1 %8, label %17, label %11
9: ; preds = %11
%10 = icmp eq i64 %16, %1
br i1 %10, label %17, label %11
11: ; preds = %6, %9
%12 = phi i64 [ %16, %9 ], [ 0, %6 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = tail call i32 @regexec(i32* %13, i8* %2, i64 %3, i32* %4, i32 %5)
%15 = icmp eq i32 %14, 0
%16 = add nuw i64 %12, 1
br i1 %15, label %17, label %9
17: ; preds = %9, %11, %6
%18 = phi i32 [ %7, %6 ], [ 0, %11 ], [ %14, %9 ]
ret i32 %18
}