#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 */
double asin(double);
double atan(double);
double clip(double, int, double);
double cosine(double);
double sine(double);
double softsaw(double phase, double sharpness) {
  sharpness = clip(sharpness, (1e-10), 1.0 - (1e-10));
  return atan(sharpness * sine(phase) / (1.0 + sharpness * cosine(phase))) /
         asin(sharpness);
}


x86 assembly (clang, -O0):
<softsaw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xor    %edi,%edi
movsd  0xe97(%rip),%xmm1
call   1040 <clip@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1070 <sine@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <cosine@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm1
movsd  0xe33(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1050 <atan@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <asin@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<softsaw>:
sub    $0x18,%rsp
movaps %xmm1,%xmm2
movsd  %xmm0,(%rsp)
movsd  0xe9c(%rip),%xmm1
movaps %xmm2,%xmm0
xor    %edi,%edi
call   1040 <clip@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1070 <sine@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1030 <cosine@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0xe66(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1050 <atan@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <asin@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @softsaw(double %0, double %1) {
%3 = alloca double
%4 = alloca double
store double %0, double* %3
store double %1, double* %4
%5 = load double, double* %4
%6 = call double @clip(double %5, i32 0, double 0x3FEFFFFFFFF24190)
store double %6, double* %4
%7 = load double, double* %4
%8 = load double, double* %3
%9 = call double @sine(double %8)
%10 = fmul double %7, %9
%11 = load double, double* %4
%12 = load double, double* %3
%13 = call double @cosine(double %12)
%14 = call double @llvm.fmuladd.f64(double %11, double %13, double 1.000000e+00)
%15 = fdiv double %10, %14
%16 = call double @atan(double %15)
%17 = load double, double* %4
%18 = call double @asin(double %17)
%19 = fdiv double %16, %18
ret double %19
}

LLVM IR (-O2):
define double @softsaw(double %0, double %1) {
%3 = tail call double @clip(double %1, i32 0, double 0x3FEFFFFFFFF24190)
%4 = tail call double @sine(double %0)
%5 = fmul double %3, %4
%6 = tail call double @cosine(double %0)
%7 = tail call double @llvm.fmuladd.f64(double %3, double %6, double 1.000000e+00)
%8 = fdiv double %5, %7
%9 = tail call double @atan(double %8)
%10 = tail call double @asin(double %3)
%11 = fdiv double %9, %10
ret double %11
}