#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*/ SEEK_END;
scalar_t__ fgets(char *, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
scalar_t__ strstr(char *, char *);
int find_in_file(char *path_to_file, char *string_to_find) {
  FILE *logfile = fopen(path_to_file, "r");
  fseek(logfile, 0L, SEEK_END);
  long filesize = ftell(logfile);
  rewind(logfile);
  char str[100];
  int find_counter = 0;
  while (fgets(str, filesize, logfile)) {
    if (strstr(str, string_to_find)) {
      find_counter++;
    }
  }
  if (find_counter > 0) {
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<find_in_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1060 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <rewind@plt>
movl   $0x0,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1209 <find_in_file+0xa9>
lea    -0x90(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     1204 <find_in_file+0xa4>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11bd <find_in_file+0x5d>
cmpl   $0x0,-0x94(%rbp)
jle    1222 <find_in_file+0xc2>
movl   $0x0,-0x4(%rbp)
jmp    1229 <find_in_file+0xc9>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_in_file>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%r14
lea    0xe89(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
mov    %r15,%rdi
call   1050 <ftell@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1030 <rewind@plt>
mov    %rsp,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11ee <find_in_file+0x8e>
mov    %rsp,%r13
nopl   (%rax)
mov    %r13,%rdi
mov    %r14,%rsi
call   1080 <strstr@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    11c0 <find_in_file+0x60>
xor    %eax,%eax
test   %ebx,%ebx
sete   %al
jmp    11f3 <find_in_file+0x93>
mov    $0x1,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
define i32 @find_in_file(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca [100 x i8]
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = load i32, i32* @SEEK_END
%14 = call i32 @fseek(i32* %12, i64 0, i32 %13)
%15 = load i32*, i32** %6
%16 = call i64 @ftell(i32* %15)
store i64 %16, i64* %7
%17 = load i32*, i32** %6
%18 = call i32 @rewind(i32* %17)
store i32 0, i32* %9
br label %19
19: ; preds = %33, %2
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%21 = load i64, i64* %7
%22 = load i32*, i32** %6
%23 = call i64 @fgets(i8* %20, i64 %21, i32* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %19
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%27 = load i8*, i8** %5
%28 = call i64 @strstr(i8* %26, i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
br label %33
33: ; preds = %30, %25
br label %19
34: ; preds = %19
%35 = load i32, i32* %9
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %34
store i32 0, i32* %3
br label %39
38: ; preds = %34
store i32 1, i32* %3
br label %39
39: ; preds = %38, %37
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
define i32 @find_in_file(i8* nocapture %0, i8* %1) {
%3 = alloca [100 x i8]
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @SEEK_END
%6 = tail call i32 @fseek(i32* %4, i64 0, i32 %5)
%7 = tail call i64 @ftell(i32* %4)
%8 = tail call i32 @rewind(i32* %4)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = call i64 @fgets(i8* %9, i64 %7, i32* %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %2, %12
%13 = phi i32 [ %17, %12 ], [ 0, %2 ]
%14 = call i64 @strstr(i8* %9, i8* %1)
%15 = icmp ne i64 %14, 0
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %13, %16
%18 = call i64 @fgets(i8* %9, i64 %7, i32* %4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %12
20: ; preds = %12
%21 = icmp eq i32 %17, 0
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %20, %2
%24 = phi i32 [ 1, %2 ], [ %22, %20 ]
ret i32 %24
}