#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 *, char *);
int /*<<< orphan*/ rand();
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ srand(int);
scalar_t__ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ to64(char *, int /*<<< orphan*/, int);
void EncryptPasswd(char *pw) {
  char *cpw;
  char cSalt[] = "$6$01234567$";
  (void)srand((int)time((time_t *)NULL));
  to64(&cSalt[3], rand(), 8);
  cpw = crypt(pw, cSalt);
  sprintf(pw, "%.99s", cpw);
}


x86 assembly (clang, -O0):
<EncryptPasswd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xe8d(%rip),%rax
mov    %rax,-0x1d(%rbp)
mov    0xe8b(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xe86(%rip),%al
mov    %al,-0x11(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    -0x1d(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    $0x8,%edx
call   1040 <to64@plt>
mov    -0x8(%rbp),%rdi
lea    -0x1d(%rbp),%rsi
call   1030 <crypt@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe31(%rip),%rsi
call   1070 <sprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EncryptPasswd>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movabs $0x24373635343332,%rax
mov    %rax,0xd(%rsp)
movabs $0x3433323130243624,%rax
32 33 34
mov    %rax,0x8(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xb(%rsp),%r14
xor    %eax,%eax
call   1080 <rand@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x8,%edx
call   1040 <to64@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <crypt@plt>
lea    0xe48(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1070 <sprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.EncryptPasswd.cSalt = [13 x i8] c"$6$01234567$\00"
@.str = [6 x i8] c"%.99s\00"
define void @EncryptPasswd(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [13 x i8]
store i8* %0, i8** %2
%5 = bitcast [13 x i8]* %4 to i8*
%6 = call i64 @time(i32* null)
%7 = trunc i64 %6 to i32
%8 = call i32 @srand(i32 %7)
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 3
%10 = call i32 (...) @rand()
%11 = call i32 @to64(i8* %9, i32 %10, i32 8)
%12 = load i8*, i8** %2
%13 = getelementptr inbounds [13 x i8], [13 x i8]* %4, i64 0, i64 0
%14 = call i8* @crypt(i8* %12, i8* %13)
store i8* %14, i8** %3
%15 = load i8*, i8** %2
%16 = load i8*, i8** %3
%17 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %16)
ret void
}

LLVM IR (-O2):
@__const.EncryptPasswd.cSalt = [13 x i8] c"$6$01234567$\00"
@.str = [6 x i8] c"%.99s\00"
define void @EncryptPasswd(i8* %0) {
%2 = alloca [13 x i8]
%3 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @time(i32* null)
%5 = trunc i64 %4 to i32
%6 = tail call i32 @srand(i32 %5)
%7 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 3
%8 = tail call i32 (...) @rand()
%9 = call i32 @to64(i8* %7, i32 %8, i32 8)
%10 = call i8* @crypt(i8* %0, i8* %3)
%11 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10)
ret void
}