#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 /*<<< orphan*/ *memchr(unsigned char const *, char, size_t);
int /*<<< orphan*/ memcmp(unsigned char const *, unsigned char const *, size_t);
int equal_case(const unsigned char *pattern, size_t pattern_len,
               const unsigned char *subject, size_t subject_len) {
  if (memchr(pattern, '\0', pattern_len) != NULL)
    return 0;
  if (pattern_len != subject_len)
    return 0;
  return !memcmp(pattern, subject, pattern_len);
}


x86 assembly (clang, -O0):
<equal_case>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
xor    %esi,%esi
call   1030 <memchr@plt>
cmp    $0x0,%rax
je     115d <equal_case+0x3d>
movl   $0x0,-0x4(%rbp)
jmp    1198 <equal_case+0x78>
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     1177 <equal_case+0x57>
movl   $0x0,-0x4(%rbp)
jmp    1198 <equal_case+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%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):
<equal_case>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %ebp,%ebp
xor    %esi,%esi
mov    %rbx,%rdx
call   1030 <memchr@plt>
cmp    %r12,%rbx
jne    1160 <equal_case+0x40>
test   %rax,%rax
jne    1160 <equal_case+0x40>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <bcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @equal_case(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
%10 = load i8*, i8** %6
%11 = load i64, i64* %7
%12 = call i32* @memchr(i8* %10, i8 signext 0, i64 %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %4
store i32 0, i32* %5
br label %28
15: ; preds = %4
%16 = load i64, i64* %7
%17 = load i64, i64* %9
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 0, i32* %5
br label %28
20: ; preds = %15
%21 = load i8*, i8** %6
%22 = load i8*, i8** %8
%23 = load i64, i64* %7
%24 = call i32 @memcmp(i8* %21, i8* %22, i64 %23)
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
store i32 %27, i32* %5
br label %28
28: ; preds = %20, %19, %14
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
define i32 @equal_case(i8* %0, i64 %1, i8* nocapture %2, i64 %3) {
%5 = tail call i32* @memchr(i8* %0, i8 signext 0, i64 %1)
%6 = icmp eq i32* %5, null
%7 = icmp eq i64 %1, %3
%8 = and i1 %7, %6
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = tail call i32 @bcmp(i8* %0, i8* %2, i64 %1)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %4, %9
%14 = phi i32 [ %12, %9 ], [ 0, %4 ]
ret i32 %14
}