#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 __WORDSIZE;
int __bitmap_intersects(unsigned long const *, unsigned long const *, int);
int bitmap_intersects(const unsigned long *src1, const unsigned long *src2,
                      int nbits) {
  if (nbits <= __WORDSIZE)
    return ((*src1 & *src2) &
            (((nbits) % __WORDSIZE) ? (1UL << ((nbits) % __WORDSIZE)) - 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)
mov    -0x1c(%rbp),%eax
mov    0x2ebb(%rip),%rcx
cmp    (%rcx),%eax
jg     11b2 <bitmap_intersects+0xa2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
and    (%rcx),%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e97(%rip),%rcx
cltd
idivl  (%rcx)
cmp    $0x0,%edx
je     1183 <bitmap_intersects+0x73>
mov    -0x1c(%rbp),%eax
mov    0x2e81(%rip),%rcx
cltd
idivl  (%rcx)
mov    %edx,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
sub    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1193 <bitmap_intersects+0x83>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    1193 <bitmap_intersects+0x83>
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    11c5 <bitmap_intersects+0xb5>
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>:
mov    0x2ed1(%rip),%rax
mov    (%rax),%ecx
cmp    %edx,%ecx
jge    1122 <bitmap_intersects+0x12>
jmp    1030 <__bitmap_intersects@plt>
mov    (%rsi),%rsi
and    (%rdi),%rsi
mov    %edx,%eax
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0xffffffffffffffff,%rax
shl    %cl,%rax
not    %rax
cmp    $0x1,%edx
sbb    %rcx,%rcx
or     %rax,%rcx
xor    %eax,%eax
test   %rcx,%rsi
setne  %al
ret

LLVM IR (-O0):
@__WORDSIZE = global i32 0
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 = load i32, i32* @__WORDSIZE
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %34
11: ; preds = %3
%12 = load i64*, i64** %5
%13 = load i64, i64* %12
%14 = load i64*, i64** %6
%15 = load i64, i64* %14
%16 = and i64 %13, %15
%17 = load i32, i32* %7
%18 = load i32, i32* @__WORDSIZE
%19 = srem i32 %17, %18
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %11
%22 = load i32, i32* %7
%23 = load i32, i32* @__WORDSIZE
%24 = srem i32 %22, %23
%25 = zext i32 %24 to i64
%26 = shl i64 1, %25
%27 = sub i64 %26, 1
br label %29
28: ; preds = %11
br label %29
29: ; preds = %28, %21
%30 = phi i64 [ %27, %21 ], [ -1, %28 ]
%31 = and i64 %16, %30
%32 = icmp ne i64 %31, 0
%33 = zext i1 %32 to i32
store i32 %33, i32* %4
br label %39
34: ; preds = %3
%35 = load i64*, i64** %5
%36 = load i64*, i64** %6
%37 = load i32, i32* %7
%38 = call i32 @__bitmap_intersects(i64* %35, i64* %36, i32 %37)
store i32 %38, i32* %4
br label %39
39: ; preds = %34, %29
%40 = load i32, i32* %4
ret i32 %40
}

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