#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 exp_l(double, double, double);
double exp_r(double, double, double);
double linearfunc(double, double, double);
double power_l(double, double, double);
double power_r(double, double, double);
double intersldfunc(int fun_type, double n_sub, double i, double nu,
                    double sld_l, double sld_r) {
  double sld_i, func;
  if (nu == 0.0) {
    nu = 1e-13;
  }
  switch (fun_type) {
  case 1:
    func = power_r(n_sub, i, nu);
    break;
  case 2:
    func = power_l(n_sub, i, nu);
    break;
  case 3:
    func = exp_r(n_sub, i, nu);
    break;
  case 4:
    func = exp_l(n_sub, i, nu);
    break;
  case 5:
    func = linearfunc(n_sub, i, nu);
    break;
  default:
    func = err_mod_func(n_sub, i, nu);
    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):
<intersldfunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11a9 <intersldfunc+0x49>
jp     11a9 <intersldfunc+0x49>
movsd  0xe5c(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x4,%eax
ja     1268 <intersldfunc+0x108>
mov    -0x48(%rbp),%rax
lea    0xe47(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1050 <power_r@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    1281 <intersldfunc+0x121>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1040 <power_l@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    1281 <intersldfunc+0x121>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1060 <exp_r@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    1281 <intersldfunc+0x121>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1070 <exp_l@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    1281 <intersldfunc+0x121>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1080 <linearfunc@plt>
movsd  %xmm0,-0x40(%rbp)
jmp    1281 <intersldfunc+0x121>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1030 <err_mod_func@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    12b7 <intersldfunc+0x157>
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1312 <intersldfunc+0x1b2>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1303 <intersldfunc+0x1a3>
movsd  0xd35(%rip),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    130d <intersldfunc+0x1ad>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1312 <intersldfunc+0x1b2>
movsd  -0x38(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intersldfunc>:
sub    $0x18,%rsp
movsd  %xmm4,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
movapd %xmm2,%xmm3
xorpd  %xmm2,%xmm2
cmpeqsd %xmm3,%xmm2
movsd  0xe7b(%rip),%xmm4
andpd  %xmm2,%xmm4
andnpd %xmm3,%xmm2
orpd   %xmm4,%xmm2
add    $0xffffffff,%edi
cmp    $0x4,%edi
ja     11b0 <intersldfunc+0x50>
lea    0xe70(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
call   1050 <power_r@plt>
jmp    11d1 <intersldfunc+0x71>
call   1030 <err_mod_func@plt>
jmp    11d1 <intersldfunc+0x71>
call   1040 <power_l@plt>
jmp    11d1 <intersldfunc+0x71>
call   1060 <exp_r@plt>
jmp    11d1 <intersldfunc+0x71>
call   1070 <exp_l@plt>
jmp    11d1 <intersldfunc+0x71>
call   1080 <linearfunc@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm3
ucomisd %xmm3,%xmm2
jbe    11f1 <intersldfunc+0x91>
subsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm3,%xmm2
jmp    1218 <intersldfunc+0xb8>
ucomisd %xmm2,%xmm3
jbe    1218 <intersldfunc+0xb8>
movsd  0xe09(%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 @intersldfunc(i32 %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store i32 %0, i32* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%15 = load double, double* %10
%16 = fcmp oeq double %15, 0.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %6
store double 1.000000e-13, double* %10
br label %18
18: ; preds = %17, %6
%19 = load i32, i32* %7
switch i32 %19, label %45 [
i32 1, label %20
i32 2, label %25
i32 3, label %30
i32 4, label %35
i32 5, label %40
]
20: ; preds = %18
%21 = load double, double* %8
%22 = load double, double* %9
%23 = load double, double* %10
%24 = call double @power_r(double %21, double %22, double %23)
store double %24, double* %14
br label %50
25: ; preds = %18
%26 = load double, double* %8
%27 = load double, double* %9
%28 = load double, double* %10
%29 = call double @power_l(double %26, double %27, double %28)
store double %29, double* %14
br label %50
30: ; preds = %18
%31 = load double, double* %8
%32 = load double, double* %9
%33 = load double, double* %10
%34 = call double @exp_r(double %31, double %32, double %33)
store double %34, double* %14
br label %50
35: ; preds = %18
%36 = load double, double* %8
%37 = load double, double* %9
%38 = load double, double* %10
%39 = call double @exp_l(double %36, double %37, double %38)
store double %39, double* %14
br label %50
40: ; preds = %18
%41 = load double, double* %8
%42 = load double, double* %9
%43 = load double, double* %10
%44 = call double @linearfunc(double %41, double %42, double %43)
store double %44, double* %14
br label %50
45: ; preds = %18
%46 = load double, double* %8
%47 = load double, double* %9
%48 = load double, double* %10
%49 = call double @err_mod_func(double %46, double %47, double %48)
store double %49, double* %14
br label %50
50: ; preds = %45, %40, %35, %30, %25, %20
%51 = load double, double* %12
%52 = load double, double* %11
%53 = fcmp ogt double %51, %52
br i1 %53, label %54, label %61
54: ; preds = %50
%55 = load double, double* %12
%56 = load double, double* %11
%57 = fsub double %55, %56
%58 = load double, double* %14
%59 = load double, double* %11
%60 = call double @llvm.fmuladd.f64(double %57, double %58, double %59)
store double %60, double* %13
br label %77
61: ; preds = %50
%62 = load double, double* %12
%63 = load double, double* %11
%64 = fcmp olt double %62, %63
br i1 %64, label %65, label %74
65: ; preds = %61
%66 = load double, double* %14
%67 = fsub double 1.000000e+00, %66
store double %67, double* %14
%68 = load double, double* %11
%69 = load double, double* %12
%70 = fsub double %68, %69
%71 = load double, double* %14
%72 = load double, double* %12
%73 = call double @llvm.fmuladd.f64(double %70, double %71, double %72)
store double %73, double* %13
br label %76
74: ; preds = %61
%75 = load double, double* %12
store double %75, double* %13
br label %76
76: ; preds = %74, %65
br label %77
77: ; preds = %76, %54
%78 = load double, double* %13
ret double %78
}

LLVM IR (-O2):
define double @intersldfunc(i32 %0, double %1, double %2, double %3, double %4, double %5) {
%7 = fcmp oeq double %3, 0.000000e+00
%8 = select i1 %7, double 1.000000e-13, double %3
switch i32 %0, label %19 [
i32 1, label %9
i32 2, label %11
i32 3, label %13
i32 4, label %15
i32 5, label %17
]
9: ; preds = %6
%10 = tail call double @power_r(double %1, double %2, double %8)
br label %21
11: ; preds = %6
%12 = tail call double @power_l(double %1, double %2, double %8)
br label %21
13: ; preds = %6
%14 = tail call double @exp_r(double %1, double %2, double %8)
br label %21
15: ; preds = %6
%16 = tail call double @exp_l(double %1, double %2, double %8)
br label %21
17: ; preds = %6
%18 = tail call double @linearfunc(double %1, double %2, double %8)
br label %21
19: ; preds = %6
%20 = tail call double @err_mod_func(double %1, double %2, double %8)
br label %21
21: ; preds = %19, %17, %15, %13, %11, %9
%22 = phi double [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ], [ %12, %11 ], [ %10, %9 ]
%23 = fcmp ogt double %5, %4
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = fsub double %5, %4
%26 = tail call double @llvm.fmuladd.f64(double %25, double %22, double %4)
br label %33
27: ; preds = %21
%28 = fcmp olt double %5, %4
br i1 %28, label %29, label %33
29: ; preds = %27
%30 = fsub double 1.000000e+00, %22
%31 = fsub double %4, %5
%32 = tail call double @llvm.fmuladd.f64(double %31, double %30, double %5)
br label %33
33: ; preds = %27, %29, %24
%34 = phi double [ %26, %24 ], [ %32, %29 ], [ %5, %27 ]
ret double %34
}