#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*/ SEEK_SET;
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
char *strtok(char *, char *);
int count_significant_lines(FILE *fp) {
  char str[8192], *ptr;
  int count = 0;
  fseek(fp, 0, SEEK_SET);
  while (!feof(fp)) {
    fgets(str, 8192, fp);
    if (feof(fp))
      break;
    ptr = strtok(str, " \r\t\n");
    if (!ptr || ptr[0] == '#')
      continue;
    count++;
  }
  return count;
}


x86 assembly (clang, -O0):
<count_significant_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x201c(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118c <count_significant_lines+0x4c>
jmp    120d <count_significant_lines+0xcd>
lea    -0x2010(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x2000,%esi
call   1030 <fgets@plt>
mov    -0x8(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%rax
je     11b9 <count_significant_lines+0x79>
jmp    120d <count_significant_lines+0xcd>
lea    -0x2010(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x2018(%rbp)
cmpq   $0x0,-0x2018(%rbp)
je     11f4 <count_significant_lines+0xb4>
mov    -0x2018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11f9 <count_significant_lines+0xb9>
jmp    116d <count_significant_lines+0x2d>
mov    -0x201c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x201c(%rbp)
jmp    116d <count_significant_lines+0x2d>
mov    -0x201c(%rbp),%eax
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_significant_lines>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x2008,%rsp
mov    %rdi,%rbx
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
xor    %esi,%esi
call   1050 <fseek@plt>
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %rax,%rax
je     1181 <count_significant_lines+0x41>
mov    %r14d,%eax
add    $0x2008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
mov    %rsp,%rbp
lea    0xe72(%rip),%r15
jmp    119d <count_significant_lines+0x5d>
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %rax,%rax
jne    1170 <count_significant_lines+0x30>
mov    %rbp,%rdi
mov    $0x2000,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %rax,%rax
jne    1170 <count_significant_lines+0x30>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     1190 <count_significant_lines+0x50>
cmpb   $0x23,(%rax)
je     1190 <count_significant_lines+0x50>
add    $0x1,%r14d
jmp    1190 <count_significant_lines+0x50>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [5 x i8] c" \0D\09\0A\00"
define i32 @count_significant_lines(i32* %0) {
%2 = alloca i32*
%3 = alloca [8192 x i8]
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %5
%6 = load i32*, i32** %2
%7 = load i32, i32* @SEEK_SET
%8 = call i32 @fseek(i32* %6, i32 0, i32 %7)
br label %9
9: ; preds = %34, %33, %1
%10 = load i32*, i32** %2
%11 = call i64 @feof(i32* %10)
%12 = icmp ne i64 %11, 0
%13 = xor i1 %12, true
br i1 %13, label %14, label %37
14: ; preds = %9
%15 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%16 = load i32*, i32** %2
%17 = call i32 @fgets(i8* %15, i32 8192, i32* %16)
%18 = load i32*, i32** %2
%19 = call i64 @feof(i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %14
br label %37
22: ; preds = %14
%23 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
%24 = call i8* @strtok(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %24, i8** %4
%25 = load i8*, i8** %4
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %33
27: ; preds = %22
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 35
br i1 %32, label %33, label %34
33: ; preds = %27, %22
br label %9
34: ; preds = %27
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %9
37: ; preds = %21, %9
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [5 x i8] c" \0D\09\0A\00"
define i32 @count_significant_lines(i32* nocapture %0) {
%2 = alloca [8192 x i8]
%3 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @SEEK_SET
%5 = tail call i32 @fseek(i32* %0, i32 0, i32 %4)
%6 = call i64 @feof(i32* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %27
8: ; preds = %1, %23
%9 = phi i32 [ %24, %23 ], [ 0, %1 ]
br label %10
10: ; preds = %8, %20
%11 = call i32 @fgets(i8* %3, i32 8192, i32* %0)
%12 = call i64 @feof(i32* %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i8, i8* %15
%19 = icmp eq i8 %18, 35
br i1 %19, label %20, label %23
20: ; preds = %17, %14
%21 = call i64 @feof(i32* %0)
%22 = icmp eq i64 %21, 0
br i1 %22, label %10, label %27
23: ; preds = %17
%24 = add nuw nsw i32 %9, 1
%25 = call i64 @feof(i32* %0)
%26 = icmp eq i64 %25, 0
br i1 %26, label %8, label %27
27: ; preds = %23, %20, %10, %1
%28 = phi i32 [ 0, %1 ], [ %9, %10 ], [ %9, %20 ], [ %24, %23 ]
ret i32 %28
}