int ret_cnum(flag, z)
int flag;
double z;
{
  if (flag == 0) {
    if (z > 0.9)
      return 1;
    else if (z > 0.8)
      return 2;
    else if (z > 0.7)
      return 3;
    else if (z > 0.6)
      return 4;
    else if (z > 0.5)
      return 5;
    else if (z > 0.4)
      return 6;
    else
      return 7;
  } else {
    if (z > 0.9)
      return 8;
    else if (z > 0.8)
      return 9;
    else if (z > 0.7)
      return 10;
    else if (z > 0.6)
      return 11;
    else if (z > 0.5)
      return 12;
    else if (z > 0.4)
      return 13;
    else
      return 14;
  }
}


x86 assembly (clang, -O0):
<ret_cnum>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11f4 <ret_cnum+0xf4>
movsd  -0x10(%rbp),%xmm0
movsd  0xedd(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1139 <ret_cnum+0x39>
movl   $0x1,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xec2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115c <ret_cnum+0x5c>
movl   $0x2,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xea7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117f <ret_cnum+0x7f>
movl   $0x3,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xe8c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a2 <ret_cnum+0xa2>
movl   $0x4,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xe71(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c5 <ret_cnum+0xc5>
movl   $0x5,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xe56(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e8 <ret_cnum+0xe8>
movl   $0x6,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movl   $0x7,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xdff(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1217 <ret_cnum+0x117>
movl   $0x8,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xde4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    123a <ret_cnum+0x13a>
movl   $0x9,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xdc9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    125d <ret_cnum+0x15d>
movl   $0xa,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xdae(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1280 <ret_cnum+0x180>
movl   $0xb,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xd93(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12a3 <ret_cnum+0x1a3>
movl   $0xc,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movsd  -0x10(%rbp),%xmm0
movsd  0xd78(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12c6 <ret_cnum+0x1c6>
movl   $0xd,-0x4(%rbp)
jmp    12cd <ret_cnum+0x1cd>
movl   $0xe,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ret_cnum>:
test   %edi,%edi
je     116d <ret_cnum+0x6d>
mov    $0x8,%eax
ucomisd 0xeef(%rip),%xmm0
ja     11b8 <ret_cnum+0xb8>
mov    $0x9,%eax
ucomisd 0xee4(%rip),%xmm0
ja     11b8 <ret_cnum+0xb8>
mov    $0xa,%eax
ucomisd 0xed9(%rip),%xmm0
ja     11b8 <ret_cnum+0xb8>
mov    $0xb,%eax
ucomisd 0xed2(%rip),%xmm0
ja     11b8 <ret_cnum+0xb8>
mov    $0xc,%eax
ucomisd 0xecb(%rip),%xmm0
ja     11b8 <ret_cnum+0xb8>
xor    %ecx,%ecx
ucomisd 0xec7(%rip),%xmm0
seta   %cl
mov    $0xe,%eax
sub    %ecx,%eax
jmp    11b8 <ret_cnum+0xb8>
mov    $0x1,%eax
ucomisd 0xe86(%rip),%xmm0
ja     11b8 <ret_cnum+0xb8>
mov    $0x2,%eax
ucomisd 0xe7f(%rip),%xmm0
ja     11b8 <ret_cnum+0xb8>
mov    $0x3,%eax
ucomisd 0xe78(%rip),%xmm0
ja     11b8 <ret_cnum+0xb8>
mov    $0x4,%eax
ucomisd 0xe71(%rip),%xmm0
ja     11b8 <ret_cnum+0xb8>
mov    $0x5,%eax
ucomisd 0xe6a(%rip),%xmm0
jbe    11b9 <ret_cnum+0xb9>
ret
xor    %eax,%eax
ucomisd 0xe65(%rip),%xmm0
seta   %al
xor    $0x7,%eax
ret

LLVM IR (-O0):
define i32 @ret_cnum(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %33
8: ; preds = %2
%9 = load double, double* %5
%10 = fcmp ogt double %9, 9.000000e-01
br i1 %10, label %11, label %12
11: ; preds = %8
store i32 1, i32* %3
br label %58
12: ; preds = %8
%13 = load double, double* %5
%14 = fcmp ogt double %13, 8.000000e-01
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 2, i32* %3
br label %58
16: ; preds = %12
%17 = load double, double* %5
%18 = fcmp ogt double %17, 0x3FE6666666666666
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 3, i32* %3
br label %58
20: ; preds = %16
%21 = load double, double* %5
%22 = fcmp ogt double %21, 6.000000e-01
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 4, i32* %3
br label %58
24: ; preds = %20
%25 = load double, double* %5
%26 = fcmp ogt double %25, 5.000000e-01
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 5, i32* %3
br label %58
28: ; preds = %24
%29 = load double, double* %5
%30 = fcmp ogt double %29, 4.000000e-01
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 6, i32* %3
br label %58
32: ; preds = %28
store i32 7, i32* %3
br label %58
33: ; preds = %2
%34 = load double, double* %5
%35 = fcmp ogt double %34, 9.000000e-01
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 8, i32* %3
br label %58
37: ; preds = %33
%38 = load double, double* %5
%39 = fcmp ogt double %38, 8.000000e-01
br i1 %39, label %40, label %41
40: ; preds = %37
store i32 9, i32* %3
br label %58
41: ; preds = %37
%42 = load double, double* %5
%43 = fcmp ogt double %42, 0x3FE6666666666666
br i1 %43, label %44, label %45
44: ; preds = %41
store i32 10, i32* %3
br label %58
45: ; preds = %41
%46 = load double, double* %5
%47 = fcmp ogt double %46, 6.000000e-01
br i1 %47, label %48, label %49
48: ; preds = %45
store i32 11, i32* %3
br label %58
49: ; preds = %45
%50 = load double, double* %5
%51 = fcmp ogt double %50, 5.000000e-01
br i1 %51, label %52, label %53
52: ; preds = %49
store i32 12, i32* %3
br label %58
53: ; preds = %49
%54 = load double, double* %5
%55 = fcmp ogt double %54, 4.000000e-01
br i1 %55, label %56, label %57
56: ; preds = %53
store i32 13, i32* %3
br label %58
57: ; preds = %53
store i32 14, i32* %3
br label %58
58: ; preds = %57, %56, %52, %48, %44, %40, %36, %32, %31, %27, %23, %19, %15, %11
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
define i32 @ret_cnum(i32 %0, double %1) {
%3 = icmp eq i32 %0, 0
%4 = fcmp ogt double %1, 9.000000e-01
br i1 %3, label %5, label %17
5: ; preds = %2
br i1 %4, label %29, label %6
6: ; preds = %5
%7 = fcmp ogt double %1, 8.000000e-01
br i1 %7, label %29, label %8
8: ; preds = %6
%9 = fcmp ogt double %1, 0x3FE6666666666666
br i1 %9, label %29, label %10
10: ; preds = %8
%11 = fcmp ogt double %1, 6.000000e-01
br i1 %11, label %29, label %12
12: ; preds = %10
%13 = fcmp ogt double %1, 5.000000e-01
br i1 %13, label %29, label %14
14: ; preds = %12
%15 = fcmp ogt double %1, 4.000000e-01
%16 = select i1 %15, i32 6, i32 7
br label %29
17: ; preds = %2
br i1 %4, label %29, label %18
18: ; preds = %17
%19 = fcmp ogt double %1, 8.000000e-01
br i1 %19, label %29, label %20
20: ; preds = %18
%21 = fcmp ogt double %1, 0x3FE6666666666666
br i1 %21, label %29, label %22
22: ; preds = %20
%23 = fcmp ogt double %1, 6.000000e-01
br i1 %23, label %29, label %24
24: ; preds = %22
%25 = fcmp ogt double %1, 5.000000e-01
br i1 %25, label %29, label %26
26: ; preds = %24
%27 = fcmp ogt double %1, 4.000000e-01
%28 = select i1 %27, i32 13, i32 14
br label %29
29: ; preds = %26, %24, %22, %20, %18, %17, %14, %12, %10, %8, %6, %5
%30 = phi i32 [ 1, %5 ], [ 2, %6 ], [ 3, %8 ], [ 4, %10 ], [ 5, %12 ], [ %16, %14 ], [ 8, %17 ], [ 9, %18 ], [ 10, %20 ], [ 11, %22 ], [ 12, %24 ], [ %28, %26 ]
ret i32 %30
}