#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 */
struct timeval {
  int /*<<< orphan*/ tv_sec;
  int /*<<< orphan*/ tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ random();
int /*<<< orphan*/ to64(char *, int /*<<< orphan*/, int);
char *crypt_make_salt(void) {
  static char salt[32];
  struct timeval tv;
  gettimeofday(&tv, 0);
  memcpy(salt, "$1$", 3);
  to64(&salt[3], tv.tv_usec, 3);
  to64(&salt[6], tv.tv_sec, 2);
  to64(&salt[8], random(), 5);
  to64(&salt[13], random(), 5);
  to64(&salt[17], random(), 5);
  to64(&salt[22], random(), 5);
  salt[27] = '\0';
  return salt;
}


x86 assembly (clang, -O0):
<crypt_make_salt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
lea    0x2ef6(%rip),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x3,%edx
call   1050 <memcpy@plt>
mov    -0x4(%rbp),%esi
lea    0x2edb(%rip),%rdi
add    $0x3,%rdi
mov    $0x3,%edx
call   1030 <to64@plt>
mov    -0x8(%rbp),%esi
lea    0x2ec3(%rip),%rdi
add    $0x6,%rdi
mov    $0x2,%edx
call   1030 <to64@plt>
mov    $0x0,%al
call   1060 <random@plt>
mov    %eax,%esi
lea    0x2ea5(%rip),%rdi
add    $0x8,%rdi
mov    $0x5,%edx
call   1030 <to64@plt>
mov    $0x0,%al
call   1060 <random@plt>
mov    %eax,%esi
lea    0x2e87(%rip),%rdi
add    $0xd,%rdi
mov    $0x5,%edx
call   1030 <to64@plt>
mov    $0x0,%al
call   1060 <random@plt>
mov    %eax,%esi
lea    0x2e69(%rip),%rdi
add    $0x11,%rdi
mov    $0x5,%edx
call   1030 <to64@plt>
mov    $0x0,%al
call   1060 <random@plt>
mov    %eax,%esi
lea    0x2e4b(%rip),%rdi
add    $0x16,%rdi
mov    $0x5,%edx
call   1030 <to64@plt>
movb   $0x0,0x2e51(%rip)
lea    0x2e2f(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypt_make_salt>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
lea    0x2ef8(%rip),%rbx
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1050 <memcpy@plt>
mov    0xc(%rsp),%esi
lea    0x2edc(%rip),%rdi
mov    $0x3,%edx
call   1030 <to64@plt>
mov    0x8(%rsp),%esi
lea    0x2eca(%rip),%rdi
mov    $0x2,%edx
call   1030 <to64@plt>
xor    %eax,%eax
call   1060 <random@plt>
lea    0x2eb4(%rip),%rdi
mov    %eax,%esi
mov    $0x5,%edx
call   1030 <to64@plt>
xor    %eax,%eax
call   1060 <random@plt>
lea    0x2e9f(%rip),%rdi
mov    %eax,%esi
mov    $0x5,%edx
call   1030 <to64@plt>
xor    %eax,%eax
call   1060 <random@plt>
lea    0x2e89(%rip),%rdi
mov    %eax,%esi
mov    $0x5,%edx
call   1030 <to64@plt>
xor    %eax,%eax
call   1060 <random@plt>
lea    0x2e74(%rip),%rdi
mov    %eax,%esi
mov    $0x5,%edx
call   1030 <to64@plt>
movb   $0x0,0x2e66(%rip)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@crypt_make_salt.salt = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"$1$\00"
define i8* @crypt_make_salt() {
%1 = alloca %struct.timeval
%2 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
%3 = call i32 @memcpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%5 = load i32, i32* %4
%6 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 3), i32 %5, i32 3)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%8 = load i32, i32* %7
%9 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 6), i32 %8, i32 2)
%10 = call i32 (...) @random()
%11 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 8), i32 %10, i32 5)
%12 = call i32 (...) @random()
%13 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 13), i32 %12, i32 5)
%14 = call i32 (...) @random()
%15 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 17), i32 %14, i32 5)
%16 = call i32 (...) @random()
%17 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 22), i32 %16, i32 5)
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 27)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@crypt_make_salt.salt = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"$1$\00"
define i8* @crypt_make_salt() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
%4 = call i32 @memcpy(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%6 = load i32, i32* %5
%7 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 3), i32 %6, i32 3)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 6), i32 %9, i32 2)
%11 = call i32 (...) @random()
%12 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 8), i32 %11, i32 5)
%13 = call i32 (...) @random()
%14 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 13), i32 %13, i32 5)
%15 = call i32 (...) @random()
%16 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 17), i32 %15, i32 5)
%17 = call i32 (...) @random()
%18 = call i32 @to64(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 22), i32 %17, i32 5)
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 27)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @crypt_make_salt.salt, i64 0, i64 0)
}