#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 atan(float);
float lerp(float, float, int /*<<< orphan*/);
float min(float, float);
int /*<<< orphan*/ saturatef(float);
float soft_min(float m, float x) {
  const float hpi_i = 0.63661977236758134307553505349006;
  float xm = x / m;
  float softx = min(m, m * 1.25 * hpi_i * atan(xm));
  return lerp(x, softx, saturatef(xm));
}


x86 assembly (clang, -O0):
<soft_min>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  0xeb6(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
divss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe6b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0x10(%rbp),%xmm0
call   1050 <atan@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm2,%xmm2
mulsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
call   1030 <min@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
call   1040 <saturatef@plt>
movss  -0x1c(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
mov    %eax,%edi
call   1060 <lerp@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<soft_min>:
sub    $0x18,%rsp
movss  %xmm1,0xc(%rsp)
movaps %xmm0,%xmm2
movaps %xmm1,%xmm0
movss  %xmm2,0x4(%rsp)
divss  %xmm2,%xmm0
movss  %xmm0,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
mulsd  0xe91(%rip),%xmm1
mulsd  0xe91(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
call   1050 <atan@plt>
cvtss2sd %xmm0,%xmm0
mulsd  0x10(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
movss  0x4(%rsp),%xmm0
call   1030 <min@plt>
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsp),%xmm0
call   1040 <saturatef@plt>
movss  0xc(%rsp),%xmm0
movss  0x4(%rsp),%xmm1
mov    %eax,%edi
add    $0x18,%rsp
jmp    1060 <lerp@plt>

LLVM IR (-O0):
define float @soft_min(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %3
store float %1, float* %4
store float 0x3FE45F3060000000, float* %5
%8 = load float, float* %4
%9 = load float, float* %3
%10 = fdiv float %8, %9
store float %10, float* %6
%11 = load float, float* %3
%12 = load float, float* %3
%13 = fpext float %12 to double
%14 = fmul double %13, 1.250000e+00
%15 = fmul double %14, 0x3FE45F3060000000
%16 = load float, float* %6
%17 = call float @atan(float %16)
%18 = fpext float %17 to double
%19 = fmul double %15, %18
%20 = fptrunc double %19 to float
%21 = call float @min(float %11, float %20)
store float %21, float* %7
%22 = load float, float* %4
%23 = load float, float* %7
%24 = load float, float* %6
%25 = call i32 @saturatef(float %24)
%26 = call float @lerp(float %22, float %23, i32 %25)
ret float %26
}

LLVM IR (-O2):
define float @soft_min(float %0, float %1) {
%3 = fdiv float %1, %0
%4 = fpext float %0 to double
%5 = fmul double %4, 1.250000e+00
%6 = fmul double %5, 0x3FE45F3060000000
%7 = tail call float @atan(float %3)
%8 = fpext float %7 to double
%9 = fmul double %6, %8
%10 = fptrunc double %9 to float
%11 = tail call float @min(float %0, float %10)
%12 = tail call i32 @saturatef(float %3)
%13 = tail call float @lerp(float %1, float %11, i32 %12)
ret float %13
}