#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 */
float cmop_db2lin(float);
float kneecurve(float, float, float);
float lin2db(float);
float compcurve(float x, float k, float slope, float linearthreshold,
                float linearthresholdknee, float threshold, float knee,
                float kneedboffset) {
  if (x < linearthreshold)
    return x;
  if (knee <= 0.0f)
    return cmop_db2lin(threshold + slope * (lin2db(x) - threshold));
  if (x < linearthresholdknee)
    return kneecurve(x, k, linearthreshold);
  return cmop_db2lin(kneedboffset + slope * (lin2db(x) - threshold - knee));
}


x86 assembly (clang, -O0):
<compcurve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  %xmm3,-0x14(%rbp)
movss  %xmm4,-0x18(%rbp)
movss  %xmm5,-0x1c(%rbp)
movss  %xmm6,-0x20(%rbp)
movss  %xmm7,-0x24(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1182 <compcurve+0x52>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    124e <compcurve+0x11e>
xorps  %xmm0,%xmm0
ucomiss -0x20(%rbp),%xmm0
jb     11d6 <compcurve+0xa6>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <lin2db@plt>
movss  -0x2c(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x28(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <cmop_db2lin@plt>
movss  %xmm0,-0x4(%rbp)
jmp    124e <compcurve+0x11e>
movss  -0x8(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1207 <compcurve+0xd7>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm2
call   1050 <kneecurve@plt>
movss  %xmm0,-0x4(%rbp)
jmp    124e <compcurve+0x11e>
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <lin2db@plt>
movss  -0x34(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x30(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm2
subss  -0x20(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <cmop_db2lin@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compcurve>:
sub    $0x18,%rsp
ucomiss %xmm0,%xmm3
jbe    113e <compcurve+0xe>
add    $0x18,%rsp
ret
xorps  %xmm8,%xmm8
ucomiss %xmm6,%xmm8
jae    1159 <compcurve+0x29>
ucomiss %xmm0,%xmm4
jbe    1187 <compcurve+0x57>
movaps %xmm3,%xmm2
add    $0x18,%rsp
jmp    1050 <kneecurve@plt>
movss  %xmm5,0x8(%rsp)
movss  %xmm2,0xc(%rsp)
call   1040 <lin2db@plt>
movss  0x8(%rsp),%xmm1
subss  %xmm1,%xmm0
mulss  0xc(%rsp),%xmm0
addss  %xmm1,%xmm0
add    $0x18,%rsp
jmp    1030 <cmop_db2lin@plt>
movss  %xmm5,0x8(%rsp)
movss  %xmm2,0xc(%rsp)
movss  %xmm7,0x14(%rsp)
movss  %xmm6,0x10(%rsp)
call   1040 <lin2db@plt>
subss  0x8(%rsp),%xmm0
subss  0x10(%rsp),%xmm0
mulss  0xc(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
add    $0x18,%rsp
jmp    1030 <cmop_db2lin@plt>

LLVM IR (-O0):
define float @compcurve(float %0, float %1, float %2, float %3, float %4, float %5, float %6, float %7) {
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
store float %0, float* %10
store float %1, float* %11
store float %2, float* %12
store float %3, float* %13
store float %4, float* %14
store float %5, float* %15
store float %6, float* %16
store float %7, float* %17
%18 = load float, float* %10
%19 = load float, float* %13
%20 = fcmp olt float %18, %19
br i1 %20, label %21, label %23
21: ; preds = %8
%22 = load float, float* %10
store float %22, float* %9
br label %55
23: ; preds = %8
%24 = load float, float* %16
%25 = fcmp ole float %24, 0.000000e+00
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = load float, float* %15
%28 = load float, float* %12
%29 = load float, float* %10
%30 = call float @lin2db(float %29)
%31 = load float, float* %15
%32 = fsub float %30, %31
%33 = call float @llvm.fmuladd.f32(float %28, float %32, float %27)
%34 = call float @cmop_db2lin(float %33)
store float %34, float* %9
br label %55
35: ; preds = %23
%36 = load float, float* %10
%37 = load float, float* %14
%38 = fcmp olt float %36, %37
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = load float, float* %10
%41 = load float, float* %11
%42 = load float, float* %13
%43 = call float @kneecurve(float %40, float %41, float %42)
store float %43, float* %9
br label %55
44: ; preds = %35
%45 = load float, float* %17
%46 = load float, float* %12
%47 = load float, float* %10
%48 = call float @lin2db(float %47)
%49 = load float, float* %15
%50 = fsub float %48, %49
%51 = load float, float* %16
%52 = fsub float %50, %51
%53 = call float @llvm.fmuladd.f32(float %46, float %52, float %45)
%54 = call float @cmop_db2lin(float %53)
store float %54, float* %9
br label %55
55: ; preds = %44, %39, %26, %21
%56 = load float, float* %9
ret float %56
}

LLVM IR (-O2):
define float @compcurve(float %0, float %1, float %2, float %3, float %4, float %5, float %6, float %7) {
%9 = fcmp olt float %0, %3
br i1 %9, label %27, label %10
10: ; preds = %8
%11 = fcmp ugt float %6, 0.000000e+00
br i1 %11, label %17, label %12
12: ; preds = %10
%13 = tail call float @lin2db(float %0)
%14 = fsub float %13, %5
%15 = tail call float @llvm.fmuladd.f32(float %2, float %14, float %5)
%16 = tail call float @cmop_db2lin(float %15)
br label %27
17: ; preds = %10
%18 = fcmp olt float %0, %4
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call float @kneecurve(float %0, float %1, float %3)
br label %27
21: ; preds = %17
%22 = tail call float @lin2db(float %0)
%23 = fsub float %22, %5
%24 = fsub float %23, %6
%25 = tail call float @llvm.fmuladd.f32(float %2, float %24, float %7)
%26 = tail call float @cmop_db2lin(float %25)
br label %27
27: ; preds = %8, %21, %19, %12
%28 = phi float [ %16, %12 ], [ %20, %19 ], [ %26, %21 ], [ %0, %8 ]
ret float %28
}