#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__ CryptCrack(char *, char *);
int EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ isprint(int);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(int argc, char *argv[]) {
  FILE *pDicFile;
  int charInput, index = 0;
  char word[128];
  if (argc != 2) {
    printf("Parameter number error.\n");
    return 1;
  }
  if (strlen(argv[1]) != 13) {
    printf("Ciphertext length error.(Should be 13 characters)\n");
    return 1;
  }
  pDicFile = fopen("/usr/share/dict/words", "r");
  if (pDicFile == NULL) {
    printf("Cannot find dictionary file: %s\n", "/usr/share/dict/words");
    return 1;
  }
  do {
    charInput = fgetc(pDicFile);
    if (charInput == '\n') {
      word[index] = '\0';
      index = 0;
      if (strlen(word) <= 8) {
        if (CryptCrack(word, argv[1])) {
          printf("Password: %s\n", word);
          break;
        }
      }
    }
    if (isprint(charInput)) {
      if (index < (128 - 1))
        word[index++] = (char)charInput;
      else {
        word[128 - 1] = '\0';
        printf("Word is too long: %s\n", word);
        index = 0;
      }
    }
  } while (charInput != EOF);
  fclose(pDicFile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b4 <main+0x44>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1332 <main+0x1c2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
cmp    $0xd,%eax
je     11e4 <main+0x74>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1332 <main+0x1c2>
lea    0xe61(%rip),%rdi
lea    0xe70(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1227 <main+0xb7>
lea    0xe57(%rip),%rdi
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1332 <main+0x1c2>
jmp    122c <main+0xbc>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jne    12ac <main+0x13c>
movslq -0x20(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
movl   $0x0,-0x20(%rbp)
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x8,%eax
jg     12a7 <main+0x137>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1090 <CryptCrack@plt>
cmp    $0x0,%rax
je     12a2 <main+0x132>
lea    -0xa0(%rbp),%rsi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1322 <main+0x1b2>
jmp    12a7 <main+0x137>
jmp    12ac <main+0x13c>
mov    -0x1c(%rbp),%edi
call   1070 <isprint@plt>
cmp    $0x0,%rax
je     130b <main+0x19b>
cmpl   $0x7f,-0x20(%rbp)
jge    12e6 <main+0x176>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x20(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x20(%rbp)
cltq
mov    %cl,-0xa0(%rbp,%rax,1)
jmp    1306 <main+0x196>
movb   $0x0,-0x21(%rbp)
lea    -0xa0(%rbp),%rsi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x20(%rbp)
jmp    130b <main+0x19b>
jmp    1310 <main+0x1a0>
mov    -0x1c(%rbp),%eax
mov    0x2cce(%rip),%rcx
cmp    (%rcx),%eax
jne    122c <main+0xbc>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
cmp    $0x2,%edi
jne    1259 <main+0xd9>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1050 <strlen@plt>
cmp    $0xd,%eax
jne    1262 <main+0xe2>
lea    0xe4a(%rip),%rdi
lea    0xe59(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1285 <main+0x105>
mov    %rax,%rbx
xor    %r12d,%r12d
mov    %rsp,%r15
mov    0x2e0d(%rip),%r13
jmp    11f5 <main+0x75>
nopl   (%rax)
movslq %r12d,%rax
add    $0x1,%r12d
mov    %bpl,(%rsp,%rax,1)
cmp    0x0(%r13),%ebp
je     12ad <main+0x12d>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
mov    %eax,%ebp
cmp    $0xa,%eax
jne    122c <main+0xac>
movslq %r12d,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %r15,%rdi
call   1050 <strlen@plt>
xor    %r12d,%r12d
cmp    $0x8,%eax
jg     122c <main+0xac>
mov    0x8(%r14),%rsi
mov    %r15,%rdi
call   10a0 <CryptCrack@plt>
test   %rax,%rax
jne    129c <main+0x11c>
mov    %ebp,%edi
call   1080 <isprint@plt>
test   %rax,%rax
je     11eb <main+0x6b>
cmp    $0x7e,%r12d
jle    11e0 <main+0x60>
movb   $0x0,0x7f(%rsp)
xor    %r12d,%r12d
lea    0xdfa(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11eb <main+0x6b>
lea    0xe2f(%rip),%rdi
jmp    1269 <main+0xe9>
lea    0xdf4(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd8c(%rip),%rdi
lea    0xd6d(%rip),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    126e <main+0xee>
lea    0xd96(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    1273 <main+0xf3>

LLVM IR (-O0):
@.str = [25 x i8] c"Parameter number error.\0A\00"
@.str.1 = [51 x i8] c"Ciphertext length error.(Should be 13 characters)\0A\00"
@.str.2 = [22 x i8] c"/usr/share/dict/words\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [33 x i8] c"Cannot find dictionary file: %s\0A\00"
@.str.5 = [14 x i8] c"Password: %s\0A\00"
@.str.6 = [22 x i8] c"Word is too long: %s\0A\00"
@EOF = global i32 0
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 [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %80
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strlen(i8* %17)
%19 = icmp ne i32 %18, 13
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %80
22: ; preds = %14
%23 = call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %80
28: ; preds = %22
br label %29
29: ; preds = %73, %28
%30 = load i32*, i32** %6
%31 = call i32 @fgetc(i32* %30)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %53
34: ; preds = %29
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %36
store i8 0, i8* %37
store i32 0, i32* %8
%38 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
%40 = icmp sle i32 %39, 8
br i1 %40, label %41, label %52
41: ; preds = %34
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i64 @CryptCrack(i8* %42, i8* %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %41
%49 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %49)
br label %77
51: ; preds = %41
br label %52
52: ; preds = %51, %34
br label %53
53: ; preds = %52, %29
%54 = load i32, i32* %7
%55 = call i64 @isprint(i32 %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %72
57: ; preds = %53
%58 = load i32, i32* %8
%59 = icmp slt i32 %58, 127
br i1 %59, label %60, label %67
60: ; preds = %57
%61 = load i32, i32* %7
%62 = trunc i32 %61 to i8
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 1
store i32 %64, i32* %8
%65 = sext i32 %63 to i64
%66 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 %65
store i8 %62, i8* %66
br label %71
67: ; preds = %57
%68 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 127
store i8 0, i8* %68
%69 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %69)
store i32 0, i32* %8
br label %71
71: ; preds = %67, %60
br label %72
72: ; preds = %71, %53
br label %73
73: ; preds = %72
%74 = load i32, i32* %7
%75 = load i32, i32* @EOF
%76 = icmp ne i32 %74, %75
br i1 %76, label %29, label %77
77: ; preds = %73, %48
%78 = load i32*, i32** %6
%79 = call i32 @fclose(i32* %78)
store i32 0, i32* %3
br label %80
80: ; preds = %77, %26, %20, %12
%81 = load i32, i32* %3
ret i32 %81
}

LLVM IR (-O2):
@.str.2 = [22 x i8] c"/usr/share/dict/words\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [33 x i8] c"Cannot find dictionary file: %s\0A\00"
@.str.5 = [14 x i8] c"Password: %s\0A\00"
@.str.6 = [22 x i8] c"Word is too long: %s\0A\00"
@EOF = global i32 0
@str = [50 x i8] c"Ciphertext length error.(Should be 13 characters)\00"
@str.7 = [24 x i8] c"Parameter number error.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.7, i64 0, i64 0))
br label %56
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* %10)
%12 = icmp eq i32 %11, 13
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
br label %56
15: ; preds = %8
%16 = tail call i32* @fopen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 127
br label %22
20: ; preds = %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %56
22: ; preds = %18, %50
%23 = phi i32 [ %51, %50 ], [ 0, %18 ]
%24 = call i32 @fgetc(i32* %16)
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = sext i32 %23 to i64
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %27
store i8 0, i8* %28
%29 = call i32 @strlen(i8* %4)
%30 = icmp slt i32 %29, 9
br i1 %30, label %31, label %37
31: ; preds = %26
%32 = load i8*, i8** %9
%33 = call i64 @CryptCrack(i8* %4, i8* %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %54
37: ; preds = %26, %31, %22
%38 = phi i32 [ 0, %31 ], [ 0, %26 ], [ %23, %22 ]
%39 = call i64 @isprint(i32 %24)
%40 = icmp eq i64 %39, 0
br i1 %40, label %50, label %41
41: ; preds = %37
%42 = icmp slt i32 %38, 127
br i1 %42, label %43, label %48
43: ; preds = %41
%44 = trunc i32 %24 to i8
%45 = add nsw i32 %38, 1
%46 = sext i32 %38 to i64
%47 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 %46
store i8 %44, i8* %47
br label %50
48: ; preds = %41
store i8 0, i8* %19
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %4)
br label %50
50: ; preds = %37, %48, %43
%51 = phi i32 [ %45, %43 ], [ 0, %48 ], [ %38, %37 ]
%52 = load i32, i32* @EOF
%53 = icmp eq i32 %24, %52
br i1 %53, label %54, label %22
54: ; preds = %50, %35
%55 = call i32 @fclose(i32* %16)
br label %56
56: ; preds = %54, %20, %13, %6
%57 = phi i32 [ 1, %6 ], [ 1, %13 ], [ 1, %20 ], [ 0, %54 ]
ret i32 %57
}