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

/* Variables and functions */
char *crypt(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ rand();
int /*<<< orphan*/ srand(int);
scalar_t__ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ to64(char *, int /*<<< orphan*/, int);
void change_password(char *user, char *pw, FILE *f) {
  char *cpw, salt[3];
  (void)srand((int)time((time_t *)NULL));
  to64(&salt[0], rand(), 2);
  cpw = crypt(pw, salt);
  free(pw);
  fprintf(f, "%s:%s\n", user, cpw);
}


x86 assembly (clang, -O0):
<change_password>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    -0x23(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
mov    $0x2,%edx
call   1050 <to64@plt>
mov    -0x10(%rbp),%rdi
lea    -0x23(%rbp),%rsi
call   1040 <crypt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe20(%rip),%rsi
call   1070 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_password>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r15
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0xd(%rsp),%r12
mov    %r12,%rdi
mov    %eax,%esi
mov    $0x2,%edx
call   1050 <to64@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <crypt@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1030 <free@plt>
lea    0xe34(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1070 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s:%s\0A\00"
define void @change_password(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca [3 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%9 = call i64 @time(i32* null)
%10 = trunc i64 %9 to i32
%11 = call i32 @srand(i32 %10)
%12 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%13 = call i32 (...) @rand()
%14 = call i32 @to64(i8* %12, i32 %13, i32 2)
%15 = load i8*, i8** %5
%16 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%17 = call i8* @crypt(i8* %15, i8* %16)
store i8* %17, i8** %7
%18 = load i8*, i8** %5
%19 = call i32 @free(i8* %18)
%20 = load i32*, i32** %6
%21 = load i8*, i8** %4
%22 = load i8*, i8** %7
%23 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
ret void
}

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