void df_to_index(float df, int *index1_p, float *weight1_p) {
  int index1;
  float indexf;
  assert(df >= 1);
  assert(index1_p);
  assert(weight1_p);
  if (df <= 30) {
    indexf = df - 1;
  } else if (df <= 100) {
    indexf = (df - 30) / 10 + 29;
  } else {
    indexf = (df - 100) / 100 + 36;
  }
  index1 = (int)floor(indexf);
  if (index1 >= 45) {
    *index1_p = 44;
    *weight1_p = 0;
  } else {
    *index1_p = index1;
    *weight1_p = 1 - (indexf - index1);
  }
}


x86 assembly (clang, -O0):
<df_to_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xec2(%rip),%xmm1
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <assert@plt>
movss  0xe8e(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     1197 <df_to_index+0x77>
movss  -0x4(%rbp),%xmm0
movss  0xe7b(%rip),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    120f <df_to_index+0xef>
movss  0xe69(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
jb     11dc <df_to_index+0xbc>
movss  -0x4(%rbp),%xmm0
movss  0xe4a(%rip),%xmm1
subss  %xmm1,%xmm0
movss  0xe52(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe42(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    120a <df_to_index+0xea>
movss  -0x4(%rbp),%xmm0
movss  0xe1f(%rip),%xmm1
subss  %xmm1,%xmm0
movss  0xe13(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe0b(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    120f <df_to_index+0xef>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
call   1040 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x2d,-0x1c(%rbp)
jl     1248 <df_to_index+0x128>
mov    -0x10(%rbp),%rax
movl   $0x2c,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
jmp    1273 <df_to_index+0x153>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movss  -0x20(%rbp),%xmm1
cvtsi2ssl -0x1c(%rbp),%xmm0
subss  %xmm0,%xmm1
movss  0xd9d(%rip),%xmm0
subss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<df_to_index>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movss  %xmm0,0x4(%rsp)
xor    %edi,%edi
ucomiss 0xec7(%rip),%xmm0
setae  %dil
xor    %eax,%eax
call   1040 <assert@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <assert@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <assert@plt>
movss  0x4(%rsp),%xmm0
movss  0xe9e(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    1192 <df_to_index+0x72>
movss  0xe99(%rip),%xmm1
ucomiss %xmm0,%xmm1
jae    119c <df_to_index+0x7c>
addss  0xe9c(%rip),%xmm0
divss  0xe84(%rip),%xmm0
addss  0xe90(%rip),%xmm0
jmp    11b4 <df_to_index+0x94>
addss  0xe6e(%rip),%xmm0
jmp    11b4 <df_to_index+0x94>
addss  0xe6c(%rip),%xmm0
divss  0xe68(%rip),%xmm0
addss  0xe64(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
call   1030 <floorf@plt>
cvttss2si %xmm0,%eax
cmp    $0x2d,%eax
jl     11d3 <df_to_index+0xb3>
movl   $0x2c,(%rbx)
xorps  %xmm0,%xmm0
jmp    11ea <df_to_index+0xca>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mov    %eax,(%rbx)
subss  0x4(%rsp),%xmm0
addss  0xe16(%rip),%xmm0
movss  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @df_to_index(float %0, i32* %1, float* %2) {
%4 = alloca float
%5 = alloca i32*
%6 = alloca float*
%7 = alloca i32
%8 = alloca float
store float %0, float* %4
store i32* %1, i32** %5
store float* %2, float** %6
%9 = load float, float* %4
%10 = fcmp oge float %9, 1.000000e+00
%11 = zext i1 %10 to i32
%12 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %11)
%13 = load i32*, i32** %5
%14 = call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %13)
%15 = load float*, float** %6
%16 = call i32 (float*, ...) bitcast (i32 (...)* @assert to i32 (float*, ...)*)(float* %15)
%17 = load float, float* %4
%18 = fcmp ole float %17, 3.000000e+01
br i1 %18, label %19, label %22
19: ; preds = %3
%20 = load float, float* %4
%21 = fsub float %20, 1.000000e+00
store float %21, float* %8
br label %36
22: ; preds = %3
%23 = load float, float* %4
%24 = fcmp ole float %23, 1.000000e+02
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load float, float* %4
%27 = fsub float %26, 3.000000e+01
%28 = fdiv float %27, 1.000000e+01
%29 = fadd float %28, 2.900000e+01
store float %29, float* %8
br label %35
30: ; preds = %22
%31 = load float, float* %4
%32 = fsub float %31, 1.000000e+02
%33 = fdiv float %32, 1.000000e+02
%34 = fadd float %33, 3.600000e+01
store float %34, float* %8
br label %35
35: ; preds = %30, %25
br label %36
36: ; preds = %35, %19
%37 = load float, float* %8
%38 = fpext float %37 to double
%39 = call double @llvm.floor.f64(double %38)
%40 = fptosi double %39 to i32
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = icmp sge i32 %41, 45
br i1 %42, label %43, label %46
43: ; preds = %36
%44 = load i32*, i32** %5
store i32 44, i32* %44
%45 = load float*, float** %6
store float 0.000000e+00, float* %45
br label %55
46: ; preds = %36
%47 = load i32, i32* %7
%48 = load i32*, i32** %5
store i32 %47, i32* %48
%49 = load float, float* %8
%50 = load i32, i32* %7
%51 = sitofp i32 %50 to float
%52 = fsub float %49, %51
%53 = fsub float 1.000000e+00, %52
%54 = load float*, float** %6
store float %53, float* %54
br label %55
55: ; preds = %46, %43
ret void
}

LLVM IR (-O2):
define void @df_to_index(float %0, i32* %1, float* %2) {
%4 = fcmp oge float %0, 1.000000e+00
%5 = zext i1 %4 to i32
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %5)
%7 = tail call i32 (i32*, ...) bitcast (i32 (...)* @assert to i32 (i32*, ...)*)(i32* %1)
%8 = tail call i32 (float*, ...) bitcast (i32 (...)* @assert to i32 (float*, ...)*)(float* %2)
%9 = fcmp ugt float %0, 3.000000e+01
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = fadd float %0, -1.000000e+00
br label %22
12: ; preds = %3
%13 = fcmp ugt float %0, 1.000000e+02
br i1 %13, label %18, label %14
14: ; preds = %12
%15 = fadd float %0, -3.000000e+01
%16 = fdiv float %15, 1.000000e+01
%17 = fadd float %16, 2.900000e+01
br label %22
18: ; preds = %12
%19 = fadd float %0, -1.000000e+02
%20 = fdiv float %19, 1.000000e+02
%21 = fadd float %20, 3.600000e+01
br label %22
22: ; preds = %14, %18, %10
%23 = phi float [ %11, %10 ], [ %17, %14 ], [ %21, %18 ]
%24 = tail call float @llvm.floor.f32(float %23)
%25 = fptosi float %24 to i32
%26 = icmp sgt i32 %25, 44
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 44, i32* %1
br label %32
28: ; preds = %22
store i32 %25, i32* %1
%29 = sitofp i32 %25 to float
%30 = fsub float %29, %23
%31 = fadd float %30, 1.000000e+00
br label %32
32: ; preds = %28, %27
%33 = phi float [ %31, %28 ], [ 0.000000e+00, %27 ]
store float %33, float* %2
ret void
}