#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 */
int /*<<< orphan*/ des_crypt(char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/);
int main(int argc, char **argv) {
  char rndChar[] =
      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./";
  char salt[3];
  if (argc == 1) {
    printf("usage: %s passwd\n       %s salt passwd\n", argv[0], argv[0]);
    exit(1);
  }
  srand((unsigned int)time(0));
  salt[0] = (argc > 2) ? (argv[1][0]) : rndChar[rand() % 64];
  salt[1] = (argc > 2) ? (argv[1][1]) : rndChar[rand() % 64];
  salt[3] = 0;
  puts(des_crypt(argv[(argc > 2) ? 2 : 1], salt));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x41,%edx
call   1070 <memcpy@plt>
cmpl   $0x1,-0x8(%rbp)
jne    11d9 <main+0x59>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe77(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
cmpl   $0x2,-0x8(%rbp)
jle    1204 <main+0x84>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x68(%rbp)
jmp    121e <main+0x9e>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x40,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movsbl -0x60(%rbp,%rax,1),%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    %al,-0x63(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1242 <main+0xc2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x6c(%rbp)
jmp    125c <main+0xdc>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x40,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movsbl -0x60(%rbp,%rax,1),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %al,-0x62(%rbp)
movb   $0x0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%esi
mov    $0x1,%ecx
mov    $0x2,%edx
cmp    $0x2,%esi
cmovg  %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x63(%rbp),%rsi
call   1030 <des_crypt@plt>
mov    %eax,%edi
call   1040 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
je     1214 <main+0xa4>
mov    %edi,%ebp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
cmp    $0x3,%ebp
jl     11a9 <main+0x39>
mov    0x8(%rbx),%rax
mov    (%rax),%cl
mov    %cl,0x5(%rsp)
add    $0x1,%rax
mov    $0x2,%ecx
jmp    11eb <main+0x7b>
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
cltq
lea    0xe3a(%rip),%rbp
mov    (%rax,%rbp,1),%al
mov    %al,0x5(%rsp)
xor    %eax,%eax
call   1090 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
cltq
add    %rbp,%rax
mov    $0x1,%ecx
mov    (%rax),%al
mov    %al,0x6(%rsp)
movb   $0x0,0x8(%rsp)
mov    (%rbx,%rcx,8),%rdi
lea    0x5(%rsp),%rsi
call   1030 <des_crypt@plt>
mov    %eax,%edi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    (%rbx),%rdx
lea    0xe23(%rip),%rdi
mov    %rdx,%rsi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@__const.main.rndChar = [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./\00"
@.str = [40 x i8] c"usage: %s passwd\0A %s salt passwd\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [65 x i8]
%7 = alloca [3 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [65 x i8]* %6 to i8*
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = call i64 @time(i32 0)
%22 = trunc i64 %21 to i32
%23 = call i32 @srand(i32 %22)
%24 = load i32, i32* %4
%25 = icmp sgt i32 %24, 2
br i1 %25, label %26, label %33
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
br label %40
33: ; preds = %20
%34 = call i32 (...) @rand()
%35 = srem i32 %34, 64
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
br label %40
40: ; preds = %33, %26
%41 = phi i32 [ %32, %26 ], [ %39, %33 ]
%42 = trunc i32 %41 to i8
%43 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
store i8 %42, i8* %43
%44 = load i32, i32* %4
%45 = icmp sgt i32 %44, 2
br i1 %45, label %46, label %53
46: ; preds = %40
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = getelementptr inbounds i8, i8* %49, i64 1
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
br label %60
53: ; preds = %40
%54 = call i32 (...) @rand()
%55 = srem i32 %54, 64
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [65 x i8], [65 x i8]* %6, i64 0, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
br label %60
60: ; preds = %53, %46
%61 = phi i32 [ %52, %46 ], [ %59, %53 ]
%62 = trunc i32 %61 to i8
%63 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 1
store i8 %62, i8* %63
%64 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 3
store i8 0, i8* %64
%65 = load i8**, i8*** %5
%66 = load i32, i32* %4
%67 = icmp sgt i32 %66, 2
%68 = zext i1 %67 to i64
%69 = select i1 %67, i32 2, i32 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %65, i64 %70
%72 = load i8*, i8** %71
%73 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 0
%74 = call i32 @des_crypt(i8* %72, i8* %73)
%75 = call i32 @puts(i32 %74)
%76 = load i32, i32* %3
ret i32 %76
}

LLVM IR (-O2):
@__const.main.rndChar = [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./\00"
@.str = [40 x i8] c"usage: %s passwd\0A %s salt passwd\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i8]
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = tail call i64 @time(i32 0)
%12 = trunc i64 %11 to i32
%13 = tail call i32 @srand(i32 %12)
%14 = icmp sgt i32 %0, 2
br i1 %14, label %15, label %20
15: ; preds = %10
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = load i8, i8* %17
store i8 %18, i8* %4
%19 = getelementptr inbounds i8, i8* %17, i64 1
br label %30
20: ; preds = %10
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 64
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.main.rndChar, i64 0, i64 %23
%25 = load i8, i8* %24
store i8 %25, i8* %4
%26 = tail call i32 (...) @rand()
%27 = srem i32 %26, 64
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.main.rndChar, i64 0, i64 %28
br label %30
30: ; preds = %20, %15
%31 = phi i64 [ 1, %20 ], [ 2, %15 ]
%32 = phi i8* [ %29, %20 ], [ %19, %15 ]
%33 = load i8, i8* %32
%34 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 1
store i8 %33, i8* %34
%35 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 3
store i8 0, i8* %35
%36 = getelementptr inbounds i8*, i8** %1, i64 %31
%37 = load i8*, i8** %36
%38 = call i32 @des_crypt(i8* %37, i8* %4)
%39 = call i32 @puts(i32 %38)
ret i32 0
}