#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, ...);
char *readWordFromFile(int /*<<< orphan*/ *, int *);
int main(int argc, char **argv) {
  FILE *in = fopen("input.txt", "r");
  int L = -1;
  int checker = 0;
  int numWords = 0;
  fscanf(in, "%d", &L);
  while (checker != EOF) {
    char *word = readWordFromFile(in, &checker);
    printf("(word): %s\n", word);
    if (word != NULL)
      numWords++;
  }
  printf("Total Number Of Words: %d\n", numWords);
  fclose(in);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6f(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x20(%rbp),%eax
mov    0x2e38(%rip),%rcx
cmp    (%rcx),%eax
je     11f4 <main+0xa4>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <readWordFromFile@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x30(%rbp)
je     11ef <main+0x9f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a6 <main+0x56>
mov    -0x24(%rbp),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
movl   $0xffffffff,0x4(%rsp)
ff
movl   $0x0,(%rsp)
lea    0xe85(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1050 <fscanf@plt>
mov    0x2e4d(%rip),%r13
cmpl   $0x0,0x0(%r13)
je     11dd <main+0x8d>
mov    %rsp,%r14
lea    0xe63(%rip),%r15
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <readWordFromFile@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%rbx
sbb    $0xffffffff,%ebp
mov    (%rsp),%eax
cmp    0x0(%r13),%eax
jne    11b0 <main+0x60>
jmp    11df <main+0x8f>
xor    %ebp,%ebp
lea    0xe35(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@EOF = global i32 0
@.str.3 = [12 x i8] c"(word): %s\0A\00"
@.str.4 = [27 x i8] c"Total Number Of Words: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %2, %11
%12 = phi i32 [ %17, %11 ], [ 0, %2 ]
%13 = call i8* @readWordFromFile(i32* %5, i32* %4)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = icmp ne i8* %13, null
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %12, %16
%18 = load i32, i32* %4
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %11
21: ; preds = %11, %2
%22 = phi i32 [ 0, %2 ], [ %17, %11 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = call i32 @fclose(i32* %5)
ret i32 0
}