#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*/ CW_dataPadAdd(int /*<<< orphan*/, unsigned char *,
                                 unsigned int, unsigned char **,
                                 unsigned int *);
int /*<<< orphan*/ free(unsigned char *);
int myic_DESEncrypt(unsigned char *, int /*<<< orphan*/, unsigned char *, int,
                    unsigned char *, int *);
int /*<<< orphan*/ strlen(char *);
int DesEnc(unsigned char *pInData, int nInDataLen, unsigned char *pOutData,
           int *pOutDataLen) {
  int rv;
  unsigned char *padDate = NULL;
  unsigned int padDateLen = 0;
  CW_dataPadAdd(0, pInData, (unsigned int)nInDataLen, &padDate, &padDateLen);
  rv = myic_DESEncrypt((unsigned char *)"abcd1234", strlen("abcd1234"), padDate,
                       (int)padDateLen, pOutData, pOutDataLen);
  if (rv != 0) {
    if (padDate != NULL) {
      free(padDate);
    }
    return rv;
  }
  if (padDate != NULL) {
    free(padDate);
  }
  return 0;
}


x86 assembly (clang, -O0):
<DesEnc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %edi,%edi
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
call   1060 <CW_dataPadAdd@plt>
lea    0xe7d(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%esi
mov    -0x38(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
lea    0xe60(%rip),%rdi
call   1040 <myic_DESEncrypt@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     11d1 <DesEnc+0x91>
cmpq   $0x0,-0x38(%rbp)
je     11c6 <DesEnc+0x86>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ec <DesEnc+0xac>
cmpq   $0x0,-0x38(%rbp)
je     11e5 <DesEnc+0xa5>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DesEnc>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%edx
mov    %rdi,%rsi
movq   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
xor    %edi,%edi
call   1060 <CW_dataPadAdd@plt>
lea    0xe83(%rip),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    0x8(%rsp),%rdx
mov    0x4(%rsp),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15,%r8
mov    %r14,%r9
call   1040 <myic_DESEncrypt@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     11af <DesEnc+0x6f>
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"abcd1234\00"
define i32 @DesEnc(i8* %0, i32 %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32* %3, i32** %9
store i8* null, i8** %11
store i32 0, i32* %12
%13 = load i8*, i8** %6
%14 = load i32, i32* %7
%15 = call i32 @CW_dataPadAdd(i32 0, i8* %13, i32 %14, i8** %11, i32* %12)
%16 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%17 = load i8*, i8** %11
%18 = load i32, i32* %12
%19 = load i8*, i8** %8
%20 = load i32*, i32** %9
%21 = call i32 @myic_DESEncrypt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %16, i8* %17, i32 %18, i8* %19, i32* %20)
store i32 %21, i32* %10
%22 = load i32, i32* %10
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %4
%25 = load i8*, i8** %11
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i8*, i8** %11
%29 = call i32 @free(i8* %28)
br label %30
30: ; preds = %27, %24
%31 = load i32, i32* %10
store i32 %31, i32* %5
br label %39
32: ; preds = %4
%33 = load i8*, i8** %11
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i8*, i8** %11
%37 = call i32 @free(i8* %36)
br label %38
38: ; preds = %35, %32
store i32 0, i32* %5
br label %39
39: ; preds = %38, %30
%40 = load i32, i32* %5
ret i32 %40
}

LLVM IR (-O2):
@.str = [9 x i8] c"abcd1234\00"
define i32 @DesEnc(i8* %0, i32 %1, i8* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%8 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%9 = call i32 @CW_dataPadAdd(i32 0, i8* %0, i32 %1, i8** %5, i32* %6)
%10 = call i32 @strlen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = call i32 @myic_DESEncrypt(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %11, i32 %12, i8* %2, i32* %3)
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %4
%17 = call i32 @free(i8* %14)
br label %18
18: ; preds = %4, %16
ret i32 %13
}