double wheeler_smith(int *grade, int words, int bigwords, int sentences) {
  double idx =
      (((double)words) / sentences) * 10.0 * (((double)bigwords) / words);
  if (idx <= 16)
    *grade = 0;
  else if (idx <= 20)
    *grade = 5;
  else if (idx <= 24)
    *grade = 6;
  else if (idx <= 29)
    *grade = 7;
  else if (idx <= 34)
    *grade = 8;
  else if (idx <= 38)
    *grade = 9;
  else if (idx <= 42)
    *grade = 10;
  else
    *grade = 99;
  return idx;
}


x86 assembly (clang, -O0):
<wheeler_smith>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xee1(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
cvtsi2sdl -0xc(%rbp),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb6(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1164 <wheeler_smith+0x64>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
jmp    1258 <wheeler_smith+0x158>
movsd  0xea4(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1186 <wheeler_smith+0x86>
mov    -0x8(%rbp),%rax
movl   $0x5,(%rax)
jmp    1253 <wheeler_smith+0x153>
movsd  0xe8a(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11a8 <wheeler_smith+0xa8>
mov    -0x8(%rbp),%rax
movl   $0x6,(%rax)
jmp    124e <wheeler_smith+0x14e>
movsd  0xe70(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11ca <wheeler_smith+0xca>
mov    -0x8(%rbp),%rax
movl   $0x7,(%rax)
jmp    1249 <wheeler_smith+0x149>
movsd  0xe56(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11ec <wheeler_smith+0xec>
mov    -0x8(%rbp),%rax
movl   $0x8,(%rax)
jmp    1244 <wheeler_smith+0x144>
movsd  0xe3c(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     120e <wheeler_smith+0x10e>
mov    -0x8(%rbp),%rax
movl   $0x9,(%rax)
jmp    123f <wheeler_smith+0x13f>
movsd  0xe22(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1230 <wheeler_smith+0x130>
mov    -0x8(%rbp),%rax
movl   $0xa,(%rax)
jmp    123a <wheeler_smith+0x13a>
mov    -0x8(%rbp),%rax
movl   $0x63,(%rax)
jmp    123f <wheeler_smith+0x13f>
jmp    1244 <wheeler_smith+0x144>
jmp    1249 <wheeler_smith+0x149>
jmp    124e <wheeler_smith+0x14e>
jmp    1253 <wheeler_smith+0x153>
jmp    1258 <wheeler_smith+0x158>
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<wheeler_smith>:
cvtsi2sd %ecx,%xmm0
movd   %esi,%xmm1
movd   %edx,%xmm2
punpckldq %xmm1,%xmm2
cvtdq2pd %xmm2,%xmm1
movapd %xmm1,%xmm2
shufpd $0x1,%xmm0,%xmm2
divpd  %xmm2,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
mulsd  0xecf(%rip),%xmm0
mulsd  %xmm1,%xmm0
xor    %eax,%eax
movsd  0xec9(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11bd <wheeler_smith+0xbd>
mov    $0x5,%eax
movsd  0xebe(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11bd <wheeler_smith+0xbd>
mov    $0x6,%eax
movsd  0xeb3(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11bd <wheeler_smith+0xbd>
mov    $0x7,%eax
movsd  0xea8(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11bd <wheeler_smith+0xbd>
mov    $0x8,%eax
movsd  0xe9d(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11bd <wheeler_smith+0xbd>
mov    $0x9,%eax
movsd  0xe92(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11bd <wheeler_smith+0xbd>
movsd  0xe8c(%rip),%xmm1
ucomisd %xmm0,%xmm1
mov    $0x63,%ecx
mov    $0xa,%eax
cmovb  %ecx,%eax
mov    %eax,(%rdi)
ret

LLVM IR (-O0):
define double @wheeler_smith(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %6
%11 = sitofp i32 %10 to double
%12 = load i32, i32* %8
%13 = sitofp i32 %12 to double
%14 = fdiv double %11, %13
%15 = fmul double %14, 1.000000e+01
%16 = load i32, i32* %7
%17 = sitofp i32 %16 to double
%18 = load i32, i32* %6
%19 = sitofp i32 %18 to double
%20 = fdiv double %17, %19
%21 = fmul double %15, %20
store double %21, double* %9
%22 = load double, double* %9
%23 = fcmp ole double %22, 1.600000e+01
br i1 %23, label %24, label %26
24: ; preds = %4
%25 = load i32*, i32** %5
store i32 0, i32* %25
br label %64
26: ; preds = %4
%27 = load double, double* %9
%28 = fcmp ole double %27, 2.000000e+01
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = load i32*, i32** %5
store i32 5, i32* %30
br label %63
31: ; preds = %26
%32 = load double, double* %9
%33 = fcmp ole double %32, 2.400000e+01
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = load i32*, i32** %5
store i32 6, i32* %35
br label %62
36: ; preds = %31
%37 = load double, double* %9
%38 = fcmp ole double %37, 2.900000e+01
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = load i32*, i32** %5
store i32 7, i32* %40
br label %61
41: ; preds = %36
%42 = load double, double* %9
%43 = fcmp ole double %42, 3.400000e+01
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = load i32*, i32** %5
store i32 8, i32* %45
br label %60
46: ; preds = %41
%47 = load double, double* %9
%48 = fcmp ole double %47, 3.800000e+01
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = load i32*, i32** %5
store i32 9, i32* %50
br label %59
51: ; preds = %46
%52 = load double, double* %9
%53 = fcmp ole double %52, 4.200000e+01
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = load i32*, i32** %5
store i32 10, i32* %55
br label %58
56: ; preds = %51
%57 = load i32*, i32** %5
store i32 99, i32* %57
br label %58
58: ; preds = %56, %54
br label %59
59: ; preds = %58, %49
br label %60
60: ; preds = %59, %44
br label %61
61: ; preds = %60, %39
br label %62
62: ; preds = %61, %34
br label %63
63: ; preds = %62, %29
br label %64
64: ; preds = %63, %24
%65 = load double, double* %9
ret double %65
}

LLVM IR (-O2):
define double @wheeler_smith(i32* nocapture writeonly %0, i32 %1, i32 %2, i32 %3) {
%5 = sitofp i32 %3 to double
%6 = insertelement <2 x i32> poison, i32 %2, i64 0
%7 = insertelement <2 x i32> %6, i32 %1, i64 1
%8 = sitofp <2 x i32> %7 to <2 x double>
%9 = extractelement <2 x double> %8, i64 1
%10 = insertelement <2 x double> poison, double %9, i64 0
%11 = insertelement <2 x double> %10, double %5, i64 1
%12 = fdiv <2 x double> %8, %11
%13 = extractelement <2 x double> %12, i64 1
%14 = fmul double %13, 1.000000e+01
%15 = extractelement <2 x double> %12, i64 0
%16 = fmul double %15, %14
%17 = fcmp ugt double %16, 1.600000e+01
br i1 %17, label %18, label %31
18: ; preds = %4
%19 = fcmp ugt double %16, 2.000000e+01
br i1 %19, label %20, label %31
20: ; preds = %18
%21 = fcmp ugt double %16, 2.400000e+01
br i1 %21, label %22, label %31
22: ; preds = %20
%23 = fcmp ugt double %16, 2.900000e+01
br i1 %23, label %24, label %31
24: ; preds = %22
%25 = fcmp ugt double %16, 3.400000e+01
br i1 %25, label %26, label %31
26: ; preds = %24
%27 = fcmp ugt double %16, 3.800000e+01
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = fcmp ugt double %16, 4.200000e+01
%30 = select i1 %29, i32 99, i32 10
br label %31
31: ; preds = %28, %26, %24, %22, %20, %18, %4
%32 = phi i32 [ 0, %4 ], [ 5, %18 ], [ 6, %20 ], [ 7, %22 ], [ 8, %24 ], [ 9, %26 ], [ %30, %28 ]
store i32 %32, i32* %0
ret double %16
}