#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*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ read_word_from_file(int /*<<< orphan*/ *, char *);
long long num_of_words_in_seed_file(char *seed_file_name) {
  FILE *f;
  f = fopen(seed_file_name, "r");
  long long num_of_words = 0;
  char tmp[2000];
  while (read_word_from_file(f, tmp) > 0)
    num_of_words++;
  fclose(f);
  return num_of_words;
}


x86 assembly (clang, -O0):
<num_of_words_in_seed_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7f0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x7f0(%rbp),%rsi
call   1030 <read_word_from_file@plt>
cmp    $0x0,%rax
jle    1186 <num_of_words_in_seed_file+0x56>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115b <num_of_words_in_seed_file+0x2b>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rax
add    $0x7f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_of_words_in_seed_file>:
push   %r15
push   %r14
push   %rbx
sub    $0x7d0,%rsp
lea    0xebd(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
mov    $0xffffffffffffffff,%rbx
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <read_word_from_file@plt>
add    $0x1,%rbx
test   %rax,%rax
jg     1160 <num_of_words_in_seed_file+0x30>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rax
add    $0x7d0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i64 @num_of_words_in_seed_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i64
%5 = alloca [2000 x i8]
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
store i64 0, i64* %4
br label %8
8: ; preds = %13, %1
%9 = load i32*, i32** %3
%10 = getelementptr inbounds [2000 x i8], [2000 x i8]* %5, i64 0, i64 0
%11 = call i64 @read_word_from_file(i32* %9, i8* %10)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i64, i64* %4
%15 = add nsw i64 %14, 1
store i64 %15, i64* %4
br label %8
16: ; preds = %8
%17 = load i32*, i32** %3
%18 = call i32 @fclose(i32* %17)
%19 = load i64, i64* %4
ret i64 %19
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i64 @num_of_words_in_seed_file(i8* nocapture %0) {
%2 = alloca [2000 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %5, %1
%6 = phi i64 [ 0, %1 ], [ %9, %5 ]
%7 = call i64 @read_word_from_file(i32* %3, i8* %4)
%8 = icmp sgt i64 %7, 0
%9 = add nuw nsw i64 %6, 1
br i1 %8, label %5, label %10
10: ; preds = %5
%11 = call i32 @fclose(i32* %3)
ret i64 %6
}