#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 */

/* Variables and functions */
char *crypt(int /*<<< orphan*/, char *);
int /*<<< orphan*/ getpass(char *);
unsigned long getpid();
int /*<<< orphan*/ puts(char *);
unsigned long time(int /*<<< orphan*/ *);
int main(void) {
  unsigned long seed[2];
  char salt[] = "$1$........";
  const char *const seedchars = "./0123456789ABCDEFGHIJKLMNOPQRST"
                                "UVWXYZabcdefghijklmnopqrstuvwxyz";
  char *password;
  int i;
  seed[0] = time(NULL);
  seed[1] = getpid() ^ (seed[0] >> 14 & 0x30000);
  for (i = 0; i < 8; i++)
    salt[3 + i] = seedchars[(seed[i / 5] >> (i % 5) * 6) & 0x3f];
  password = crypt(getpass("Password:"), salt);
  puts(password);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x2c(%rbp)
mov    0xe98(%rip),%eax
mov    %eax,-0x24(%rbp)
lea    0xe92(%rip),%rax
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x20(%rbp),%rcx
shr    $0xe,%rcx
and    $0x30000,%rcx
xor    %rcx,%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x8,-0x44(%rbp)
jge    1211 <main+0xc1>
mov    -0x44(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cltq
mov    -0x20(%rbp,%rax,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x44(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    -0x50(%rbp),%rax
imul   $0x6,%edx,%ecx
mov    %ecx,%ecx
shr    %cl,%rax
mov    %rax,%rcx
and    $0x3f,%rcx
lea    0xe18(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x44(%rbp),%eax
add    $0x3,%eax
cltq
mov    %cl,-0x2c(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11af <main+0x5f>
lea    0xe35(%rip),%rdi
call   1070 <getpass@plt>
mov    %eax,%edi
lea    -0x2c(%rbp),%rsi
call   1050 <crypt@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x2e2e2e2e2e243124,%rax
2e 2e 2e
mov    %rax,(%rsp)
movl   $0x2e2e2e,0x8(%rsp)
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %ebx,%ecx
shr    $0xe,%ecx
and    $0x30000,%ecx
xor    %eax,%ecx
mov    %ebx,%esi
and    $0x3f,%esi
lea    0xe77(%rip),%rdi
mov    (%rsi,%rdi,1),%dl
mov    %dl,0x3(%rsp)
mov    %ebx,%edx
shr    $0x6,%edx
and    $0x3f,%edx
mov    (%rdx,%rdi,1),%dl
mov    %dl,0x4(%rsp)
mov    %ebx,%edx
shr    $0xc,%edx
and    $0x3f,%edx
mov    (%rdx,%rdi,1),%dl
mov    %dl,0x5(%rsp)
mov    %ebx,%edx
shr    $0x12,%edx
and    $0x3f,%edx
mov    (%rdx,%rdi,1),%dl
mov    %dl,0x6(%rsp)
shr    $0x18,%ebx
and    $0x3f,%ebx
mov    (%rbx,%rdi,1),%dl
mov    %dl,0x7(%rsp)
mov    %eax,%edx
and    $0x3f,%edx
mov    (%rdx,%rdi,1),%dl
mov    %dl,0x8(%rsp)
shr    $0x6,%eax
and    $0x3f,%eax
mov    (%rax,%rdi,1),%al
mov    %al,0x9(%rsp)
shr    $0xc,%ecx
and    $0x3f,%ecx
mov    (%rcx,%rdi,1),%al
mov    %al,0xa(%rsp)
lea    0xe4a(%rip),%rdi
call   1070 <getpass@plt>
mov    %rsp,%rsi
mov    %eax,%edi
call   1050 <crypt@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.salt = [12 x i8] c"$1$........\00"
@.str = [65 x i8] c"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
@.str.1 = [10 x i8] c"Password:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i64]
%3 = alloca [12 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [12 x i8]* %3 to i8*
store i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8** %4
%8 = call i64 @time(i32* null)
%9 = getelementptr inbounds [2 x i64], [2 x i64]* %2, i64 0, i64 0
store i64 %8, i64* %9
%10 = call i64 (...) @getpid()
%11 = getelementptr inbounds [2 x i64], [2 x i64]* %2, i64 0, i64 0
%12 = load i64, i64* %11
%13 = lshr i64 %12, 14
%14 = and i64 %13, 196608
%15 = xor i64 %10, %14
%16 = getelementptr inbounds [2 x i64], [2 x i64]* %2, i64 0, i64 1
store i64 %15, i64* %16
store i32 0, i32* %6
br label %17
17: ; preds = %38, %0
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 8
br i1 %19, label %20, label %41
20: ; preds = %17
%21 = load i32, i32* %6
%22 = sdiv i32 %21, 5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [2 x i64], [2 x i64]* %2, i64 0, i64 %23
%25 = load i64, i64* %24
%26 = load i32, i32* %6
%27 = srem i32 %26, 5
%28 = mul nsw i32 %27, 6
%29 = zext i32 %28 to i64
%30 = lshr i64 %25, %29
%31 = and i64 %30, 63
%32 = getelementptr inbounds i8, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 %31
%33 = load i8, i8* %32
%34 = load i32, i32* %6
%35 = add nsw i32 3, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %36
store i8 %33, i8* %37
br label %38
38: ; preds = %20
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %17
41: ; preds = %17
%42 = call i32 @getpass(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%43 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%44 = call i8* @crypt(i32 %42, i8* %43)
store i8* %44, i8** %5
%45 = load i8*, i8** %5
%46 = call i32 @puts(i8* %45)
ret i32 0
}

LLVM IR (-O2):
@__const.main.salt = [12 x i8] c"$1$........\00"
@.str = [65 x i8] c"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\00"
@.str.1 = [10 x i8] c"Password:\00"
define i32 @main() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%3 = tail call i64 @time(i32* null)
%4 = tail call i64 (...) @getpid()
%5 = lshr i64 %3, 14
%6 = and i64 %5, 196608
%7 = xor i64 %4, %6
%8 = and i64 %3, 63
%9 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 3
store i8 %10, i8* %11
%12 = lshr i64 %3, 6
%13 = and i64 %12, 63
%14 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 4
store i8 %15, i8* %16
%17 = lshr i64 %3, 12
%18 = and i64 %17, 63
%19 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 5
store i8 %20, i8* %21
%22 = lshr i64 %3, 18
%23 = and i64 %22, 63
%24 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 6
store i8 %25, i8* %26
%27 = lshr i64 %3, 24
%28 = and i64 %27, 63
%29 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 7
store i8 %30, i8* %31
%32 = and i64 %4, 63
%33 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 8
store i8 %34, i8* %35
%36 = lshr i64 %4, 6
%37 = and i64 %36, 63
%38 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 9
store i8 %39, i8* %40
%41 = lshr i64 %7, 12
%42 = and i64 %41, 63
%43 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 10
store i8 %44, i8* %45
%46 = tail call i32 @getpass(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%47 = call i8* @crypt(i32 %46, i8* %2)
%48 = call i32 @puts(i8* dereferenceable(1) %47)
ret i32 0
}