#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_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ counterFile(int /*<<< orphan*/ *, int *, int *, int *,
                               int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ printCounterResults(int *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int main(int argc, char *argv[]) {
  if (argc <= 0 || argc >= 3) {
    fprintf(stderr,
            "%s: program expected either 0 or 1 arguments, but instead "
            "revieved %i \n",
            argv[0], argc - 1);
    exit(EXIT_FAILURE);
  } else if (argc == 1) {
    printf("\n");
    printf("[WINDOWS] To indicate the end of input: Ctrl+Z \n");
    printf("[LINUX & OSX] To indicate the end of input: Ctrl+D \n");
    printf("Enter Text (Up to %i characters): \n", 2048);
    FILE *filename;
    filename = stdin;
    if (filename == NULL) {
      printf("\n");
      printf("Could not open file or file not found! \n");
      fclose(filename);
      exit(EXIT_FAILURE);
    } else {
      int lines = 0;
      int characters = 0;
      int words = 0;
      printf("\n");
      counterFile(filename, &lines, &characters, &words, &argc);
      printf("\n");
      printCounterResults(&lines, &characters, &words);
      fclose(filename);
    }
    exit(EXIT_SUCCESS);
  } else if (argc == 2) {
    FILE *filename;
    filename = fopen(argv[1], "r");
    if (filename == NULL) {
      printf("\n");
      printf("Could not open file or file not found! \n");
      fclose(filename);
      exit(EXIT_FAILURE);
    } else {
      int lines = 0;
      int characters = 0;
      int words = 0;
      printf("\n");
      counterFile(filename, &lines, &characters, &words, &argc);
      printf("\n");
      printCounterResults(&lines, &characters, &words);
      fclose(filename);
    }
    exit(EXIT_SUCCESS);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    119a <main+0x2a>
cmpl   $0x3,-0x8(%rbp)
jl     11ca <main+0x5a>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
lea    0xe49(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
jne    12cf <main+0x15f>
lea    0xf1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
mov    $0x800,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    125d <main+0xed>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
lea    -0x8(%rbp),%r8
call   1060 <counterFile@plt>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1080 <printCounterResults@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2d00(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jne    13a1 <main+0x231>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe13(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    132f <main+0x1bf>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
lea    -0x8(%rbp),%r8
call   1060 <counterFile@plt>
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x34(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   1080 <printCounterResults@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2c2e(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    13a6 <main+0x236>
jmp    13ab <main+0x23b>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ecx
mov    %edi,0x14(%rsp)
lea    -0x3(%rcx),%eax
cmp    $0xfffffffd,%eax
ja     11c6 <main+0x36>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
add    $0xffffffff,%ecx
lea    0xe41(%rip),%rsi
call   1070 <fprintf@plt>
jmp    1243 <main+0xb3>
cmp    $0x1,%ecx
jne    1211 <main+0x81>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe92(%rip),%rdi
call   1040 <puts@plt>
lea    0xeb6(%rip),%rdi
call   1040 <puts@plt>
lea    0xe54(%rip),%rdi
mov    $0x800,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%rbx
test   %rbx,%rbx
je     1226 <main+0x96>
jmp    1254 <main+0xc4>
mov    0x8(%rsi),%rdi
lea    0xe50(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
jne    1251 <main+0xc1>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe9b(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1050 <fclose@plt>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    %rax,%rbx
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x10(%rsp),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0x14(%rsp),%r8
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1080 <counterFile@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   10a0 <printCounterResults@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [72 x i8] c"%s: program expected either 0 or 1 arguments, but instead revieved %i \0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [49 x i8] c"[WINDOWS] To indicate the end of input: Ctrl+Z \0A\00"
@.str.3 = [53 x i8] c"[LINUX & OSX] To indicate the end of input: Ctrl+D \0A\00"
@.str.4 = [36 x i8] c"Enter Text (Up to %i characters): \0A\00"
@stdin = global i32* null
@.str.5 = [41 x i8] c"Could not open file or file not found! \0A\00"
@EXIT_SUCCESS = global i32 0
@.str.6 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp sle i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp sge i32 %17, 3
br i1 %18, label %19, label %29
19: ; preds = %16, %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = load i32, i32* %4
%25 = sub nsw i32 %24, 1
%26 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0), i8* %23, i32 %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %16
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %58
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 2048)
%37 = load i32*, i32** @stdin
store i32* %37, i32** %6
%38 = load i32*, i32** %6
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %47
40: ; preds = %32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%43 = load i32*, i32** %6
%44 = call i32 @fclose(i32* %43)
%45 = load i32, i32* @EXIT_FAILURE
%46 = call i32 @exit(i32 %45)
unreachable
47: ; preds = %32
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%49 = load i32*, i32** %6
%50 = call i32 @counterFile(i32* %49, i32* %7, i32* %8, i32* %9, i32* %4)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%52 = call i32 @printCounterResults(i32* %7, i32* %8, i32* %9)
%53 = load i32*, i32** %6
%54 = call i32 @fclose(i32* %53)
br label %55
55: ; preds = %47
%56 = load i32, i32* @EXIT_SUCCESS
%57 = call i32 @exit(i32 %56)
unreachable
58: ; preds = %29
%59 = load i32, i32* %4
%60 = icmp eq i32 %59, 2
br i1 %60, label %61, label %86
61: ; preds = %58
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i32* @fopen(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %65, i32** %10
%66 = load i32*, i32** %10
%67 = icmp eq i32* %66, null
br i1 %67, label %68, label %75
68: ; preds = %61
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%71 = load i32*, i32** %10
%72 = call i32 @fclose(i32* %71)
%73 = load i32, i32* @EXIT_FAILURE
%74 = call i32 @exit(i32 %73)
unreachable
75: ; preds = %61
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%77 = load i32*, i32** %10
%78 = call i32 @counterFile(i32* %77, i32* %11, i32* %12, i32* %13, i32* %4)
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%80 = call i32 @printCounterResults(i32* %11, i32* %12, i32* %13)
%81 = load i32*, i32** %10
%82 = call i32 @fclose(i32* %81)
br label %83
83: ; preds = %75
%84 = load i32, i32* @EXIT_SUCCESS
%85 = call i32 @exit(i32 %84)
unreachable
86: ; preds = %58
br label %87
87: ; preds = %86
br label %88
88: ; preds = %87
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [72 x i8] c"%s: program expected either 0 or 1 arguments, but instead revieved %i \0A\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [36 x i8] c"Enter Text (Up to %i characters): \0A\00"
@stdin = global i32* null
@EXIT_SUCCESS = global i32 0
@.str.6 = [2 x i8] c"r\00"
@str.7 = [48 x i8] c"[WINDOWS] To indicate the end of input: Ctrl+Z \00"
@str.8 = [52 x i8] c"[LINUX & OSX] To indicate the end of input: Ctrl+D \00"
@str.9 = [40 x i8] c"Could not open file or file not found! \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
%10 = add i32 %0, -3
%11 = icmp ult i32 %10, -2
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = add nsw i32 %0, -1
%16 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = tail call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = icmp eq i32 %0, 1
br i1 %20, label %21, label %45
21: ; preds = %19
%22 = tail call i32 @putchar(i32 10)
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.7, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.8, i64 0, i64 0))
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0), i32 2048)
%26 = load i32*, i32** @stdin
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %34
28: ; preds = %21
%29 = tail call i32 @putchar(i32 10)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.9, i64 0, i64 0))
%31 = tail call i32 @fclose(i32* null)
%32 = load i32, i32* @EXIT_FAILURE
%33 = tail call i32 @exit(i32 %32)
unreachable
34: ; preds = %21
%35 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%36 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%37 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%38 = tail call i32 @putchar(i32 10)
%39 = call i32 @counterFile(i32* %26, i32* %4, i32* %5, i32* %6, i32* %3)
%40 = call i32 @putchar(i32 10)
%41 = call i32 @printCounterResults(i32* %4, i32* %5, i32* %6)
%42 = call i32 @fclose(i32* %26)
%43 = load i32, i32* @EXIT_SUCCESS
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %19
%46 = getelementptr inbounds i8*, i8** %1, i64 1
%47 = load i8*, i8** %46
%48 = tail call i32* @fopen(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %56
50: ; preds = %45
%51 = tail call i32 @putchar(i32 10)
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.9, i64 0, i64 0))
%53 = tail call i32 @fclose(i32* null)
%54 = load i32, i32* @EXIT_FAILURE
%55 = tail call i32 @exit(i32 %54)
unreachable
56: ; preds = %45
%57 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%58 = bitcast i32* %8 to i8*
store i32 0, i32* %8
%59 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%60 = tail call i32 @putchar(i32 10)
%61 = call i32 @counterFile(i32* %48, i32* %7, i32* %8, i32* %9, i32* %3)
%62 = call i32 @putchar(i32 10)
%63 = call i32 @printCounterResults(i32* %7, i32* %8, i32* %9)
%64 = call i32 @fclose(i32* %48)
%65 = load i32, i32* @EXIT_SUCCESS
%66 = call i32 @exit(i32 %65)
unreachable
}