#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ found();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  char line[80];
  char *tok;
  if (argc < 2) {
    printf("No filename entered.\n");
    exit(1);
  }
  if ((fp = fopen(argv[1], "r")) == NULL) {
    printf("Could not open file.\n");
    exit(1);
  }
  while (fgets(line, sizeof line, fp) != NULL) {
    tok = strtok(line, " ");
    while (tok != NULL) {
      printf("Token is %s \n", tok);
      if (!strcmp(tok, "small")) {
        found();
      }
      tok = strtok(NULL, " ");
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11bb <main+0x3b>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11f5 <main+0x75>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    11fa <main+0x7a>
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x50,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1285 <main+0x105>
lea    -0x70(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     1280 <main+0x100>
mov    -0x78(%rbp),%rsi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x78(%rbp),%rdi
lea    0xdec(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1267 <main+0xe7>
mov    $0x0,%al
call   1070 <found@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdbc(%rip),%rsi
call   1090 <strtok@plt>
mov    %rax,-0x78(%rbp)
jmp    122a <main+0xaa>
jmp    11fa <main+0x7a>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
cmp    $0x1,%edi
jle    1280 <main+0xf0>
mov    0x8(%rsi),%rdi
lea    0xe4e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1289 <main+0xf9>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1267 <main+0xd7>
lea    0xe1f(%rip),%r13
mov    %rsp,%r15
lea    0xe17(%rip),%r12
lea    0xe1e(%rip),%rbx
jmp    1215 <main+0x85>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1267 <main+0xd7>
mov    %r15,%rdi
mov    %r13,%rsi
call   10a0 <strtok@plt>
test   %rax,%rax
je     1200 <main+0x70>
mov    %rax,%rbp
jmp    1242 <main+0xb2>
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r13,%rsi
call   10a0 <strtok@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1200 <main+0x70>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    1230 <main+0xa0>
xor    %eax,%eax
call   1080 <found@plt>
jmp    1230 <main+0xa0>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xda6(%rip),%rdi
jmp    1290 <main+0x100>
lea    0xd88(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"No filename entered.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"Could not open file.\0A\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [14 x i8] c"Token is %s \0A\00"
@.str.5 = [6 x i8] c"small\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [80 x i8]
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %14
br label %24
24: ; preds = %45, %23
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%26 = load i32*, i32** %6
%27 = call i32* @fgets(i8* %25, i32 80, i32* %26)
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %46
29: ; preds = %24
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%31 = call i8* @strtok(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %31, i8** %8
br label %32
32: ; preds = %43, %29
%33 = load i8*, i8** %8
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %45
35: ; preds = %32
%36 = load i8*, i8** %8
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %36)
%38 = load i8*, i8** %8
%39 = call i32 @strcmp(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp ne i32 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %35
%42 = call i32 (...) @found()
br label %43
43: ; preds = %41, %35
%44 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %44, i8** %8
br label %32
45: ; preds = %32
br label %24
46: ; preds = %24
%47 = load i32*, i32** %6
%48 = call i32 @fclose(i32* %47)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c" \00"
@.str.4 = [14 x i8] c"Token is %s \0A\00"
@.str.5 = [6 x i8] c"small\00"
@str = [21 x i8] c"Could not open file.\00"
@str.6 = [21 x i8] c"No filename entered.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.6, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = call i32* @fgets(i8* %4, i32 80, i32* %12)
%16 = icmp eq i32* %15, null
br i1 %16, label %36, label %23
17: ; preds = %9
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %33, %23
%21 = call i32* @fgets(i8* %4, i32 80, i32* %12)
%22 = icmp eq i32* %21, null
br i1 %22, label %36, label %23
23: ; preds = %14, %20
%24 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i8* %24, null
br i1 %25, label %20, label %26
26: ; preds = %23, %33
%27 = phi i8* [ %34, %33 ], [ %24, %23 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = call i32 @strcmp(i8* %27, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 (...) @found()
br label %33
33: ; preds = %31, %26
%34 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i8* %34, null
br i1 %35, label %20, label %26
36: ; preds = %20, %14
%37 = call i32 @fclose(i32* %12)
ret i32 0
}