#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 regexec(int /*<<< orphan*/ const *, char *, int /*<<< orphan*/,
            int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int carryOutServMatch(char *in, char *out, const char *regexStrs[][2],
                      const regex_t regexM[], int size) {
  int i = 0, reti;
  int known = 0;
  for (i = 0; i < size; i++) {
    reti = regexec(&(regexM[i]), in, 0, NULL, 0);
    if (!reti) {
      known = 1;
      strncpy(out, regexStrs[i][1], 200);
      return known;
    }
  }
  return known;
}


x86 assembly (clang, -O0):
<carryOutServMatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11d2 <carryOutServMatch+0xb2>
mov    -0x28(%rbp),%rdi
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   1040 <regexec@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    11bf <carryOutServMatch+0x9f>
movl   $0x1,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x30(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rsi
mov    $0xc8,%edx
call   1030 <strncpy@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d8 <carryOutServMatch+0xb8>
jmp    11c4 <carryOutServMatch+0xa4>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1151 <carryOutServMatch+0x31>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<carryOutServMatch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %r8d,%r8d
jle    1170 <carryOutServMatch+0x50>
mov    %rcx,%r12
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r13
mov    %r8d,%ebx
shl    $0x2,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r12,%rbp,1),%rdi
mov    %r13,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <regexec@plt>
test   %eax,%eax
je     1174 <carryOutServMatch+0x54>
add    $0x4,%rbp
cmp    %rbp,%rbx
jne    1150 <carryOutServMatch+0x30>
xor    %eax,%eax
jmp    118b <carryOutServMatch+0x6b>
mov    0x8(%r15,%rbp,4),%rsi
mov    %r14,%rdi
mov    $0xc8,%edx
call   1030 <strncpy@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @carryOutServMatch(i8* %0, i8* %1, [2 x i8*]* %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [2 x i8*]*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store [2 x i8*]* %2, [2 x i8*]** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
store i32 0, i32* %12
store i32 0, i32* %14
store i32 0, i32* %12
br label %15
15: ; preds = %39, %5
%16 = load i32, i32* %12
%17 = load i32, i32* %11
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %42
19: ; preds = %15
%20 = load i32*, i32** %10
%21 = load i32, i32* %12
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i8*, i8** %7
%25 = call i32 @regexec(i32* %23, i8* %24, i32 0, i32* null, i32 0)
store i32 %25, i32* %13
%26 = load i32, i32* %13
%27 = icmp ne i32 %26, 0
br i1 %27, label %38, label %28
28: ; preds = %19
store i32 1, i32* %14
%29 = load i8*, i8** %8
%30 = load [2 x i8*]*, [2 x i8*]** %9
%31 = load i32, i32* %12
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [2 x i8*], [2 x i8*]* %30, i64 %32
%34 = getelementptr inbounds [2 x i8*], [2 x i8*]* %33, i64 0, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strncpy(i8* %29, i8* %35, i32 200)
%37 = load i32, i32* %14
store i32 %37, i32* %6
br label %44
38: ; preds = %19
br label %39
39: ; preds = %38
%40 = load i32, i32* %12
%41 = add nsw i32 %40, 1
store i32 %41, i32* %12
br label %15
42: ; preds = %15
%43 = load i32, i32* %14
store i32 %43, i32* %6
br label %44
44: ; preds = %42, %28
%45 = load i32, i32* %6
ret i32 %45
}

LLVM IR (-O2):
define i32 @carryOutServMatch(i8* %0, i8* %1, [2 x i8*]* nocapture %2, i32* %3, i32 %4) {
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %22
7: ; preds = %5
%8 = zext i32 %4 to i64
br label %9
9: ; preds = %7, %19
%10 = phi i64 [ 0, %7 ], [ %20, %19 ]
%11 = getelementptr inbounds i32, i32* %3, i64 %10
%12 = tail call i32 @regexec(i32* %11, i8* %0, i32 0, i32* null, i32 0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = and i64 %10, 4294967295
%16 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 %15, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strncpy(i8* %1, i8* %17, i32 200)
br label %22
19: ; preds = %9
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %8
br i1 %21, label %22, label %9
22: ; preds = %19, %5, %14
%23 = phi i32 [ 1, %14 ], [ 0, %5 ], [ 0, %19 ]
ret i32 %23
}