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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void main() {
  int i = 0;
  printf("Original numer: %d\n", i);
  i = ((i) | 1 << (3));
  printf("After 3rd bit set: %d\n", i);
  i = ((i) & ~(1 << (3)));
  printf("After 3rd bit reset: %d\n", i);
  printf("If 3rd bit is set in 8 : %d\n", ((8) & (1 << (3))));
  printf("If 4th bit is set in 8 : %d\n", ((8) & (1 << (4))));
  i |= 1;
  printf("%d\n", i);
  printf("%d\n", i & 1);
  i &= ~1;
  printf("%d\n", i);
  i |= (1 | 2);
  printf("%d\n", i);
  printf("%d\n", (i & (1 | 2)));
  i &= ~(1 | 2);
  printf("%d\n", i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xed7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0xfffffff7,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
mov    $0x8,%esi
call   1030 <printf@plt>
lea    0xeeb(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
and    $0x1,%esi
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0xfffffffe,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
or     $0x3,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
and    $0x3,%esi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
and    $0xfffffffc,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
mov    $0x8,%esi
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
mov    $0x8,%esi
call   1030 <printf@plt>
lea    0xf0b(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
lea    0xef9(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Original numer: %d\0A\00"
@.str.1 = [23 x i8] c"After 3rd bit set: %d\0A\00"
@.str.2 = [25 x i8] c"After 3rd bit reset: %d\0A\00"
@.str.3 = [29 x i8] c"If 3rd bit is set in 8 : %d\0A\00"
@.str.4 = [29 x i8] c"If 4th bit is set in 8 : %d\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = load i32, i32* %1
%5 = or i32 %4, 8
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = and i32 %8, -9
store i32 %9, i32* %1
%10 = load i32, i32* %1
%11 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 8)
%13 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 0)
%14 = load i32, i32* %1
%15 = or i32 %14, 1
store i32 %15, i32* %1
%16 = load i32, i32* %1
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %1
%19 = and i32 %18, 1
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %1
%22 = and i32 %21, -2
store i32 %22, i32* %1
%23 = load i32, i32* %1
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %1
%26 = or i32 %25, 3
store i32 %26, i32* %1
%27 = load i32, i32* %1
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %1
%30 = and i32 %29, 3
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %1
%33 = and i32 %32, -4
store i32 %33, i32* %1
%34 = load i32, i32* %1
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %34)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Original numer: %d\0A\00"
@.str.1 = [23 x i8] c"After 3rd bit set: %d\0A\00"
@.str.2 = [25 x i8] c"After 3rd bit reset: %d\0A\00"
@.str.3 = [29 x i8] c"If 3rd bit is set in 8 : %d\0A\00"
@.str.4 = [29 x i8] c"If 4th bit is set in 8 : %d\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 8)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 8)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 1)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 0)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 3)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 0)
ret void
}