#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 */
scalar_t__ EOF;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int get_dict_len(char *dict_dir) {
  FILE *file = fopen(dict_dir, "r");
  assert(file != NULL);
  char word[45 + 1];
  int counter = 0;
  while (fscanf(file, "%s", word) != EOF) {
    counter++;
  }
  return counter;
}


x86 assembly (clang, -O0):
<get_dict_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xe8a(%rip),%rsi
call   1030 <fscanf@plt>
mov    0x2e64(%rip),%rcx
cmp    (%rcx),%rax
je     119b <get_dict_len+0x6b>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1169 <get_dict_len+0x39>
mov    -0x44(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_dict_len>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
lea    0xebd(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
mov    $0xffffffff,%ebp
lea    0xe9d(%rip),%r14
mov    %rsp,%r15
mov    0x2e79(%rip),%r12
nop
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <fscanf@plt>
add    $0x1,%ebp
cmp    (%r12),%rax
jne    1170 <get_dict_len+0x40>
mov    %ebp,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
define i32 @get_dict_len(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [46 x i8]
%5 = alloca i32
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
%8 = load i32*, i32** %3
%9 = icmp ne i32* %8, null
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
store i32 0, i32* %5
br label %12
12: ; preds = %18, %1
%13 = load i32*, i32** %3
%14 = getelementptr inbounds [46 x i8], [46 x i8]* %4, i64 0, i64 0
%15 = call i64 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i64, i64* @EOF
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %12
21: ; preds = %12
%22 = load i32, i32* %5
ret i32 %22
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
define i32 @get_dict_len(i8* nocapture %0) {
%2 = alloca [46 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp ne i32* %3, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = getelementptr inbounds [46 x i8], [46 x i8]* %2, i64 0, i64 0
br label %8
8: ; preds = %8, %1
%9 = phi i32 [ 0, %1 ], [ %13, %8 ]
%10 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
%13 = add nuw nsw i32 %9, 1
br i1 %12, label %14, label %8
14: ; preds = %8
ret i32 %9
}