#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*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
void readAndParse(char *the_filename, char *search_token, int flag) {
  FILE *file;
  char line[1000];
  if ((file = fopen(the_filename, "r")) == NULL)
    printf("File could not be opened\n");
  else {
    fscanf(file, "%s", line);
    while (!feof(file)) {
      if (strcmp(line, search_token) == 0) {
        fscanf(file, "%s", line);
        if (flag == 0) {
          fgets(line, 1000, file);
        } else if (flag == 1) {
          printf(" ");
          fscanf(file, "%s", line);
        } else if (flag == 2) {
          printf(" ");
        } else if (flag == 3) {
          printf(" ");
          fscanf(file, "%s", line);
          fscanf(file, "%s", line);
        } else if (flag == 4) {
          printf(" ");
          fscanf(file, "%s", line);
          fscanf(file, "%s", line);
          fscanf(file, "%s", line);
        }
        printf("%s", line);
        break;
      }
      fscanf(file, "%s", line);
    }
    fclose(file);
  }
  return;
}


x86 assembly (clang, -O0):
<readAndParse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11b7 <readAndParse+0x47>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    138d <readAndParse+0x21d>
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xe53(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ec <readAndParse+0x7c>
jmp    1384 <readAndParse+0x214>
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1368 <readAndParse+0x1f8>
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xe04(%rip),%rsi
call   1050 <fscanf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1241 <readAndParse+0xd1>
lea    -0x410(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x3e8,%esi
call   1060 <fgets@plt>
jmp    134e <readAndParse+0x1de>
cmpl   $0x1,-0x14(%rbp)
jne    1275 <readAndParse+0x105>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xdb1(%rip),%rsi
call   1050 <fscanf@plt>
jmp    1349 <readAndParse+0x1d9>
cmpl   $0x2,-0x14(%rbp)
jne    1292 <readAndParse+0x122>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1344 <readAndParse+0x1d4>
cmpl   $0x3,-0x14(%rbp)
jne    12dd <readAndParse+0x16d>
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xd60(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xd49(%rip),%rsi
call   1050 <fscanf@plt>
jmp    133f <readAndParse+0x1cf>
cmpl   $0x4,-0x14(%rbp)
jne    133a <readAndParse+0x1ca>
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xd15(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xcfe(%rip),%rsi
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xce7(%rip),%rsi
call   1050 <fscanf@plt>
jmp    133f <readAndParse+0x1cf>
jmp    1344 <readAndParse+0x1d4>
jmp    1349 <readAndParse+0x1d9>
jmp    134e <readAndParse+0x1de>
lea    -0x410(%rbp),%rsi
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1384 <readAndParse+0x214>
mov    -0x20(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xca2(%rip),%rsi
call   1050 <fscanf@plt>
jmp    11ce <readAndParse+0x5e>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readAndParse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
lea    0xe66(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1222 <readAndParse+0x92>
mov    %rax,%r13
lea    0xe54(%rip),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1070 <fscanf@plt>
mov    %r13,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
jne    12f8 <readAndParse+0x168>
mov    %rsp,%rbp
lea    0xe2f(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1070 <fscanf@plt>
test   %rbx,%rbx
je     123f <readAndParse+0xaf>
mov    %r13,%rdi
call   10a0 <feof@plt>
test   %eax,%eax
je     11f0 <readAndParse+0x60>
jmp    12f8 <readAndParse+0x168>
lea    0xdf0(%rip),%rdi
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>
cmp    $0x4,%r14d
ja     12e7 <readAndParse+0x157>
mov    %r14d,%eax
lea    0xdad(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %rsp,%rdi
mov    $0x3e8,%esi
mov    %r13,%rdx
call   1080 <fgets@plt>
jmp    12e7 <readAndParse+0x157>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0xd97(%rip),%rsi
mov    %rsp,%rdx
mov    %r13,%rdi
jmp    12e2 <readAndParse+0x152>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    12e7 <readAndParse+0x157>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0xd72(%rip),%rbx
mov    %rsp,%rbp
jmp    12cb <readAndParse+0x13b>
mov    $0x20,%edi
call   1030 <putchar@plt>
lea    0xd5c(%rip),%rbx
mov    %rsp,%rbp
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1070 <fscanf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1070 <fscanf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1070 <fscanf@plt>
lea    0xd28(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
call   1050 <fclose@plt>
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [26 x i8] c"File could not be opened\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c" \00"
define void @readAndParse(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca [1000 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %7
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %90
14: ; preds = %3
%15 = load i32*, i32** %7
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%17 = call i32 @fscanf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %83, %14
%19 = load i32*, i32** %7
%20 = call i32 @feof(i32* %19)
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
br i1 %22, label %23, label %87
23: ; preds = %18
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%25 = load i8*, i8** %5
%26 = call i64 @strcmp(i8* %24, i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %83
28: ; preds = %23
%29 = load i32*, i32** %7
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%31 = call i32 @fscanf(i32* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = load i32, i32* %6
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %28
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%36 = load i32*, i32** %7
%37 = call i32 @fgets(i8* %35, i32 1000, i32* %36)
br label %80
38: ; preds = %28
%39 = load i32, i32* %6
%40 = icmp eq i32 %39, 1
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32*, i32** %7
%44 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%45 = call i32 @fscanf(i32* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %44)
br label %79
46: ; preds = %38
%47 = load i32, i32* %6
%48 = icmp eq i32 %47, 2
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %78
51: ; preds = %46
%52 = load i32, i32* %6
%53 = icmp eq i32 %52, 3
br i1 %53, label %54, label %62
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%56 = load i32*, i32** %7
%57 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%58 = call i32 @fscanf(i32* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %57)
%59 = load i32*, i32** %7
%60 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%61 = call i32 @fscanf(i32* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %60)
br label %77
62: ; preds = %51
%63 = load i32, i32* %6
%64 = icmp eq i32 %63, 4
br i1 %64, label %65, label %76
65: ; preds = %62
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%67 = load i32*, i32** %7
%68 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%69 = call i32 @fscanf(i32* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %68)
%70 = load i32*, i32** %7
%71 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%72 = call i32 @fscanf(i32* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %71)
%73 = load i32*, i32** %7
%74 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%75 = call i32 @fscanf(i32* %73, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %74)
br label %76
76: ; preds = %65, %62
br label %77
77: ; preds = %76, %54
br label %78
78: ; preds = %77, %49
br label %79
79: ; preds = %78, %41
br label %80
80: ; preds = %79, %34
%81 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %81)
br label %87
83: ; preds = %23
%84 = load i32*, i32** %7
%85 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%86 = call i32 @fscanf(i32* %84, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %85)
br label %18
87: ; preds = %80, %18
%88 = load i32*, i32** %7
%89 = call i32 @fclose(i32* %88)
br label %90
90: ; preds = %87, %12
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%s\00"
@str = [25 x i8] c"File could not be opened\00"
define void @readAndParse(i8* nocapture %0, i8* %1, i32 %2) {
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %42
10: ; preds = %3
%11 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%12 = call i32 @feof(i32* %6)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %40
14: ; preds = %10, %37
%15 = call i64 @strcmp(i8* %5, i8* %1)
%16 = icmp eq i64 %15, 0
%17 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br i1 %16, label %18, label %37
18: ; preds = %14
switch i32 %2, label %35 [
i32 0, label %19
i32 1, label %21
i32 2, label %24
i32 3, label %26
i32 4, label %30
]
19: ; preds = %18
%20 = call i32 @fgets(i8* %5, i32 1000, i32* %6)
br label %35
21: ; preds = %18
%22 = call i32 @putchar(i32 32)
%23 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br label %35
24: ; preds = %18
%25 = call i32 @putchar(i32 32)
br label %35
26: ; preds = %18
%27 = call i32 @putchar(i32 32)
%28 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%29 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br label %35
30: ; preds = %18
%31 = call i32 @putchar(i32 32)
%32 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%33 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%34 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br label %35
35: ; preds = %18, %21, %26, %30, %24, %19
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
br label %40
37: ; preds = %14
%38 = call i32 @feof(i32* %6)
%39 = icmp eq i32 %38, 0
br i1 %39, label %14, label %40
40: ; preds = %37, %10, %35
%41 = call i32 @fclose(i32* %6)
br label %42
42: ; preds = %40, %8
ret void
}