#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 */
char EOF;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int strlen(char const *);
int seacrchInFile(const char *fileName, const char *string) {
  FILE *filePointer;
  int i = 0;
  int rowNumber = 1;
  int columnNUmber = 1;
  int totalOccurence = 0;
  int counter = 0;
  char ch;
  if (NULL == (filePointer = fopen(fileName, "r"))) {
    fprintf(stderr, "File <%s> not found in directory\n", fileName);
    return -1;
  }
  for (ch = fgetc(filePointer); ch != EOF; ch = fgetc(filePointer)) {
    ++counter;
    if (ch == '\n') {
      ++rowNumber;
      columnNUmber = 1;
    }
    for (i = 0; i < strlen(string); ++i) {
      if (ch == string[i]) {
        ch = fgetc(filePointer);
        while (ch == '\t' || ch == ' ' || ch == '\n')
          ch = fgetc(filePointer);
      } else
        break;
    }
    if (i == strlen(string)) {
      fprintf(stdout, "'%s' found in [%d,%d]\n", string, rowNumber,
              columnNUmber);
      ++totalOccurence;
    }
    fseek(filePointer, counter, SEEK_SET);
    if (ch != '\n')
      ++columnNUmber;
  }
  fclose(filePointer);
  return totalOccurence;
}


x86 assembly (clang, -O0):
<seacrchInFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11dc <seacrchInFile+0x7c>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1371 <seacrchInFile+0x211>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x35(%rbp)
movsbl -0x35(%rbp),%eax
mov    0x2df5(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1362 <seacrchInFile+0x202>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movsbl -0x35(%rbp),%eax
cmp    $0xa,%eax
jne    1224 <seacrchInFile+0xc4>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jge    12da <seacrchInFile+0x17a>
movsbl -0x35(%rbp),%eax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    12c2 <seacrchInFile+0x162>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x35(%rbp)
movsbl -0x35(%rbp),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x3d(%rbp)
je     129c <seacrchInFile+0x13c>
movsbl -0x35(%rbp),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x3d(%rbp)
je     129c <seacrchInFile+0x13c>
movsbl -0x35(%rbp),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
test   $0x1,%al
jne    12ac <seacrchInFile+0x14c>
jmp    12bd <seacrchInFile+0x15d>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x35(%rbp)
jmp    126b <seacrchInFile+0x10b>
jmp    12c7 <seacrchInFile+0x167>
jmp    12da <seacrchInFile+0x17a>
jmp    12cc <seacrchInFile+0x16c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    122b <seacrchInFile+0xcb>
mov    -0x24(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jne    1321 <seacrchInFile+0x1c1>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
lea    0xd13(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    0x2ca1(%rip),%rax
mov    (%rax),%edx
call   1070 <fseek@plt>
movsbl -0x35(%rbp),%eax
cmp    $0xa,%eax
je     134c <seacrchInFile+0x1ec>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1351 <seacrchInFile+0x1f1>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x35(%rbp)
jmp    11e8 <seacrchInFile+0x88>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seacrchInFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe85(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11b3 <seacrchInFile+0x53>
mov    %rax,%rbp
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
mov    0x2e4f(%rip),%rax
movl   $0x0,0xc(%rsp)
cmp    (%rax),%bl
jne    11e1 <seacrchInFile+0x81>
mov    %rbp,%rdi
call   1030 <fclose@plt>
mov    0xc(%rsp),%eax
jmp    11d2 <seacrchInFile+0x72>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x100000600,%r12
xor    %r15d,%r15d
movl   $0x0,0xc(%rsp)
mov    $0x1,%r13d
movl   $0x1,0x8(%rsp)
jmp    1277 <seacrchInFile+0x117>
cs nopw 0x0(%rax,%rax,1)
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
lea    0xe04(%rip),%rsi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    0x14(%rsp),%r13d
mov    %r13d,%r8d
xor    %eax,%eax
call   1060 <fprintf@plt>
addl   $0x1,0xc(%rsp)
mov    0x10(%rsp),%r15d
mov    0x2d8a(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    %r15d,%esi
call   1070 <fseek@plt>
xor    %eax,%eax
cmp    $0xa,%bl
setne  %al
add    %eax,%r13d
mov    %rbp,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
mov    0x2d79(%rip),%rax
cmp    (%rax),%bl
je     11a5 <seacrchInFile+0x45>
cmp    $0xa,%bl
sete   0x7(%rsp)
mov    $0x1,%eax
cmove  %eax,%r13d
mov    %r14,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
mov    %r15d,0x10(%rsp)
mov    %r13d,0x14(%rsp)
jle    1300 <seacrchInFile+0x1a0>
xor    %r15d,%r15d
xor    %r13d,%r13d
mov    0x8(%rsp),%eax
jmp    12cb <seacrchInFile+0x16b>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15
add    $0x1,%r13d
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r15
mov    0x8(%rsp),%eax
jge    1313 <seacrchInFile+0x1b3>
cmp    (%r14,%r15,1),%bl
jne    1310 <seacrchInFile+0x1b0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
cmp    $0x20,%al
ja     12b0 <seacrchInFile+0x150>
movzbl %bl,%eax
bt     %rax,%r12
jb     12e0 <seacrchInFile+0x180>
jmp    12b0 <seacrchInFile+0x150>
nopl   0x0(%rax)
xor    %r13d,%r13d
mov    0x8(%rsp),%eax
jmp    1313 <seacrchInFile+0x1b3>
nopl   0x0(%rax)
mov    %r15d,%r13d
addl   $0x1,0x10(%rsp)
xor    %ecx,%ecx
mov    0x7(%rsp),%dl
mov    %dl,%cl
add    %ecx,%eax
mov    %r14,%rdi
mov    %eax,%r15d
call   1040 <strlen@plt>
cmp    %eax,%r13d
mov    %r15d,0x8(%rsp)
je     1210 <seacrchInFile+0xb0>
mov    0x14(%rsp),%r13d
jmp    123a <seacrchInFile+0xda>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [34 x i8] c"File <%s> not found in directory\0A\00"
@EOF = global i8 0
@stdout = global i32 0
@.str.2 = [23 x i8] c"'%s' found in [%d,%d]\0A\00"
@SEEK_SET = global i32 0
define i32 @seacrchInFile(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %7
store i32 1, i32* %8
store i32 1, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
%13 = load i8*, i8** %4
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
%15 = icmp eq i32* null, %14
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %4
%19 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %18)
store i32 -1, i32* %3
br label %112
20: ; preds = %2
%21 = load i32*, i32** %6
%22 = call signext i8 @fgetc(i32* %21)
store i8 %22, i8* %12
br label %23
23: ; preds = %105, %20
%24 = load i8, i8* %12
%25 = sext i8 %24 to i32
%26 = load i8, i8* @EOF
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %25, %27
br i1 %28, label %29, label %108
29: ; preds = %23
%30 = load i32, i32* %11
%31 = add nsw i32 %30, 1
store i32 %31, i32* %11
%32 = load i8, i8* %12
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
store i32 1, i32* %9
br label %38
38: ; preds = %35, %29
store i32 0, i32* %7
br label %39
39: ; preds = %77, %38
%40 = load i32, i32* %7
%41 = load i8*, i8** %5
%42 = call i32 @strlen(i8* %41)
%43 = icmp slt i32 %40, %42
br i1 %43, label %44, label %80
44: ; preds = %39
%45 = load i8, i8* %12
%46 = sext i8 %45 to i32
%47 = load i8*, i8** %5
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %46, %52
br i1 %53, label %54, label %75
54: ; preds = %44
%55 = load i32*, i32** %6
%56 = call signext i8 @fgetc(i32* %55)
store i8 %56, i8* %12
br label %57
57: ; preds = %71, %54
%58 = load i8, i8* %12
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 9
br i1 %60, label %69, label %61
61: ; preds = %57
%62 = load i8, i8* %12
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 32
br i1 %64, label %69, label %65
65: ; preds = %61
%66 = load i8, i8* %12
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 10
br label %69
69: ; preds = %65, %61, %57
%70 = phi i1 [ true, %61 ], [ true, %57 ], [ %68, %65 ]
br i1 %70, label %71, label %74
71: ; preds = %69
%72 = load i32*, i32** %6
%73 = call signext i8 @fgetc(i32* %72)
store i8 %73, i8* %12
br label %57
74: ; preds = %69
br label %76
75: ; preds = %44
br label %80
76: ; preds = %74
br label %77
77: ; preds = %76
%78 = load i32, i32* %7
%79 = add nsw i32 %78, 1
store i32 %79, i32* %7
br label %39
80: ; preds = %75, %39
%81 = load i32, i32* %7
%82 = load i8*, i8** %5
%83 = call i32 @strlen(i8* %82)
%84 = icmp eq i32 %81, %83
br i1 %84, label %85, label %93
85: ; preds = %80
%86 = load i32, i32* @stdout
%87 = load i8*, i8** %5
%88 = load i32, i32* %8
%89 = load i32, i32* %9
%90 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %87, i32 %88, i32 %89)
%91 = load i32, i32* %10
%92 = add nsw i32 %91, 1
store i32 %92, i32* %10
br label %93
93: ; preds = %85, %80
%94 = load i32*, i32** %6
%95 = load i32, i32* %11
%96 = load i32, i32* @SEEK_SET
%97 = call i32 @fseek(i32* %94, i32 %95, i32 %96)
%98 = load i8, i8* %12
%99 = sext i8 %98 to i32
%100 = icmp ne i32 %99, 10
br i1 %100, label %101, label %104
101: ; preds = %93
%102 = load i32, i32* %9
%103 = add nsw i32 %102, 1
store i32 %103, i32* %9
br label %104
104: ; preds = %101, %93
br label %105
105: ; preds = %104
%106 = load i32*, i32** %6
%107 = call signext i8 @fgetc(i32* %106)
store i8 %107, i8* %12
br label %23
108: ; preds = %23
%109 = load i32*, i32** %6
%110 = call i32 @fclose(i32* %109)
%111 = load i32, i32* %10
store i32 %111, i32* %3
br label %112
112: ; preds = %108, %16
%113 = load i32, i32* %3
ret i32 %113
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [34 x i8] c"File <%s> not found in directory\0A\00"
@EOF = global i8 0
@stdout = global i32 0
@.str.2 = [23 x i8] c"'%s' found in [%d,%d]\0A\00"
@SEEK_SET = global i32 0
define i32 @seacrchInFile(i8* %0, i8* %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %65
8: ; preds = %2
%9 = tail call signext i8 @fgetc(i32* %3)
%10 = load i8, i8* @EOF
%11 = icmp eq i8 %9, %10
br i1 %11, label %62, label %12
12: ; preds = %8, %52
%13 = phi i8 [ %59, %52 ], [ %9, %8 ]
%14 = phi i32 [ %18, %52 ], [ 0, %8 ]
%15 = phi i32 [ %53, %52 ], [ 0, %8 ]
%16 = phi i32 [ %58, %52 ], [ 1, %8 ]
%17 = phi i32 [ %21, %52 ], [ 1, %8 ]
%18 = add nuw nsw i32 %14, 1
%19 = icmp eq i8 %13, 10
%20 = zext i1 %19 to i32
%21 = add nuw nsw i32 %17, %20
%22 = select i1 %19, i32 1, i32 %16
%23 = tail call i32 @strlen(i8* %1)
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %43
25: ; preds = %12, %35
%26 = phi i64 [ %36, %35 ], [ 0, %12 ]
%27 = phi i8 [ %33, %35 ], [ %13, %12 ]
%28 = phi i32 [ %37, %35 ], [ 0, %12 ]
%29 = getelementptr inbounds i8, i8* %1, i64 %26
%30 = load i8, i8* %29
%31 = icmp eq i8 %27, %30
br i1 %31, label %32, label %41
32: ; preds = %25, %34
%33 = tail call signext i8 @fgetc(i32* %3)
switch i8 %33, label %35 [
i8 32, label %34
i8 10, label %34
i8 9, label %34
]
34: ; preds = %32, %32, %32
br label %32
35: ; preds = %32
%36 = add nuw nsw i64 %26, 1
%37 = add nuw nsw i32 %28, 1
%38 = tail call i32 @strlen(i8* %1)
%39 = sext i32 %38 to i64
%40 = icmp slt i64 %36, %39
br i1 %40, label %25, label %43
41: ; preds = %25
%42 = trunc i64 %26 to i32
br label %43
43: ; preds = %35, %41, %12
%44 = phi i32 [ 0, %12 ], [ %42, %41 ], [ %37, %35 ]
%45 = phi i8 [ %13, %12 ], [ %27, %41 ], [ %33, %35 ]
%46 = tail call i32 @strlen(i8* %1)
%47 = icmp eq i32 %44, %46
br i1 %47, label %48, label %52
48: ; preds = %43
%49 = load i32, i32* @stdout
%50 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %1, i32 %21, i32 %22)
%51 = add nsw i32 %15, 1
br label %52
52: ; preds = %48, %43
%53 = phi i32 [ %51, %48 ], [ %15, %43 ]
%54 = load i32, i32* @SEEK_SET
%55 = tail call i32 @fseek(i32* %3, i32 %18, i32 %54)
%56 = icmp ne i8 %45, 10
%57 = zext i1 %56 to i32
%58 = add nsw i32 %22, %57
%59 = tail call signext i8 @fgetc(i32* %3)
%60 = load i8, i8* @EOF
%61 = icmp eq i8 %59, %60
br i1 %61, label %62, label %12
62: ; preds = %52, %8
%63 = phi i32 [ 0, %8 ], [ %53, %52 ]
%64 = tail call i32 @fclose(i32* %3)
br label %65
65: ; preds = %62, %5
%66 = phi i32 [ -1, %5 ], [ %63, %62 ]
ret i32 %66
}