#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__ EXIT_SUCCESS;
scalar_t__ matchCharWithPattern(int, int);
int evaluateMatch(int pattern, int letter, int index, int counterPosition,
                  int wasItCounted) {
  if (index != 0) {
    return matchCharWithPattern(pattern, letter) == EXIT_SUCCESS &&
           counterPosition == index && wasItCounted == 0;
  } else {
    return matchCharWithPattern(pattern, letter) == EXIT_SUCCESS &&
           wasItCounted == 0;
  }
}


x86 assembly (clang, -O0):
<evaluateMatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1180 <evaluateMatch+0x70>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <matchCharWithPattern@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e97(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x19(%rbp)
jne    1170 <evaluateMatch+0x60>
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x10(%rbp),%ecx
mov    %al,-0x19(%rbp)
jne    1170 <evaluateMatch+0x60>
cmpl   $0x0,-0x18(%rbp)
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <evaluateMatch+0xa8>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <matchCharWithPattern@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e49(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x1a(%rbp)
jne    11ad <evaluateMatch+0x9d>
cmpl   $0x0,-0x18(%rbp)
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evaluateMatch>:
push   %rbp
push   %r14
push   %rbx
mov    %r8d,%ebx
mov    %ecx,%r14d
mov    %edx,%ebp
call   1030 <matchCharWithPattern@plt>
mov    0x2eb8(%rip),%rcx
mov    (%rcx),%rdx
cmp    %rdx,%rax
sete   %cl
test   %ebp,%ebp
je     1143 <evaluateMatch+0x33>
cmp    %rdx,%rax
sete   %al
cmp    %ebp,%r14d
sete   %cl
and    %al,%cl
test   %ebx,%ebx
sete   %al
and    %cl,%al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i64 0
define i32 @evaluateMatch(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%12 = load i32, i32* %9
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %5
%15 = load i32, i32* %7
%16 = load i32, i32* %8
%17 = call i64 @matchCharWithPattern(i32 %15, i32 %16)
%18 = load i64, i64* @EXIT_SUCCESS
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %27
20: ; preds = %14
%21 = load i32, i32* %10
%22 = load i32, i32* %9
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %11
%26 = icmp eq i32 %25, 0
br label %27
27: ; preds = %24, %20, %14
%28 = phi i1 [ false, %20 ], [ false, %14 ], [ %26, %24 ]
%29 = zext i1 %28 to i32
store i32 %29, i32* %6
br label %42
30: ; preds = %5
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = call i64 @matchCharWithPattern(i32 %31, i32 %32)
%34 = load i64, i64* @EXIT_SUCCESS
%35 = icmp eq i64 %33, %34
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load i32, i32* %11
%38 = icmp eq i32 %37, 0
br label %39
39: ; preds = %36, %30
%40 = phi i1 [ false, %30 ], [ %38, %36 ]
%41 = zext i1 %40 to i32
store i32 %41, i32* %6
br label %42
42: ; preds = %39, %27
%43 = load i32, i32* %6
ret i32 %43
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i64 0
define i32 @evaluateMatch(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp eq i32 %2, 0
%7 = tail call i64 @matchCharWithPattern(i32 %0, i32 %1)
%8 = load i64, i64* @EXIT_SUCCESS
%9 = icmp eq i64 %7, %8
br i1 %6, label %13, label %10
10: ; preds = %5
%11 = icmp eq i32 %3, %2
%12 = and i1 %11, %9
br label %13
13: ; preds = %5, %10
%14 = phi i1 [ %12, %10 ], [ %9, %5 ]
%15 = icmp eq i32 %4, 0
%16 = and i1 %15, %14
%17 = zext i1 %16 to i32
ret i32 %17
}