void a_corner_unpack(corner, array_out) int corner;
int array_out[8];
{
  int ii;
  for (ii = 0; ii < 7; ii++) {
    array_out[ii] = corner % 3;
    corner = corner / 3;
  }
  array_out[7] =
      (2 * (array_out[0] + array_out[1] + array_out[2] + array_out[3] +
            array_out[4] + array_out[5] + array_out[6])) %
      3;
  return;
}


x86 assembly (clang, -O0):
<a_corner_unpack>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x7,-0x14(%rbp)
jge    114e <a_corner_unpack+0x4e>
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1112 <a_corner_unpack+0x12>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x10(%rbp),%rcx
add    0x4(%rcx),%eax
mov    -0x10(%rbp),%rcx
add    0x8(%rcx),%eax
mov    -0x10(%rbp),%rcx
add    0xc(%rcx),%eax
mov    -0x10(%rbp),%rcx
add    0x10(%rcx),%eax
mov    -0x10(%rbp),%rcx
add    0x14(%rcx),%eax
mov    -0x10(%rbp),%rcx
add    0x18(%rcx),%eax
shl    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x10(%rbp),%rax
mov    %edx,0x1c(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<a_corner_unpack>:
push   %r15
push   %r14
push   %rbx
movslq %edi,%r10
imul   $0x55555556,%r10,%r9
mov    %r9,%rax
shr    $0x3f,%rax
shr    $0x20,%r9
add    %eax,%r9d
lea    (%r9,%r9,2),%r8d
imul   $0x38e38e39,%r10,%r11
imul   $0x4bda12f7,%r10,%r14
imul   $0x1948b0fd,%r10,%r15
imul   $0xffffffff86d90545,%r10,%rcx
shr    $0x20,%rcx
add    %r10d,%ecx
imul   $0x59e60383,%r10,%rbx
sub    %r8d,%r10d
mov    %r10d,(%rsi)
movslq %r9d,%rdi
imul   $0x55555556,%rdi,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rax
add    %edx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%edi
mov    %edi,0x4(%rsi)
mov    %r11,%rax
shr    $0x3f,%rax
shr    $0x20,%r11
sar    %r11d
add    %eax,%r11d
movslq %r11d,%r8
imul   $0x55555556,%r8,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rax
add    %edx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%r8d
mov    %r8d,0x8(%rsi)
mov    %r14,%rax
shr    $0x3f,%rax
shr    $0x20,%r14
sar    $0x3,%r14d
add    %eax,%r14d
movslq %r14d,%r9
imul   $0x55555556,%r9,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x20,%rdx
add    %eax,%edx
lea    (%rdx,%rdx,2),%eax
sub    %eax,%r9d
mov    %r9d,0xc(%rsi)
mov    %r15,%rax
shr    $0x3f,%rax
shr    $0x20,%r15
sar    $0x3,%r15d
add    %eax,%r15d
movslq %r15d,%r11
imul   $0x55555556,%r11,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0x20,%rdx
add    %eax,%edx
lea    (%rdx,%rdx,2),%eax
sub    %eax,%r11d
mov    %r11d,0x10(%rsi)
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x7,%ecx
add    %eax,%ecx
movslq %ecx,%rax
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,0x14(%rsi)
mov    %rbx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rbx
sar    $0x8,%ebx
add    %ecx,%ebx
movslq %ebx,%rcx
imul   $0x55555556,%rcx,%rdx
mov    %rdx,%rbx
shr    $0x3f,%rbx
shr    $0x20,%rdx
add    %ebx,%edx
lea    (%rdx,%rdx,2),%edx
sub    %edx,%ecx
mov    %ecx,0x18(%rsi)
add    %r10d,%edi
add    %r8d,%edi
add    %r9d,%edi
add    %r11d,%edi
add    %eax,%edi
add    %ecx,%edi
add    %edi,%edi
movslq %edi,%rax
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,0x1c(%rsi)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @a_corner_unpack(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %6
6: ; preds = %18, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 7
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load i32, i32* %3
%11 = srem i32 %10, 3
%12 = load i32*, i32** %4
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
store i32 %11, i32* %15
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 3
store i32 %17, i32* %3
br label %18
18: ; preds = %9
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %6
21: ; preds = %6
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i64 0
%24 = load i32, i32* %23
%25 = load i32*, i32** %4
%26 = getelementptr inbounds i32, i32* %25, i64 1
%27 = load i32, i32* %26
%28 = add nsw i32 %24, %27
%29 = load i32*, i32** %4
%30 = getelementptr inbounds i32, i32* %29, i64 2
%31 = load i32, i32* %30
%32 = add nsw i32 %28, %31
%33 = load i32*, i32** %4
%34 = getelementptr inbounds i32, i32* %33, i64 3
%35 = load i32, i32* %34
%36 = add nsw i32 %32, %35
%37 = load i32*, i32** %4
%38 = getelementptr inbounds i32, i32* %37, i64 4
%39 = load i32, i32* %38
%40 = add nsw i32 %36, %39
%41 = load i32*, i32** %4
%42 = getelementptr inbounds i32, i32* %41, i64 5
%43 = load i32, i32* %42
%44 = add nsw i32 %40, %43
%45 = load i32*, i32** %4
%46 = getelementptr inbounds i32, i32* %45, i64 6
%47 = load i32, i32* %46
%48 = add nsw i32 %44, %47
%49 = mul nsw i32 2, %48
%50 = srem i32 %49, 3
%51 = load i32*, i32** %4
%52 = getelementptr inbounds i32, i32* %51, i64 7
store i32 %50, i32* %52
ret void
}

LLVM IR (-O2):
define void @a_corner_unpack(i32 %0, i32* nocapture %1) {
%3 = srem i32 %0, 3
store i32 %3, i32* %1
%4 = sdiv i32 %0, 3
%5 = srem i32 %4, 3
%6 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %5, i32* %6
%7 = sdiv i32 %0, 9
%8 = srem i32 %7, 3
%9 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %8, i32* %9
%10 = sdiv i32 %0, 27
%11 = srem i32 %10, 3
%12 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %11, i32* %12
%13 = sdiv i32 %0, 81
%14 = srem i32 %13, 3
%15 = getelementptr inbounds i32, i32* %1, i64 4
store i32 %14, i32* %15
%16 = sdiv i32 %0, 243
%17 = srem i32 %16, 3
%18 = getelementptr inbounds i32, i32* %1, i64 5
store i32 %17, i32* %18
%19 = sdiv i32 %0, 729
%20 = srem i32 %19, 3
%21 = getelementptr inbounds i32, i32* %1, i64 6
store i32 %20, i32* %21
%22 = add nsw i32 %5, %3
%23 = add nsw i32 %22, %8
%24 = add nsw i32 %23, %11
%25 = add nsw i32 %24, %14
%26 = add nsw i32 %25, %17
%27 = add nsw i32 %26, %20
%28 = shl nsw i32 %27, 1
%29 = srem i32 %28, 3
%30 = getelementptr inbounds i32, i32* %1, i64 7
store i32 %29, i32* %30
ret void
}