#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int strcmp2(char *, char *);
int isInDictionary1(char *query) {
  char line[50];
  int res;
  FILE *searchFPtr = fopen("3plus4Wordlist.txt", "r");
  if (searchFPtr == NULL)
    printf("Search file could not be opened.\n");
  else {
    while (fgets(line, sizeof line, searchFPtr) != NULL) {
      res = strcmp2(line, query);
      if (res == 0) {
        printf("found %s\n", query);
        fclose(searchFPtr);
        return 0;
      } else if (res > 0) {
        fclose(searchFPtr);
        return 1;
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<isInDictionary1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe9d(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1191 <isInDictionary1+0x41>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1221 <isInDictionary1+0xd1>
jmp    1196 <isInDictionary1+0x46>
lea    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rdx
mov    $0x32,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     121c <isInDictionary1+0xcc>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <strcmp2@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jne    11f3 <isInDictionary1+0xa3>
mov    -0x10(%rbp),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x60(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1228 <isInDictionary1+0xd8>
cmpl   $0x0,-0x54(%rbp)
jle    1212 <isInDictionary1+0xc2>
mov    -0x60(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1228 <isInDictionary1+0xd8>
jmp    1217 <isInDictionary1+0xc7>
jmp    1196 <isInDictionary1+0x46>
jmp    1221 <isInDictionary1+0xd1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isInDictionary1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
lea    0xe8c(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11b8 <isInDictionary1+0x58>
mov    %rax,%r15
mov    %rsp,%rbx
mov    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x32,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11e6 <isInDictionary1+0x86>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <strcmp2@plt>
test   %eax,%eax
je     11cb <isInDictionary1+0x6b>
jle    1190 <isInDictionary1+0x30>
jmp    11de <isInDictionary1+0x7e>
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
jmp    11e6 <isInDictionary1+0x86>
lea    0xe43(%rip),%rdi
xor    %ebp,%ebp
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"3plus4Wordlist.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [34 x i8] c"Search file could not be opened.\0A\00"
@.str.3 = [10 x i8] c"found %s\0A\00"
define i32 @isInDictionary1(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [50 x i8]
%5 = alloca i32
%6 = alloca i32*
store i8* %0, i8** %3
%7 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %38
12: ; preds = %1
br label %13
13: ; preds = %36, %12
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%15 = load i32*, i32** %6
%16 = call i32* @fgets(i8* %14, i32 50, i32* %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %37
18: ; preds = %13
%19 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%20 = load i8*, i8** %3
%21 = call i32 @strcmp2(i8* %19, i8* %20)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = load i32*, i32** %6
%28 = call i32 @fclose(i32* %27)
store i32 0, i32* %2
br label %39
29: ; preds = %18
%30 = load i32, i32* %5
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32*, i32** %6
%34 = call i32 @fclose(i32* %33)
store i32 1, i32* %2
br label %39
35: ; preds = %29
br label %36
36: ; preds = %35
br label %13
37: ; preds = %13
br label %38
38: ; preds = %37, %10
store i32 1, i32* %2
br label %39
39: ; preds = %38, %32, %24
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@.str = [19 x i8] c"3plus4Wordlist.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [10 x i8] c"found %s\0A\00"
@str = [33 x i8] c"Search file could not be opened.\00"
define i32 @isInDictionary1(i8* %0) {
%2 = alloca [50 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 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 %6, label %8
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %21
8: ; preds = %1, %17
%9 = call i32* @fgets(i8* %3, i32 50, i32* %4)
%10 = icmp eq i32* %9, null
br i1 %10, label %21, label %11
11: ; preds = %8
%12 = call i32 @strcmp2(i8* %3, i8* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%16 = call i32 @fclose(i32* %4)
br label %21
17: ; preds = %11
%18 = icmp sgt i32 %12, 0
br i1 %18, label %19, label %8
19: ; preds = %17
%20 = call i32 @fclose(i32* %4)
br label %21
21: ; preds = %8, %6, %19, %14
%22 = phi i32 [ 0, %14 ], [ 1, %19 ], [ 1, %6 ], [ 1, %8 ]
ret i32 %22
}