unsigned long
OPENCOMM_DesDecRaw(unsigned char *pbDesDecKey, unsigned long ulDesDecKeyLen,
                   unsigned char *pbInData, unsigned long ulInDataLen,
                   unsigned char *pbOutData, unsigned long *ulOutDataLen) {
  unsigned long work[2], dk[32];
  unsigned char cp[8];
  if (ulInDataLen != 8)
    return 0xEE20;
  if (ulDesDecKeyLen != 128)
    return 0xEE20;
  memcpy(cp, pbInData, 8);
  scrunch(cp, work);
  memcpy(dk, pbDesDecKey, ulDesDecKeyLen);
  desfunc(work, dk);
  unscrun(work, cp);
  memcpy(pbOutData, cp, 8);
  *ulOutDataLen = 8;
  return 0;
}


x86 assembly (clang, -O0):
<OPENCOMM_DesDecRaw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
cmpq   $0x8,-0x28(%rbp)
je     117b <OPENCOMM_DesDecRaw+0x3b>
movq   $0xee20,-0x8(%rbp)
jmp    120f <OPENCOMM_DesDecRaw+0xcf>
cmpq   $0x80,-0x18(%rbp)
je     1196 <OPENCOMM_DesDecRaw+0x56>
movq   $0xee20,-0x8(%rbp)
jmp    120f <OPENCOMM_DesDecRaw+0xcf>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x158(%rbp)
lea    -0x158(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0x0,%al
call   1060 <scrunch@plt>
lea    -0x150(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <memcpy@plt>
lea    -0x50(%rbp),%rdi
lea    -0x150(%rbp),%rsi
mov    $0x0,%al
call   1050 <desfunc@plt>
lea    -0x50(%rbp),%rdi
lea    -0x158(%rbp),%rsi
mov    $0x0,%al
call   1040 <unscrun@plt>
mov    -0x30(%rbp),%rax
mov    -0x158(%rbp),%rcx
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rax
movq   $0x8,(%rax)
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OPENCOMM_DesDecRaw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    $0xee20,%r12d
cmp    $0x80,%rsi
jne    1201 <OPENCOMM_DesDecRaw+0xd1>
cmp    $0x8,%rcx
jne    1201 <OPENCOMM_DesDecRaw+0xd1>
mov    %r9,%r14
mov    %r8,%r15
mov    %rdi,%rbx
mov    (%rdx),%rax
mov    %rax,0x8(%rsp)
xor    %r12d,%r12d
lea    0x8(%rsp),%r13
lea    0x10(%rsp),%rbp
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scrunch@plt>
movups (%rbx),%xmm0
movups 0x10(%rbx),%xmm1
movups 0x20(%rbx),%xmm2
movups 0x30(%rbx),%xmm3
movaps %xmm0,0x20(%rsp)
movaps %xmm1,0x30(%rsp)
movaps %xmm2,0x40(%rsp)
movaps %xmm3,0x50(%rsp)
movups 0x40(%rbx),%xmm0
movaps %xmm0,0x60(%rsp)
movups 0x50(%rbx),%xmm0
movaps %xmm0,0x70(%rsp)
movups 0x60(%rbx),%xmm0
movaps %xmm0,0x80(%rsp)
movups 0x70(%rbx),%xmm0
movaps %xmm0,0x90(%rsp)
lea    0x20(%rsp),%rsi
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <desfunc@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <unscrun@plt>
mov    0x8(%rsp),%rax
mov    %rax,(%r15)
movq   $0x8,(%r14)
mov    %r12,%rax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @OPENCOMM_DesDecRaw(i8* %0, i64 %1, i8* %2, i64 %3, i8* %4, i64* %5) {
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i64*
%14 = alloca [2 x i64]
%15 = alloca [32 x i64]
%16 = alloca [8 x i8]
store i8* %0, i8** %8
store i64 %1, i64* %9
store i8* %2, i8** %10
store i64 %3, i64* %11
store i8* %4, i8** %12
store i64* %5, i64** %13
%17 = load i64, i64* %11
%18 = icmp ne i64 %17, 8
br i1 %18, label %19, label %20
19: ; preds = %6
store i64 60960, i64* %7
br label %43
20: ; preds = %6
%21 = load i64, i64* %9
%22 = icmp ne i64 %21, 128
br i1 %22, label %23, label %24
23: ; preds = %20
store i64 60960, i64* %7
br label %43
24: ; preds = %20
%25 = getelementptr inbounds [8 x i8], [8 x i8]* %16, i64 0, i64 0
%26 = load i8*, i8** %10
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %16, i64 0, i64 0
%28 = getelementptr inbounds [2 x i64], [2 x i64]* %14, i64 0, i64 0
%29 = call i32 (i8*, i64*, ...) bitcast (i32 (...)* @scrunch to i32 (i8*, i64*, ...)*)(i8* %27, i64* %28)
%30 = getelementptr inbounds [32 x i64], [32 x i64]* %15, i64 0, i64 0
%31 = bitcast i64* %30 to i8*
%32 = load i8*, i8** %8
%33 = load i64, i64* %9
%34 = getelementptr inbounds [2 x i64], [2 x i64]* %14, i64 0, i64 0
%35 = getelementptr inbounds [32 x i64], [32 x i64]* %15, i64 0, i64 0
%36 = call i32 (i64*, i64*, ...) bitcast (i32 (...)* @desfunc to i32 (i64*, i64*, ...)*)(i64* %34, i64* %35)
%37 = getelementptr inbounds [2 x i64], [2 x i64]* %14, i64 0, i64 0
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %16, i64 0, i64 0
%39 = call i32 (i64*, i8*, ...) bitcast (i32 (...)* @unscrun to i32 (i64*, i8*, ...)*)(i64* %37, i8* %38)
%40 = load i8*, i8** %12
%41 = getelementptr inbounds [8 x i8], [8 x i8]* %16, i64 0, i64 0
%42 = load i64*, i64** %13
store i64 8, i64* %42
store i64 0, i64* %7
br label %43
43: ; preds = %24, %23, %19
%44 = load i64, i64* %7
ret i64 %44
}

LLVM IR (-O2):
define i64 @OPENCOMM_DesDecRaw(i8* nocapture %0, i64 %1, i8* nocapture %2, i64 %3, i8* nocapture writeonly %4, i64* nocapture writeonly %5) {
%7 = alloca [2 x i64]
%8 = alloca [32 x i64]
%9 = alloca i64
%10 = bitcast [2 x i64]* %7 to i8*
%11 = bitcast [32 x i64]* %8 to i8*
%12 = bitcast i64* %9 to i8*
%13 = icmp eq i64 %3, 8
%14 = icmp eq i64 %1, 128
%15 = and i1 %14, %13
br i1 %15, label %16, label %26
16: ; preds = %6
%17 = bitcast i8* %2 to i64*
%18 = load i64, i64* %17
store i64 %18, i64* %9
%19 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
%20 = call i32 (i8*, i64*, ...) bitcast (i32 (...)* @scrunch to i32 (i8*, i64*, ...)*)(i8* %12, i64* %19)
%21 = getelementptr inbounds [32 x i64], [32 x i64]* %8, i64 0, i64 0
%22 = call i32 (i64*, i64*, ...) bitcast (i32 (...)* @desfunc to i32 (i64*, i64*, ...)*)(i64* %19, i64* %21)
%23 = call i32 (i64*, i8*, ...) bitcast (i32 (...)* @unscrun to i32 (i64*, i8*, ...)*)(i64* %19, i8* %12)
%24 = bitcast i8* %4 to i64*
%25 = load i64, i64* %9
store i64 %25, i64* %24
store i64 8, i64* %5
br label %26
26: ; preds = %6, %16
%27 = phi i64 [ 0, %16 ], [ 60960, %6 ]
ret i64 %27
}