#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 */
int /*<<< orphan*/ assert(int);
float Crossfadef(float y0, float y1, float x, float x_low, float x_high) {
  float dx = x_high - x_low;
  assert(dx >= 0.0f);
  float dx0 = x - x_low;
  float dx1 = x_high - x;
  if (dx0 <= 0.0f) {
    return y0;
  } else if (dx1 <= 0.0f) {
    return y1;
  } else {
    return (dx1 * y0 + dx0 * y1) / dx;
  }
}


x86 assembly (clang, -O0):
<Crossfadef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  %xmm3,-0x14(%rbp)
movss  %xmm4,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movss  -0x10(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x20(%rbp),%xmm0
jb     1192 <Crossfadef+0x82>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11d4 <Crossfadef+0xc4>
xorps  %xmm0,%xmm0
ucomiss -0x24(%rbp),%xmm0
jb     11ae <Crossfadef+0x9e>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11d4 <Crossfadef+0xc4>
movss  -0x24(%rbp),%xmm0
movss  -0x8(%rbp),%xmm2
movss  -0x20(%rbp),%xmm1
mulss  -0xc(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
divss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Crossfadef>:
sub    $0x18,%rsp
movss  %xmm3,0x10(%rsp)
movss  %xmm2,0x14(%rsp)
movss  %xmm1,0x8(%rsp)
movss  %xmm0,(%rsp)
movss  %xmm4,0xc(%rsp)
subss  %xmm3,%xmm4
xorps  %xmm0,%xmm0
xor    %edi,%edi
movss  %xmm4,0x4(%rsp)
ucomiss %xmm0,%xmm4
setae  %dil
call   1030 <assert@plt>
xorps  %xmm4,%xmm4
movss  0x14(%rsp),%xmm3
movaps %xmm3,%xmm0
subss  0x10(%rsp),%xmm0
ucomiss %xmm0,%xmm4
jae    1197 <Crossfadef+0x87>
movss  0x4(%rsp),%xmm2
movss  0xc(%rsp),%xmm1
subss  %xmm3,%xmm1
ucomiss %xmm1,%xmm4
movss  0x8(%rsp),%xmm3
jae    11a1 <Crossfadef+0x91>
mulss  %xmm3,%xmm0
mulss  (%rsp),%xmm1
addss  %xmm0,%xmm1
divss  %xmm2,%xmm1
movaps %xmm1,%xmm0
add    $0x18,%rsp
ret
movss  (%rsp),%xmm0
add    $0x18,%rsp
ret
movaps %xmm3,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @Crossfadef(float %0, float %1, float %2, float %3, float %4) {
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
store float %0, float* %7
store float %1, float* %8
store float %2, float* %9
store float %3, float* %10
store float %4, float* %11
%15 = load float, float* %11
%16 = load float, float* %10
%17 = fsub float %15, %16
store float %17, float* %12
%18 = load float, float* %12
%19 = fcmp oge float %18, 0.000000e+00
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load float, float* %9
%23 = load float, float* %10
%24 = fsub float %22, %23
store float %24, float* %13
%25 = load float, float* %11
%26 = load float, float* %9
%27 = fsub float %25, %26
store float %27, float* %14
%28 = load float, float* %13
%29 = fcmp ole float %28, 0.000000e+00
br i1 %29, label %30, label %32
30: ; preds = %5
%31 = load float, float* %7
store float %31, float* %6
br label %46
32: ; preds = %5
%33 = load float, float* %14
%34 = fcmp ole float %33, 0.000000e+00
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = load float, float* %8
store float %36, float* %6
br label %46
37: ; preds = %32
%38 = load float, float* %14
%39 = load float, float* %7
%40 = load float, float* %13
%41 = load float, float* %8
%42 = fmul float %40, %41
%43 = call float @llvm.fmuladd.f32(float %38, float %39, float %42)
%44 = load float, float* %12
%45 = fdiv float %43, %44
store float %45, float* %6
br label %46
46: ; preds = %37, %35, %30
%47 = load float, float* %6
ret float %47
}

LLVM IR (-O2):
define float @Crossfadef(float %0, float %1, float %2, float %3, float %4) {
%6 = fsub float %4, %3
%7 = fcmp oge float %6, 0.000000e+00
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = fsub float %2, %3
%11 = fsub float %4, %2
%12 = fcmp ugt float %10, 0.000000e+00
br i1 %12, label %13, label %19
13: ; preds = %5
%14 = fcmp ugt float %11, 0.000000e+00
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = fmul float %10, %1
%17 = tail call float @llvm.fmuladd.f32(float %11, float %0, float %16)
%18 = fdiv float %17, %6
br label %19
19: ; preds = %13, %5, %15
%20 = phi float [ %18, %15 ], [ %0, %5 ], [ %1, %13 ]
ret float %20
}