#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*/ *);
char fgetc(int /*<<< orphan*/ *);
scalar_t__ ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
unsigned int getSizeOfDenominations(FILE *f) {
  unsigned int count = 0;
  char ch;
  if (f == NULL) {
    fclose(f);
    return 0;
  } else {
    while (!feof(f)) {
      ch = fgetc(f);
      if (ch == '\n') {
        count++;
      }
    }
    if (count == 0) {
      if (ftell(f) > 0) {
        rewind(f);
        return 1;
      } else {
        rewind(f);
        return 0;
      }
    } else {
      rewind(f);
      return ++count;
    }
  }
}


x86 assembly (clang, -O0):
<getSizeOfDenominations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1183 <getSizeOfDenominations+0x33>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    1229 <getSizeOfDenominations+0xd9>
jmp    1188 <getSizeOfDenominations+0x38>
mov    -0x10(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a6 <getSizeOfDenominations+0x56>
jmp    11cd <getSizeOfDenominations+0x7d>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0xa,%eax
jne    11c8 <getSizeOfDenominations+0x78>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <getSizeOfDenominations+0x38>
cmpl   $0x0,-0x14(%rbp)
jne    1214 <getSizeOfDenominations+0xc4>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
cmp    $0x0,%rax
jle    11ff <getSizeOfDenominations+0xaf>
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
movl   $0x1,-0x4(%rbp)
jmp    1229 <getSizeOfDenominations+0xd9>
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
movl   $0x0,-0x4(%rbp)
jmp    1229 <getSizeOfDenominations+0xd9>
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSizeOfDenominations>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     117f <getSizeOfDenominations+0x2f>
mov    %rdi,%r14
call   1070 <feof@plt>
test   %eax,%eax
je     118a <getSizeOfDenominations+0x3a>
mov    %r14,%rdi
call   1060 <ftell@plt>
xor    %ebx,%ebx
test   %rax,%rax
setg   %bl
mov    %r14,%rdi
call   1040 <rewind@plt>
jmp    11bc <getSizeOfDenominations+0x6c>
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <fclose@plt>
jmp    11bc <getSizeOfDenominations+0x6c>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
add    %ecx,%ebx
mov    %r14,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     1190 <getSizeOfDenominations+0x40>
test   %ebx,%ebx
je     1165 <getSizeOfDenominations+0x15>
mov    %r14,%rdi
call   1040 <rewind@plt>
add    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @getSizeOfDenominations(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8
store i32* %0, i32** %3
store i32 0, i32* %4
%6 = load i32*, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32*, i32** %3
%10 = call i32 @fclose(i32* %9)
store i32 0, i32* %2
br label %45
11: ; preds = %1
br label %12
12: ; preds = %26, %11
%13 = load i32*, i32** %3
%14 = call i32 @feof(i32* %13)
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %27
17: ; preds = %12
%18 = load i32*, i32** %3
%19 = call signext i8 @fgetc(i32* %18)
store i8 %19, i8* %5
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = load i32, i32* %4
%25 = add i32 %24, 1
store i32 %25, i32* %4
br label %26
26: ; preds = %23, %17
br label %12
27: ; preds = %12
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %40
30: ; preds = %27
%31 = load i32*, i32** %3
%32 = call i64 @ftell(i32* %31)
%33 = icmp sgt i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32*, i32** %3
%36 = call i32 @rewind(i32* %35)
store i32 1, i32* %2
br label %45
37: ; preds = %30
%38 = load i32*, i32** %3
%39 = call i32 @rewind(i32* %38)
store i32 0, i32* %2
br label %45
40: ; preds = %27
%41 = load i32*, i32** %3
%42 = call i32 @rewind(i32* %41)
%43 = load i32, i32* %4
%44 = add i32 %43, 1
store i32 %44, i32* %4
store i32 %44, i32* %2
br label %45
45: ; preds = %40, %37, %34, %8
%46 = load i32, i32* %2
ret i32 %46
}

LLVM IR (-O2):
define i32 @getSizeOfDenominations(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = tail call i32 @feof(i32* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %18
6: ; preds = %1
%7 = tail call i32 @fclose(i32* null)
br label %26
8: ; preds = %3, %8
%9 = phi i32 [ %13, %8 ], [ 0, %3 ]
%10 = tail call signext i8 @fgetc(i32* %0)
%11 = icmp eq i8 %10, 10
%12 = zext i1 %11 to i32
%13 = add i32 %9, %12
%14 = tail call i32 @feof(i32* %0)
%15 = icmp eq i32 %14, 0
br i1 %15, label %8, label %16
16: ; preds = %8
%17 = icmp eq i32 %13, 0
br i1 %17, label %18, label %23
18: ; preds = %3, %16
%19 = tail call i64 @ftell(i32* %0)
%20 = icmp sgt i64 %19, 0
%21 = tail call i32 @rewind(i32* %0)
%22 = zext i1 %20 to i32
br label %26
23: ; preds = %16
%24 = tail call i32 @rewind(i32* %0)
%25 = add i32 %13, 1
br label %26
26: ; preds = %18, %23, %6
%27 = phi i32 [ 0, %6 ], [ %25, %23 ], [ %22, %18 ]
ret i32 %27
}