#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 */
int /*<<< orphan*/ EXIT_FAILURE;
char *crypt(char *, char *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int rand();
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
char *strerror(scalar_t__);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Usage: %s plain_text_file\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  errno = 0;
  FILE *in = fopen(argv[1], "r");
  if (in == NULL) {
    printf("%s: Couldn't open file %s; %s\n", argv[0], argv[1],
           strerror(errno));
    exit(EXIT_FAILURE);
  }
  time_t t;
  time(&t);
  srand(t);
  int count = 0;
  while (!feof(in)) {
    char text[50];
    fscanf(in, "%s\n", text);
    char salt[20];
    sprintf(salt, "$1$");
    char dict[] =
        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
    int i = 0;
    for (i = 3; i < 8 + 3; i++)
      salt[i] = dict[rand() % 64];
    salt[i] = '$';
    salt[i + 1] = '\0';
    printf("user%d:%s\n", count++, crypt(text, salt));
  }
  fclose(in);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1216 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
mov    0x2dc3(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde8(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12a0 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0xe0(%rbp)
mov    0x2d75(%rip),%rax
mov    (%rax),%rdi
call   10e0 <strerror@plt>
mov    -0xe8(%rbp),%rsi
mov    -0xe0(%rbp),%rdx
mov    %rax,%rcx
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
lea    -0x1c(%rbp),%rdi
call   10a0 <time@plt>
mov    -0x1c(%rbp),%edi
call   1070 <srand@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12d6 <main+0x106>
jmp    13c5 <main+0x1f5>
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xd53(%rip),%rsi
call   1060 <fscanf@plt>
lea    -0x80(%rbp),%rdi
lea    0xd47(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0xd0(%rbp),%rdi
lea    0xd48(%rip),%rsi
mov    $0x41,%edx
call   1090 <memcpy@plt>
movl   $0x0,-0xd4(%rbp)
movl   $0x3,-0xd4(%rbp)
cmpl   $0xb,-0xd4(%rbp)
jge    136b <main+0x19b>
mov    $0x0,%al
call   10f0 <rand@plt>
mov    $0x40,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
mov    -0xd0(%rbp,%rax,1),%cl
movslq -0xd4(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1326 <main+0x156>
movslq -0xd4(%rbp),%rax
movb   $0x24,-0x80(%rbp,%rax,1)
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x80(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp)
cltq
mov    %rax,-0xf0(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1030 <crypt@plt>
mov    -0xf0(%rbp),%rsi
mov    %rax,%rdx
lea    0xc87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12b8 <main+0xe8>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbp
cmp    $0x1,%edi
jle    1394 <main+0x1e4>
mov    0x2e0f(%rip),%r14
movq   $0x0,(%r14)
mov    0x8(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     13a8 <main+0x1f8>
mov    %rax,%rbx
lea    0x1c(%rsp),%rdi
call   1090 <time@plt>
mov    0x1c(%rsp),%edi
call   1070 <srand@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    137b <main+0x1cb>
lea    0x20(%rsp),%r15
lea    0xe2d(%rip),%r14
lea    0xe12(%rip),%r13
xor    %r12d,%r12d
nopl   (%rax)
mov    %rbx,%rdi
lea    0xdfe(%rip),%rsi
mov    %r15,%rdx
call   1060 <fscanf@plt>
movl   $0x243124,(%rsp)
xor    %eax,%eax
call   10d0 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
cltq
movzbl (%rax,%r14,1),%eax
mov    %al,0x3(%rsp)
xor    %eax,%eax
call   10d0 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
cltq
movzbl (%rax,%r14,1),%eax
mov    %al,0x4(%rsp)
xor    %eax,%eax
call   10d0 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
cltq
movzbl (%rax,%r14,1),%eax
mov    %al,0x5(%rsp)
xor    %eax,%eax
call   10d0 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
cltq
movzbl (%rax,%r14,1),%eax
mov    %al,0x6(%rsp)
xor    %eax,%eax
call   10d0 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
cltq
movzbl (%rax,%r14,1),%eax
mov    %al,0x7(%rsp)
xor    %eax,%eax
call   10d0 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
cltq
movzbl (%rax,%r14,1),%eax
mov    %al,0x8(%rsp)
xor    %eax,%eax
call   10d0 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
cltq
movzbl (%rax,%r14,1),%eax
mov    %al,0x9(%rsp)
xor    %eax,%eax
call   10d0 <rand@plt>
lea    0x3f(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xffffffc0,%ecx
sub    %ecx,%eax
cltq
movzbl (%rax,%r14,1),%eax
mov    %al,0xa(%rsp)
movw   $0x24,0xb(%rsp)
lea    0x1(%r12),%rbp
mov    %r15,%rdi
mov    %rsp,%rsi
call   1030 <crypt@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
mov    %rbp,%r12
test   %eax,%eax
je     1230 <main+0x80>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%rbp),%rsi
lea    0xc61(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    13cf <main+0x21f>
mov    0x0(%rbp),%rbx
mov    0x8(%rbp),%rbp
mov    (%r14),%rdi
call   10c0 <strerror@plt>
lea    0xc5e(%rip),%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c02(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"Usage: %s plain_text_file\0A\00"
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"%s: Couldn't open file %s; %s\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [4 x i8] c"$1$\00"
@__const.main.dict = [65 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./\00"
@.str.5 = [11 x i8] c"user%d:%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [50 x i8]
%10 = alloca [20 x i8]
%11 = alloca [65 x i8]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
store i64 0, i64* @errno
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %6
%27 = load i32*, i32** %6
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %41
29: ; preds = %22
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i64, i64* @errno
%37 = call i8* @strerror(i64 %36)
%38 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %32, i8* %35, i8* %37)
%39 = load i32, i32* @EXIT_FAILURE
%40 = call i32 @exit(i32 %39)
unreachable
41: ; preds = %22
%42 = call i32 @time(i32* %7)
%43 = load i32, i32* %7
%44 = call i32 @srand(i32 %43)
store i32 0, i32* %8
br label %45
45: ; preds = %72, %41
%46 = load i32*, i32** %6
%47 = call i32 @feof(i32* %46)
%48 = icmp ne i32 %47, 0
%49 = xor i1 %48, true
br i1 %49, label %50, label %88
50: ; preds = %45
%51 = load i32*, i32** %6
%52 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%53 = call i32 @fscanf(i32* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%55 = call i32 @sprintf(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%56 = bitcast [65 x i8]* %11 to i8*
store i32 0, i32* %12
store i32 3, i32* %12
br label %57
57: ; preds = %69, %50
%58 = load i32, i32* %12
%59 = icmp slt i32 %58, 11
br i1 %59, label %60, label %72
60: ; preds = %57
%61 = call i32 (...) @rand()
%62 = srem i32 %61, 64
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [65 x i8], [65 x i8]* %11, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = load i32, i32* %12
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %67
store i8 %65, i8* %68
br label %69
69: ; preds = %60
%70 = load i32, i32* %12
%71 = add nsw i32 %70, 1
store i32 %71, i32* %12
br label %57
72: ; preds = %57
%73 = load i32, i32* %12
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %74
store i8 36, i8* %75
%76 = load i32, i32* %12
%77 = add nsw i32 %76, 1
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 %78
store i8 0, i8* %79
%80 = load i32, i32* %8
%81 = add nsw i32 %80, 1
store i32 %81, i32* %8
%82 = sext i32 %80 to i64
%83 = inttoptr i64 %82 to i8*
%84 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%85 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%86 = call i8* @crypt(i8* %84, i8* %85)
%87 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %83, i8* %86)
br label %45
88: ; preds = %45
%89 = load i32*, i32** %6
%90 = call i32 @fclose(i32* %89)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Usage: %s plain_text_file\0A\00"
@EXIT_FAILURE = global i32 0
@errno = global i64 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [31 x i8] c"%s: Couldn't open file %s; %s\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@__const.main.dict = [65 x i8] c"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./\00"
@.str.5 = [11 x i8] c"user%d:%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [50 x i8]
%5 = alloca [20 x i8]
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
store i64 0, i64* @errno
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %25
17: ; preds = %12
%18 = load i8*, i8** %1
%19 = load i8*, i8** %13
%20 = load i64, i64* @errno
%21 = tail call i8* @strerror(i64 %20)
%22 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %19, i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %12
%26 = bitcast i32* %3 to i8*
%27 = call i32 @time(i32* %3)
%28 = load i32, i32* %3
%29 = call i32 @srand(i32 %28)
%30 = call i32 @feof(i32* %15)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %95
32: ; preds = %25
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%35 = bitcast [20 x i8]* %5 to i32*
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 3
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 4
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 5
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 6
%40 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 7
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 8
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 9
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 10
%44 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 11
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 12
br label %46
46: ; preds = %32, %46
%47 = phi i64 [ 0, %32 ], [ %89, %46 ]
%48 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %33)
store i32 2371876, i32* %35
%49 = call i32 (...) @rand()
%50 = srem i32 %49, 64
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.main.dict, i64 0, i64 %51
%53 = load i8, i8* %52
store i8 %53, i8* %36
%54 = call i32 (...) @rand()
%55 = srem i32 %54, 64
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.main.dict, i64 0, i64 %56
%58 = load i8, i8* %57
store i8 %58, i8* %37
%59 = call i32 (...) @rand()
%60 = srem i32 %59, 64
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.main.dict, i64 0, i64 %61
%63 = load i8, i8* %62
store i8 %63, i8* %38
%64 = call i32 (...) @rand()
%65 = srem i32 %64, 64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.main.dict, i64 0, i64 %66
%68 = load i8, i8* %67
store i8 %68, i8* %39
%69 = call i32 (...) @rand()
%70 = srem i32 %69, 64
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.main.dict, i64 0, i64 %71
%73 = load i8, i8* %72
store i8 %73, i8* %40
%74 = call i32 (...) @rand()
%75 = srem i32 %74, 64
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.main.dict, i64 0, i64 %76
%78 = load i8, i8* %77
store i8 %78, i8* %41
%79 = call i32 (...) @rand()
%80 = srem i32 %79, 64
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.main.dict, i64 0, i64 %81
%83 = load i8, i8* %82
store i8 %83, i8* %42
%84 = call i32 (...) @rand()
%85 = srem i32 %84, 64
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.main.dict, i64 0, i64 %86
%88 = load i8, i8* %87
store i8 %88, i8* %43
store i8 36, i8* %44
store i8 0, i8* %45
%89 = add nuw i64 %47, 1
%90 = inttoptr i64 %47 to i8*
%91 = call i8* @crypt(i8* %33, i8* %34)
%92 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %90, i8* %91)
%93 = call i32 @feof(i32* %15)
%94 = icmp eq i32 %93, 0
br i1 %94, label %46, label %95
95: ; preds = %46, %25
%96 = call i32 @fclose(i32* %15)
ret i32 0
}