#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 max(float, float);
float min(float, float);
float filtered_pulse(float edge0, float edge1, float x, float dx) {
  float x0 = x - dx * 0.5;
  float x1 = x0 + dx;
  return max(0, (min(x1, edge1) - max(x0, edge0)) / dx);
}


x86 assembly (clang, -O0):
<filtered_pulse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe93(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
call   1030 <min@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
call   1040 <max@plt>
movss  -0x1c(%rbp),%xmm1
subss  %xmm0,%xmm1
divss  -0x10(%rbp),%xmm1
xorps  %xmm0,%xmm0
call   1040 <max@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filtered_pulse>:
sub    $0x18,%rsp
movss  %xmm3,0x10(%rsp)
movss  %xmm0,0x14(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm3,%xmm2
mulsd  0xeba(%rip),%xmm2
addsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
movss  %xmm0,0xc(%rsp)
addss  %xmm3,%xmm0
call   1030 <min@plt>
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
call   1040 <max@plt>
movss  0x8(%rsp),%xmm1
subss  %xmm0,%xmm1
divss  0x10(%rsp),%xmm1
xorps  %xmm0,%xmm0
add    $0x18,%rsp
jmp    1040 <max@plt>

LLVM IR (-O0):
define float @filtered_pulse(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%11 = load float, float* %7
%12 = fpext float %11 to double
%13 = load float, float* %8
%14 = fpext float %13 to double
%15 = fneg double %14
%16 = call double @llvm.fmuladd.f64(double %15, double 5.000000e-01, double %12)
%17 = fptrunc double %16 to float
store float %17, float* %9
%18 = load float, float* %9
%19 = load float, float* %8
%20 = fadd float %18, %19
store float %20, float* %10
%21 = load float, float* %10
%22 = load float, float* %6
%23 = call float @min(float %21, float %22)
%24 = load float, float* %9
%25 = load float, float* %5
%26 = call float @max(float %24, float %25)
%27 = fsub float %23, %26
%28 = load float, float* %8
%29 = fdiv float %27, %28
%30 = call float @max(float 0.000000e+00, float %29)
ret float %30
}

LLVM IR (-O2):
define float @filtered_pulse(float %0, float %1, float %2, float %3) {
%5 = fpext float %2 to double
%6 = fpext float %3 to double
%7 = fneg double %6
%8 = tail call double @llvm.fmuladd.f64(double %7, double 5.000000e-01, double %5)
%9 = fptrunc double %8 to float
%10 = fadd float %9, %3
%11 = tail call float @min(float %10, float %1)
%12 = tail call float @max(float %9, float %0)
%13 = fsub float %11, %12
%14 = fdiv float %13, %3
%15 = tail call float @max(float 0.000000e+00, float %14)
ret float %15
}