#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;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ print_binary(int);
int /*<<< orphan*/ printf(char *, ...);
void test_bit_clear() {
  printf("\n===== test_bit_clear\n");
  uint8_t value = 0xaf;
  uint8_t bp = 2;
  uint8_t result = value & ~(1 << bp);
  printf("Initial value            : ");
  print_binary(value);
  printf("Result of clearing bit %d : ", bp);
  print_binary(result);
  assert(result == 0b10101011);
}


x86 assembly (clang, -O0):
<test_bit_clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xaf,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0xc(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1050 <print_binary@plt>
mov    -0x8(%rbp),%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
call   1050 <print_binary@plt>
cmpl   $0xab,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bit_clear>:
push   %rax
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xaf,%edi
call   1060 <print_binary@plt>
lea    0xeb0(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xab,%edi
call   1060 <print_binary@plt>
mov    $0x1,%edi
pop    %rax
jmp    1050 <assert@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"\0A===== test_bit_clear\0A\00"
@.str.1 = [28 x i8] c"Initial value : \00"
@.str.2 = [29 x i8] c"Result of clearing bit %d : \00"
define void @test_bit_clear() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 175, i32* %1
store i32 2, i32* %2
%5 = load i32, i32* %1
%6 = load i32, i32* %2
%7 = shl i32 1, %6
%8 = xor i32 %7, -1
%9 = and i32 %5, %8
store i32 %9, i32* %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = call i32 @print_binary(i32 %11)
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %3
%16 = call i32 @print_binary(i32 %15)
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 171
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
ret void
}

LLVM IR (-O2):
@.str.1 = [28 x i8] c"Initial value : \00"
@.str.2 = [29 x i8] c"Result of clearing bit %d : \00"
@str = [22 x i8] c"\0A===== test_bit_clear\00"
define void @test_bit_clear() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @print_binary(i32 175)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 2)
%5 = tail call i32 @print_binary(i32 171)
%6 = tail call i32 @assert(i32 1)
ret void
}