#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__ memcasecmp(char const *, char const *, unsigned int);
int /*<<< orphan*/ strlen(char const *);
int match2(const char *lhs, const void *vpx, unsigned offset, unsigned length) {
  const char *px = (const char *)vpx;
  unsigned lhs_length = (unsigned)strlen(lhs);
  if (length - offset < lhs_length)
    return 0;
  return memcasecmp(lhs, px + offset, lhs_length) == 0;
}


x86 assembly (clang, -O0):
<match2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
sub    -0x1c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jae    1165 <match2+0x45>
movl   $0x0,-0x4(%rbp)
jmp    118a <match2+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%eax
add    %rax,%rsi
mov    -0x2c(%rbp),%edx
call   1040 <memcasecmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
sub    %ebp,%ebx
xor    %ecx,%ecx
cmp    %eax,%ebx
jb     1158 <match2+0x38>
mov    %ebp,%ecx
add    %rcx,%r14
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <memcasecmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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