#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 /*<<< orphan*/ fisError(char *);
int /*<<< orphan*/ printf(char *, double, double, double, double);
double fisTrapezoidMf(double x, double *params) {
  double a = params[0], b = params[1], c = params[2], d = params[3];
  double y1 = 0, y2 = 0;
  if (a > b) {
    printf("a = %f, b = %f, c = %f, d = %f\n", a, b, c, d);
    fisError("Illegal parameters in fisTrapezoidMf() --> a > b");
  }
  if (b > c) {
    printf("a = %f, b = %f, c = %f, d = %f\n", a, b, c, d);
    fisError("Illegal parameters in fisTrapezoidMf() --> b > c");
  }
  if (c > d) {
    printf("a = %f, b = %f, c = %f, d = %f\n", a, b, c, d);
    fisError("Illegal parameters in fisTrapezoidMf() --> c > d");
  }
  if (b <= x)
    y1 = 1;
  else if (x < a)
    y1 = 0;
  else if (a != b)
    y1 = (x - a) / (b - a);
  if (x <= c)
    y2 = 1;
  else if (d < x)
    y2 = 0;
  else if (c != d)
    y2 = (d - x) / (d - c);
  return (((y1) < (y2) ? (y1) : (y2)));
}


x86 assembly (clang, -O0):
<fisTrapezoidMf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11b4 <fisTrapezoidMf+0x94>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
lea    0xe79(%rip),%rdi
call   1030 <fisError@plt>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11f0 <fisTrapezoidMf+0xd0>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
lea    0xe29(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6e(%rip),%rdi
call   1030 <fisError@plt>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    122c <fisTrapezoidMf+0x10c>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
lea    0xded(%rip),%rdi
call   1040 <printf@plt>
lea    0xe63(%rip),%rdi
call   1030 <fisError@plt>
movsd  -0x20(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1252 <fisTrapezoidMf+0x132>
movsd  0xdb8(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    12b5 <fisTrapezoidMf+0x195>
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1273 <fisTrapezoidMf+0x153>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    12b0 <fisTrapezoidMf+0x190>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jne    128e <fisTrapezoidMf+0x16e>
jp     128e <fisTrapezoidMf+0x16e>
jmp    12ab <fisTrapezoidMf+0x18b>
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    12b0 <fisTrapezoidMf+0x190>
jmp    12b5 <fisTrapezoidMf+0x195>
movsd  -0x8(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     12db <fisTrapezoidMf+0x1bb>
movsd  0xd2f(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    133e <fisTrapezoidMf+0x21e>
movsd  -0x30(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12fc <fisTrapezoidMf+0x1dc>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1339 <fisTrapezoidMf+0x219>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jne    1317 <fisTrapezoidMf+0x1f7>
jp     1317 <fisTrapezoidMf+0x1f7>
jmp    1334 <fisTrapezoidMf+0x214>
movsd  -0x30(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1339 <fisTrapezoidMf+0x219>
jmp    133e <fisTrapezoidMf+0x21e>
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1361 <fisTrapezoidMf+0x241>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    136b <fisTrapezoidMf+0x24b>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fisTrapezoidMf>:
sub    $0x28,%rsp
movapd %xmm0,%xmm4
movsd  (%rdi),%xmm6
movsd  0x8(%rdi),%xmm1
movsd  0x10(%rdi),%xmm2
movsd  0x18(%rdi),%xmm3
ucomisd %xmm1,%xmm6
movsd  %xmm0,0x20(%rsp)
movsd  %xmm3,(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm6,0x8(%rsp)
ja     1215 <fisTrapezoidMf+0xf5>
ucomisd %xmm2,%xmm1
ja     125d <fisTrapezoidMf+0x13d>
ucomisd %xmm3,%xmm2
jbe    11b0 <fisTrapezoidMf+0x90>
lea    0xe8f(%rip),%rdi
movapd %xmm6,%xmm0
movsd  (%rsp),%xmm3
call   1040 <printf@plt>
lea    0xefc(%rip),%rdi
call   1030 <fisError@plt>
movsd  0x8(%rsp),%xmm6
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  (%rsp),%xmm3
movsd  0x20(%rsp),%xmm4
movsd  0xe48(%rip),%xmm5
ucomisd %xmm1,%xmm4
movapd %xmm5,%xmm0
jae    11e4 <fisTrapezoidMf+0xc4>
ucomisd %xmm4,%xmm6
xorpd  %xmm0,%xmm0
ja     11e4 <fisTrapezoidMf+0xc4>
ucomisd %xmm1,%xmm6
jne    11d4 <fisTrapezoidMf+0xb4>
jnp    11e4 <fisTrapezoidMf+0xc4>
movapd %xmm4,%xmm0
subsd  %xmm6,%xmm0
subsd  %xmm6,%xmm1
divsd  %xmm1,%xmm0
ucomisd %xmm4,%xmm2
jae    120c <fisTrapezoidMf+0xec>
ucomisd %xmm3,%xmm4
xorpd  %xmm5,%xmm5
ja     120c <fisTrapezoidMf+0xec>
ucomisd %xmm3,%xmm2
jne    11fc <fisTrapezoidMf+0xdc>
jnp    120c <fisTrapezoidMf+0xec>
movapd %xmm3,%xmm5
subsd  %xmm4,%xmm5
subsd  %xmm2,%xmm3
divsd  %xmm3,%xmm5
minsd  %xmm5,%xmm0
add    $0x28,%rsp
ret
lea    0xdec(%rip),%rdi
movapd %xmm6,%xmm0
movsd  (%rsp),%xmm3
call   1040 <printf@plt>
lea    0xdf7(%rip),%rdi
call   1030 <fisError@plt>
movsd  0x8(%rsp),%xmm6
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  (%rsp),%xmm3
movsd  0x20(%rsp),%xmm4
ucomisd %xmm2,%xmm1
jbe    116c <fisTrapezoidMf+0x4c>
lea    0xda4(%rip),%rdi
movapd %xmm6,%xmm0
movsd  (%rsp),%xmm3
call   1040 <printf@plt>
lea    0xde0(%rip),%rdi
call   1030 <fisError@plt>
movsd  0x8(%rsp),%xmm6
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  (%rsp),%xmm3
movsd  0x20(%rsp),%xmm4
ucomisd %xmm3,%xmm2
ja     1172 <fisTrapezoidMf+0x52>
jmp    11b0 <fisTrapezoidMf+0x90>

LLVM IR (-O0):
@.str = [32 x i8] c"a = %f, b = %f, c = %f, d = %f\0A\00"
@.str.1 = [49 x i8] c"Illegal parameters in fisTrapezoidMf() --> a > b\00"
@.str.2 = [49 x i8] c"Illegal parameters in fisTrapezoidMf() --> b > c\00"
@.str.3 = [49 x i8] c"Illegal parameters in fisTrapezoidMf() --> c > d\00"
define double @fisTrapezoidMf(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %3
store double* %1, double** %4
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
store double %13, double* %5
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
store double %16, double* %6
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 2
%19 = load double, double* %18
store double %19, double* %7
%20 = load double*, double** %4
%21 = getelementptr inbounds double, double* %20, i64 3
%22 = load double, double* %21
store double %22, double* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
%23 = load double, double* %5
%24 = load double, double* %6
%25 = fcmp ogt double %23, %24
br i1 %25, label %26, label %33
26: ; preds = %2
%27 = load double, double* %5
%28 = load double, double* %6
%29 = load double, double* %7
%30 = load double, double* %8
%31 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %27, double %28, double %29, double %30)
%32 = call i32 @fisError(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %26, %2
%34 = load double, double* %6
%35 = load double, double* %7
%36 = fcmp ogt double %34, %35
br i1 %36, label %37, label %44
37: ; preds = %33
%38 = load double, double* %5
%39 = load double, double* %6
%40 = load double, double* %7
%41 = load double, double* %8
%42 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %38, double %39, double %40, double %41)
%43 = call i32 @fisError(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %37, %33
%45 = load double, double* %7
%46 = load double, double* %8
%47 = fcmp ogt double %45, %46
br i1 %47, label %48, label %55
48: ; preds = %44
%49 = load double, double* %5
%50 = load double, double* %6
%51 = load double, double* %7
%52 = load double, double* %8
%53 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %49, double %50, double %51, double %52)
%54 = call i32 @fisError(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %48, %44
%56 = load double, double* %6
%57 = load double, double* %3
%58 = fcmp ole double %56, %57
br i1 %58, label %59, label %60
59: ; preds = %55
store double 1.000000e+00, double* %9
br label %79
60: ; preds = %55
%61 = load double, double* %3
%62 = load double, double* %5
%63 = fcmp olt double %61, %62
br i1 %63, label %64, label %65
64: ; preds = %60
store double 0.000000e+00, double* %9
br label %78
65: ; preds = %60
%66 = load double, double* %5
%67 = load double, double* %6
%68 = fcmp une double %66, %67
br i1 %68, label %69, label %77
69: ; preds = %65
%70 = load double, double* %3
%71 = load double, double* %5
%72 = fsub double %70, %71
%73 = load double, double* %6
%74 = load double, double* %5
%75 = fsub double %73, %74
%76 = fdiv double %72, %75
store double %76, double* %9
br label %77
77: ; preds = %69, %65
br label %78
78: ; preds = %77, %64
br label %79
79: ; preds = %78, %59
%80 = load double, double* %3
%81 = load double, double* %7
%82 = fcmp ole double %80, %81
br i1 %82, label %83, label %84
83: ; preds = %79
store double 1.000000e+00, double* %10
br label %103
84: ; preds = %79
%85 = load double, double* %8
%86 = load double, double* %3
%87 = fcmp olt double %85, %86
br i1 %87, label %88, label %89
88: ; preds = %84
store double 0.000000e+00, double* %10
br label %102
89: ; preds = %84
%90 = load double, double* %7
%91 = load double, double* %8
%92 = fcmp une double %90, %91
br i1 %92, label %93, label %101
93: ; preds = %89
%94 = load double, double* %8
%95 = load double, double* %3
%96 = fsub double %94, %95
%97 = load double, double* %8
%98 = load double, double* %7
%99 = fsub double %97, %98
%100 = fdiv double %96, %99
store double %100, double* %10
br label %101
101: ; preds = %93, %89
br label %102
102: ; preds = %101, %88
br label %103
103: ; preds = %102, %83
%104 = load double, double* %9
%105 = load double, double* %10
%106 = fcmp olt double %104, %105
br i1 %106, label %107, label %109
107: ; preds = %103
%108 = load double, double* %9
br label %111
109: ; preds = %103
%110 = load double, double* %10
br label %111
111: ; preds = %109, %107
%112 = phi double [ %108, %107 ], [ %110, %109 ]
ret double %112
}

LLVM IR (-O2):
@.str = [32 x i8] c"a = %f, b = %f, c = %f, d = %f\0A\00"
@.str.1 = [49 x i8] c"Illegal parameters in fisTrapezoidMf() --> a > b\00"
@.str.2 = [49 x i8] c"Illegal parameters in fisTrapezoidMf() --> b > c\00"
@.str.3 = [49 x i8] c"Illegal parameters in fisTrapezoidMf() --> c > d\00"
define double @fisTrapezoidMf(double %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = getelementptr inbounds double, double* %1, i64 1
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %1, i64 2
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %1, i64 3
%9 = load double, double* %8
%10 = fcmp ogt double %3, %5
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %3, double %5, double %7, double %9)
%13 = tail call i32 @fisError(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %11, %2
%15 = fcmp ogt double %5, %7
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %3, double %5, double %7, double %9)
%18 = tail call i32 @fisError(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %16, %14
%20 = fcmp ogt double %7, %9
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %3, double %5, double %7, double %9)
%23 = tail call i32 @fisError(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %21, %19
%25 = fcmp ugt double %5, %0
br i1 %25, label %26, label %34
26: ; preds = %24
%27 = fcmp ule double %3, %0
%28 = fcmp une double %3, %5
%29 = select i1 %27, i1 %28, i1 false
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = fsub double %0, %3
%32 = fsub double %5, %3
%33 = fdiv double %31, %32
br label %34
34: ; preds = %26, %24, %30
%35 = phi double [ %33, %30 ], [ 1.000000e+00, %24 ], [ 0.000000e+00, %26 ]
%36 = fcmp ult double %7, %0
br i1 %36, label %37, label %45
37: ; preds = %34
%38 = fcmp uge double %9, %0
%39 = fcmp une double %7, %9
%40 = select i1 %38, i1 %39, i1 false
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = fsub double %9, %0
%43 = fsub double %9, %7
%44 = fdiv double %42, %43
br label %45
45: ; preds = %37, %34, %41
%46 = phi double [ %44, %41 ], [ 1.000000e+00, %34 ], [ 0.000000e+00, %37 ]
%47 = fcmp olt double %35, %46
%48 = select i1 %47, double %35, double %46
ret double %48
}