#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_SET;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ *strstr(char *, char const *);
int fn_in_file(char const *fn, FILE *file) {
  char chunk[1024];
  fseek(file, 0, SEEK_SET);
  while (fgets(chunk, 1024, file) != NULL) {
    if ((strstr(chunk, fn)) != NULL) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<fn_in_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e92(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     11a1 <fn_in_file+0x71>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     119c <fn_in_file+0x6c>
movl   $0x1,-0x4(%rbp)
jmp    11a8 <fn_in_file+0x78>
jmp    1157 <fn_in_file+0x27>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn_in_file>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
mov    0x2e96(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
mov    %rsi,%rdi
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %rsp,%rbp
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     118b <fn_in_file+0x5b>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1160 <fn_in_file+0x30>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @fn_in_file(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [1024 x i8]
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = load i32*, i32** %5
%8 = load i32, i32* @SEEK_SET
%9 = call i32 @fseek(i32* %7, i32 0, i32 %8)
br label %10
10: ; preds = %21, %2
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = load i32*, i32** %5
%13 = call i32* @fgets(i8* %11, i32 1024, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %22
15: ; preds = %10
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%17 = load i8*, i8** %4
%18 = call i32* @strstr(i8* %16, i8* %17)
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 1, i32* %3
br label %23
21: ; preds = %15
br label %10
22: ; preds = %10
store i32 0, i32* %3
br label %23
23: ; preds = %22, %20
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @fn_in_file(i8* nocapture %0, i32* nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @fseek(i32* %1, i32 0, i32 %5)
br label %7
7: ; preds = %10, %2
%8 = call i32* @fgets(i8* %4, i32 1024, i32* %1)
%9 = icmp eq i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = call i32* @strstr(i8* %4, i8* dereferenceable(1) %0)
%12 = icmp eq i32* %11, null
br i1 %12, label %7, label %13
13: ; preds = %7, %10
%14 = phi i32 [ 1, %10 ], [ 0, %7 ]
ret i32 %14
}