#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 */
typedef unsigned int uint8_t;
typedef int uint64_t;
typedef int uint32_t;

/* Variables and functions */
void set_bit(bool on, uint64_t seq, uint8_t *window, uint32_t W) {
  uint32_t bitno = seq % W;
  uint32_t blockno = bitno / 8;
  bitno %= 8;
  window[blockno] &= ~(1u << bitno);
  window[blockno] |= (uint8_t)on << bitno;
}


x86 assembly (clang, -O0):
<set_bit>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
xor    $0xffffffff,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
and    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%ecx
shl    %cl,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
or     (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_bit>:
mov    %rdx,%r8
mov    %esi,%eax
cltd
idiv   %ecx
mov    %edx,%ecx
lea    0x7(%rcx),%eax
test   %edx,%edx
cmovns %edx,%eax
mov    %eax,%edx
sar    $0x3,%edx
and    $0xfffffff8,%eax
sub    %eax,%ecx
movslq %edx,%rax
shl    %cl,%edi
mov    (%r8,%rax,4),%edx
btr    %ecx,%edx
or     %edx,%edi
mov    %edi,(%r8,%rax,4)
ret

LLVM IR (-O0):
define void @set_bit(i32 %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%11 = load i32, i32* %6
%12 = load i32, i32* %8
%13 = srem i32 %11, %12
store i32 %13, i32* %9
%14 = load i32, i32* %9
%15 = sdiv i32 %14, 8
store i32 %15, i32* %10
%16 = load i32, i32* %9
%17 = srem i32 %16, 8
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = shl i32 1, %18
%20 = xor i32 %19, -1
%21 = load i32*, i32** %7
%22 = load i32, i32* %10
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = and i32 %25, %20
store i32 %26, i32* %24
%27 = load i32, i32* %5
%28 = load i32, i32* %9
%29 = shl i32 %27, %28
%30 = load i32*, i32** %7
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = or i32 %34, %29
store i32 %35, i32* %33
ret void
}

LLVM IR (-O2):
define void @set_bit(i32 %0, i32 %1, i32* nocapture %2, i32 %3) {
%5 = srem i32 %1, %3
%6 = sdiv i32 %5, 8
%7 = srem i32 %5, 8
%8 = shl nuw nsw i32 1, %7
%9 = xor i32 %8, -1
%10 = sext i32 %6 to i64
%11 = getelementptr inbounds i32, i32* %2, i64 %10
%12 = load i32, i32* %11
%13 = and i32 %12, %9
%14 = shl i32 %0, %7
%15 = or i32 %13, %14
store i32 %15, i32* %11
ret void
}