#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 flsnz8(unsigned char);
int string_equal_bits(const unsigned char *a, const unsigned char *b,
                      int ignore) {
  int beg;
  unsigned char c;
  beg = ignore >> 3;
  while (1) {
    unsigned char d;
    c = a[beg];
    d = b[beg];
    beg++;
    c ^= d;
    if (c)
      break;
    if (!d)
      return -1;
  }
  return (beg << 3) - flsnz8(c);
}


x86 assembly (clang, -O0):
<string_equal_bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
sar    $0x3,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x22(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movzbl -0x22(%rbp),%ecx
movzbl -0x21(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x21(%rbp)
cmpb   $0x0,-0x21(%rbp)
je     116d <string_equal_bits+0x5d>
jmp    1188 <string_equal_bits+0x78>
cmpb   $0x0,-0x22(%rbp)
jne    1183 <string_equal_bits+0x73>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <string_equal_bits+0x94>
jmp    112c <string_equal_bits+0x1c>
mov    -0x20(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0x28(%rbp)
movzbl -0x21(%rbp),%edi
call   1030 <flsnz8@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_equal_bits>:
push   %rbx
mov    %edx,%ebx
mov    %edx,%eax
sar    $0x3,%eax
cltq
and    $0xfffffff8,%ebx
jmp    1130 <string_equal_bits+0x20>
nop
mov    $0x3,%edx
add    $0x1,%rax
add    $0x8,%ebx
test   %edx,%edx
jne    1146 <string_equal_bits+0x36>
movzbl (%rsi,%rax,1),%ecx
xor    %edx,%edx
test   %cl,%cl
sete   %r8b
xor    (%rdi,%rax,1),%cl
jne    1120 <string_equal_bits+0x10>
mov    %r8b,%dl
jmp    1125 <string_equal_bits+0x15>
cmp    $0x3,%edx
jne    1157 <string_equal_bits+0x47>
movzbl %cl,%edi
call   1030 <flsnz8@plt>
sub    %eax,%ebx
jmp    115c <string_equal_bits+0x4c>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @string_equal_bits(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%11 = load i32, i32* %7
%12 = ashr i32 %11, 3
store i32 %12, i32* %8
br label %13
13: ; preds = %3, %39
%14 = load i8*, i8** %5
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
store i8 %18, i8* %9
%19 = load i8*, i8** %6
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
store i8 %23, i8* %10
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
%26 = load i8, i8* %10
%27 = zext i8 %26 to i32
%28 = load i8, i8* %9
%29 = zext i8 %28 to i32
%30 = xor i32 %29, %27
%31 = trunc i32 %30 to i8
store i8 %31, i8* %9
%32 = load i8, i8* %9
%33 = icmp ne i8 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %13
br label %40
35: ; preds = %13
%36 = load i8, i8* %10
%37 = icmp ne i8 %36, 0
br i1 %37, label %39, label %38
38: ; preds = %35
store i32 -1, i32* %4
br label %46
39: ; preds = %35
br label %13
40: ; preds = %34
%41 = load i32, i32* %8
%42 = shl i32 %41, 3
%43 = load i8, i8* %9
%44 = call i32 @flsnz8(i8 zeroext %43)
%45 = sub nsw i32 %42, %44
store i32 %45, i32* %4
br label %46
46: ; preds = %40, %38
%47 = load i32, i32* %4
ret i32 %47
}

LLVM IR (-O2):
define i32 @string_equal_bits(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = ashr i32 %2, 3
%5 = sext i32 %4 to i64
br label %6
6: ; preds = %6, %3
%7 = phi i64 [ %12, %6 ], [ %5, %3 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %1, i64 %7
%11 = load i8, i8* %10
%12 = add i64 %7, 1
%13 = xor i8 %11, %9
%14 = icmp eq i8 %13, 0
%15 = icmp eq i8 %11, 0
%16 = zext i1 %15 to i32
%17 = select i1 %14, i32 %16, i32 3
switch i32 %17, label %23 [
i32 0, label %6
i32 3, label %18
]
18: ; preds = %6
%19 = trunc i64 %12 to i32
%20 = shl i32 %19, 3
%21 = tail call i32 @flsnz8(i8 zeroext %13)
%22 = sub nsw i32 %20, %21
br label %23
23: ; preds = %6, %18
%24 = phi i32 [ %22, %18 ], [ -1, %6 ]
ret i32 %24
}