#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 err_mod_func(double, double, double);
double linearfunc(double, double, double);
double interfunc(int fun_type, double n_sub, double i, double sld_l,
                 double sld_r) {
  double sld_i, func;
  switch (fun_type) {
  case 0:
    func = err_mod_func(n_sub, i, 2.5);
    break;
  default:
    func = linearfunc(n_sub, i, 1.0);
    break;
  }
  if (sld_r > sld_l) {
    sld_i = (sld_r - sld_l) * func + sld_l;
  } else if (sld_r < sld_l) {
    func = 1.0 - func;
    sld_i = (sld_l - sld_r) * func + sld_r;
  } else {
    sld_i = sld_r;
  }
  return sld_i;
}


x86 assembly (clang, -O0):
<interfunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    -0x4(%rbp),%eax
test   %eax,%eax
jne    1170 <interfunc+0x50>
jmp    114f <interfunc+0x2f>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe9f(%rip),%xmm2
call   1030 <err_mod_func@plt>
movsd  %xmm0,-0x38(%rbp)
jmp    118c <interfunc+0x6c>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe86(%rip),%xmm2
call   1040 <linearfunc@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11c2 <interfunc+0xa2>
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    121d <interfunc+0xfd>
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    120e <interfunc+0xee>
movsd  0xe2a(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1218 <interfunc+0xf8>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    121d <interfunc+0xfd>
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interfunc>:
sub    $0x18,%rsp
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
test   %edi,%edi
je     1143 <interfunc+0x23>
movsd  0xec4(%rip),%xmm2
call   1040 <linearfunc@plt>
jmp    1150 <interfunc+0x30>
movsd  0xebd(%rip),%xmm2
call   1030 <err_mod_func@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
ucomisd %xmm3,%xmm2
jbe    1170 <interfunc+0x50>
subsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm3,%xmm2
jmp    1197 <interfunc+0x77>
ucomisd %xmm2,%xmm3
jbe    1197 <interfunc+0x77>
movsd  0xe82(%rip),%xmm1
subsd  %xmm0,%xmm1
subsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
movapd %xmm3,%xmm0
add    $0x18,%rsp
ret
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @interfunc(i32 %0, double %1, double %2, double %3, double %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store i32 %0, i32* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%13 = load i32, i32* %6
switch i32 %13, label %18 [
i32 0, label %14
]
14: ; preds = %5
%15 = load double, double* %7
%16 = load double, double* %8
%17 = call double @err_mod_func(double %15, double %16, double 2.500000e+00)
store double %17, double* %12
br label %22
18: ; preds = %5
%19 = load double, double* %7
%20 = load double, double* %8
%21 = call double @linearfunc(double %19, double %20, double 1.000000e+00)
store double %21, double* %12
br label %22
22: ; preds = %18, %14
%23 = load double, double* %10
%24 = load double, double* %9
%25 = fcmp ogt double %23, %24
br i1 %25, label %26, label %33
26: ; preds = %22
%27 = load double, double* %10
%28 = load double, double* %9
%29 = fsub double %27, %28
%30 = load double, double* %12
%31 = load double, double* %9
%32 = call double @llvm.fmuladd.f64(double %29, double %30, double %31)
store double %32, double* %11
br label %49
33: ; preds = %22
%34 = load double, double* %10
%35 = load double, double* %9
%36 = fcmp olt double %34, %35
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = load double, double* %12
%39 = fsub double 1.000000e+00, %38
store double %39, double* %12
%40 = load double, double* %9
%41 = load double, double* %10
%42 = fsub double %40, %41
%43 = load double, double* %12
%44 = load double, double* %10
%45 = call double @llvm.fmuladd.f64(double %42, double %43, double %44)
store double %45, double* %11
br label %48
46: ; preds = %33
%47 = load double, double* %10
store double %47, double* %11
br label %48
48: ; preds = %46, %37
br label %49
49: ; preds = %48, %26
%50 = load double, double* %11
ret double %50
}

LLVM IR (-O2):
define double @interfunc(i32 %0, double %1, double %2, double %3, double %4) {
%6 = icmp eq i32 %0, 0
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call double @err_mod_func(double %1, double %2, double 2.500000e+00)
br label %11
9: ; preds = %5
%10 = tail call double @linearfunc(double %1, double %2, double 1.000000e+00)
br label %11
11: ; preds = %9, %7
%12 = phi double [ %8, %7 ], [ %10, %9 ]
%13 = fcmp ogt double %4, %3
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = fsub double %4, %3
%16 = tail call double @llvm.fmuladd.f64(double %15, double %12, double %3)
br label %23
17: ; preds = %11
%18 = fcmp olt double %4, %3
br i1 %18, label %19, label %23
19: ; preds = %17
%20 = fsub double 1.000000e+00, %12
%21 = fsub double %3, %4
%22 = tail call double @llvm.fmuladd.f64(double %21, double %20, double %4)
br label %23
23: ; preds = %17, %19, %14
%24 = phi double [ %16, %14 ], [ %22, %19 ], [ %4, %17 ]
ret double %24
}