#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_subset(unsigned long const *, unsigned long const *, int);
int bitmap_subset(const unsigned long *src1, const unsigned long *src2,
                  int nbits) {
  if (nbits <= ((int)sizeof(unsigned long) * 8))
    return !((*src1 & ~(*src2)) &
             (((nbits) % ((int)sizeof(unsigned long) * 8))
                  ? (1UL << ((nbits) % ((int)sizeof(unsigned long) * 8))) - 1
                  : ~0UL));
  else
    return __bitmap_subset(src1, src2, nbits);
}


x86 assembly (clang, -O0):
<bitmap_subset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x40,-0x1c(%rbp)
jg     11af <bitmap_subset+0x9f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rcx
xor    $0xffffffffffffffff,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     117e <bitmap_subset+0x6e>
mov    -0x1c(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
sub    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    118e <bitmap_subset+0x7e>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    118e <bitmap_subset+0x7e>
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    11c2 <bitmap_subset+0xb2>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <__bitmap_subset@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitmap_subset>:
cmp    $0x40,%edx
jg     114c <bitmap_subset+0x3c>
lea    0x3f(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xffffffc0,%eax
sub    %eax,%edx
mov    $0xffffffffffffffff,%rax
mov    %edx,%ecx
shl    %cl,%rax
mov    (%rsi),%rcx
cmp    $0x1,%edx
sbb    %rdx,%rdx
not    %rax
or     %rax,%rdx
and    (%rdi),%rdx
not    %rcx
xor    %eax,%eax
test   %rcx,%rdx
sete   %al
ret
jmp    1030 <__bitmap_subset@plt>

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

LLVM IR (-O2):
define i32 @bitmap_subset(i64* %0, i64* %1, i32 %2) {
%4 = icmp slt i32 %2, 65
br i1 %4, label %5, label %19
5: ; preds = %3
%6 = load i64, i64* %0
%7 = load i64, i64* %1
%8 = xor i64 %7, -1
%9 = srem i32 %2, 64
%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 %6, %14
%16 = and i64 %15, %8
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
br label %21
19: ; preds = %3
%20 = tail call i32 @__bitmap_subset(i64* %0, i64* %1, i32 %2)
br label %21
21: ; preds = %19, %5
%22 = phi i32 [ %18, %5 ], [ %20, %19 ]
ret i32 %22
}