#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 M_PI;
int pow(float, int);
float sin(int);
float waveshaper_nonlin_rect_sine(float signal, float curve) {
  float value = sin(2 * M_PI * curve * pow(signal, 1 / (curve + 1)));
  if (value < 0.0f)
    value = -value;
  signal = (0.5f * value + 0.5f) * signal;
  return signal;
}


x86 assembly (clang, -O0):
<waveshaper_nonlin_rect_sine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    0x2eaf(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xea7(%rip),%xmm2
addss  -0x8(%rbp),%xmm2
movss  0xe9a(%rip),%xmm1
divss  %xmm2,%xmm1
cvttss2si %xmm1,%edi
call   1040 <pow@plt>
movss  -0x10(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1030 <sin@plt>
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11b2 <waveshaper_nonlin_rect_sine+0x92>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe45(%rip),%xmm1
mulss  %xmm1,%xmm0
addss  %xmm1,%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<waveshaper_nonlin_rect_sine>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    (%rax),%eax
add    %eax,%eax
cvtsi2ss %eax,%xmm2
movss  %xmm0,0x4(%rsp)
mulss  %xmm1,%xmm2
movss  %xmm2,(%rsp)
movss  0xeb9(%rip),%xmm2
addss  %xmm2,%xmm1
divss  %xmm1,%xmm2
cvttss2si %xmm2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  (%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1030 <sin@plt>
movaps 0xe9c(%rip),%xmm2
xorps  %xmm0,%xmm2
xorps  %xmm3,%xmm3
movaps %xmm0,%xmm1
cmpltss %xmm3,%xmm1
andps  %xmm1,%xmm2
andnps %xmm0,%xmm1
orps   %xmm2,%xmm1
movss  0xe71(%rip),%xmm0
mulss  %xmm0,%xmm1
addss  %xmm0,%xmm1
mulss  0x4(%rsp),%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
@M_PI = global i32 0
define float @waveshaper_nonlin_rect_sine(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %3
store float %1, float* %4
%6 = load i32, i32* @M_PI
%7 = mul nsw i32 2, %6
%8 = sitofp i32 %7 to float
%9 = load float, float* %4
%10 = fmul float %8, %9
%11 = load float, float* %3
%12 = load float, float* %4
%13 = fadd float %12, 1.000000e+00
%14 = fdiv float 1.000000e+00, %13
%15 = fptosi float %14 to i32
%16 = call i32 @pow(float %11, i32 %15)
%17 = sitofp i32 %16 to float
%18 = fmul float %10, %17
%19 = fptosi float %18 to i32
%20 = call float @sin(i32 %19)
store float %20, float* %5
%21 = load float, float* %5
%22 = fcmp olt float %21, 0.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %2
%24 = load float, float* %5
%25 = fneg float %24
store float %25, float* %5
br label %26
26: ; preds = %23, %2
%27 = load float, float* %5
%28 = call float @llvm.fmuladd.f32(float 5.000000e-01, float %27, float 5.000000e-01)
%29 = load float, float* %3
%30 = fmul float %28, %29
store float %30, float* %3
%31 = load float, float* %3
ret float %31
}

LLVM IR (-O2):
@M_PI = global i32 0
define float @waveshaper_nonlin_rect_sine(float %0, float %1) {
%3 = load i32, i32* @M_PI
%4 = shl nsw i32 %3, 1
%5 = sitofp i32 %4 to float
%6 = fmul float %5, %1
%7 = fadd float %1, 1.000000e+00
%8 = fdiv float 1.000000e+00, %7
%9 = fptosi float %8 to i32
%10 = tail call i32 @pow(float %0, i32 %9)
%11 = sitofp i32 %10 to float
%12 = fmul float %6, %11
%13 = fptosi float %12 to i32
%14 = tail call float @sin(i32 %13)
%15 = fcmp olt float %14, 0.000000e+00
%16 = fneg float %14
%17 = select i1 %15, float %16, float %14
%18 = tail call float @llvm.fmuladd.f32(float %17, float 5.000000e-01, float 5.000000e-01)
%19 = fmul float %18, %0
ret float %19
}