#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ cookey(unsigned long *, unsigned long *);
int /*<<< orphan*/ deskey(unsigned char *, int, unsigned long *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned long *, unsigned long);
unsigned long OPENCOMM_DesExpandDecKey(unsigned char *pbDesKey,
                                       unsigned long ulDesKeyLen,
                                       unsigned char *pbDesDecKey,
                                       unsigned long *ulDesDecKeyLen) {
  unsigned long kn[32], dough[32];
  if (ulDesKeyLen != 8)
    return 0xEE20;
  deskey(pbDesKey, 1, kn);
  cookey(kn, dough);
  *ulDesDecKeyLen = 128;
  memcpy(pbDesDecKey, dough, *ulDesDecKeyLen);
  return 0;
}


x86 assembly (clang, -O0):
<OPENCOMM_DesExpandDecKey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x8,-0x18(%rbp)
je     1163 <OPENCOMM_DesExpandDecKey+0x33>
movq   $0xee20,-0x8(%rbp)
jmp    11b5 <OPENCOMM_DesExpandDecKey+0x85>
mov    -0x10(%rbp),%rdi
lea    -0x130(%rbp),%rdx
mov    $0x1,%esi
call   1030 <deskey@plt>
lea    -0x130(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1040 <cookey@plt>
mov    -0x28(%rbp),%rax
movq   $0x80,(%rax)
mov    -0x20(%rbp),%rdi
lea    -0x230(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    (%rax),%rdx
call   1050 <memcpy@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OPENCOMM_DesExpandDecKey>:
mov    $0xee20,%eax
cmp    $0x8,%rsi
jne    1199 <OPENCOMM_DesExpandDecKey+0x69>
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
lea    0x100(%rsp),%r15
mov    $0x1,%esi
mov    %r15,%rdx
call   1030 <deskey@plt>
mov    %rsp,%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <cookey@plt>
movq   $0x80,(%rbx)
mov    $0x80,%edx
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <memcpy@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @OPENCOMM_DesExpandDecKey(i8* %0, i64 %1, i8* %2, i64* %3) {
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64*
%10 = alloca [32 x i64]
%11 = alloca [32 x i64]
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i64* %3, i64** %9
%12 = load i64, i64* %7
%13 = icmp ne i64 %12, 8
br i1 %13, label %14, label %15
14: ; preds = %4
store i64 60960, i64* %5
br label %28
15: ; preds = %4
%16 = load i8*, i8** %6
%17 = getelementptr inbounds [32 x i64], [32 x i64]* %10, i64 0, i64 0
%18 = call i32 @deskey(i8* %16, i32 1, i64* %17)
%19 = getelementptr inbounds [32 x i64], [32 x i64]* %10, i64 0, i64 0
%20 = getelementptr inbounds [32 x i64], [32 x i64]* %11, i64 0, i64 0
%21 = call i32 @cookey(i64* %19, i64* %20)
%22 = load i64*, i64** %9
store i64 128, i64* %22
%23 = load i8*, i8** %8
%24 = getelementptr inbounds [32 x i64], [32 x i64]* %11, i64 0, i64 0
%25 = load i64*, i64** %9
%26 = load i64, i64* %25
%27 = call i32 @memcpy(i8* %23, i64* %24, i64 %26)
store i64 0, i64* %5
br label %28
28: ; preds = %15, %14
%29 = load i64, i64* %5
ret i64 %29
}

LLVM IR (-O2):
define i64 @OPENCOMM_DesExpandDecKey(i8* %0, i64 %1, i8* %2, i64* nocapture writeonly %3) {
%5 = alloca [32 x i64]
%6 = alloca [32 x i64]
%7 = bitcast [32 x i64]* %5 to i8*
%8 = bitcast [32 x i64]* %6 to i8*
%9 = icmp eq i64 %1, 8
br i1 %9, label %10, label %16
10: ; preds = %4
%11 = getelementptr inbounds [32 x i64], [32 x i64]* %5, i64 0, i64 0
%12 = call i32 @deskey(i8* %0, i32 1, i64* %11)
%13 = getelementptr inbounds [32 x i64], [32 x i64]* %6, i64 0, i64 0
%14 = call i32 @cookey(i64* %11, i64* %13)
store i64 128, i64* %3
%15 = call i32 @memcpy(i8* %2, i64* %13, i64 128)
br label %16
16: ; preds = %4, %10
%17 = phi i64 [ 0, %10 ], [ 60960, %4 ]
ret i64 %17
}