#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stringutils_is_empty_line(char *);
int filesystem_count_lines(FILE *file) {
  assert(file != NULL);
  rewind(file);
  char buffer[255];
  int lines = 0;
  while (fgets(buffer, 255, file) != NULL) {
    if (!stringutils_is_empty_line(buffer)) {
      lines++;
    }
  }
  rewind(file);
  return lines;
}


x86 assembly (clang, -O0):
<filesystem_count_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
movl   $0x0,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0xff,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11bc <filesystem_count_lines+0x7c>
lea    -0x110(%rbp),%rdi
call   1060 <stringutils_is_empty_line@plt>
cmp    $0x0,%eax
jne    11b7 <filesystem_count_lines+0x77>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1174 <filesystem_count_lines+0x34>
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0x114(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filesystem_count_lines>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
mov    %r14,%rdi
call   1030 <rewind@plt>
mov    %rsp,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11a3 <filesystem_count_lines+0x63>
mov    %rsp,%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
call   1060 <stringutils_is_empty_line@plt>
cmp    $0x1,%eax
adc    $0x0,%ebp
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    1180 <filesystem_count_lines+0x40>
mov    %r14,%rdi
call   1030 <rewind@plt>
mov    %ebp,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @filesystem_count_lines(i32* %0) {
%2 = alloca i32*
%3 = alloca [255 x i8]
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = icmp ne i32* %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = load i32*, i32** %2
%10 = call i32 @rewind(i32* %9)
store i32 0, i32* %4
br label %11
11: ; preds = %23, %1
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%13 = load i32*, i32** %2
%14 = call i32* @fgets(i8* %12, i32 255, i32* %13)
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %24
16: ; preds = %11
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%18 = call i32 @stringutils_is_empty_line(i8* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %23
23: ; preds = %20, %16
br label %11
24: ; preds = %11
%25 = load i32*, i32** %2
%26 = call i32 @rewind(i32* %25)
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
define i32 @filesystem_count_lines(i32* %0) {
%2 = alloca [255 x i8]
%3 = icmp ne i32* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i32 @rewind(i32* %0)
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%8 = call i32* @fgets(i8* %7, i32 255, i32* %0)
%9 = icmp eq i32* %8, null
br i1 %9, label %18, label %10
10: ; preds = %1, %10
%11 = phi i32 [ %15, %10 ], [ 0, %1 ]
%12 = call i32 @stringutils_is_empty_line(i8* %7)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %11, %14
%16 = call i32* @fgets(i8* %7, i32 255, i32* %0)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %10
18: ; preds = %10, %1
%19 = phi i32 [ 0, %1 ], [ %15, %10 ]
%20 = call i32 @rewind(i32* %0)
ret i32 %19
}