#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*/ *);
scalar_t__ fgets(unsigned char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(unsigned char *, char *);
int strlen(unsigned char *);
unsigned int getentries(unsigned char *file) {
  FILE *fi;
  unsigned int s = 0;
  unsigned char buf[100];
  fi = fopen(file, "r");
  if (!fi)
    return 0;
  while (fgets(buf, 100, fi))
    if ((buf[0] != '#') && (buf[0] != ';') && (strlen(buf) > 10))
      s++;
  fclose(fi);
  return s;
}


x86 assembly (clang, -O0):
<getentries>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1181 <getentries+0x41>
movl   $0x0,-0x4(%rbp)
jmp    11eb <getentries+0xab>
jmp    1186 <getentries+0x46>
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x64,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11dc <getentries+0x9c>
movzbl -0x80(%rbp),%eax
cmp    $0x23,%eax
je     11d7 <getentries+0x97>
movzbl -0x80(%rbp),%eax
cmp    $0x3b,%eax
je     11d7 <getentries+0x97>
lea    -0x80(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xa,%eax
jle    11d7 <getentries+0x97>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1186 <getentries+0x46>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getentries>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xeb1(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11c0 <getentries+0x80>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     11b6 <getentries+0x76>
mov    %rsp,%rbp
jmp    1195 <getentries+0x55>
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11b6 <getentries+0x76>
movzbl (%rsp),%eax
cmp    $0x23,%al
je     1180 <getentries+0x40>
cmp    $0x3b,%al
je     1180 <getentries+0x40>
mov    %rbp,%rdi
call   1040 <strlen@plt>
xor    %ecx,%ecx
cmp    $0xb,%eax
setge  %cl
add    %ecx,%r14d
jmp    1180 <getentries+0x40>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    11c3 <getentries+0x83>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @getentries(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca [100 x i8]
store i8* %0, i8** %3
store i32 0, i32* %5
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %1
store i32 0, i32* %2
br label %40
12: ; preds = %1
br label %13
13: ; preds = %35, %12
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%15 = load i32*, i32** %4
%16 = call i64 @fgets(i8* %14, i32 100, i32* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %36
18: ; preds = %13
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = icmp ne i32 %21, 35
br i1 %22, label %23, label %35
23: ; preds = %18
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = icmp ne i32 %26, 59
br i1 %27, label %28, label %35
28: ; preds = %23
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = icmp sgt i32 %30, 10
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = load i32, i32* %5
%34 = add i32 %33, 1
store i32 %34, i32* %5
br label %35
35: ; preds = %32, %28, %23, %18
br label %13
36: ; preds = %13
%37 = load i32*, i32** %4
%38 = call i32 @fclose(i32* %37)
%39 = load i32, i32* %5
store i32 %39, i32* %2
br label %40
40: ; preds = %36, %11
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @getentries(i8* nocapture %0) {
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %24, label %6
6: ; preds = %1
%7 = call i64 @fgets(i8* %3, i32 100, i32* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %6, %17
%10 = phi i32 [ %18, %17 ], [ 0, %6 ]
%11 = load i8, i8* %3
switch i8 %11, label %12 [
i8 59, label %17
i8 35, label %17
]
12: ; preds = %9
%13 = call i32 @strlen(i8* %3)
%14 = icmp sgt i32 %13, 10
%15 = zext i1 %14 to i32
%16 = add i32 %10, %15
br label %17
17: ; preds = %12, %9, %9
%18 = phi i32 [ %10, %9 ], [ %10, %9 ], [ %16, %12 ]
%19 = call i64 @fgets(i8* %3, i32 100, i32* %4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %9
21: ; preds = %17, %6
%22 = phi i32 [ 0, %6 ], [ %18, %17 ]
%23 = call i32 @fclose(i32* %4)
br label %24
24: ; preds = %1, %21
%25 = phi i32 [ %22, %21 ], [ 0, %1 ]
ret i32 %25
}