#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 timezone {
  int dummy;
};
struct timeval {
  scalar_t__ tv_sec;
  scalar_t__ tv_usec;
};

/* Variables and functions */
scalar_t__ clock();
scalar_t__ getdef_bool(char *);
scalar_t__ getpid();
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
int /*<<< orphan*/ l64a(scalar_t__);
int /*<<< orphan*/ strcat(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *crypt_make_salt(void) {
  struct timeval tv;
  static char result[40];
  result[0] = '\0';
  if (getdef_bool("MD5_CRYPT_ENAB")) {
    strcpy(result, "$1$");
  }
  gettimeofday(&tv, (struct timezone *)0);
  strcat(result, l64a(tv.tv_usec));
  strcat(result, l64a(tv.tv_sec + getpid() + clock()));
  if (strlen(result) > 3 + 8)
    result[11] = '\0';
  return result;
}


x86 assembly (clang, -O0):
<crypt_make_salt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movb   $0x0,0x2ee1(%rip)
lea    0xe6a(%rip),%rdi
call   1080 <getdef_bool@plt>
cmp    $0x0,%rax
je     11b8 <crypt_make_salt+0x38>
lea    0x2ec4(%rip),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <gettimeofday@plt>
mov    -0x8(%rbp),%rdi
call   1090 <l64a@plt>
mov    %eax,%esi
lea    0x2e99(%rip),%rdi
call   10a0 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <clock@plt>
mov    -0x18(%rbp),%rdi
add    %rax,%rdi
call   1090 <l64a@plt>
mov    %eax,%esi
lea    0x2e5b(%rip),%rdi
call   10a0 <strcat@plt>
lea    0x2e4f(%rip),%rdi
call   1060 <strlen@plt>
cmp    $0xb,%eax
jle    1236 <crypt_make_salt+0xb6>
movb   $0x0,0x2e45(%rip)
lea    0x2e33(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypt_make_salt>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movb   $0x0,0x2ee2(%rip)
lea    0xe6b(%rip),%rdi
call   1080 <getdef_bool@plt>
test   %rax,%rax
je     11b2 <crypt_make_salt+0x32>
lea    0x2eca(%rip),%rdi
lea    0xe62(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1070 <gettimeofday@plt>
mov    0x10(%rsp),%rdi
call   1090 <l64a@plt>
lea    0x2ea1(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   10a0 <strcat@plt>
mov    0x8(%rsp),%rbx
xor    %eax,%eax
call   1040 <getpid@plt>
add    %rax,%rbx
xor    %eax,%eax
call   1050 <clock@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1090 <l64a@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   10a0 <strcat@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
cmp    $0xc,%eax
jl     1218 <crypt_make_salt+0x98>
movb   $0x0,0x2e63(%rip)
lea    0x2e51(%rip),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
%struct.timezone = type { i32 }
@crypt_make_salt.result = internal global [40 x i8] zeroinitializer
@.str = [15 x i8] c"MD5_CRYPT_ENAB\00"
@.str.1 = [4 x i8] c"$1$\00"
define i8* @crypt_make_salt() {
%1 = alloca %struct.timeval
store i8 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0)
%2 = call i64 @getdef_bool(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @strcpy(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %4, %0
%7 = call i32 @gettimeofday(%struct.timeval* %1, %struct.timezone* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%9 = load i64, i64* %8
%10 = call i32 @l64a(i64 %9)
%11 = call i32 @strcat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%13 = load i64, i64* %12
%14 = call i64 (...) @getpid()
%15 = add nsw i64 %13, %14
%16 = call i64 (...) @clock()
%17 = add nsw i64 %15, %16
%18 = call i32 @l64a(i64 %17)
%19 = call i32 @strcat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0), i32 %18)
%20 = call i32 @strlen(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0))
%21 = icmp sgt i32 %20, 11
br i1 %21, label %22, label %23
22: ; preds = %6
store i8 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 11)
br label %23
23: ; preds = %22, %6
ret i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
%struct.timezone = type { i32 }
@crypt_make_salt.result = internal global [40 x i8] zeroinitializer
@.str = [15 x i8] c"MD5_CRYPT_ENAB\00"
@.str.1 = [4 x i8] c"$1$\00"
define i8* @crypt_make_salt() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
store i8 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0)
%3 = tail call i64 @getdef_bool(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 @strcpy(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = call i32 @gettimeofday(%struct.timeval* %1, %struct.timezone* null)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%10 = load i64, i64* %9
%11 = tail call i32 @l64a(i64 %10)
%12 = tail call i32 @strcat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%14 = load i64, i64* %13
%15 = tail call i64 (...) @getpid()
%16 = add nsw i64 %15, %14
%17 = tail call i64 (...) @clock()
%18 = add nsw i64 %16, %17
%19 = tail call i32 @l64a(i64 %18)
%20 = tail call i32 @strcat(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0), i32 %19)
%21 = tail call i32 @strlen(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0))
%22 = icmp sgt i32 %21, 11
br i1 %22, label %23, label %24
23: ; preds = %7
store i8 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 11)
br label %24
24: ; preds = %23, %7
ret i8* getelementptr inbounds ([40 x i8], [40 x i8]* @crypt_make_salt.result, i64 0, i64 0)
}