#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 getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  printf("enter the sentence:\n");
  char ch;
  float len = 0.0f, num = 1.0f;
  while ((ch = getchar()) != '.') {
    switch (ch) {
    case ' ':
      num += 1;
      break;
    default:
      len += 1;
    }
  }
  printf("%.1f\n", len / num);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xeb3(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x2e,%eax
je     11a6 <main+0x86>
mov    -0x5(%rbp),%al
sub    $0x20,%al
jne    118f <main+0x6f>
jmp    1178 <main+0x58>
movss  0xe80(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11a1 <main+0x81>
movss  0xe69(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    1152 <main+0x32>
movss  -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe5e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
movss  0xebb(%rip),%xmm1
xorps  %xmm0,%xmm0
movss  %xmm0,(%rsp)
movss  %xmm1,0x4(%rsp)
jmp    1174 <main+0x44>
cs nopw 0x0(%rax,%rax,1)
nop
movss  0x4(%rsp),%xmm0
addss  0xe92(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x20,%al
je     1160 <main+0x30>
cmp    $0x2e,%al
je     1197 <main+0x67>
movss  (%rsp),%xmm0
addss  0xe70(%rip),%xmm0
movss  %xmm0,(%rsp)
jmp    1174 <main+0x44>
movss  (%rsp),%xmm0
divss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe57(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"enter the sentence:\0A\00"
@.str.1 = [6 x i8] c"%.1f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store float 0.000000e+00, float* %3
store float 1.000000e+00, float* %4
br label %6
6: ; preds = %19, %0
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 46
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
switch i32 %12, label %16 [
i32 32, label %13
]
13: ; preds = %10
%14 = load float, float* %4
%15 = fadd float %14, 1.000000e+00
store float %15, float* %4
br label %19
16: ; preds = %10
%17 = load float, float* %3
%18 = fadd float %17, 1.000000e+00
store float %18, float* %3
br label %19
19: ; preds = %16, %13
br label %6
20: ; preds = %6
%21 = load float, float* %3
%22 = load float, float* %4
%23 = fdiv float %21, %22
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %24)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%.1f\0A\00"
@str = [20 x i8] c"enter the sentence:\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %10, %0
%3 = phi float [ %11, %10 ], [ 0.000000e+00, %0 ]
%4 = phi float [ %6, %10 ], [ 1.000000e+00, %0 ]
br label %5
5: ; preds = %2, %8
%6 = phi float [ %9, %8 ], [ %4, %2 ]
%7 = tail call signext i8 (...) @getchar()
switch i8 %7, label %10 [
i8 46, label %12
i8 32, label %8
]
8: ; preds = %5
%9 = fadd float %6, 1.000000e+00
br label %5
10: ; preds = %5
%11 = fadd float %3, 1.000000e+00
br label %2
12: ; preds = %5
%13 = fdiv float %3, %6
%14 = fpext float %13 to double
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %14)
ret i32 0
}