#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 */
scalar_t__ exp(double);
double log(scalar_t__);
double approx2(double x1, double x2, double c1, double c2) {
  double T1 = log(1 + exp(c1 * x1));
  double T2 = log(1 + exp(c1 * x2));
  return c2 * (T1 * T1 - T2 * T2);
}


x86 assembly (clang, -O0):
<approx2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <exp@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1040 <log@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <exp@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1040 <log@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm2
mulsd  -0x30(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<approx2>:
sub    $0x28,%rsp
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm2,%xmm0
call   1030 <exp@plt>
lea    0x1(%rax),%rdi
call   1040 <log@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <exp@plt>
lea    0x1(%rax),%rdi
call   1040 <log@plt>
mulsd  %xmm0,%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
mulsd  0x20(%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @approx2(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%11 = load double, double* %7
%12 = load double, double* %5
%13 = fmul double %11, %12
%14 = call i64 @exp(double %13)
%15 = add nsw i64 1, %14
%16 = call double @log(i64 %15)
store double %16, double* %9
%17 = load double, double* %7
%18 = load double, double* %6
%19 = fmul double %17, %18
%20 = call i64 @exp(double %19)
%21 = add nsw i64 1, %20
%22 = call double @log(i64 %21)
store double %22, double* %10
%23 = load double, double* %8
%24 = load double, double* %9
%25 = load double, double* %9
%26 = load double, double* %10
%27 = load double, double* %10
%28 = fmul double %26, %27
%29 = fneg double %28
%30 = call double @llvm.fmuladd.f64(double %24, double %25, double %29)
%31 = fmul double %23, %30
ret double %31
}

LLVM IR (-O2):
define double @approx2(double %0, double %1, double %2, double %3) {
%5 = fmul double %0, %2
%6 = tail call i64 @exp(double %5)
%7 = add nsw i64 %6, 1
%8 = tail call double @log(i64 %7)
%9 = fmul double %1, %2
%10 = tail call i64 @exp(double %9)
%11 = add nsw i64 %10, 1
%12 = tail call double @log(i64 %11)
%13 = fneg double %12
%14 = fmul double %12, %13
%15 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %14)
%16 = fmul double %15, %3
ret double %16
}