#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 match_here(char const *, char const *);
int match(const char *re, const char *s) {
  if (*re == '^')
    return match_here(re + 1, s);
  while (*s) {
    if (match_here(re, s))
      return 1;
    s++;
  }
  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 <match_here@plt>
mov    %eax,-0x4(%rbp)
jmp    1195 <match+0x85>
jmp    114e <match+0x3e>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     118e <match+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <match_here@plt>
cmp    $0x0,%eax
je     117d <match+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    1195 <match+0x85>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114e <match+0x3e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rbp
cmpb   $0x5e,(%rdi)
jne    1132 <match+0x22>
add    $0x1,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <match_here@plt>
xor    %r14d,%r14d
cmpb   $0x0,(%rbx)
je     1161 <match+0x51>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <match_here@plt>
test   %eax,%eax
jne    115b <match+0x4b>
cmpb   $0x0,0x1(%rbx)
lea    0x1(%rbx),%rbx
jne    1140 <match+0x30>
jmp    1161 <match+0x51>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
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 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 94
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8*, i8** %5
%14 = call i32 @match_here(i8* %12, i8* %13)
store i32 %14, i32* %3
br label %30
15: ; preds = %2
br label %16
16: ; preds = %26, %15
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = load i8*, i8** %5
%23 = call i32 @match_here(i8* %21, i8* %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 1, i32* %3
br label %30
26: ; preds = %20
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %5
br label %16
29: ; preds = %16
store i32 0, i32* %3
br label %30
30: ; preds = %29, %25, %10
%31 = load i32, i32* %3
ret i32 %31
}

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 %8, label %5
5: ; preds = %2
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 0
br i1 %7, label %19, label %14
8: ; preds = %2
%9 = getelementptr inbounds i8, i8* %0, i64 1
%10 = tail call i32 @match_here(i8* %9, i8* %1)
br label %19
11: ; preds = %14
%12 = load i8, i8* %18
%13 = icmp eq i8 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %5, %11
%15 = phi i8* [ %18, %11 ], [ %1, %5 ]
%16 = tail call i32 @match_here(i8* %0, i8* %15)
%17 = icmp eq i32 %16, 0
%18 = getelementptr inbounds i8, i8* %15, i64 1
br i1 %17, label %11, label %19
19: ; preds = %14, %11, %5, %8
%20 = phi i32 [ %10, %8 ], [ 0, %5 ], [ 1, %14 ], [ 0, %11 ]
ret i32 %20
}