#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__ double_equal(double, double);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double, double, double);
int /*<<< orphan*/ stderr;
double inter_low(double x, double x1, double y1, double x2, double y2) {
  if (x1 > x2 || x < x1 || x > x2) {
    fprintf(stderr, "inter_low: x %g x1 %g x2 %g.\n", x, x1, x2);
    error("impossible situation.");
  }
  if (double_equal(x1, x2) && y1 < y2)
    return y1;
  if (double_equal(x1, x2) && y1 > y2)
    return y2;
  return y1 + (x - x1) * (y2 - y1) / (x2 - x1);
}


x86 assembly (clang, -O0):
<inter_low>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
ja     1185 <inter_low+0x55>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     1185 <inter_low+0x55>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11b5 <inter_low+0x85>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
lea    0xe5c(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe6e(%rip),%rdi
call   1050 <error@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1040 <double_equal@plt>
cmp    $0x0,%rax
je     11f1 <inter_low+0xc1>
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f1 <inter_low+0xc1>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125d <inter_low+0x12d>
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1040 <double_equal@plt>
cmp    $0x0,%rax
je     1229 <inter_low+0xf9>
movsd  -0x20(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1229 <inter_low+0xf9>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    125d <inter_low+0x12d>
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
subsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  -0x28(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inter_low>:
sub    $0x28,%rsp
movsd  %xmm4,(%rsp)
movsd  %xmm2,0x20(%rsp)
ucomisd %xmm3,%xmm0
movsd  %xmm3,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
ja     1163 <inter_low+0x33>
ucomisd %xmm0,%xmm1
ja     1163 <inter_low+0x33>
ucomisd %xmm3,%xmm1
jbe    119a <inter_low+0x6a>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
movsd  0x18(%rsp),%xmm0
movapd %xmm3,%xmm2
call   1030 <fprintf@plt>
lea    0xe95(%rip),%rdi
call   1050 <error@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm3
movapd %xmm1,%xmm0
movapd %xmm3,%xmm1
call   1040 <double_equal@plt>
movsd  0x20(%rsp),%xmm0
movsd  (%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    11c2 <inter_low+0x92>
test   %rax,%rax
je     11c2 <inter_low+0x92>
add    $0x28,%rsp
ret
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1040 <double_equal@plt>
movsd  0x20(%rsp),%xmm0
ucomisd (%rsp),%xmm0
jbe    11ef <inter_low+0xbf>
test   %rax,%rax
je     11ef <inter_low+0xbf>
movsd  (%rsp),%xmm0
add    $0x28,%rsp
ret
movsd  0x8(%rsp),%xmm3
movsd  0x18(%rsp),%xmm2
subsd  %xmm3,%xmm2
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm2,%xmm1
movsd  0x10(%rsp),%xmm2
subsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"inter_low: x %g x1 %g x2 %g.\0A\00"
@.str.1 = [22 x i8] c"impossible situation.\00"
define double @inter_low(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* %8
%13 = load double, double* %10
%14 = fcmp ogt double %12, %13
br i1 %14, label %23, label %15
15: ; preds = %5
%16 = load double, double* %7
%17 = load double, double* %8
%18 = fcmp olt double %16, %17
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load double, double* %7
%21 = load double, double* %10
%22 = fcmp ogt double %20, %21
br i1 %22, label %23, label %30
23: ; preds = %19, %15, %5
%24 = load i32, i32* @stderr
%25 = load double, double* %7
%26 = load double, double* %8
%27 = load double, double* %10
%28 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), double %25, double %26, double %27)
%29 = call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %23, %19
%31 = load double, double* %8
%32 = load double, double* %10
%33 = call i64 @double_equal(double %31, double %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %30
%36 = load double, double* %9
%37 = load double, double* %11
%38 = fcmp olt double %36, %37
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = load double, double* %9
store double %40, double* %6
br label %66
41: ; preds = %35, %30
%42 = load double, double* %8
%43 = load double, double* %10
%44 = call i64 @double_equal(double %42, double %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %41
%47 = load double, double* %9
%48 = load double, double* %11
%49 = fcmp ogt double %47, %48
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = load double, double* %11
store double %51, double* %6
br label %66
52: ; preds = %46, %41
%53 = load double, double* %9
%54 = load double, double* %7
%55 = load double, double* %8
%56 = fsub double %54, %55
%57 = load double, double* %11
%58 = load double, double* %9
%59 = fsub double %57, %58
%60 = fmul double %56, %59
%61 = load double, double* %10
%62 = load double, double* %8
%63 = fsub double %61, %62
%64 = fdiv double %60, %63
%65 = fadd double %53, %64
store double %65, double* %6
br label %66
66: ; preds = %52, %50, %39
%67 = load double, double* %6
ret double %67
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"inter_low: x %g x1 %g x2 %g.\0A\00"
@.str.1 = [22 x i8] c"impossible situation.\00"
define double @inter_low(double %0, double %1, double %2, double %3, double %4) {
%6 = fcmp ogt double %1, %3
%7 = fcmp olt double %0, %1
%8 = or i1 %7, %6
%9 = fcmp ogt double %0, %3
%10 = or i1 %9, %8
br i1 %10, label %11, label %15
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), double %0, double %1, double %3)
%14 = tail call i32 @error(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %5, %11
%16 = tail call i64 @double_equal(double %1, double %3)
%17 = icmp ne i64 %16, 0
%18 = fcmp olt double %2, %4
%19 = and i1 %18, %17
br i1 %19, label %32, label %20
20: ; preds = %15
%21 = tail call i64 @double_equal(double %1, double %3)
%22 = icmp ne i64 %21, 0
%23 = fcmp ogt double %2, %4
%24 = and i1 %23, %22
br i1 %24, label %32, label %25
25: ; preds = %20
%26 = fsub double %0, %1
%27 = fsub double %4, %2
%28 = fmul double %26, %27
%29 = fsub double %3, %1
%30 = fdiv double %28, %29
%31 = fadd double %30, %2
br label %32
32: ; preds = %20, %15, %25
%33 = phi double [ %31, %25 ], [ %2, %15 ], [ %4, %20 ]
ret double %33
}