#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 CHAR_BIT;
void vector_clear_bits(unsigned long *vector, unsigned long step,
                       unsigned long start, unsigned long size) {
  unsigned long bit;
  for (bit = start; bit < size; bit += step) {
    unsigned long i = bit / (CHAR_BIT * sizeof(unsigned long));
    unsigned long mask = 1L << (bit % (CHAR_BIT * sizeof(unsigned long)));
    vector[i] &= ~mask;
  }
}


x86 assembly (clang, -O0):
<vector_clear_bits>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1194 <vector_clear_bits+0x94>
mov    -0x28(%rbp),%rax
mov    0x2eab(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x3,%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2e90(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x3,%rcx
xor    %edx,%edx
div    %rcx
mov    %rdx,%rcx
mov    $0x1,%eax
shl    %cl,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdx
xor    $0xffffffffffffffff,%rdx
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
and    (%rax,%rcx,8),%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    111c <vector_clear_bits+0x1c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<vector_clear_bits>:
cmp    %rcx,%rdx
jae    1159 <vector_clear_bits+0x59>
mov    %rcx,%r8
mov    %rdx,%r9
mov    0x2ece(%rip),%rax
movslq (%rax),%r10
shl    $0x3,%r10
jmp    1141 <vector_clear_bits+0x41>
nopl   0x0(%rax,%rax,1)
mov    %r9,%rax
xor    %edx,%edx
div    %r10
mov    %rdx,%rcx
mov    $0xfffffffffffffffe,%rdx
rol    %cl,%rdx
and    %rdx,(%rdi,%rax,8)
add    %rsi,%r9
cmp    %r8,%r9
jae    1159 <vector_clear_bits+0x59>
mov    %r9,%rax
or     %r10,%rax
shr    $0x20,%rax
jne    1120 <vector_clear_bits+0x20>
mov    %r9d,%eax
xor    %edx,%edx
div    %r10d
mov    %edx,%ecx
jmp    112b <vector_clear_bits+0x2b>
ret

LLVM IR (-O0):
@CHAR_BIT = global i32 0
define void @vector_clear_bits(i64* %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i64* %0, i64** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%12 = load i64, i64* %7
store i64 %12, i64* %9
br label %13
13: ; preds = %36, %4
%14 = load i64, i64* %9
%15 = load i64, i64* %8
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %40
17: ; preds = %13
%18 = load i64, i64* %9
%19 = load i32, i32* @CHAR_BIT
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 8
%22 = udiv i64 %18, %21
store i64 %22, i64* %10
%23 = load i64, i64* %9
%24 = load i32, i32* @CHAR_BIT
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 8
%27 = urem i64 %23, %26
%28 = shl i64 1, %27
store i64 %28, i64* %11
%29 = load i64, i64* %11
%30 = xor i64 %29, -1
%31 = load i64*, i64** %5
%32 = load i64, i64* %10
%33 = getelementptr inbounds i64, i64* %31, i64 %32
%34 = load i64, i64* %33
%35 = and i64 %34, %30
store i64 %35, i64* %33
br label %36
36: ; preds = %17
%37 = load i64, i64* %6
%38 = load i64, i64* %9
%39 = add i64 %38, %37
store i64 %39, i64* %9
br label %13
40: ; preds = %13
ret void
}

LLVM IR (-O2):
@CHAR_BIT = global i32 0
define void @vector_clear_bits(i64* nocapture %0, i64 %1, i64 %2, i64 %3) {
%5 = icmp ult i64 %2, %3
br i1 %5, label %6, label %21
6: ; preds = %4
%7 = load i32, i32* @CHAR_BIT
%8 = sext i32 %7 to i64
%9 = shl nsw i64 %8, 3
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ %2, %6 ], [ %19, %10 ]
%12 = udiv i64 %11, %9
%13 = urem i64 %11, %9
%14 = shl nuw i64 1, %13
%15 = xor i64 %14, -1
%16 = getelementptr inbounds i64, i64* %0, i64 %12
%17 = load i64, i64* %16
%18 = and i64 %17, %15
store i64 %18, i64* %16
%19 = add i64 %11, %1
%20 = icmp ult i64 %19, %3
br i1 %20, label %10, label %21
21: ; preds = %10, %4
ret void
}