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


x86 assembly (clang, -O0):
<bitmap_intersects>:
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     11a6 <bitmap_intersects+0x96>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
and    (%rcx),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1177 <bitmap_intersects+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_intersects+0x77>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    1187 <bitmap_intersects+0x77>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
and    %rcx,%rax
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11b9 <bitmap_intersects+0xa9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <__bitmap_intersects@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitmap_intersects>:
cmp    $0x20,%edx
jg     1146 <bitmap_intersects+0x36>
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
cmp    $0x1,%edx
sbb    %rcx,%rcx
not    %rax
or     %rax,%rcx
and    (%rdi),%rcx
xor    %eax,%eax
test   %rcx,(%rsi)
setne  %al
ret
jmp    1030 <__bitmap_intersects@plt>

LLVM IR (-O0):
define i32 @bitmap_intersects(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 %31
10: ; preds = %3
%11 = load i64*, i64** %5
%12 = load i64, i64* %11
%13 = load i64*, i64** %6
%14 = load i64, i64* %13
%15 = and 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 = zext i1 %29 to i32
store i32 %30, i32* %4
br label %36
31: ; preds = %3
%32 = load i64*, i64** %5
%33 = load i64*, i64** %6
%34 = load i32, i32* %7
%35 = call i32 @__bitmap_intersects(i64* %32, i64* %33, i32 %34)
store i32 %35, i32* %4
br label %36
36: ; preds = %31, %26
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
define i32 @bitmap_intersects(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 = srem i32 %2, 32
%9 = icmp eq i32 %8, 0
%10 = zext i32 %8 to i64
%11 = shl nsw i64 -1, %10
%12 = xor i64 %11, -1
%13 = select i1 %9, i64 -1, i64 %12
%14 = and i64 %6, %13
%15 = and i64 %14, %7
%16 = icmp ne i64 %15, 0
%17 = zext i1 %16 to i32
br label %20
18: ; preds = %3
%19 = tail call i32 @__bitmap_intersects(i64* %0, i64* %1, i32 %2)
br label %20
20: ; preds = %18, %5
%21 = phi i32 [ %17, %5 ], [ %19, %18 ]
ret i32 %21
}