#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 log(double);
double explin(double x, double a, double b, double c, double d) {
  if (x <= a)
    return c;
  if (x >= b)
    return d;
  return (log(x / a)) / (log(b / a)) * (d - c) + c;
}


x86 assembly (clang, -O0):
<explin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1154 <explin+0x44>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11be <explin+0xae>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1173 <explin+0x63>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11be <explin+0xae>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm2
subsd  -0x28(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<explin>:
ucomisd %xmm0,%xmm1
jae    1180 <explin+0x70>
ucomisd %xmm2,%xmm0
jae    117d <explin+0x6d>
sub    $0x28,%rsp
divsd  %xmm1,%xmm0
movsd  %xmm3,0x20(%rsp)
movsd  %xmm4,0x18(%rsp)
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1030 <log@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
call   1030 <log@plt>
movsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
subsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x28,%rsp
ret
movaps %xmm4,%xmm3
movaps %xmm3,%xmm0
ret

LLVM IR (-O0):
define double @explin(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
%12 = load double, double* %7
%13 = load double, double* %8
%14 = fcmp ole double %12, %13
br i1 %14, label %15, label %17
15: ; preds = %5
%16 = load double, double* %10
store double %16, double* %6
br label %38
17: ; preds = %5
%18 = load double, double* %7
%19 = load double, double* %9
%20 = fcmp oge double %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load double, double* %11
store double %22, double* %6
br label %38
23: ; preds = %17
%24 = load double, double* %7
%25 = load double, double* %8
%26 = fdiv double %24, %25
%27 = call double @log(double %26)
%28 = load double, double* %9
%29 = load double, double* %8
%30 = fdiv double %28, %29
%31 = call double @log(double %30)
%32 = fdiv double %27, %31
%33 = load double, double* %11
%34 = load double, double* %10
%35 = fsub double %33, %34
%36 = load double, double* %10
%37 = call double @llvm.fmuladd.f64(double %32, double %35, double %36)
store double %37, double* %6
br label %38
38: ; preds = %23, %21, %15
%39 = load double, double* %6
ret double %39
}

LLVM IR (-O2):
define double @explin(double %0, double %1, double %2, double %3, double %4) {
%6 = fcmp ugt double %0, %1
br i1 %6, label %7, label %17
7: ; preds = %5
%8 = fcmp ult double %0, %2
br i1 %8, label %9, label %17
9: ; preds = %7
%10 = fdiv double %0, %1
%11 = tail call double @log(double %10)
%12 = fdiv double %2, %1
%13 = tail call double @log(double %12)
%14 = fdiv double %11, %13
%15 = fsub double %4, %3
%16 = tail call double @llvm.fmuladd.f64(double %14, double %15, double %3)
br label %17
17: ; preds = %7, %5, %9
%18 = phi double [ %16, %9 ], [ %3, %5 ], [ %4, %7 ]
ret double %18
}