#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 /*<<< orphan*/ printf(char *, ...);
main() {
  int a = 10, b = 20;
  printf("Bitwise operations");
  printf("Bitwise AND\n 10&20=%d", (a & b));
  printf("Bitwise OR\n 10|20=%d", (a | b));
  printf("Bitwise XOR\n 10^20=%d", (a ^ b));
  printf("Bitwise NOT\n ~10=%d", (~a));
  printf("10 shifted left by 2 places: %d", (a << 2));
  printf("20 shifted right by 2 places: %d", (b >> 2));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xa,-0x4(%rbp)
movl   $0x14,-0x8(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
and    -0x8(%rbp),%esi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
or     -0x8(%rbp),%esi
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
xor    -0x8(%rbp),%esi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
xor    $0xffffffff,%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
shl    $0x2,%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
sar    $0x2,%esi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
mov    $0x1e,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef5(%rip),%rdi
mov    $0x1e,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef8(%rip),%rdi
mov    $0xfffffff5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
mov    $0x28,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf06(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Bitwise operations\00"
@.str.1 = [22 x i8] c"Bitwise AND\0A 10&20=%d\00"
@.str.2 = [21 x i8] c"Bitwise OR\0A 10|20=%d\00"
@.str.3 = [22 x i8] c"Bitwise XOR\0A 10^20=%d\00"
@.str.4 = [20 x i8] c"Bitwise NOT\0A ~10=%d\00"
@.str.5 = [32 x i8] c"10 shifted left by 2 places: %d\00"
@.str.6 = [33 x i8] c"20 shifted right by 2 places: %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 10, i32* %1
store i32 20, i32* %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %1
%5 = load i32, i32* %2
%6 = and i32 %4, %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = or i32 %8, %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = xor i32 %12, %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %1
%17 = xor i32 %16, -1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %1
%20 = shl i32 %19, 2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %2
%23 = ashr i32 %22, 2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Bitwise operations\00"
@.str.1 = [22 x i8] c"Bitwise AND\0A 10&20=%d\00"
@.str.2 = [21 x i8] c"Bitwise OR\0A 10|20=%d\00"
@.str.3 = [22 x i8] c"Bitwise XOR\0A 10^20=%d\00"
@.str.4 = [20 x i8] c"Bitwise NOT\0A ~10=%d\00"
@.str.5 = [32 x i8] c"10 shifted left by 2 places: %d\00"
@.str.6 = [33 x i8] c"20 shifted right by 2 places: %d\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 30)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 30)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 -11)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 40)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 5)
ret i32 0
}