#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
scalar_t__ prefix(char const *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *find(const char *word) {
  FILE *fp;
  char *line = NULL;
  size_t len = 0;
  ssize_t read;
  fp = fopen("/usr/local/bin/google-10000-english-usa.txt", "r");
  if (fp == NULL) {
    printf("Could not open file.\n");
    exit(EXIT_FAILURE);
  }
  char *buffer = (char *)malloc(200);
  buffer[0] = '\0';
  while ((read = getline(&line, &len, fp)) != -1) {
    line[strlen(line) - 1] = '\0';
    if (strlen(line) > strlen(buffer) && prefix(word, line) == 0) {
      strcpy(buffer, line);
    }
  }
  fclose(fp);
  free(line);
  return buffer;
}


x86 assembly (clang, -O0):
<find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xe3d(%rip),%rdi
lea    0xe62(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11f8 <find+0x58>
lea    0xe49(%rip),%rdi
call   1070 <printf@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    $0xc8,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10b0 <getline@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1296 <find+0xf6>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jle    1291 <find+0xf1>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <prefix@plt>
cmp    $0x0,%rax
jne    1291 <find+0xf1>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    120d <find+0x6d>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe36(%rip),%rdi
lea    0xe5b(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12a4 <find+0x104>
mov    %rax,%r15
mov    $0xc8,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %r15,%rdx
call   10b0 <getline@plt>
cmp    $0xffffffff,%eax
je     1280 <find+0xe0>
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%r13
jmp    1233 <find+0x93>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   10b0 <getline@plt>
cmp    $0xffffffff,%eax
je     1280 <find+0xe0>
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1070 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
mov    0x8(%rsp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1070 <strlen@plt>
cmp    %eax,%ebp
jle    1220 <find+0x80>
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1090 <prefix@plt>
test   %rax,%rax
jne    1220 <find+0x80>
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
jmp    1220 <find+0x80>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd83(%rip),%rdi
call   1050 <puts@plt>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"/usr/local/bin/google-10000-english-usa.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"Could not open file.\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @find(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %4
store i64 0, i64* %5
%8 = call i32* @fopen(i8* getelementptr inbounds ([44 x i8], [44 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** %3
%9 = load i32*, i32** %3
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %1
%16 = call i64 @malloc(i32 200)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = getelementptr inbounds i8, i8* %18, i64 0
store i8 0, i8* %19
br label %20
20: ; preds = %45, %15
%21 = load i32*, i32** %3
%22 = call i32 @getline(i8** %4, i64* %5, i32* %21)
store i32 %22, i32* %6
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %46
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = load i8*, i8** %4
%27 = call i32 @strlen(i8* %26)
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %25, i64 %29
store i8 0, i8* %30
%31 = load i8*, i8** %4
%32 = call i32 @strlen(i8* %31)
%33 = load i8*, i8** %7
%34 = call i32 @strlen(i8* %33)
%35 = icmp sgt i32 %32, %34
br i1 %35, label %36, label %45
36: ; preds = %24
%37 = load i8*, i8** %2
%38 = load i8*, i8** %4
%39 = call i64 @prefix(i8* %37, i8* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %36
%42 = load i8*, i8** %7
%43 = load i8*, i8** %4
%44 = call i32 @strcpy(i8* %42, i8* %43)
br label %45
45: ; preds = %41, %36, %24
br label %20
46: ; preds = %20
%47 = load i32*, i32** %3
%48 = call i32 @fclose(i32* %47)
%49 = load i8*, i8** %4
%50 = call i32 @free(i8* %49)
%51 = load i8*, i8** %7
ret i8* %51
}

LLVM IR (-O2):
@.str = [44 x i8] c"/usr/local/bin/google-10000-english-usa.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@str = [21 x i8] c"Could not open file.\00"
define i8* @find(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%5 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = tail call i64 @malloc(i32 200)
%14 = inttoptr i64 %13 to i8*
store i8 0, i8* %14
%15 = call i32 @getline(i8** %2, i64* %3, i32* %6)
%16 = icmp eq i32 %15, -1
br i1 %16, label %37, label %17
17: ; preds = %12, %34
%18 = load i8*, i8** %2
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, -1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
store i8 0, i8* %22
%23 = load i8*, i8** %2
%24 = call i32 @strlen(i8* %23)
%25 = call i32 @strlen(i8* %14)
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %34
27: ; preds = %17
%28 = load i8*, i8** %2
%29 = call i64 @prefix(i8* %0, i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8*, i8** %2
%33 = call i32 @strcpy(i8* %14, i8* %32)
br label %34
34: ; preds = %31, %27, %17
%35 = call i32 @getline(i8** %2, i64* %3, i32* %6)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %17
37: ; preds = %34, %12
%38 = call i32 @fclose(i32* %6)
%39 = load i8*, i8** %2
%40 = call i32 @free(i8* %39)
ret i8* %14
}