#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 */
typedef int /*<<< orphan*/ time_t;

/* Variables and functions */
char *crypt(char const *, char const *);
int /*<<< orphan*/ dw_ap_to64(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ rand();
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ time(int /*<<< orphan*/ *);
char *DWCrypt(char *szsrcStr, char *sztarStr) {
  char salt[10];
  char *p;
  sztarStr[0] = '\0';
  srand((int)time((time_t *)NULL));
  dw_ap_to64(&salt[0], rand(), 8);
  salt[8] = '\0';
  p = crypt((const char *)szsrcStr, (const char *)salt);
  if (p == NULL || *p == '\0') {
    return NULL;
  }
  strcpy(sztarStr, p);
  return sztarStr;
}


x86 assembly (clang, -O0):
<DWCrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    -0x22(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
mov    $0x8,%edx
call   1060 <dw_ap_to64@plt>
movb   $0x0,-0x1a(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x22(%rbp),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11d6 <DWCrypt+0x76>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11e3 <DWCrypt+0x83>
movq   $0x0,-0x8(%rbp)
jmp    11f8 <DWCrypt+0x98>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DWCrypt>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movb   $0x0,(%rsi)
xor    %r12d,%r12d
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1080 <rand@plt>
lea    0xe(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x8,%edx
call   1060 <dw_ap_to64@plt>
movb   $0x0,0x16(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <crypt@plt>
test   %rax,%rax
je     11cd <DWCrypt+0x6d>
cmpb   $0x0,(%rax)
je     11ca <DWCrypt+0x6a>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %r14,%r12
jmp    11cd <DWCrypt+0x6d>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @DWCrypt(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [10 x i8]
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i64 0
store i8 0, i8* %9
%10 = call i64 @time(i32* null)
%11 = trunc i64 %10 to i32
%12 = call i32 @srand(i32 %11)
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%14 = call i32 (...) @rand()
%15 = call i32 @dw_ap_to64(i8* %13, i32 %14, i32 8)
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 8
store i8 0, i8* %16
%17 = load i8*, i8** %4
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%19 = call i8* @crypt(i8* %17, i8* %18)
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = icmp eq i8* %20, null
br i1 %21, label %27, label %22
22: ; preds = %2
%23 = load i8*, i8** %7
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22, %2
store i8* null, i8** %3
br label %33
28: ; preds = %22
%29 = load i8*, i8** %5
%30 = load i8*, i8** %7
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = load i8*, i8** %5
store i8* %32, i8** %3
br label %33
33: ; preds = %28, %27
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
define i8* @DWCrypt(i8* %0, i8* %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
store i8 0, i8* %1
%5 = tail call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = tail call i32 @srand(i32 %6)
%8 = tail call i32 (...) @rand()
%9 = call i32 @dw_ap_to64(i8* %4, i32 %8, i32 8)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 8
store i8 0, i8* %10
%11 = call i8* @crypt(i8* %0, i8* %4)
%12 = icmp eq i8* %11, null
br i1 %12, label %18, label %13
13: ; preds = %2
%14 = load i8, i8* %11
%15 = icmp eq i8 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i32 @strcpy(i8* %1, i8* %11)
br label %18
18: ; preds = %2, %13, %16
%19 = phi i8* [ %1, %16 ], [ null, %13 ], [ null, %2 ]
ret i8* %19
}