#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int count = 0;
  char line[100 * 1024];
  FILE *fp;
  if ((fp = fopen(argv[1], "r")) == NULL) {
    return 1;
  }
  while ((fgets(line, 100 * 1024, fp)) != NULL) {
    if (line[0] == '>') {
      count++;
    }
  }
  printf("count: %d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x19030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea1(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x19028(%rbp)
cmp    $0x0,%rax
jne    1181 <main+0x51>
movl   $0x1,-0x4(%rbp)
jmp    11dc <main+0xac>
jmp    1186 <main+0x56>
lea    -0x19020(%rbp),%rdi
mov    -0x19028(%rbp),%rdx
mov    $0x19000,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11c6 <main+0x96>
movsbl -0x19020(%rbp),%eax
cmp    $0x3e,%eax
jne    11c1 <main+0x91>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1186 <main+0x56>
mov    -0x14(%rbp),%esi
lea    0xe32(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x19030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x19008,%rsp
mov    0x8(%rsi),%rdi
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11b0 <main+0x80>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x19000,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
xor    %r14d,%r14d
mov    $0x0,%ebp
test   %rax,%rax
je     11a0 <main+0x70>
xor    %ebp,%ebp
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
cmpb   $0x3e,(%rsp)
sete   %al
add    %eax,%ebp
mov    %r15,%rdi
mov    $0x19000,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    1180 <main+0x50>
lea    0xe5b(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
jmp    11b6 <main+0x86>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x19008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [11 x i8] c"count: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [102400 x i8]
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %8
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %3
br label %33
15: ; preds = %2
br label %16
16: ; preds = %29, %15
%17 = getelementptr inbounds [102400 x i8], [102400 x i8]* %7, i64 0, i64 0
%18 = load i32*, i32** %8
%19 = call i32* @fgets(i8* %17, i32 102400, i32* %18)
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %30
21: ; preds = %16
%22 = getelementptr inbounds [102400 x i8], [102400 x i8]* %7, i64 0, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 62
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %29
29: ; preds = %26, %21
br label %16
30: ; preds = %16
%31 = load i32, i32* %6
%32 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %31)
store i32 0, i32* %3
br label %33
33: ; preds = %30, %14
%34 = load i32, i32* %3
ret i32 %34
}

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