#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *strstr(char *, char *);
int main() {
  char arr[64];
  FILE *fp;
  fp = fopen("text1.txt", "rt");
  while (fgets(arr, 64, fp) != NULL) {
    if (strstr(arr, "school") != NULL) {
      printf("%s\n", arr);
    }
  }
  printf("\n[Press ENTER to close]");
  getchar();
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rdx
mov    $0x40,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11d3 <main+0x73>
lea    -0x50(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1080 <strstr@plt>
cmp    $0x0,%rax
je     11ce <main+0x6e>
lea    -0x50(%rbp),%rsi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1186 <main+0x26>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    -0x58(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xe80(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x40,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11df <main+0x6f>
lea    0xe62(%rip),%r14
mov    %rsp,%rbx
jmp    11c5 <main+0x55>
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11df <main+0x6f>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     11b0 <main+0x40>
mov    %rbx,%rdi
call   1030 <puts@plt>
jmp    11b0 <main+0x40>
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"text1.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [7 x i8] c"school\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [24 x i8] c"\0A[Press ENTER to close]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
br label %5
5: ; preds = %17, %0
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%7 = load i32*, i32** %3
%8 = call i32* @fgets(i8* %6, i32 64, i32* %7)
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %18
10: ; preds = %5
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%12 = call i32* @strstr(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %10
br label %5
18: ; preds = %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (...) @getchar()
%21 = load i32*, i32** %3
%22 = call i32 @fclose(i32* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"text1.txt\00"
@.str.1 = [3 x i8] c"rt\00"
@.str.2 = [7 x i8] c"school\00"
@.str.4 = [24 x i8] c"\0A[Press ENTER to close]\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32* @fgets(i8* %2, i32 64, i32* %3)
%5 = icmp eq i32* %4, null
br i1 %5, label %14, label %6
6: ; preds = %0, %11
%7 = call i32* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = call i32 @puts(i8* %2)
br label %11
11: ; preds = %9, %6
%12 = call i32* @fgets(i8* %2, i32 64, i32* %3)
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %6
14: ; preds = %11, %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (...) @getchar()
%17 = call i32 @fclose(i32* %3)
ret i32 0
}