#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 cosine(double);
int fabs(int);
int hypot(int, int);
int sine(double);
double softarc(double phase, double sharpness) {
  if (sharpness < (1e-10)) {
    return cosine(phase);
  } else if (sharpness < 1) {
    phase *= 0.5;
    return (hypot((1 + sharpness) * cosine(phase),
                  (1 - sharpness) * sine(phase)) -
            1) /
           sharpness;
  } else {
    return fabs(cosine(0.5 * phase)) * 2 - 1;
  }
}


x86 assembly (clang, -O0):
<softarc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xea6(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    117d <softarc+0x3d>
movsd  -0x10(%rbp),%xmm0
call   1030 <cosine@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1245 <softarc+0x105>
movsd  0xe83(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    121d <softarc+0xdd>
movsd  0xe78(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe5e(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <cosine@plt>
movsd  -0x30(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
movsd  0xe2e(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <sine@plt>
movsd  -0x28(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1060 <hypot@plt>
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1245 <softarc+0x105>
movsd  0xdeb(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <cosine@plt>
mov    %eax,%edi
call   1040 <fabs@plt>
shl    $0x1,%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<softarc>:
push   %rbx
sub    $0x20,%rsp
movsd  0xeb3(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    115d <softarc+0x1d>
call   1030 <cosine@plt>
jmp    11fd <softarc+0xbd>
movsd  0xea3(%rip),%xmm2
ucomisd %xmm1,%xmm2
mulsd  0xe9f(%rip),%xmm0
jbe    11ec <softarc+0xac>
movapd %xmm1,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
movsd  %xmm2,(%rsp)
call   1030 <cosine@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%ebx
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <sine@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
cvttsd2si %xmm0,%esi
mov    %ebx,%edi
call   1060 <hypot@plt>
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x8(%rsp),%xmm0
jmp    1204 <softarc+0xc4>
call   1030 <cosine@plt>
mov    %eax,%edi
call   1040 <fabs@plt>
add    %eax,%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @softarc(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %5
%7 = fcmp olt double %6, 1.000000e-10
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load double, double* %4
%10 = call i32 @cosine(double %9)
%11 = sitofp i32 %10 to double
store double %11, double* %3
br label %45
12: ; preds = %2
%13 = load double, double* %5
%14 = fcmp olt double %13, 1.000000e+00
br i1 %14, label %15, label %37
15: ; preds = %12
%16 = load double, double* %4
%17 = fmul double %16, 5.000000e-01
store double %17, double* %4
%18 = load double, double* %5
%19 = fadd double 1.000000e+00, %18
%20 = load double, double* %4
%21 = call i32 @cosine(double %20)
%22 = sitofp i32 %21 to double
%23 = fmul double %19, %22
%24 = fptosi double %23 to i32
%25 = load double, double* %5
%26 = fsub double 1.000000e+00, %25
%27 = load double, double* %4
%28 = call i32 @sine(double %27)
%29 = sitofp i32 %28 to double
%30 = fmul double %26, %29
%31 = fptosi double %30 to i32
%32 = call i32 @hypot(i32 %24, i32 %31)
%33 = sub nsw i32 %32, 1
%34 = sitofp i32 %33 to double
%35 = load double, double* %5
%36 = fdiv double %34, %35
store double %36, double* %3
br label %45
37: ; preds = %12
%38 = load double, double* %4
%39 = fmul double 5.000000e-01, %38
%40 = call i32 @cosine(double %39)
%41 = call i32 @fabs(i32 %40)
%42 = mul nsw i32 %41, 2
%43 = sub nsw i32 %42, 1
%44 = sitofp i32 %43 to double
store double %44, double* %3
br label %45
45: ; preds = %37, %15, %8
%46 = load double, double* %3
ret double %46
}

LLVM IR (-O2):
define double @softarc(double %0, double %1) {
%3 = fcmp olt double %1, 1.000000e-10
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @cosine(double %0)
%6 = sitofp i32 %5 to double
br label %31
7: ; preds = %2
%8 = fcmp olt double %1, 1.000000e+00
%9 = fmul double %0, 5.000000e-01
br i1 %8, label %10, label %25
10: ; preds = %7
%11 = fadd double %1, 1.000000e+00
%12 = tail call i32 @cosine(double %9)
%13 = sitofp i32 %12 to double
%14 = fmul double %11, %13
%15 = fptosi double %14 to i32
%16 = fsub double 1.000000e+00, %1
%17 = tail call i32 @sine(double %9)
%18 = sitofp i32 %17 to double
%19 = fmul double %16, %18
%20 = fptosi double %19 to i32
%21 = tail call i32 @hypot(i32 %15, i32 %20)
%22 = add nsw i32 %21, -1
%23 = sitofp i32 %22 to double
%24 = fdiv double %23, %1
br label %31
25: ; preds = %7
%26 = tail call i32 @cosine(double %9)
%27 = tail call i32 @fabs(i32 %26)
%28 = shl nsw i32 %27, 1
%29 = add nsw i32 %28, -1
%30 = sitofp i32 %29 to double
br label %31
31: ; preds = %25, %10, %4
%32 = phi double [ %6, %4 ], [ %24, %10 ], [ %30, %25 ]
ret double %32
}