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

/* Variables and functions */
int /*<<< orphan*/ barf(char *, char *);
char *crypt(char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main(int argc, char *argv[]) {
  FILE *wordlist;
  char *hash, word[30], salt[3];
  if (argc < 2)
    barf("Usage: %s <wordlist file> <password hash>\n", argv[0]);
  strncpy(salt, argv[2], 2);
  salt[2] = '\0';
  printf("Salt value is \'%s\'\n", salt);
  if ((wordlist = fopen(argv[1], "r")) == NULL)
    barf("Fatal: couldn't open the file \'%s\'.\n", argv[1]);
  while (fgets(word, 30, wordlist) != NULL) {
    word[strlen(word) - 1] = '\0';
    hash = crypt(word, salt);
    printf("trying word:   %-30s ==> %15s\n", word, hash);
    if (strcmp(hash, argv[2]) == 0) {
      printf("The hash \"%s\" is from the ", argv[2]);
      printf("plaintext password \"%s\".\n", word);
      fclose(wordlist);
      exit(0);
    }
  }
  printf("Couldn't find the plaintext password in the supplied wordlist.\n");
  fclose(wordlist);
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    11d3 <main+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe32(%rip),%rdi
call   1040 <barf@plt>
lea    -0x43(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x41(%rbp)
lea    -0x43(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe31(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1235 <main+0x95>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe11(%rip),%rdi
call   1040 <barf@plt>
jmp    123a <main+0x9a>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x1e,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     12e8 <main+0x148>
lea    -0x40(%rbp),%rdi
call   1070 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x40(%rbp,%rax,1)
lea    -0x40(%rbp),%rdi
lea    -0x43(%rbp),%rsi
call   1050 <crypt@plt>
mov    %rax,-0x20(%rbp)
lea    -0x40(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    12e3 <main+0x143>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
jmp    123a <main+0x9a>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
cmp    $0x1,%edi
jg     11d5 <main+0x25>
mov    (%r14),%rsi
lea    0xe30(%rip),%rdi
call   1050 <barf@plt>
mov    0x10(%r14),%rsi
lea    0xd(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xf(%rsp)
lea    0xe34(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x8(%r14),%rdi
lea    0xe33(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1229 <main+0x79>
mov    0x8(%r14),%rsi
lea    0xe1d(%rip),%rdi
call   1050 <barf@plt>
lea    0x10(%rsp),%rbx
lea    0xd(%rsp),%r12
lea    0xe2c(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1e,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     12c7 <main+0x117>
mov    %rbx,%rdi
call   1080 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <crypt@plt>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x10(%r14),%rsi
mov    %rbp,%rdi
call   10b0 <strcmp@plt>
test   %rax,%rax
jne    1240 <main+0x90>
mov    0x10(%r14),%rsi
lea    0xde7(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xdf4(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    0xdec(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Usage: %s <wordlist file> <password hash>\0A\00"
@.str.1 = [20 x i8] c"Salt value is '%s'\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [37 x i8] c"Fatal: couldn't open the file '%s'.\0A\00"
@.str.4 = [31 x i8] c"trying word: %-30s ==> %15s\0A\00"
@.str.5 = [27 x i8] c"The hash \22%s\22 is from the \00"
@.str.6 = [26 x i8] c"plaintext password \22%s\22.\0A\00"
@.str.7 = [64 x i8] c"Couldn't find the plaintext password in the supplied wordlist.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca [30 x i8]
%9 = alloca [3 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @barf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %12, %2
%18 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @strncpy(i8* %18, i8* %21, i32 2)
%23 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 2
store i8 0, i8* %23
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %29, i32** %6
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %36
31: ; preds = %17
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @barf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %31, %17
br label %37
37: ; preds = %70, %36
%38 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%39 = load i32*, i32** %6
%40 = call i32* @fgets(i8* %38, i32 30, i32* %39)
%41 = icmp ne i32* %40, null
br i1 %41, label %42, label %71
42: ; preds = %37
%43 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%44 = call i32 @strlen(i8* %43)
%45 = sub nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 %46
store i8 0, i8* %47
%48 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%49 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%50 = call i8* @crypt(i8* %48, i8* %49)
store i8* %50, i8** %7
%51 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%52 = load i8*, i8** %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %51, i8* %52)
%54 = load i8*, i8** %7
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 2
%57 = load i8*, i8** %56
%58 = call i64 @strcmp(i8* %54, i8* %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %70
60: ; preds = %42
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %63)
%65 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %65)
%67 = load i32*, i32** %6
%68 = call i32 @fclose(i32* %67)
%69 = call i32 @exit(i32 0)
unreachable
70: ; preds = %42
br label %37
71: ; preds = %37
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.7, i64 0, i64 0))
%73 = load i32*, i32** %6
%74 = call i32 @fclose(i32* %73)
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@.str = [43 x i8] c"Usage: %s <wordlist file> <password hash>\0A\00"
@.str.1 = [20 x i8] c"Salt value is '%s'\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [37 x i8] c"Fatal: couldn't open the file '%s'.\0A\00"
@.str.4 = [31 x i8] c"trying word: %-30s ==> %15s\0A\00"
@.str.5 = [27 x i8] c"The hash \22%s\22 is from the \00"
@.str.6 = [26 x i8] c"plaintext password \22%s\22.\0A\00"
@str = [63 x i8] c"Couldn't find the plaintext password in the supplied wordlist.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [30 x i8]
%4 = alloca [3 x i8]
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @barf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %11
11: ; preds = %8, %2
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = call i32 @strncpy(i8* %6, i8* %13, i32 2)
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
store i8 0, i8* %15
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %11
%22 = load i8*, i8** %17
%23 = call i32 @barf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21, %11
br label %25
25: ; preds = %24, %28
%26 = call i32* @fgets(i8* %5, i32 30, i32* %19)
%27 = icmp eq i32* %26, null
br i1 %27, label %44, label %28
28: ; preds = %25
%29 = call i32 @strlen(i8* %5)
%30 = add nsw i32 %29, -1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 %31
store i8 0, i8* %32
%33 = call i8* @crypt(i8* %5, i8* %6)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %5, i8* %33)
%35 = load i8*, i8** %12
%36 = call i64 @strcmp(i8* %33, i8* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %25
38: ; preds = %28
%39 = load i8*, i8** %12
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %39)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%42 = call i32 @fclose(i32* %19)
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %25
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
%46 = call i32 @fclose(i32* %19)
ret i32 0
}