int sliceedge_pack(array_in)
int array_in[12];
{
  int temp_arr[4], eloc_arr[12], ii, count;
  count = 0;
  for (ii = 0; ii < 12; ii++) {
    if (array_in[ii] != 0)
      temp_arr[count++] = array_in[ii] - 1;
    eloc_arr[ii] = (array_in[ii] != 0);
  }
  return perm_n_pack(4, temp_arr) * 495 + a_eloc_pack(eloc_arr);
}


x86 assembly (clang, -O0):
<sliceedge_pack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0xc,-0x54(%rbp)
jge    119f <sliceedge_pack+0x7f>
mov    -0x8(%rbp),%rax
movslq -0x54(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1175 <sliceedge_pack+0x55>
mov    -0x8(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
sub    $0x1,%ecx
mov    -0x58(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x58(%rbp)
cltq
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x8(%rbp),%rax
movslq -0x54(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
setne  %al
and    $0x1,%al
movzbl %al,%ecx
movslq -0x54(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    113a <sliceedge_pack+0x1a>
lea    -0x20(%rbp),%rsi
mov    $0x4,%edi
mov    $0x0,%al
call   1030 <perm_n_pack@plt>
imul   $0x1ef,%eax,%eax
mov    %eax,-0x5c(%rbp)
lea    -0x50(%rbp),%rdi
mov    $0x0,%al
call   1040 <a_eloc_pack@plt>
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
add    %ecx,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sliceedge_pack>:
push   %rbx
sub    $0x40,%rsp
xor    %eax,%eax
xor    %r8d,%r8d
jmp    1145 <sliceedge_pack+0x25>
nopl   0x0(%rax)
xor    %ecx,%ecx
test   %edx,%edx
setne  %cl
mov    %ecx,0x10(%rsp,%rax,4)
add    $0x1,%rax
cmp    $0xc,%rax
je     115b <sliceedge_pack+0x3b>
mov    (%rdi,%rax,4),%edx
test   %edx,%edx
je     1130 <sliceedge_pack+0x10>
lea    -0x1(%rdx),%esi
movslq %r8d,%rcx
add    $0x1,%r8d
mov    %esi,(%rsp,%rcx,4)
jmp    1130 <sliceedge_pack+0x10>
mov    %rsp,%rsi
mov    $0x4,%edi
xor    %eax,%eax
call   1030 <perm_n_pack@plt>
imul   $0x1ef,%eax,%ebx
lea    0x10(%rsp),%rdi
xor    %eax,%eax
call   1040 <a_eloc_pack@plt>
add    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @sliceedge_pack(i32* nocapture %0) {
%2 = alloca [4 x i32]
%3 = alloca [12 x i32]
%4 = bitcast [4 x i32]* %2 to i8*
%5 = bitcast [12 x i32]* %3 to i8*
br label %6
6: ; preds = %1, %17
%7 = phi i64 [ 0, %1 ], [ %22, %17 ]
%8 = phi i32 [ 0, %1 ], [ %18, %17 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %7
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %6
%13 = add nsw i32 %10, -1
%14 = add nsw i32 %8, 1
%15 = sext i32 %8 to i64
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 %15
store i32 %13, i32* %16
br label %17
17: ; preds = %12, %6
%18 = phi i32 [ %14, %12 ], [ %8, %6 ]
%19 = icmp ne i32 %10, 0
%20 = zext i1 %19 to i32
%21 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 %7
store i32 %20, i32* %21
%22 = add nuw nsw i64 %7, 1
%23 = icmp eq i64 %22, 12
br i1 %23, label %24, label %6
24: ; preds = %17
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%26 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @perm_n_pack to i32 (i32, i32*, ...)*)(i32 4, i32* %25)
%27 = mul nsw i32 %26, 495
%28 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%29 = call i32 (i32*, ...) bitcast (i32 (...)* @a_eloc_pack to i32 (i32*, ...)*)(i32* %28)
%30 = add nsw i32 %27, %29
ret i32 %30
}