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

/* Variables and functions */
int regcomp(int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int searchPattern(char *string, char *searchPattern, regmatch_t *match,
                  int flag) {
  regex_t preg;
  int regStatus = regcomp(&preg, searchPattern, flag);
  if (regStatus != 0) {
    return -1;
  }
  int Doesmatch = regexec(&preg, string, sizeof(string), match, 0);
  if (Doesmatch != 0) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<searchPattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    -0x28(%rbp),%rdi
call   1030 <regcomp@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1160 <searchPattern+0x40>
movl   $0xffffffff,-0x4(%rbp)
jmp    1199 <searchPattern+0x79>
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%rdi
mov    $0x8,%edx
xor    %r8d,%r8d
call   1040 <regexec@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1192 <searchPattern+0x72>
movl   $0x0,-0x4(%rbp)
jmp    1199 <searchPattern+0x79>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<searchPattern>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
lea    0x4(%rsp),%rdi
mov    %ecx,%edx
call   1030 <regcomp@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
jne    1162 <searchPattern+0x42>
lea    0x4(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1040 <regexec@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @searchPattern(i8* %0, i8* %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i32 %3, i32* %9
%13 = load i8*, i8** %7
%14 = load i32, i32* %9
%15 = call i32 @regcomp(i32* %10, i8* %13, i32 %14)
store i32 %15, i32* %11
%16 = load i32, i32* %11
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %4
store i32 -1, i32* %5
br label %27
19: ; preds = %4
%20 = load i8*, i8** %6
%21 = load i32*, i32** %8
%22 = call i32 @regexec(i32* %10, i8* %20, i32 8, i32* %21, i32 0)
store i32 %22, i32* %12
%23 = load i32, i32* %12
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 0, i32* %5
br label %27
26: ; preds = %19
store i32 1, i32* %5
br label %27
27: ; preds = %26, %25, %18
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
define i32 @searchPattern(i8* %0, i8* %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = call i32 @regcomp(i32* %5, i8* %1, i32 %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = call i32 @regexec(i32* %5, i8* %0, i32 8, i32* %2, i32 0)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %4, %9
%14 = phi i32 [ %12, %9 ], [ -1, %4 ]
ret i32 %14
}