#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 */
scalar_t__ match1(int /*<<< orphan*/, char *);
int match2(char *str, char *pat) {
  if (*pat == '\0')
    return 1;
  while (*str != '\0') {
    if (match1(str++, pat))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<match2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    113c <match2+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    118d <match2+0x7d>
jmp    1141 <match2+0x31>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1186 <match2+0x76>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
call   1030 <match1@plt>
cmp    $0x0,%rax
je     1181 <match2+0x71>
movl   $0x1,-0x4(%rbp)
jmp    118d <match2+0x7d>
jmp    1141 <match2+0x31>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r14d
cmpb   $0x0,(%rsi)
je     1151 <match2+0x41>
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %ebp,%ebx
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,0x0(%rbp)
je     114e <match2+0x3e>
add    $0x1,%rbp
mov    %ebx,%edi
mov    %r15,%rsi
call   1030 <match1@plt>
add    $0x1,%ebx
test   %rax,%rax
je     1130 <match2+0x20>
jmp    1151 <match2+0x41>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @match2(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** %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 1, i32* %3
br label %27
11: ; preds = %2
br label %12
12: ; preds = %25, %11
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %12
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %4
%20 = ptrtoint i8* %18 to i32
%21 = load i8*, i8** %5
%22 = call i64 @match1(i32 %20, i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %17
store i32 1, i32* %3
br label %27
25: ; preds = %17
br label %12
26: ; preds = %12
store i32 0, i32* %3
br label %27
27: ; preds = %26, %24, %10
%28 = load i32, i32* %3
ret i32 %28
}

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