#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 bitfield_get(char *, int);
void bitfield_clear(char *bitfield, int index) {
  if (bitfield_get(bitfield, index) == 1)
    bitfield[index / 8] = (~(1 << (index % 8)) & bitfield[index / 8]);
}


x86 assembly (clang, -O0):
<bitfield_clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <bitfield_get@plt>
cmp    $0x1,%eax
jne    1190 <bitfield_clear+0x80>
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%eax
mov    $0x8,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x20(%rbp),%eax
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
and    %ecx,%eax
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x19(%rbp),%dl
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitfield_clear>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <bitfield_get@plt>
cmp    $0x1,%eax
jne    1143 <bitfield_clear+0x33>
mov    %ebx,%ecx
and    $0x7,%cl
mov    $0x1,%eax
shl    %cl,%eax
lea    0x7(%rbx),%ecx
test   %ebx,%ebx
cmovns %ebx,%ecx
sar    $0x3,%ecx
movslq %ecx,%rcx
not    %al
and    %al,(%r14,%rcx,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @bitfield_clear(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = load i32, i32* %4
%7 = call i32 @bitfield_get(i8* %5, i32 %6)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %28
9: ; preds = %2
%10 = load i32, i32* %4
%11 = srem i32 %10, 8
%12 = shl i32 1, %11
%13 = xor i32 %12, -1
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sdiv i32 %15, 8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = and i32 %13, %20
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = sdiv i32 %24, 8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8 %22, i8* %27
br label %28
28: ; preds = %9, %2
ret void
}

LLVM IR (-O2):
define void @bitfield_clear(i8* %0, i32 %1) {
%3 = tail call i32 @bitfield_get(i8* %0, i32 %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = and i32 %1, 7
%7 = shl nuw nsw i32 1, %6
%8 = sdiv i32 %1, 8
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = trunc i32 %7 to i8
%13 = xor i8 %12, -1
%14 = and i8 %11, %13
store i8 %14, i8* %10
br label %15
15: ; preds = %5, %2
ret void
}