#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_set() {
  printf("\n===== test_bit_set\n");
  uint8_t value = 0xf0;
  uint8_t bp = 2;
  uint8_t result = value | (1 << bp);
  printf("Initial value           : ");
  print_binary(value);
  printf("Result of setting bit %d : ", bp + 1);
  print_binary(result);
  assert(result == 0b11110100);
}


x86 assembly (clang, -O0):
<test_bit_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xf0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1050 <print_binary@plt>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%edi
call   1050 <print_binary@plt>
cmpl   $0xf4,-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_set>:
push   %rax
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xf0,%edi
call   1060 <print_binary@plt>
lea    0xeaf(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xf4,%edi
call   1060 <print_binary@plt>
mov    $0x1,%edi
pop    %rax
jmp    1050 <assert@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"\0A===== test_bit_set\0A\00"
@.str.1 = [27 x i8] c"Initial value : \00"
@.str.2 = [28 x i8] c"Result of setting bit %d : \00"
define void @test_bit_set() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 240, i32* %1
store i32 2, i32* %2
%5 = load i32, i32* %1
%6 = load i32, i32* %2
%7 = shl i32 1, %6
%8 = or i32 %5, %7
store i32 %8, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %1
%11 = call i32 @print_binary(i32 %10)
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 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, 244
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
ret void
}

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