void flipBits(unsigned char *dataPoint) {
  unsigned char data = *dataPoint;
  unsigned char newData = 0;
  int i = 0;
  for (i = 7; i >= 0; i--) {
    if (i >= 4) {
      newData = newData | (((1 << i) & data) >> (7 - (7 - i) * 2));
    } else {
      newData = newData | (((1 << i) & data) << (7 - 2 * i));
    }
  }
  *dataPoint = newData;
}


x86 assembly (clang, -O0):
<flipBits>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x9(%rbp)
movb   $0x0,-0xa(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x7,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     11a8 <flipBits+0xa8>
cmpl   $0x4,-0x10(%rbp)
jl     116b <flipBits+0x6b>
movzbl -0xa(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
movzbl -0x9(%rbp),%ecx
and    %ecx,%edx
mov    $0x7,%esi
sub    -0x10(%rbp),%esi
shl    $0x1,%esi
mov    $0x7,%ecx
sub    %esi,%ecx
sar    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %al,-0xa(%rbp)
jmp    1195 <flipBits+0x95>
movzbl -0xa(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
movzbl -0x9(%rbp),%ecx
and    %ecx,%edx
mov    -0x10(%rbp),%esi
shl    $0x1,%esi
mov    $0x7,%ecx
sub    %esi,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %al,-0xa(%rbp)
jmp    119a <flipBits+0x9a>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1123 <flipBits+0x23>
mov    -0xa(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<flipBits>:
mov    (%rdi),%al
rol    $0x4,%al
mov    %eax,%ecx
and    $0x33,%cl
shl    $0x2,%cl
shr    $0x2,%al
and    $0x33,%al
or     %cl,%al
mov    %eax,%ecx
and    $0x55,%cl
add    %cl,%cl
shr    %al
and    $0x55,%al
or     %cl,%al
mov    %al,(%rdi)
ret

LLVM IR (-O0):
define void @flipBits(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
store i8 %7, i8* %3
store i8 0, i8* %4
store i32 0, i32* %5
store i32 7, i32* %5
br label %8
8: ; preds = %44, %1
%9 = load i32, i32* %5
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %47
11: ; preds = %8
%12 = load i32, i32* %5
%13 = icmp sge i32 %12, 4
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = load i8, i8* %4
%16 = zext i8 %15 to i32
%17 = load i32, i32* %5
%18 = shl i32 1, %17
%19 = load i8, i8* %3
%20 = zext i8 %19 to i32
%21 = and i32 %18, %20
%22 = load i32, i32* %5
%23 = sub nsw i32 7, %22
%24 = mul nsw i32 %23, 2
%25 = sub nsw i32 7, %24
%26 = ashr i32 %21, %25
%27 = or i32 %16, %26
%28 = trunc i32 %27 to i8
store i8 %28, i8* %4
br label %43
29: ; preds = %11
%30 = load i8, i8* %4
%31 = zext i8 %30 to i32
%32 = load i32, i32* %5
%33 = shl i32 1, %32
%34 = load i8, i8* %3
%35 = zext i8 %34 to i32
%36 = and i32 %33, %35
%37 = load i32, i32* %5
%38 = mul nsw i32 2, %37
%39 = sub nsw i32 7, %38
%40 = shl i32 %36, %39
%41 = or i32 %31, %40
%42 = trunc i32 %41 to i8
store i8 %42, i8* %4
br label %43
43: ; preds = %29, %14
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = add nsw i32 %45, -1
store i32 %46, i32* %5
br label %8
47: ; preds = %8
%48 = load i8, i8* %4
%49 = load i8*, i8** %2
store i8 %48, i8* %49
ret void
}

LLVM IR (-O2):
define void @flipBits(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = call i8 @llvm.bitreverse.i8(i8 %2)
store i8 %3, i8* %0
ret void
}