#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 */
scalar_t__ crypt(char *, char const *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char const *);
bool compare(const char *key, const char *salt, const char dictionary_path[],
             bool verbose) {
  FILE *fp;
  char *word;
  char *encrypted_word;
  char *variant;
  word = (char *)malloc(sizeof(char) * 40);
  encrypted_word = (char *)malloc(sizeof(char) * 25);
  variant = (char *)malloc(sizeof(char) * 40);
  fp = fopen(dictionary_path, "r+t");
  if (fp == NULL) {
    fprintf(stderr, "Cannot open \"%s\"\n", dictionary_path);
    return true;
  }
  if (verbose) {
    fprintf(stdout, "Searching in %s...\n", dictionary_path);
  }
  while (!feof(fp)) {
    fscanf(fp, "%s\n", word);
    if (verbose) {
      fprintf(stdout, "%s\n", word);
    }
    encrypted_word = (char *)crypt(word, salt);
    if (strcmp(encrypted_word, key) == 0) {
      fprintf(stdout, "%s\n", word);
      fclose(fp);
      return false;
    }
  }
  return true;
}


x86 assembly (clang, -O0):
<compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    $0x28,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    $0x19,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x28,%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1205 <compare+0x85>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe10(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12e4 <compare+0x164>
cmpl   $0x0,-0x24(%rbp)
je     1228 <compare+0xa8>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdf3(%rip),%rsi
call   1070 <fprintf@plt>
jmp    122d <compare+0xad>
mov    -0x30(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    124b <compare+0xcb>
jmp    12dd <compare+0x15d>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xdd0(%rip),%rsi
call   1050 <fscanf@plt>
cmpl   $0x0,-0x24(%rbp)
je     1282 <compare+0x102>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xdad(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <crypt@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12d8 <compare+0x158>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xd6c(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    12e4 <compare+0x164>
jmp    122d <compare+0xad>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x28,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    $0x19,%edi
call   1090 <malloc@plt>
mov    $0x28,%edi
call   1090 <malloc@plt>
lea    0xe41(%rip),%rsi
mov    %r13,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1250 <compare+0xd0>
mov    %rax,%rbp
test   %r12d,%r12d
je     11f0 <compare+0x70>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe2e(%rip),%rsi
mov    %r13,%rdx
call   1070 <fprintf@plt>
lea    0xe33(%rip),%r13
jmp    121b <compare+0x9b>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <crypt@plt>
mov    %rax,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     126f <compare+0xef>
mov    %rbp,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1268 <compare+0xe8>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1050 <fscanf@plt>
test   %r12d,%r12d
je     1200 <compare+0x80>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
jmp    1200 <compare+0x80>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
lea    0xda4(%rip),%rsi
mov    %r13,%rdx
call   1070 <fprintf@plt>
mov    $0x1,%eax
jmp    1291 <compare+0x111>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"r+t\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"Cannot open \22%s\22\0A\00"
@stdout = global i32 0
@.str.2 = [20 x i8] c"Searching in %s...\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @compare(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%14 = call i64 @malloc(i32 40)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %11
%16 = call i64 @malloc(i32 25)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %12
%18 = call i64 @malloc(i32 40)
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %13
%20 = load i8*, i8** %8
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %10
%22 = load i32*, i32** %10
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %28
24: ; preds = %4
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %8
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %26)
store i32 1, i32* %5
br label %68
28: ; preds = %4
%29 = load i32, i32* %9
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load i32, i32* @stdout
%33 = load i8*, i8** %8
%34 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %31, %28
br label %36
36: ; preds = %66, %35
%37 = load i32*, i32** %10
%38 = call i32 @feof(i32* %37)
%39 = icmp ne i32 %38, 0
%40 = xor i1 %39, true
br i1 %40, label %41, label %67
41: ; preds = %36
%42 = load i32*, i32** %10
%43 = load i8*, i8** %11
%44 = call i32 @fscanf(i32* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %43)
%45 = load i32, i32* %9
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %41
%48 = load i32, i32* @stdout
%49 = load i8*, i8** %11
%50 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %47, %41
%52 = load i8*, i8** %11
%53 = load i8*, i8** %7
%54 = call i64 @crypt(i8* %52, i8* %53)
%55 = inttoptr i64 %54 to i8*
store i8* %55, i8** %12
%56 = load i8*, i8** %12
%57 = load i8*, i8** %6
%58 = call i64 @strcmp(i8* %56, i8* %57)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %51
%61 = load i32, i32* @stdout
%62 = load i8*, i8** %11
%63 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %62)
%64 = load i32*, i32** %10
%65 = call i32 @fclose(i32* %64)
store i32 0, i32* %5
br label %68
66: ; preds = %51
br label %36
67: ; preds = %36
store i32 1, i32* %5
br label %68
68: ; preds = %67, %60, %24
%69 = load i32, i32* %5
ret i32 %69
}

LLVM IR (-O2):
@.str = [4 x i8] c"r+t\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"Cannot open \22%s\22\0A\00"
@stdout = global i32 0
@.str.2 = [20 x i8] c"Searching in %s...\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @compare(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i64 @malloc(i32 40)
%6 = inttoptr i64 %5 to i8*
%7 = tail call i64 @malloc(i32 25)
%8 = tail call i64 @malloc(i32 40)
%9 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %37
14: ; preds = %4
%15 = icmp eq i32 %3, 0
br i1 %15, label %19, label %16
16: ; preds = %14
%17 = load i32, i32* @stdout
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %19
19: ; preds = %16, %14
br label %20
20: ; preds = %19, %28
%21 = tail call i32 @feof(i32* %9)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %37
23: ; preds = %20
%24 = tail call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br i1 %15, label %28, label %25
25: ; preds = %23
%26 = load i32, i32* @stdout
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %28
28: ; preds = %25, %23
%29 = tail call i64 @crypt(i8* %6, i8* %1)
%30 = inttoptr i64 %29 to i8*
%31 = tail call i64 @strcmp(i8* %30, i8* %0)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %20
33: ; preds = %28
%34 = load i32, i32* @stdout
%35 = tail call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%36 = tail call i32 @fclose(i32* %9)
br label %37
37: ; preds = %20, %33, %11
%38 = phi i32 [ 1, %11 ], [ 0, %33 ], [ 1, %20 ]
ret i32 %38
}