#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*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int QuickSpheresEstimate(FILE *fpAts) {
  char buffer[85];
  int numSpheres = 0;
  rewind(fpAts);
  while (fgets(buffer, sizeof(buffer), fpAts)) {
    if (buffer[0] != '#')
      numSpheres++;
  }
  return numSpheres;
}


x86 assembly (clang, -O0):
<QuickSpheresEstimate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x55,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1173 <QuickSpheresEstimate+0x53>
movsbl -0x60(%rbp),%eax
cmp    $0x23,%eax
je     116e <QuickSpheresEstimate+0x4e>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    113c <QuickSpheresEstimate+0x1c>
mov    -0x64(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QuickSpheresEstimate>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
call   1030 <rewind@plt>
mov    %rsp,%rdi
mov    $0x55,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1170 <QuickSpheresEstimate+0x50>
mov    %rsp,%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
cmpb   $0x23,(%rsp)
setne  %al
add    %eax,%ebp
mov    %r14,%rdi
mov    $0x55,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    1150 <QuickSpheresEstimate+0x30>
mov    %ebp,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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