#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int fLineCounter(int count, char *fname) {
  FILE *lineCount;
  int accessFile;
  printf("fLineCounter start count is: %d\n", count);
  lineCount = fopen(fname, "r");
  if (lineCount == NULL) {
    printf("Cannot open file for reading\n");
    exit(1);
  }
  accessFile = getc(lineCount);
  while (accessFile != EOF) {
    if (accessFile == '\n')
      count++;
    accessFile = getc(lineCount);
  }
  printf("fLineCounter end count is: %d\n", count);
  fclose(lineCount);
  return count;
}


x86 assembly (clang, -O0):
<fLineCounter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a7 <fLineCounter+0x57>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e2b(%rip),%rcx
cmp    (%rcx),%eax
je     11e9 <fLineCounter+0x99>
cmpl   $0xa,-0x1c(%rbp)
jne    11d8 <fLineCounter+0x88>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x1c(%rbp)
jmp    11b3 <fLineCounter+0x63>
mov    -0x4(%rbp),%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fLineCounter>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xe8f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea0(%rip),%rsi
mov    %r14,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     11e7 <fLineCounter+0x87>
mov    %rax,%r14
mov    %rax,%rdi
call   1080 <getc@plt>
mov    0x2e48(%rip),%r15
cmp    (%r15),%eax
je     11c7 <fLineCounter+0x67>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%ebx
mov    %r14,%rdi
call   1080 <getc@plt>
cmp    (%r15),%eax
jne    11b0 <fLineCounter+0x50>
lea    0xe55(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"fLineCounter start count is: %d\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [30 x i8] c"Cannot open file for reading\0A\00"
@EOF = global i32 0
@.str.3 = [31 x i8] c"fLineCounter end count is: %d\0A\00"
define i32 @fLineCounter(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i8*, i8** %4
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %5
%11 = load i32*, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i32*, i32** %5
%18 = call i32 @getc(i32* %17)
store i32 %18, i32* %6
br label %19
19: ; preds = %29, %16
%20 = load i32, i32* %6
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %32
23: ; preds = %19
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %29
29: ; preds = %26, %23
%30 = load i32*, i32** %5
%31 = call i32 @getc(i32* %30)
store i32 %31, i32* %6
br label %19
32: ; preds = %19
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = load i32*, i32** %5
%36 = call i32 @fclose(i32* %35)
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [33 x i8] c"fLineCounter start count is: %d\0A\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i32 0
@.str.3 = [31 x i8] c"fLineCounter end count is: %d\0A\00"
@str = [29 x i8] c"Cannot open file for reading\00"
define i32 @fLineCounter(i32 %0, i8* nocapture %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = tail call i32 @getc(i32* %4)
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %22, label %13
13: ; preds = %9, %13
%14 = phi i32 [ %19, %13 ], [ %10, %9 ]
%15 = phi i32 [ %18, %13 ], [ %0, %9 ]
%16 = icmp eq i32 %14, 10
%17 = zext i1 %16 to i32
%18 = add nsw i32 %15, %17
%19 = tail call i32 @getc(i32* %4)
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %13
22: ; preds = %13, %9
%23 = phi i32 [ %0, %9 ], [ %18, %13 ]
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = tail call i32 @fclose(i32* %4)
ret i32 %23
}