#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 */

/* Variables and functions */
int matchhere(char *, char *);
int match(char *re, char *text) {
  if (re[0] == '^')
    return matchhere(re + 1, text);
  do {
    if (matchhere(re, text))
      return 1;
  } while (*text++ != '\0');
  return 0;
}


x86 assembly (clang, -O0):
<match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5e,%eax
jne    1149 <match+0x39>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <matchhere@plt>
mov    %eax,-0x4(%rbp)
jmp    1197 <match+0x87>
jmp    114e <match+0x3e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <matchhere@plt>
cmp    $0x0,%eax
je     1170 <match+0x60>
movl   $0x1,-0x4(%rbp)
jmp    1197 <match+0x87>
jmp    1175 <match+0x65>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    114e <match+0x3e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
cmpb   $0x5e,(%rdi)
jne    1140 <match+0x30>
add    $0x1,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <matchhere@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <matchhere@plt>
test   %eax,%eax
jne    115c <match+0x4c>
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1140 <match+0x30>
xor    %eax,%eax
jmp    1161 <match+0x51>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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