#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 */

/* Variables and functions */
char EOF;
char getchar();
int /*<<< orphan*/ ispunct(char);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ printf(char *, float);
int main(void) {
  int inword = 0, sum = 0, word = 0;
  char ch;
  while ((ch = getchar()) != EOF) {
    if (!isspace(ch) && !ispunct(ch)) {
      if (!inword) {
        inword = 1;
        word++;
      }
      sum++;
    } else
      inword = 0;
  }
  printf("Average: %.1f lpw\n", (float)sum / word);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e70(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11db <main+0x9b>
movsbl -0x11(%rbp),%edi
call   1050 <isspace@plt>
cmp    $0x0,%eax
jne    11cf <main+0x8f>
movsbl -0x11(%rbp),%edi
call   1040 <ispunct@plt>
cmp    $0x0,%eax
jne    11cf <main+0x8f>
cmpl   $0x0,-0x8(%rbp)
jne    11c1 <main+0x81>
movl   $0x1,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d6 <main+0x96>
movl   $0x0,-0x8(%rbp)
jmp    1164 <main+0x24>
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e90(%rip),%r14
pxor   %xmm0,%xmm0
movdqa %xmm0,(%rsp)
cmp    (%r14),%al
jne    118e <main+0x4e>
cvtdq2ps (%rsp),%xmm0
movaps %xmm0,%xmm1
shufps $0x55,%xmm0,%xmm1
divss  %xmm1,%xmm0
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
pxor   %xmm0,%xmm0
movdqa %xmm0,(%rsp)
xor    %ebp,%ebp
jmp    11af <main+0x6f>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %r15d,%ebp
cmp    (%r14),%al
je     1166 <main+0x26>
movsbl %al,%ebx
mov    %ebx,%edi
call   1050 <isspace@plt>
xor    %r15d,%r15d
test   %eax,%eax
jne    11a0 <main+0x60>
mov    %ebx,%edi
call   1040 <ispunct@plt>
test   %eax,%eax
jne    11a0 <main+0x60>
xor    %eax,%eax
test   %ebp,%ebp
sete   %al
movd   %eax,%xmm0
movdqa 0xe22(%rip),%xmm1
punpckldq %xmm0,%xmm1
movdqa (%rsp),%xmm0
paddd  %xmm1,%xmm0
movdqa %xmm0,(%rsp)
mov    $0x1,%r15d
jmp    11a0 <main+0x60>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [19 x i8] c"Average: %.1f lpw\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %30, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %5
%8 = sext i8 %7 to i32
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %31
12: ; preds = %6
%13 = load i8, i8* %5
%14 = call i32 @isspace(i8 signext %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %29, label %16
16: ; preds = %12
%17 = load i8, i8* %5
%18 = call i32 @ispunct(i8 signext %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %16
%21 = load i32, i32* %2
%22 = icmp ne i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
store i32 1, i32* %2
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %26
26: ; preds = %23, %20
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %30
29: ; preds = %16, %12
store i32 0, i32* %2
br label %30
30: ; preds = %29, %26
br label %6
31: ; preds = %6
%32 = load i32, i32* %3
%33 = sitofp i32 %32 to float
%34 = load i32, i32* %4
%35 = sitofp i32 %34 to float
%36 = fdiv float %33, %35
%37 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), float %36)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [19 x i8] c"Average: %.1f lpw\0A\00"
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %24, label %4
4: ; preds = %0, %18
%5 = phi i8 [ %21, %18 ], [ %1, %0 ]
%6 = phi i32 [ %19, %18 ], [ 0, %0 ]
%7 = phi <2 x i32> [ %20, %18 ], [ zeroinitializer, %0 ]
%8 = tail call i32 @isspace(i8 signext %5)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %4
%11 = tail call i32 @ispunct(i8 signext %5)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = icmp eq i32 %6, 0
%15 = zext i1 %14 to i32
%16 = insertelement <2 x i32> <i32 1, i32 poison>, i32 %15, i64 1
%17 = add nsw <2 x i32> %7, %16
br label %18
18: ; preds = %4, %10, %13
%19 = phi i32 [ 1, %13 ], [ 0, %10 ], [ 0, %4 ]
%20 = phi <2 x i32> [ %17, %13 ], [ %7, %10 ], [ %7, %4 ]
%21 = tail call signext i8 (...) @getchar()
%22 = load i8, i8* @EOF
%23 = icmp eq i8 %21, %22
br i1 %23, label %24, label %4
24: ; preds = %18, %0
%25 = phi <2 x i32> [ zeroinitializer, %0 ], [ %20, %18 ]
%26 = sitofp <2 x i32> %25 to <2 x float>
%27 = extractelement <2 x float> %26, i64 0
%28 = extractelement <2 x float> %26, i64 1
%29 = fdiv float %27, %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), float %29)
ret i32 0
}