#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 const fabsf(float);
float deadband(float value, const float threshold) {
  if (fabsf(value) < threshold) {
    value = 0;
  } else if (value > 0) {
    value -= threshold;
  } else if (value < 0) {
    value += threshold;
  }
  return value;
}


x86 assembly (clang, -O0):
<deadband>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <fabsf@plt>
movaps %xmm0,%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    114a <deadband+0x3a>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1199 <deadband+0x89>
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1173 <deadband+0x63>
movss  -0x8(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1194 <deadband+0x84>
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    118f <deadband+0x7f>
movss  -0x8(%rbp),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1194 <deadband+0x84>
jmp    1199 <deadband+0x89>
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deadband>:
movaps 0xef9(%rip),%xmm3
andps  %xmm0,%xmm3
xorps  %xmm2,%xmm2
ucomiss %xmm3,%xmm1
ja     112c <deadband+0x2c>
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jbe    1120 <deadband+0x20>
subss  %xmm1,%xmm0
jmp    1129 <deadband+0x29>
ucomiss %xmm0,%xmm2
jbe    1129 <deadband+0x29>
addss  %xmm1,%xmm0
movaps %xmm0,%xmm2
movaps %xmm2,%xmm0
ret

LLVM IR (-O0):
define float @deadband(float %0, float %1) {
%3 = alloca float
%4 = alloca float
store float %0, float* %3
store float %1, float* %4
%5 = load float, float* %3
%6 = call float @fabsf(float %5)
%7 = load float, float* %4
%8 = fcmp olt float %6, %7
br i1 %8, label %9, label %10
9: ; preds = %2
store float 0.000000e+00, float* %3
br label %26
10: ; preds = %2
%11 = load float, float* %3
%12 = fcmp ogt float %11, 0.000000e+00
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load float, float* %4
%15 = load float, float* %3
%16 = fsub float %15, %14
store float %16, float* %3
br label %25
17: ; preds = %10
%18 = load float, float* %3
%19 = fcmp olt float %18, 0.000000e+00
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load float, float* %4
%22 = load float, float* %3
%23 = fadd float %22, %21
store float %23, float* %3
br label %24
24: ; preds = %20, %17
br label %25
25: ; preds = %24, %13
br label %26
26: ; preds = %25, %9
%27 = load float, float* %3
ret float %27
}

LLVM IR (-O2):
define float @deadband(float %0, float %1) {
%3 = tail call float @llvm.fabs.f32(float %0)
%4 = fcmp olt float %3, %1
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = fcmp ogt float %0, 0.000000e+00
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = fsub float %0, %1
br label %13
9: ; preds = %5
%10 = fcmp olt float %0, 0.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = fadd float %0, %1
br label %13
13: ; preds = %2, %7, %11, %9
%14 = phi float [ %8, %7 ], [ %12, %11 ], [ %0, %9 ], [ 0.000000e+00, %2 ]
ret float %14
}