#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 *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ skip_prefix(unsigned char const **, size_t *,
                               unsigned char const *, size_t, unsigned int);
scalar_t__ strncmp(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,
               unsigned int flags) {
  if (memchr(pattern, 0, pattern_len) != NULL)
    return 0;
  if (memchr(subject, 0, subject_len) != NULL)
    return 0;
  skip_prefix(&pattern, &pattern_len, subject, subject_len, flags);
  if (pattern_len != subject_len)
    return 0;
  return (strncmp(pattern, subject, pattern_len) == 0);
}


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    %r8d,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
xor    %esi,%esi
call   1050 <memchr@plt>
cmp    $0x0,%rax
je     1171 <equal_case+0x41>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <equal_case+0xb9>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
xor    %esi,%esi
call   1050 <memchr@plt>
cmp    $0x0,%rax
je     1196 <equal_case+0x66>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <equal_case+0xb9>
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <skip_prefix@plt>
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     11c9 <equal_case+0x99>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <equal_case+0xb9>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <strncmp@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):
<equal_case>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r15d
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%rdx
mov    %rdi,0x10(%rsp)
mov    %rsi,0x8(%rsp)
xor    %ebp,%ebp
xor    %esi,%esi
call   1050 <memchr@plt>
test   %rax,%rax
jne    11aa <equal_case+0x7a>
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1050 <memchr@plt>
test   %rax,%rax
jne    11aa <equal_case+0x7a>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15d,%r8d
call   1040 <skip_prefix@plt>
cmp    %rbx,0x8(%rsp)
jne    11aa <equal_case+0x7a>
mov    0x10(%rsp),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @equal_case(i8* %0, i64 %1, i8* %2, i64 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %6
store i64 %1, i64* %7
%8 = tail call i32* @memchr(i8* %0, i32 0, i64 %1)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %22
10: ; preds = %5
%11 = tail call i32* @memchr(i8* %2, i32 0, i64 %3)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = call i32 @skip_prefix(i8** %6, i64* %7, i8* %2, i64 %3, i32 %4)
%15 = load i64, i64* %7
%16 = icmp eq i64 %15, %3
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i8*, i8** %6
%19 = call i64 @strncmp(i8* %18, i8* %2, i64 %3)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %13, %10, %5, %17
%23 = phi i32 [ %21, %17 ], [ 0, %5 ], [ 0, %10 ], [ 0, %13 ]
ret i32 %23
}