#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*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int status_count_file_lines(FILE *fp) {
  int count = 0;
  int ch = 0;
  if (!fp)
    return -1;
  while (!feof(fp)) {
    ch = fgetc(fp);
    if (ch == '\n')
      count++;
  }
  if (count == 0)
    return -2;
  else
    return count - 1;
}


x86 assembly (clang, -O0):
<status_count_file_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1151 <status_count_file_lines+0x31>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <status_count_file_lines+0x97>
jmp    1156 <status_count_file_lines+0x36>
mov    -0x10(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1174 <status_count_file_lines+0x54>
jmp    1198 <status_count_file_lines+0x78>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jne    1193 <status_count_file_lines+0x73>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <status_count_file_lines+0x36>
cmpl   $0x0,-0x14(%rbp)
jne    11ae <status_count_file_lines+0x8e>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11b7 <status_count_file_lines+0x97>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<status_count_file_lines>:
push   %rbp
push   %rbx
push   %rax
test   %rdi,%rdi
je     116a <status_count_file_lines+0x4a>
mov    %rdi,%rbx
call   1040 <feof@plt>
test   %eax,%eax
jne    1163 <status_count_file_lines+0x43>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0xa,%eax
sete   %cl
add    %ecx,%ebp
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %eax,%eax
je     1140 <status_count_file_lines+0x20>
sub    $0x1,%ebp
jae    116f <status_count_file_lines+0x4f>
mov    $0xfffffffe,%ebp
jmp    116f <status_count_file_lines+0x4f>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @status_count_file_lines(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 0, i32* %4
store i32 0, i32* %5
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 -1, i32* %2
br label %31
9: ; preds = %1
br label %10
10: ; preds = %23, %9
%11 = load i32*, i32** %3
%12 = call i32 @feof(i32* %11)
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
br i1 %14, label %15, label %24
15: ; preds = %10
%16 = load i32*, i32** %3
%17 = call i32 @fgetc(i32* %16)
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %23
23: ; preds = %20, %15
br label %10
24: ; preds = %10
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 -2, i32* %2
br label %31
28: ; preds = %24
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, 1
store i32 %30, i32* %2
br label %31
31: ; preds = %28, %27, %8
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @status_count_file_lines(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %18, label %3
3: ; preds = %1
%4 = tail call i32 @feof(i32* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %3, %6
%7 = phi i32 [ %11, %6 ], [ 0, %3 ]
%8 = tail call i32 @fgetc(i32* %0)
%9 = icmp eq i32 %8, 10
%10 = zext i1 %9 to i32
%11 = add nuw nsw i32 %7, %10
%12 = tail call i32 @feof(i32* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %6, label %14
14: ; preds = %6
%15 = icmp eq i32 %11, 0
%16 = add nsw i32 %11, -1
br i1 %15, label %17, label %18
17: ; preds = %3, %14
br label %18
18: ; preds = %17, %14, %1
%19 = phi i32 [ -1, %1 ], [ -2, %17 ], [ %16, %14 ]
ret i32 %19
}