#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ has_more_than_2eq(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main() {
  char word[21];
  FILE *f;
  int words_count = 0;
  if ((f = fopen("words.txt", "r")) == NULL) {
    printf("The file `words.txt` can not be opened.\n");
    return -1;
  }
  while (fgets(word, 21, f) != NULL) {
    if (has_more_than_2eq(word)) {
      puts(word);
      words_count++;
    }
  }
  printf("\nTotal %d words.\n", words_count);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xe83(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11b1 <main+0x51>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    121d <main+0xbd>
jmp    11b6 <main+0x56>
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x15,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     11fc <main+0x9c>
lea    -0x20(%rbp),%rdi
call   1070 <has_more_than_2eq@plt>
cmp    $0x0,%rax
je     11f7 <main+0x97>
lea    -0x20(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b6 <main+0x56>
mov    -0x2c(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe8f(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11f9 <main+0x99>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x15,%esi
mov    %rax,%rdx
call   1060 <fgets@plt>
xor    %r14d,%r14d
mov    $0x0,%ebp
test   %rax,%rax
je     11df <main+0x7f>
xor    %ebp,%ebp
mov    %rsp,%rbx
jmp    11c5 <main+0x65>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x15,%esi
mov    %r15,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11df <main+0x7f>
mov    %rbx,%rdi
call   1070 <has_more_than_2eq@plt>
test   %rax,%rax
je     11b0 <main+0x50>
mov    %rbx,%rdi
call   1030 <puts@plt>
add    $0x1,%ebp
jmp    11b0 <main+0x50>
lea    0xe26(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
jmp    120b <main+0xab>
lea    0xe1e(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"words.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [41 x i8] c"The file `words.txt` can not be opened.\0A\00"
@.str.3 = [18 x i8] c"\0ATotal %d words.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [21 x i8]
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = 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* %5, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %30
9: ; preds = %0
br label %10
10: ; preds = %24, %9
%11 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i32* @fgets(i8* %11, i32 21, i32* %12)
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %25
15: ; preds = %10
%16 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%17 = call i64 @has_more_than_2eq(i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%21 = call i32 @puts(i8* %20)
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %24
24: ; preds = %19, %15
br label %10
25: ; preds = %10
%26 = load i32, i32* %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32*, i32** %3
%29 = call i32 @fclose(i32* %28)
store i32 0, i32* %1
br label %30
30: ; preds = %25, %7
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [10 x i8] c"words.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [18 x i8] c"\0ATotal %d words.\0A\00"
@str = [40 x i8] c"The file `words.txt` can not be opened.\00"
define i32 @main() {
%1 = alloca [21 x i8]
%2 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 0
%3 = 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))
%4 = icmp eq i32* %3, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = call i32* @fgets(i8* %2, i32 21, i32* %3)
%7 = icmp eq i32* %6, null
br i1 %7, label %21, label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
br label %25
10: ; preds = %5, %17
%11 = phi i32 [ %18, %17 ], [ 0, %5 ]
%12 = call i64 @has_more_than_2eq(i8* %2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = call i32 @puts(i8* %2)
%16 = add nsw i32 %11, 1
br label %17
17: ; preds = %14, %10
%18 = phi i32 [ %16, %14 ], [ %11, %10 ]
%19 = call i32* @fgets(i8* %2, i32 21, i32* %3)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %10
21: ; preds = %17, %5
%22 = phi i32 [ 0, %5 ], [ %18, %17 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = call i32 @fclose(i32* %3)
br label %25
25: ; preds = %21, %8
%26 = phi i32 [ -1, %8 ], [ 0, %21 ]
ret i32 %26
}