#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*/ tmp;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ checkFile(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *getFileLocation(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ removeNewlines(char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strstr(char *, char *);
int getProfanity(char *word) {
  checkFile(getFileLocation(0));
  FILE *fr = fopen(getFileLocation(0), "r");
  int found = 0;
  char tmp[256] = {0x0};
  if (fr == NULL) {
    printf("couldn't find \"%s\" in %s\n", word, getFileLocation(0));
    return EXIT_FAILURE;
  }
  if (strcmp(word, "all") == 0) {
    while (fr != NULL && fgets(tmp, sizeof(tmp), fr) != NULL) {
      removeNewlines(tmp);
      printf("You have said %s time(s)\n", tmp);
    }
    return EXIT_SUCCESS;
  }
  printf("getting number of times \"%s\" is said from %s\n", word,
         getFileLocation(0));
  while (fr != NULL && fgets(tmp, sizeof(tmp), fr) != NULL) {
    if (strstr(tmp, word)) {
      removeNewlines(tmp);
      printf("You have said %s time(s)\n", tmp);
      found = 1;
    }
  }
  if (fr != NULL) {
    fclose(fr);
  }
  if (found == 0) {
    printf("You have not said %s. Yet...\n", word);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<getProfanity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
xor    %edi,%edi
call   1060 <getFileLocation@plt>
mov    %rax,%rdi
call   1030 <checkFile@plt>
xor    %edi,%edi
call   1060 <getFileLocation@plt>
mov    %rax,%rdi
lea    0xe31(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1070 <memset@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1238 <getProfanity+0x98>
mov    -0x10(%rbp),%rax
mov    %rax,-0x128(%rbp)
xor    %edi,%edi
call   1060 <getFileLocation@plt>
mov    -0x128(%rbp),%rsi
mov    %rax,%rdx
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13cb <getProfanity+0x22b>
mov    -0x10(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    12d6 <getProfanity+0x136>
jmp    1257 <getProfanity+0xb7>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x129(%rbp)
je     128c <getProfanity+0xec>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x129(%rbp)
mov    -0x129(%rbp),%al
test   $0x1,%al
jne    129f <getProfanity+0xff>
jmp    12c5 <getProfanity+0x125>
lea    -0x120(%rbp),%rdi
call   10b0 <removeNewlines@plt>
lea    -0x120(%rbp),%rsi
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1257 <getProfanity+0xb7>
mov    0x2d0c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13cb <getProfanity+0x22b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x138(%rbp)
xor    %edi,%edi
call   1060 <getFileLocation@plt>
mov    -0x138(%rbp),%rsi
mov    %rax,%rdx
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x139(%rbp)
je     1335 <getProfanity+0x195>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x139(%rbp)
mov    -0x139(%rbp),%al
test   $0x1,%al
jne    1348 <getProfanity+0x1a8>
jmp    138f <getProfanity+0x1ef>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     138a <getProfanity+0x1ea>
lea    -0x120(%rbp),%rdi
call   10b0 <removeNewlines@plt>
lea    -0x120(%rbp),%rsi
lea    0xca4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    1300 <getProfanity+0x160>
cmpq   $0x0,-0x18(%rbp)
je     13a3 <getProfanity+0x203>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    13bf <getProfanity+0x21f>
mov    -0x10(%rbp),%rsi
lea    0xcb0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2c12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getProfanity>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%r14
xor    %edi,%edi
call   1060 <getFileLocation@plt>
mov    %rax,%rdi
call   1030 <checkFile@plt>
xor    %edi,%edi
call   1060 <getFileLocation@plt>
lea    0xe41(%rip),%rsi
mov    %rax,%rdi
call   1090 <fopen@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
test   %rax,%rax
je     12e1 <getProfanity+0x151>
mov    %rax,%r15
lea    0xdd8(%rip),%rsi
mov    %r14,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1316 <getProfanity+0x186>
xor    %edi,%edi
call   1060 <getFileLocation@plt>
lea    0xdd7(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     136c <getProfanity+0x1dc>
mov    %rsp,%rbx
lea    0xd8d(%rip),%r12
xor    %ebp,%ebp
jmp    12b5 <getProfanity+0x125>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1308 <getProfanity+0x178>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10b0 <strstr@plt>
test   %rax,%rax
je     12a0 <getProfanity+0x110>
mov    %rbx,%rdi
call   10a0 <removeNewlines@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebp
jmp    12a0 <getProfanity+0x110>
xor    %edi,%edi
call   1060 <getFileLocation@plt>
lea    0xd13(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2cdd(%rip),%r12
jmp    138c <getProfanity+0x1fc>
mov    %r15,%rdi
call   1040 <fclose@plt>
test   %ebp,%ebp
jne    1385 <getProfanity+0x1f5>
jmp    1374 <getProfanity+0x1e4>
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
mov    0x2cab(%rip),%r12
test   %rax,%rax
je     138c <getProfanity+0x1fc>
mov    %rsp,%rbx
lea    0xce4(%rip),%r14
nopl   0x0(%rax)
mov    %rbx,%rdi
call   10a0 <removeNewlines@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
jne    1340 <getProfanity+0x1b0>
jmp    138c <getProfanity+0x1fc>
mov    %r15,%rdi
call   1040 <fclose@plt>
lea    0xced(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c4c(%rip),%r12
mov    (%r12),%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [26 x i8] c"couldn't find \22%s\22 in %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"all\00"
@.str.3 = [26 x i8] c"You have said %s time(s)\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [46 x i8] c"getting number of times \22%s\22 is said from %s\0A\00"
@.str.5 = [30 x i8] c"You have not said %s. Yet...\0A\00"
define i32 @getProfanity(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [256 x i8]
store i8* %0, i8** %3
%7 = call i8* @getFileLocation(i32 0)
%8 = call i32 @checkFile(i8* %7)
%9 = call i8* @getFileLocation(i32 0)
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %4
store i32 0, i32* %5
%11 = bitcast [256 x i8]* %6 to i8*
%12 = load i32*, i32** %4
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = call i8* @getFileLocation(i32 0)
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %2
br label %80
19: ; preds = %1
%20 = load i8*, i8** %3
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %41
23: ; preds = %19
br label %24
24: ; preds = %34, %23
%25 = load i32*, i32** %4
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%29 = load i32*, i32** %4
%30 = call i32* @fgets(i8* %28, i32 256, i32* %29)
%31 = icmp ne i32* %30, null
br label %32
32: ; preds = %27, %24
%33 = phi i1 [ false, %24 ], [ %31, %27 ]
br i1 %33, label %34, label %39
34: ; preds = %32
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%36 = call i32 @removeNewlines(i8* %35)
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%38 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %37)
br label %24
39: ; preds = %32
%40 = load i32, i32* @EXIT_SUCCESS
store i32 %40, i32* %2
br label %80
41: ; preds = %19
%42 = load i8*, i8** %3
%43 = call i8* @getFileLocation(i32 0)
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %42, i8* %43)
br label %45
45: ; preds = %65, %41
%46 = load i32*, i32** %4
%47 = icmp ne i32* %46, null
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%50 = load i32*, i32** %4
%51 = call i32* @fgets(i8* %49, i32 256, i32* %50)
%52 = icmp ne i32* %51, null
br label %53
53: ; preds = %48, %45
%54 = phi i1 [ false, %45 ], [ %52, %48 ]
br i1 %54, label %55, label %66
55: ; preds = %53
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%57 = load i8*, i8** %3
%58 = call i64 @strstr(i8* %56, i8* %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %55
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%62 = call i32 @removeNewlines(i8* %61)
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%64 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %63)
store i32 1, i32* %5
br label %65
65: ; preds = %60, %55
br label %45
66: ; preds = %53
%67 = load i32*, i32** %4
%68 = icmp ne i32* %67, null
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = load i32*, i32** %4
%71 = call i32 @fclose(i32* %70)
br label %72
72: ; preds = %69, %66
%73 = load i32, i32* %5
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %78
75: ; preds = %72
%76 = load i8*, i8** %3
%77 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %76)
br label %78
78: ; preds = %75, %72
%79 = load i32, i32* @EXIT_SUCCESS
store i32 %79, i32* %2
br label %80
80: ; preds = %78, %39, %14
%81 = load i32, i32* %2
ret i32 %81
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [26 x i8] c"couldn't find \22%s\22 in %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [4 x i8] c"all\00"
@.str.3 = [26 x i8] c"You have said %s time(s)\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.4 = [46 x i8] c"getting number of times \22%s\22 is said from %s\0A\00"
@.str.5 = [30 x i8] c"You have not said %s. Yet...\0A\00"
define i32 @getProfanity(i8* %0) {
%2 = alloca [256 x i8]
%3 = tail call i8* @getFileLocation(i32 0)
%4 = tail call i32 @checkFile(i8* %3)
%5 = tail call i8* @getFileLocation(i32 0)
%6 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = icmp eq i32* %6, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = tail call i8* @getFileLocation(i32 0)
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %10)
br label %46
12: ; preds = %1
%13 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = call i32* @fgets(i8* %7, i32 256, i32* %6)
%17 = icmp eq i32* %16, null
br i1 %17, label %46, label %18
18: ; preds = %15, %18
%19 = call i32 @removeNewlines(i8* %7)
%20 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%21 = call i32* @fgets(i8* %7, i32 256, i32* %6)
%22 = icmp eq i32* %21, null
br i1 %22, label %46, label %18
23: ; preds = %12
%24 = tail call i8* @getFileLocation(i32 0)
%25 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %24)
%26 = call i32* @fgets(i8* %7, i32 256, i32* %6)
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 @fclose(i32* %6)
br label %44
30: ; preds = %23, %37
%31 = phi i32 [ %38, %37 ], [ 0, %23 ]
%32 = call i64 @strstr(i8* %7, i8* %0)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = call i32 @removeNewlines(i8* %7)
%36 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %7)
br label %37
37: ; preds = %34, %30
%38 = phi i32 [ 1, %34 ], [ %31, %30 ]
%39 = call i32* @fgets(i8* %7, i32 256, i32* %6)
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %30
41: ; preds = %37
%42 = call i32 @fclose(i32* %6)
%43 = icmp eq i32 %38, 0
br i1 %43, label %44, label %46
44: ; preds = %28, %41
%45 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %46
46: ; preds = %18, %15, %41, %44, %9
%47 = phi i32* [ @EXIT_FAILURE, %9 ], [ @EXIT_SUCCESS, %44 ], [ @EXIT_SUCCESS, %41 ], [ @EXIT_SUCCESS, %15 ], [ @EXIT_SUCCESS, %18 ]
%48 = load i32, i32* %47
ret i32 %48
}