#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*/ displayBits(unsigned int);
int /*<<< orphan*/ puts(char *);
void fig10_09() {
  unsigned int number1;
  unsigned int number2;
  unsigned int mask;
  unsigned int setBits;
  number1 = 65535;
  mask = 1;
  puts("The result of combining the following");
  displayBits(number1);
  displayBits(mask);
  puts("using the bitwise AND operator & is ");
  displayBits(number1 & mask);
  number1 = 15;
  setBits = 241;
  puts("\nThe result of combining the following");
  displayBits(number1);
  displayBits(setBits);
  puts("using the bitwise inclusive OR operator | is");
  displayBits(number1 | setBits);
  number1 = 139;
  number2 = 199;
  puts("\nThe result of combining the following");
  displayBits(number1);
  displayBits(number2);
  puts("using the bitwise exclusive OR operator ^ is");
  displayBits(number1 ^ number2);
  number1 = 21845;
  puts("\nThe one's complement of");
  displayBits(number1);
  puts(" is ");
  displayBits(~number1);
}


x86 assembly (clang, -O0):
<fig10_09>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffff,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%edi
call   1040 <displayBits@plt>
mov    -0xc(%rbp),%edi
call   1040 <displayBits@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%edi
and    -0xc(%rbp),%edi
call   1040 <displayBits@plt>
movl   $0xf,-0x4(%rbp)
movl   $0xf1,-0x10(%rbp)
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%edi
call   1040 <displayBits@plt>
mov    -0x10(%rbp),%edi
call   1040 <displayBits@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%edi
or     -0x10(%rbp),%edi
call   1040 <displayBits@plt>
movl   $0x8b,-0x4(%rbp)
movl   $0xc7,-0x8(%rbp)
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%edi
call   1040 <displayBits@plt>
mov    -0x8(%rbp),%edi
call   1040 <displayBits@plt>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%edi
xor    -0x8(%rbp),%edi
call   1040 <displayBits@plt>
movl   $0x5555,-0x4(%rbp)
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%edi
call   1040 <displayBits@plt>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%edi
xor    $0xffffffff,%edi
call   1040 <displayBits@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig10_09>:
push   %rbx
lea    0xefe(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffff,%edi
call   1040 <displayBits@plt>
mov    $0x1,%edi
call   1040 <displayBits@plt>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1040 <displayBits@plt>
lea    0xec7(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0xf,%edi
call   1040 <displayBits@plt>
mov    $0xf1,%edi
call   1040 <displayBits@plt>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
mov    $0xff,%edi
call   1040 <displayBits@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x8b,%edi
call   1040 <displayBits@plt>
mov    $0xc7,%edi
call   1040 <displayBits@plt>
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4c,%edi
call   1040 <displayBits@plt>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5555,%edi
call   1040 <displayBits@plt>
lea    0xe41(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffaaaa,%edi
pop    %rbx
jmp    1040 <displayBits@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"The result of combining the following\00"
@.str.1 = [37 x i8] c"using the bitwise AND operator & is \00"
@.str.2 = [39 x i8] c"\0AThe result of combining the following\00"
@.str.3 = [45 x i8] c"using the bitwise inclusive OR operator | is\00"
@.str.4 = [45 x i8] c"using the bitwise exclusive OR operator ^ is\00"
@.str.5 = [25 x i8] c"\0AThe one's complement of\00"
@.str.6 = [5 x i8] c" is \00"
define void @fig10_09() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 65535, i32* %1
store i32 1, i32* %3
%5 = call i32 @puts(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %1
%7 = call i32 @displayBits(i32 %6)
%8 = load i32, i32* %3
%9 = call i32 @displayBits(i32 %8)
%10 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = load i32, i32* %3
%13 = and i32 %11, %12
%14 = call i32 @displayBits(i32 %13)
store i32 15, i32* %1
store i32 241, i32* %4
%15 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* %1
%17 = call i32 @displayBits(i32 %16)
%18 = load i32, i32* %4
%19 = call i32 @displayBits(i32 %18)
%20 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* %1
%22 = load i32, i32* %4
%23 = or i32 %21, %22
%24 = call i32 @displayBits(i32 %23)
store i32 139, i32* %1
store i32 199, i32* %2
%25 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* %1
%27 = call i32 @displayBits(i32 %26)
%28 = load i32, i32* %2
%29 = call i32 @displayBits(i32 %28)
%30 = call i32 @puts(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = xor i32 %31, %32
%34 = call i32 @displayBits(i32 %33)
store i32 21845, i32* %1
%35 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32, i32* %1
%37 = call i32 @displayBits(i32 %36)
%38 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%39 = load i32, i32* %1
%40 = xor i32 %39, -1
%41 = call i32 @displayBits(i32 %40)
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"The result of combining the following\00"
@.str.1 = [37 x i8] c"using the bitwise AND operator & is \00"
@.str.2 = [39 x i8] c"\0AThe result of combining the following\00"
@.str.3 = [45 x i8] c"using the bitwise inclusive OR operator | is\00"
@.str.4 = [45 x i8] c"using the bitwise exclusive OR operator ^ is\00"
@.str.5 = [25 x i8] c"\0AThe one's complement of\00"
@.str.6 = [5 x i8] c" is \00"
define void @fig10_09() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @displayBits(i32 65535)
%3 = tail call i32 @displayBits(i32 1)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @displayBits(i32 1)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @displayBits(i32 15)
%8 = tail call i32 @displayBits(i32 241)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @displayBits(i32 255)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @displayBits(i32 139)
%13 = tail call i32 @displayBits(i32 199)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32 @displayBits(i32 76)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 @displayBits(i32 21845)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%19 = tail call i32 @displayBits(i32 -21846)
ret void
}