#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*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int isAlphabetic(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main() {
  FILE *in;
  in = fopen("words.txt", "r");
  if (in == NULL) {
    fprintf(stderr, "Cannot open words.txt.\n");
    exit(1);
  }
  int totalcount, alphacount;
  char word[100];
  while (fscanf(in, "%s", word) != EOF) {
    int isAlpha = isAlphabetic(word);
    alphacount += isAlpha;
    if (isAlpha)
      printf("%s\n", word);
    totalcount++;
  }
  float percent = (alphacount / totalcount) * 100;
  printf("\n");
  printf("%d are alphabetical out of %d (%G percent).\n", alphacount,
         totalcount, percent);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b3 <main+0x53>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11b8 <main+0x58>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    0xe5d(%rip),%rsi
call   1050 <fscanf@plt>
mov    0x2e15(%rip),%rcx
cmp    (%rcx),%rax
je     1224 <main+0xc4>
lea    -0x80(%rbp),%rdi
call   1030 <isAlphabetic@plt>
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x84(%rbp)
je     1216 <main+0xb6>
lea    -0x80(%rbp),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b8 <main+0x58>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
imul   $0x64,%eax,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x88(%rbp)
ff
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
movss  -0x88(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xdca(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xe6b(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     126c <main+0xec>
mov    %rax,%r14
lea    0xe70(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
call   1070 <fscanf@plt>
mov    0x2e20(%rip),%rcx
cmp    (%rcx),%rax
jne    1218 <main+0x98>
mov    %ebx,%eax
cltd
idiv   %r13d
imul   $0x64,%eax,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2c(%rip),%rdi
mov    %ebx,%esi
mov    %r13d,%edx
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%r15
lea    0xe00(%rip),%r12
jmp    1254 <main+0xd4>
cs nopw 0x0(%rax,%rax,1)
add    %ebp,%ebx
add    $0x1,%r13d
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1070 <fscanf@plt>
mov    0x2d9d(%rip),%rcx
cmp    (%rcx),%rax
je     11cd <main+0x4d>
mov    %r15,%rdi
call   1050 <isAlphabetic@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1230 <main+0xb0>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    1230 <main+0xb0>
mov    0x2d65(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"words.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"Cannot open words.txt.\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [45 x i8] c"%d are alphabetical out of %d (%G percent).\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = alloca i32
%7 = alloca float
store i32 0, i32* %1
%8 = 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* %8, i32** %2
%9 = load i32*, i32** %2
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
br label %16
16: ; preds = %33, %15
%17 = load i32*, i32** %2
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%19 = call i64 @fscanf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %18)
%20 = load i64, i64* @EOF
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %16
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%24 = call i32 @isAlphabetic(i8* %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = load i32, i32* %4
%27 = add nsw i32 %26, %25
store i32 %27, i32* %4
%28 = load i32, i32* %6
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %30, %22
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %16
36: ; preds = %16
%37 = load i32, i32* %4
%38 = load i32, i32* %3
%39 = sdiv i32 %37, %38
%40 = mul nsw i32 %39, 100
%41 = sitofp i32 %40 to float
store float %41, float* %7
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%43 = load i32, i32* %4
%44 = load i32, i32* %3
%45 = load float, float* %7
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %43, i32 %44, double %46)
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [10 x i8] c"words.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"Cannot open words.txt.\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.6 = [45 x i8] c"%d are alphabetical out of %d (%G percent).\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = 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))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%10 = call i64 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %26, label %13
13: ; preds = %8, %21
%14 = phi i32 [ %22, %21 ], [ undef, %8 ]
%15 = phi i32 [ %17, %21 ], [ undef, %8 ]
%16 = call i32 @isAlphabetic(i8* %9)
%17 = add nsw i32 %16, %15
%18 = icmp eq i32 %16, 0
br i1 %18, label %21, label %19
19: ; preds = %13
%20 = call i32 @puts(i8* %9)
br label %21
21: ; preds = %19, %13
%22 = add nsw i32 %14, 1
%23 = call i64 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%24 = load i64, i64* @EOF
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %13
26: ; preds = %21, %8
%27 = phi i32 [ undef, %8 ], [ %17, %21 ]
%28 = phi i32 [ undef, %8 ], [ %22, %21 ]
%29 = sdiv i32 %27, %28
%30 = mul nsw i32 %29, 100
%31 = sitofp i32 %30 to float
%32 = call i32 @putchar(i32 10)
%33 = fpext float %31 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %27, i32 %28, double %33)
ret i32 0
}