#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 /*<<< orphan*/, unsigned long *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned long *, unsigned long);
unsigned long OPENCOMM_DesExpandEncKey(unsigned char *pbDesKey,
                                       unsigned long ulDesKeyLen,
                                       unsigned char *pbDesEncKey,
                                       unsigned long *ulDesEncKeyLen) {
  unsigned long kn[32], dough[32];
  if (ulDesKeyLen != 8)
    return 0xEE20;
  deskey(pbDesKey, 0, kn);
  cookey(kn, dough);
  *ulDesEncKeyLen = 128;
  memcpy(pbDesEncKey, dough, *ulDesEncKeyLen);
  return 0;
}


x86 assembly (clang, -O0):
<OPENCOMM_DesExpandEncKey>:
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_DesExpandEncKey+0x33>
movq   $0xee20,-0x8(%rbp)
jmp    11b2 <OPENCOMM_DesExpandEncKey+0x82>
mov    -0x10(%rbp),%rdi
lea    -0x130(%rbp),%rdx
xor    %esi,%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_DesExpandEncKey>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    $0xee20,%ebx
cmp    $0x8,%rsi
jne    118a <OPENCOMM_DesExpandEncKey+0x5a>
mov    %rcx,%r15
mov    %rdx,%r14
xor    %ebx,%ebx
lea    0x100(%rsp),%r12
xor    %esi,%esi
mov    %r12,%rdx
call   1030 <deskey@plt>
mov    %rsp,%r13
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <cookey@plt>
movq   $0x80,(%r15)
mov    $0x80,%edx
mov    %r14,%rdi
mov    %r13,%rsi
call   1050 <memcpy@plt>
mov    %rbx,%rax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @OPENCOMM_DesExpandEncKey(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 0, 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_DesExpandEncKey(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 0, 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
}