#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*/ memcpy(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ yxyDES2_EncryptAnyLength(char *, int);
int /*<<< orphan*/ yxyDES2_GetCiphertextAnyLength();
int /*<<< orphan*/ yxyDES2_Initialize();
int /*<<< orphan*/ yxyDES2_InitializeKey(char *);
int DESEncryptData(const char *pszInputKey, const char *pszInputPlaintext,
                   int Plaintlen, char *pszInputCiphertext) {
  if (NULL == pszInputKey || NULL == pszInputPlaintext ||
      NULL == pszInputCiphertext || Plaintlen <= 0)
    return -1;
  int temp = 0;
  yxyDES2_Initialize();
  yxyDES2_InitializeKey((char *)pszInputKey);
  temp = Plaintlen;
  yxyDES2_EncryptAnyLength((char *)pszInputPlaintext, temp);
  temp = temp % 8 == 0 ? temp : ((temp >> 3) + 1) << 3;
  memset(pszInputCiphertext, '\0', temp + 1);
  memcpy(pszInputCiphertext, yxyDES2_GetCiphertextAnyLength(), temp);
  return 0;
}


x86 assembly (clang, -O0):
<DESEncryptData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     11a5 <DESEncryptData+0x45>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     11a5 <DESEncryptData+0x45>
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
je     11a5 <DESEncryptData+0x45>
cmpl   $0x0,-0x1c(%rbp)
jg     11b1 <DESEncryptData+0x51>
movl   $0xffffffff,-0x4(%rbp)
jmp    1243 <DESEncryptData+0xe3>
movl   $0x0,-0x2c(%rbp)
mov    $0x0,%al
call   1050 <yxyDES2_Initialize@plt>
mov    -0x10(%rbp),%rdi
call   1030 <yxyDES2_InitializeKey@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1080 <yxyDES2_EncryptAnyLength@plt>
mov    -0x2c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11f9 <DESEncryptData+0x99>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1208 <DESEncryptData+0xa8>
mov    -0x2c(%rbp),%eax
sar    $0x3,%eax
add    $0x1,%eax
shl    $0x3,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1070 <yxyDES2_GetCiphertextAnyLength@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
mov    -0x2c(%rbp),%edx
call   1060 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DESEncryptData>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0xffffffff,%r14d
test   %edx,%edx
jle    11d5 <DESEncryptData+0x75>
mov    %rdi,%rbx
test   %rdi,%rdi
je     11d5 <DESEncryptData+0x75>
mov    %rsi,%r12
test   %rsi,%rsi
je     11d5 <DESEncryptData+0x75>
mov    %rcx,%r15
test   %rcx,%rcx
je     11d5 <DESEncryptData+0x75>
mov    %edx,%ebp
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <yxyDES2_Initialize@plt>
mov    %rbx,%rdi
call   1030 <yxyDES2_InitializeKey@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1080 <yxyDES2_EncryptAnyLength@plt>
lea    0x8(%rbp),%ebx
and    $0xfffffff8,%ebx
test   $0x7,%bpl
cmove  %ebp,%ebx
lea    0x1(%rbx),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
xor    %eax,%eax
call   1070 <yxyDES2_GetCiphertextAnyLength@plt>
mov    %r15,%rdi
mov    %eax,%esi
mov    %ebx,%edx
call   1060 <memcpy@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @DESEncryptData(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%11 = load i8*, i8** %6
%12 = icmp eq i8* null, %11
br i1 %12, label %22, label %13
13: ; preds = %4
%14 = load i8*, i8** %7
%15 = icmp eq i8* null, %14
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = load i8*, i8** %9
%18 = icmp eq i8* null, %17
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %8
%21 = icmp sle i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %19, %16, %13, %4
store i32 -1, i32* %5
br label %51
23: ; preds = %19
store i32 0, i32* %10
%24 = call i32 (...) @yxyDES2_Initialize()
%25 = load i8*, i8** %6
%26 = call i32 @yxyDES2_InitializeKey(i8* %25)
%27 = load i32, i32* %8
store i32 %27, i32* %10
%28 = load i8*, i8** %7
%29 = load i32, i32* %10
%30 = call i32 @yxyDES2_EncryptAnyLength(i8* %28, i32 %29)
%31 = load i32, i32* %10
%32 = srem i32 %31, 8
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %23
%35 = load i32, i32* %10
br label %41
36: ; preds = %23
%37 = load i32, i32* %10
%38 = ashr i32 %37, 3
%39 = add nsw i32 %38, 1
%40 = shl i32 %39, 3
br label %41
41: ; preds = %36, %34
%42 = phi i32 [ %35, %34 ], [ %40, %36 ]
store i32 %42, i32* %10
%43 = load i8*, i8** %9
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
%46 = call i32 @memset(i8* %43, i8 signext 0, i32 %45)
%47 = load i8*, i8** %9
%48 = call i32 (...) @yxyDES2_GetCiphertextAnyLength()
%49 = load i32, i32* %10
%50 = call i32 @memcpy(i8* %47, i32 %48, i32 %49)
store i32 0, i32* %5
br label %51
51: ; preds = %41, %22
%52 = load i32, i32* %5
ret i32 %52
}

LLVM IR (-O2):
define i32 @DESEncryptData(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = icmp eq i8* %0, null
%6 = icmp eq i8* %1, null
%7 = or i1 %5, %6
%8 = icmp eq i8* %3, null
%9 = or i1 %7, %8
%10 = icmp slt i32 %2, 1
%11 = or i1 %10, %9
br i1 %11, label %25, label %12
12: ; preds = %4
%13 = tail call i32 (...) @yxyDES2_Initialize()
%14 = tail call i32 @yxyDES2_InitializeKey(i8* %0)
%15 = tail call i32 @yxyDES2_EncryptAnyLength(i8* %1, i32 %2)
%16 = and i32 %2, 7
%17 = icmp eq i32 %16, 0
%18 = add nuw i32 %2, 8
%19 = and i32 %18, -8
%20 = select i1 %17, i32 %2, i32 %19
%21 = add nuw nsw i32 %20, 1
%22 = tail call i32 @memset(i8* %3, i8 signext 0, i32 %21)
%23 = tail call i32 (...) @yxyDES2_GetCiphertextAnyLength()
%24 = tail call i32 @memcpy(i8* %3, i32 %23, i32 %20)
br label %25
25: ; preds = %4, %12
%26 = phi i32 [ 0, %12 ], [ -1, %4 ]
ret i32 %26
}