#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 __bitmap_equal(unsigned long const *, unsigned long const *, int);
__attribute__((always_)) int
bitmap_equal(const unsigned long *src1, const unsigned long *src2, int nbits) {
  if (nbits <= 32)
    return !((*src1 ^ *src2) &
             (((nbits) % 32) ? (1UL << ((nbits) % 32)) - 1 : ~0UL));
  else
    return __bitmap_equal(src1, src2, nbits);
}


x86 assembly (clang, -O0):
<bitmap_equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jg     11a8 <bitmap_equal+0x98>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
xor    (%rcx),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1177 <bitmap_equal+0x67>
mov    -0x1c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
sub    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1187 <bitmap_equal+0x77>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    1187 <bitmap_equal+0x77>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
and    %rcx,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11bb <bitmap_equal+0xab>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <__bitmap_equal@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitmap_equal>:
cmp    $0x20,%edx
jg     1149 <bitmap_equal+0x39>
mov    (%rsi),%rsi
xor    (%rdi),%rsi
lea    0x1f(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xffffffe0,%eax
sub    %eax,%edx
mov    $0xffffffffffffffff,%rax
mov    %edx,%ecx
shl    %cl,%rax
not    %rax
cmp    $0x1,%edx
sbb    %rcx,%rcx
or     %rax,%rcx
xor    %eax,%eax
test   %rcx,%rsi
sete   %al
ret
jmp    1030 <__bitmap_equal@plt>

LLVM IR (-O0):
define i32 @bitmap_equal(i64* %0, i64* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i32
store i64* %0, i64** %5
store i64* %1, i64** %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = icmp sle i32 %8, 32
br i1 %9, label %10, label %32
10: ; preds = %3
%11 = load i64*, i64** %5
%12 = load i64, i64* %11
%13 = load i64*, i64** %6
%14 = load i64, i64* %13
%15 = xor i64 %12, %14
%16 = load i32, i32* %7
%17 = srem i32 %16, 32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %10
%20 = load i32, i32* %7
%21 = srem i32 %20, 32
%22 = zext i32 %21 to i64
%23 = shl i64 1, %22
%24 = sub i64 %23, 1
br label %26
25: ; preds = %10
br label %26
26: ; preds = %25, %19
%27 = phi i64 [ %24, %19 ], [ -1, %25 ]
%28 = and i64 %15, %27
%29 = icmp ne i64 %28, 0
%30 = xor i1 %29, true
%31 = zext i1 %30 to i32
store i32 %31, i32* %4
br label %37
32: ; preds = %3
%33 = load i64*, i64** %5
%34 = load i64*, i64** %6
%35 = load i32, i32* %7
%36 = call i32 @__bitmap_equal(i64* %33, i64* %34, i32 %35)
store i32 %36, i32* %4
br label %37
37: ; preds = %32, %26
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
define i32 @bitmap_equal(i64* %0, i64* %1, i32 %2) {
%4 = icmp slt i32 %2, 33
br i1 %4, label %5, label %18
5: ; preds = %3
%6 = load i64, i64* %0
%7 = load i64, i64* %1
%8 = xor i64 %7, %6
%9 = srem i32 %2, 32
%10 = icmp eq i32 %9, 0
%11 = zext i32 %9 to i64
%12 = shl nsw i64 -1, %11
%13 = xor i64 %12, -1
%14 = select i1 %10, i64 -1, i64 %13
%15 = and i64 %8, %14
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
br label %20
18: ; preds = %3
%19 = tail call i32 @__bitmap_equal(i64* %0, i64* %1, i32 %2)
br label %20
20: ; preds = %18, %5
%21 = phi i32 [ %17, %5 ], [ %19, %18 ]
ret i32 %21
}