int main(int argc, char *argv[]) {
  char lower = 'a';
  char *bits[7] = {};
  int i = 0;
  char *bit;
  printf("Print bits in char 'a'\n");
  for (i = 0; i < 7; i++) {
    bit = lower & (1 << i);
    printf("bit %d: %d\n", i, bit);
  }
  printf("these bits print an '%c'\n", lower);
  printf("set bit 5\n");
  lower &= ~(1 << 5);
  printf("Print bits in new char\n");
  for (i = 0; i < 7; i++) {
    bit = lower & (1 << i);
    printf("bit %d: %d\n", i, bit);
  }
  printf("these bits print an '%c'\n", lower);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x61,-0x11(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1040 <memset@plt>
movl   $0x0,-0x54(%rbp)
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x7,-0x54(%rbp)
jge    11ab <main+0x8b>
movsbl -0x11(%rbp),%eax
mov    -0x54(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cltq
mov    %rax,-0x60(%rbp)
mov    -0x54(%rbp),%esi
mov    -0x60(%rbp),%rdx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1166 <main+0x46>
movsbl -0x11(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x11(%rbp),%eax
and    $0xffffffdf,%eax
mov    %al,-0x11(%rbp)
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x7,-0x54(%rbp)
jge    122f <main+0x10f>
movsbl -0x11(%rbp),%eax
mov    -0x54(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cltq
mov    %rax,-0x60(%rbp)
mov    -0x54(%rbp),%esi
mov    -0x60(%rbp),%rdx
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11ea <main+0xca>
movsbl -0x11(%rbp),%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xefb(%rip),%rdi
call   1030 <puts@plt>
lea    0xec9(%rip),%rbx
mov    $0x1,%edx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x20,%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x40,%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe51(%rip),%r14
mov    %r14,%rdi
mov    $0x61,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x40,%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x41,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Print bits in char 'a'\0A\00"
@.str.1 = [12 x i8] c"bit %d: %d\0A\00"
@.str.2 = [26 x i8] c"these bits print an '%c'\0A\00"
@.str.3 = [11 x i8] c"set bit 5\0A\00"
@.str.4 = [24 x i8] c"Print bits in new char\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca [7 x i8*]
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 97, i8* %6
%10 = bitcast [7 x i8*]* %7 to i8*
store i32 0, i32* %8
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %12
12: ; preds = %26, %2
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 7
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i8, i8* %6
%17 = sext i8 %16 to i32
%18 = load i32, i32* %8
%19 = shl i32 1, %18
%20 = and i32 %17, %19
%21 = sext i32 %20 to i64
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %9
%23 = load i32, i32* %8
%24 = load i8*, i8** %9
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %23, i8* %24)
br label %26
26: ; preds = %15
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %12
29: ; preds = %12
%30 = load i8, i8* %6
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%34 = load i8, i8* %6
%35 = sext i8 %34 to i32
%36 = and i32 %35, -33
%37 = trunc i32 %36 to i8
store i8 %37, i8* %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %8
br label %39
39: ; preds = %53, %29
%40 = load i32, i32* %8
%41 = icmp slt i32 %40, 7
br i1 %41, label %42, label %56
42: ; preds = %39
%43 = load i8, i8* %6
%44 = sext i8 %43 to i32
%45 = load i32, i32* %8
%46 = shl i32 1, %45
%47 = and i32 %44, %46
%48 = sext i32 %47 to i64
%49 = inttoptr i64 %48 to i8*
store i8* %49, i8** %9
%50 = load i32, i32* %8
%51 = load i8*, i8** %9
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %50, i8* %51)
br label %53
53: ; preds = %42
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %39
56: ; preds = %39
%57 = load i8, i8* %6
%58 = sext i8 %57 to i32
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %58)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"bit %d: %d\0A\00"
@.str.2 = [26 x i8] c"these bits print an '%c'\0A\00"
@str = [23 x i8] c"Print bits in char 'a'\00"
@str.5 = [10 x i8] c"set bit 5\00"
@str.6 = [23 x i8] c"Print bits in new char\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* inttoptr (i64 1 to i8*))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 1, i8* null)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* null)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 3, i8* null)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 4, i8* null)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 5, i8* inttoptr (i64 32 to i8*))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 6, i8* inttoptr (i64 64 to i8*))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 97)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* inttoptr (i64 1 to i8*))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 1, i8* null)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* null)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 3, i8* null)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 4, i8* null)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 5, i8* null)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 6, i8* inttoptr (i64 64 to i8*))
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 65)
ret i32 0
}