#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 exp(int);
double fabs(double);
double Curve(double a, double x) {
  if (fabs(a) < 0.001)
    return x;
  return (1 - exp(-1 * a * x)) / (1 - exp(-1 * a));
}


x86 assembly (clang, -O0):
<Curve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
movaps 0xee2(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xec6(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1153 <Curve+0x43>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a8 <Curve+0x98>
movsd  0xead(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
movsd  0xe86(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <exp@plt>
mov    %eax,%edx
mov    -0x1c(%rbp),%eax
mov    $0x1,%ecx
sub    %edx,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Curve>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movapd 0xee2(%rip),%xmm3
andpd  %xmm0,%xmm3
movsd  0xef6(%rip),%xmm2
ucomisd %xmm3,%xmm2
ja     116e <Curve+0x5e>
xorpd  0xed8(%rip),%xmm0
movapd %xmm0,(%rsp)
mulsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <exp@plt>
mov    $0x1,%ebp
mov    $0x1,%ebx
sub    %eax,%ebx
cvttsd2si (%rsp),%edi
call   1030 <exp@plt>
sub    %eax,%ebp
mov    %ebx,%eax
cltd
idiv   %ebp
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @Curve(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* %4
%7 = call double @llvm.fabs.f64(double %6)
%8 = fcmp olt double %7, 1.000000e-03
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load double, double* %5
store double %10, double* %3
br label %26
11: ; preds = %2
%12 = load double, double* %4
%13 = fmul double -1.000000e+00, %12
%14 = load double, double* %5
%15 = fmul double %13, %14
%16 = fptosi double %15 to i32
%17 = call i32 @exp(i32 %16)
%18 = sub nsw i32 1, %17
%19 = load double, double* %4
%20 = fmul double -1.000000e+00, %19
%21 = fptosi double %20 to i32
%22 = call i32 @exp(i32 %21)
%23 = sub nsw i32 1, %22
%24 = sdiv i32 %18, %23
%25 = sitofp i32 %24 to double
store double %25, double* %3
br label %26
26: ; preds = %11, %9
%27 = load double, double* %3
ret double %27
}

LLVM IR (-O2):
define double @Curve(double %0, double %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = fcmp olt double %3, 1.000000e-03
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = fneg double %0
%7 = fmul double %6, %1
%8 = fptosi double %7 to i32
%9 = tail call i32 @exp(i32 %8)
%10 = sub nsw i32 1, %9
%11 = fptosi double %6 to i32
%12 = tail call i32 @exp(i32 %11)
%13 = sub nsw i32 1, %12
%14 = sdiv i32 %10, %13
%15 = sitofp i32 %14 to double
br label %16
16: ; preds = %2, %5
%17 = phi double [ %15, %5 ], [ %1, %2 ]
ret double %17
}