#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 int uint8_t;
typedef int uint32_t;

/* Variables and functions */
void setBit(uint32_t *bytes, uint32_t bitNumber, uint8_t val) {
  bytes[bitNumber / 32] =
      (bytes[bitNumber / 32] & ~(1 << (32 - 1 - (bitNumber % 32)))) |
      (val << (32 - 1 - (bitNumber % 32)));
}


x86 assembly (clang, -O0):
<setBit>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%eax
mov    $0x1f,%ecx
sub    %edx,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%eax
mov    %edx,%esi
mov    -0x20(%rbp),%edx
mov    $0x1f,%ecx
sub    %esi,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<setBit>:
mov    %esi,%ecx
lea    0x1f(%rcx),%eax
test   %esi,%esi
cmovns %esi,%eax
mov    %eax,%r8d
and    $0xffffffe0,%eax
sub    %eax,%ecx
mov    $0x80000000,%esi
shr    %cl,%esi
sar    $0x5,%r8d
movslq %r8d,%r8
not    %esi
mov    $0x1f,%al
sub    %cl,%al
mov    %eax,%ecx
shl    %cl,%edx
and    (%rdi,%r8,4),%esi
or     %esi,%edx
mov    %edx,(%rdi,%r8,4)
ret

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

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