void Expand(unsigned char *in, unsigned char *out) {
  int j, c;
  int i;
  for (i = 0; i < 64; in++) {
    c = *in;
    for (j = 7; j >= 0; j--)
      *out++ = (c >> j) & 1;
    i += 8;
  }
}


x86 assembly (clang, -O0):
<Expand>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x40,-0x1c(%rbp)
jge    117e <Expand+0x7e>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x18(%rbp)
movl   $0x7,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1164 <Expand+0x64>
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    112e <Expand+0x2e>
mov    -0x1c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1113 <Expand+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<Expand>:
mov    $0xfffffff8,%r8d
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movzbl (%rdi,%rcx,1),%eax
mov    %eax,%edx
shr    $0x7,%dl
mov    %dl,(%rsi,%rcx,8)
mov    %eax,%edx
shr    $0x6,%dl
and    $0x1,%dl
mov    %dl,0x1(%rsi,%rcx,8)
mov    %eax,%edx
shr    $0x5,%dl
and    $0x1,%dl
mov    %dl,0x2(%rsi,%rcx,8)
mov    %eax,%edx
shr    $0x4,%dl
and    $0x1,%dl
mov    %dl,0x3(%rsi,%rcx,8)
mov    %eax,%edx
shr    $0x3,%dl
and    $0x1,%dl
mov    %dl,0x4(%rsi,%rcx,8)
mov    %eax,%edx
shr    $0x2,%dl
and    $0x1,%dl
mov    %dl,0x5(%rsi,%rcx,8)
mov    %eax,%edx
shr    %dl
and    $0x1,%dl
mov    %dl,0x6(%rsi,%rcx,8)
and    $0x1,%al
mov    %al,0x7(%rsi,%rcx,8)
add    $0x8,%r8d
add    $0x1,%rcx
cmp    $0x38,%r8d
jb     1110 <Expand+0x10>
ret

LLVM IR (-O0):
define void @Expand(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %7
br label %8
8: ; preds = %32, %2
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 64
br i1 %10, label %11, label %35
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
store i32 %14, i32* %6
store i32 7, i32* %5
br label %15
15: ; preds = %26, %11
%16 = load i32, i32* %5
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = ashr i32 %19, %20
%22 = and i32 %21, 1
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %4
store i8 %23, i8* %24
br label %26
26: ; preds = %18
%27 = load i32, i32* %5
%28 = add nsw i32 %27, -1
store i32 %28, i32* %5
br label %15
29: ; preds = %15
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 8
store i32 %31, i32* %7
br label %32
32: ; preds = %29
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
br label %8
35: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @Expand(i8* nocapture %0, i8* nocapture writeonly %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %30, %3 ]
%5 = phi i8* [ %0, %2 ], [ %31, %3 ]
%6 = phi i8* [ %1, %2 ], [ %29, %3 ]
%7 = load i8, i8* %5
%8 = lshr i8 %7, 7
%9 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %8, i8* %6
%10 = lshr i8 %7, 6
%11 = and i8 %10, 1
%12 = getelementptr inbounds i8, i8* %6, i64 2
store i8 %11, i8* %9
%13 = lshr i8 %7, 5
%14 = and i8 %13, 1
%15 = getelementptr inbounds i8, i8* %6, i64 3
store i8 %14, i8* %12
%16 = lshr i8 %7, 4
%17 = and i8 %16, 1
%18 = getelementptr inbounds i8, i8* %6, i64 4
store i8 %17, i8* %15
%19 = lshr i8 %7, 3
%20 = and i8 %19, 1
%21 = getelementptr inbounds i8, i8* %6, i64 5
store i8 %20, i8* %18
%22 = lshr i8 %7, 2
%23 = and i8 %22, 1
%24 = getelementptr inbounds i8, i8* %6, i64 6
store i8 %23, i8* %21
%25 = lshr i8 %7, 1
%26 = and i8 %25, 1
%27 = getelementptr inbounds i8, i8* %6, i64 7
store i8 %26, i8* %24
%28 = and i8 %7, 1
%29 = getelementptr inbounds i8, i8* %6, i64 8
store i8 %28, i8* %27
%30 = add nuw nsw i32 %4, 8
%31 = getelementptr inbounds i8, i8* %5, i64 1
%32 = icmp ult i32 %4, 56
br i1 %32, label %3, label %33
33: ; preds = %3
ret void
}