#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(char *, char *);
char *getpass(char *);
unsigned long getpid();
int /*<<< orphan*/ puts(char *);
unsigned long time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  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];
  if (argc < 2)
    password = crypt(getpass("Password:"), salt);
  else
    password = crypt(argv[1], salt);
  puts(password);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe93(%rip),%rax
mov    %rax,-0x2c(%rbp)
mov    0xe91(%rip),%eax
mov    %eax,-0x24(%rbp)
lea    0xe8b(%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    1218 <main+0xc8>
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    0xe11(%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    11b6 <main+0x66>
cmpl   $0x2,-0x8(%rbp)
jge    1243 <main+0xf3>
lea    0xe24(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%rdi
lea    -0x2c(%rbp),%rsi
call   1050 <crypt@plt>
mov    %rax,-0x40(%rbp)
jmp    1258 <main+0x108>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
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   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
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    0xe6f(%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)
cmp    $0x1,%ebp
jg     121a <main+0xca>
lea    0xe3d(%rip),%rdi
call   1070 <getpass@plt>
mov    %rax,%rdi
jmp    121e <main+0xce>
mov    0x8(%r14),%rdi
mov    %rsp,%rsi
call   1050 <crypt@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
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(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i64]
%7 = alloca [12 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [12 x i8]* %7 to i8*
store i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8** %8
%12 = call i64 @time(i32* null)
%13 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 0
store i64 %12, i64* %13
%14 = call i64 (...) @getpid()
%15 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 0
%16 = load i64, i64* %15
%17 = lshr i64 %16, 14
%18 = and i64 %17, 196608
%19 = xor i64 %14, %18
%20 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 1
store i64 %19, i64* %20
store i32 0, i32* %10
br label %21
21: ; preds = %42, %2
%22 = load i32, i32* %10
%23 = icmp slt i32 %22, 8
br i1 %23, label %24, label %45
24: ; preds = %21
%25 = load i32, i32* %10
%26 = sdiv i32 %25, 5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [2 x i64], [2 x i64]* %6, i64 0, i64 %27
%29 = load i64, i64* %28
%30 = load i32, i32* %10
%31 = srem i32 %30, 5
%32 = mul nsw i32 %31, 6
%33 = zext i32 %32 to i64
%34 = lshr i64 %29, %33
%35 = and i64 %34, 63
%36 = getelementptr inbounds i8, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 %35
%37 = load i8, i8* %36
%38 = load i32, i32* %10
%39 = add nsw i32 3, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 %40
store i8 %37, i8* %41
br label %42
42: ; preds = %24
%43 = load i32, i32* %10
%44 = add nsw i32 %43, 1
store i32 %44, i32* %10
br label %21
45: ; preds = %21
%46 = load i32, i32* %4
%47 = icmp slt i32 %46, 2
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = call i8* @getpass(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%50 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%51 = call i8* @crypt(i8* %49, i8* %50)
store i8* %51, i8** %9
br label %58
52: ; preds = %45
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%57 = call i8* @crypt(i8* %55, i8* %56)
store i8* %57, i8** %9
br label %58
58: ; preds = %52, %48
%59 = load i8*, i8** %9
%60 = call i32 @puts(i8* %59)
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(i32 %0, i8** nocapture %1) {
%3 = alloca [12 x i8]
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @time(i32* null)
%6 = tail call i64 (...) @getpid()
%7 = lshr i64 %5, 14
%8 = and i64 %7, 196608
%9 = xor i64 %6, %8
%10 = and i64 %5, 63
%11 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 3
store i8 %12, i8* %13
%14 = lshr i64 %5, 6
%15 = and i64 %14, 63
%16 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 4
store i8 %17, i8* %18
%19 = lshr i64 %5, 12
%20 = and i64 %19, 63
%21 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 5
store i8 %22, i8* %23
%24 = lshr i64 %5, 18
%25 = and i64 %24, 63
%26 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 6
store i8 %27, i8* %28
%29 = lshr i64 %5, 24
%30 = and i64 %29, 63
%31 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 7
store i8 %32, i8* %33
%34 = and i64 %6, 63
%35 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 8
store i8 %36, i8* %37
%38 = lshr i64 %6, 6
%39 = and i64 %38, 63
%40 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 9
store i8 %41, i8* %42
%43 = lshr i64 %9, 12
%44 = and i64 %43, 63
%45 = getelementptr inbounds [65 x i8], [65 x i8]* @.str, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 10
store i8 %46, i8* %47
%48 = icmp slt i32 %0, 2
br i1 %48, label %49, label %51
49: ; preds = %2
%50 = tail call i8* @getpass(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %54
51: ; preds = %2
%52 = getelementptr inbounds i8*, i8** %1, i64 1
%53 = load i8*, i8** %52
br label %54
54: ; preds = %51, %49
%55 = phi i8* [ %53, %51 ], [ %50, %49 ]
%56 = call i8* @crypt(i8* %55, i8* %4)
%57 = call i32 @puts(i8* dereferenceable(1) %56)
ret i32 0
}