#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*/ crypt(char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int fscanf(int /*<<< orphan*/ *, char *, char **);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int strlen(char *);
int check_dict(char *hash, char *salt) {
  FILE *dict = fopen("dict/american-english", "r");
  if (!dict) {
    return 2;
  }
  char *dict_word;
  while (fscanf(dict, "%ms", &dict_word) == 1) {
    if (strlen(dict_word) > 8) {
      free(dict_word);
      continue;
    }
    if (strcmp(crypt(dict_word, salt), hash) == 0) {
      printf("%s\n", dict_word);
      free(dict_word);
      return 0;
    }
    free(dict_word);
  }
  return 1;
}


x86 assembly (clang, -O0):
<check_dict>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    0xe79(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ae <check_dict+0x3e>
movl   $0x2,-0x4(%rbp)
jmp    124c <check_dict+0xdc>
jmp    11b3 <check_dict+0x43>
mov    -0x20(%rbp),%rdi
lea    0xe5a(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1070 <fscanf@plt>
cmp    $0x1,%eax
jne    1245 <check_dict+0xd5>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x8,%eax
jle    11f0 <check_dict+0x80>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    11b3 <check_dict+0x43>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <crypt@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1237 <check_dict+0xc7>
mov    -0x28(%rbp),%rsi
lea    0xdff(%rip),%rdi
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    124c <check_dict+0xdc>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    11b3 <check_dict+0x43>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_dict>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xe78(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1235 <check_dict+0xc5>
mov    %rax,%rbp
lea    0xe71(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1070 <fscanf@plt>
mov    $0x1,%r15d
cmp    $0x1,%eax
jne    123b <check_dict+0xcb>
lea    0xe50(%rip),%r13
mov    %rsp,%rbx
jmp    11eb <check_dict+0x7b>
nopl   (%rax)
mov    %rsi,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <fscanf@plt>
cmp    $0x1,%eax
jne    123b <check_dict+0xcb>
mov    (%rsp),%rdi
call   1050 <strlen@plt>
mov    (%rsp),%rsi
cmp    $0x9,%eax
jge    11d0 <check_dict+0x60>
mov    %rsi,%rdi
mov    %r14,%rsi
call   1040 <crypt@plt>
mov    %eax,%edi
mov    %r12,%rsi
call   1080 <strcmp@plt>
mov    (%rsp),%rsi
test   %rax,%rax
jne    11d0 <check_dict+0x60>
lea    0xdfa(%rip),%rdi
call   1060 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %r15d,%r15d
jmp    123b <check_dict+0xcb>
mov    $0x2,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"dict/american-english\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%ms\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @check_dict(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %2
store i32 2, i32* %3
br label %40
12: ; preds = %2
br label %13
13: ; preds = %36, %21, %12
%14 = load i32*, i32** %6
%15 = call i32 @fscanf(i32* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %7)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %39
17: ; preds = %13
%18 = load i8*, i8** %7
%19 = call i32 @strlen(i8* %18)
%20 = icmp sgt i32 %19, 8
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i8*, i8** %7
%23 = call i32 @free(i8* %22)
br label %13
24: ; preds = %17
%25 = load i8*, i8** %7
%26 = load i8*, i8** %5
%27 = call i32 @crypt(i8* %25, i8* %26)
%28 = load i8*, i8** %4
%29 = call i64 @strcmp(i32 %27, i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %24
%32 = load i8*, i8** %7
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %32)
%34 = load i8*, i8** %7
%35 = call i32 @free(i8* %34)
store i32 0, i32* %3
br label %40
36: ; preds = %24
%37 = load i8*, i8** %7
%38 = call i32 @free(i8* %37)
br label %13
39: ; preds = %13
store i32 1, i32* %3
br label %40
40: ; preds = %39, %31, %11
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [22 x i8] c"dict/american-english\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%ms\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @check_dict(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %31, label %6
6: ; preds = %2
%7 = bitcast i8** %3 to i8*
%8 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %3)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %29
10: ; preds = %6, %15
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = icmp sgt i32 %12, 8
%14 = load i8*, i8** %3
br i1 %13, label %15, label %20
15: ; preds = %10, %20
%16 = phi i8* [ %24, %20 ], [ %14, %10 ]
%17 = call i32 @free(i8* %16)
%18 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %3)
%19 = icmp eq i32 %18, 1
br i1 %19, label %10, label %29
20: ; preds = %10
%21 = call i32 @crypt(i8* %14, i8* %1)
%22 = call i64 @strcmp(i32 %21, i8* %0)
%23 = icmp eq i64 %22, 0
%24 = load i8*, i8** %3
br i1 %23, label %25, label %15
25: ; preds = %20
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%27 = load i8*, i8** %3
%28 = call i32 @free(i8* %27)
br label %29
29: ; preds = %15, %6, %25
%30 = phi i32 [ 0, %25 ], [ 1, %6 ], [ 1, %15 ]
br label %31
31: ; preds = %2, %29
%32 = phi i32 [ %30, %29 ], [ 2, %2 ]
ret i32 %32
}