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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int sequence_count(FILE *file) {
  int count = 0;
  char line[1024];
  long int start_pos = ftell(file);
  while (fgets(line, sizeof(line), file)) {
    if (line[0] == '>')
      count++;
  }
  fseek(file, start_pos, SEEK_SET);
  return count;
}


x86 assembly (clang, -O0):
<sequence_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x400,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     1193 <sequence_count+0x63>
movsbl -0x410(%rbp),%eax
cmp    $0x3e,%eax
jne    118e <sequence_count+0x5e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1156 <sequence_count+0x26>
mov    -0x8(%rbp),%rdi
mov    -0x418(%rbp),%rsi
mov    0x2e3b(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
mov    -0xc(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sequence_count>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%rbx
call   1040 <ftell@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1190 <sequence_count+0x60>
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
cmpb   $0x3e,(%rsp)
sete   %al
add    %eax,%ebp
mov    %r15,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
jne    1170 <sequence_count+0x40>
mov    0x2e49(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fseek@plt>
mov    %ebp,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @sequence_count(i32* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @ftell(i32* %0)
%5 = call i64 @fgets(i8* %3, i32 1024, 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 eq i8 %9, 62
%11 = zext i1 %10 to i32
%12 = add nuw nsw i32 %8, %11
%13 = call i64 @fgets(i8* %3, i32 1024, 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 ]
%17 = load i32, i32* @SEEK_SET
%18 = call i32 @fseek(i32* %0, i64 %4, i32 %17)
ret i32 %16
}