#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__ fabs(double);
void linear_mc(double x1, double x2, double x3, double *lout, double *rout) {
  double Dqm, Dqp, Dqc, s;
  Dqm = 2. * (x2 - x1);
  Dqp = 2. * (x3 - x2);
  Dqc = 0.5 * (x3 - x1);
  s = Dqm * Dqp;
  if (s <= 0.)
    s = 0.;
  else {
    if (fabs(Dqm) < fabs(Dqp) && fabs(Dqm) < fabs(Dqc))
      s = Dqm;
    else if (fabs(Dqp) < fabs(Dqc))
      s = Dqp;
    else
      s = Dqc;
  }
  *lout = x2 - 0.5 * s;
  *rout = x2 + 0.5 * s;
}


x86 assembly (clang, -O0):
<linear_mc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
movsd  0xec7(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xeac(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
movsd  0xe89(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jb     11aa <linear_mc+0x9a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1254 <linear_mc+0x144>
movsd  -0x30(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
jge    1209 <linear_mc+0xf9>
movsd  -0x30(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
jge    1209 <linear_mc+0xf9>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    124f <linear_mc+0x13f>
movsd  -0x38(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
cmp    %rcx,%rax
jge    1240 <linear_mc+0x130>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    124a <linear_mc+0x13a>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    124f <linear_mc+0x13f>
jmp    1254 <linear_mc+0x144>
movsd  -0x10(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xdaa(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xd78(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linear_mc>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
movapd %xmm1,%xmm3
movapd %xmm2,%xmm4
unpcklpd %xmm2,%xmm3
movapd %xmm0,%xmm2
movapd %xmm1,0x30(%rsp)
unpcklpd %xmm1,%xmm2
subpd  %xmm2,%xmm3
addpd  %xmm3,%xmm3
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
movapd %xmm3,%xmm2
movapd %xmm1,0x20(%rsp)
mulsd  %xmm1,%xmm2
xorpd  %xmm5,%xmm5
ucomisd %xmm2,%xmm5
jae    11e8 <linear_mc+0xd8>
subsd  %xmm0,%xmm4
mulsd  0xe8f(%rip),%xmm4
movapd %xmm4,0x10(%rsp)
movapd %xmm3,%xmm0
movsd  %xmm3,0x8(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movaps 0x20(%rsp),%xmm0
call   1030 <fabs@plt>
movsd  0x8(%rsp),%xmm0
cmp    %rax,%rbx
jge    11bc <linear_mc+0xac>
call   1030 <fabs@plt>
mov    %rax,%rbx
movapd 0x10(%rsp),%xmm0
call   1030 <fabs@plt>
movsd  0x8(%rsp),%xmm5
cmp    %rax,%rbx
jl     11e8 <linear_mc+0xd8>
movaps 0x20(%rsp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rbx
movaps 0x10(%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
movapd 0x20(%rsp),%xmm0
jl     11e4 <linear_mc+0xd4>
movapd 0x10(%rsp),%xmm0
movapd %xmm0,%xmm5
movsd  0xe18(%rip),%xmm0
mulsd  %xmm5,%xmm0
movapd 0x30(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%r15)
mulsd  0xdf5(%rip),%xmm5
addsd  %xmm1,%xmm5
movsd  %xmm5,(%r14)
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @linear_mc(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
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double* %3, double** %9
store double* %4, double** %10
%15 = load double, double* %7
%16 = load double, double* %6
%17 = fsub double %15, %16
%18 = fmul double 2.000000e+00, %17
store double %18, double* %11
%19 = load double, double* %8
%20 = load double, double* %7
%21 = fsub double %19, %20
%22 = fmul double 2.000000e+00, %21
store double %22, double* %12
%23 = load double, double* %8
%24 = load double, double* %6
%25 = fsub double %23, %24
%26 = fmul double 5.000000e-01, %25
store double %26, double* %13
%27 = load double, double* %11
%28 = load double, double* %12
%29 = fmul double %27, %28
store double %29, double* %14
%30 = load double, double* %14
%31 = fcmp ole double %30, 0.000000e+00
br i1 %31, label %32, label %33
32: ; preds = %5
store double 0.000000e+00, double* %14
br label %59
33: ; preds = %5
%34 = load double, double* %11
%35 = call i64 @fabs(double %34)
%36 = load double, double* %12
%37 = call i64 @fabs(double %36)
%38 = icmp slt i64 %35, %37
br i1 %38, label %39, label %47
39: ; preds = %33
%40 = load double, double* %11
%41 = call i64 @fabs(double %40)
%42 = load double, double* %13
%43 = call i64 @fabs(double %42)
%44 = icmp slt i64 %41, %43
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = load double, double* %11
store double %46, double* %14
br label %58
47: ; preds = %39, %33
%48 = load double, double* %12
%49 = call i64 @fabs(double %48)
%50 = load double, double* %13
%51 = call i64 @fabs(double %50)
%52 = icmp slt i64 %49, %51
br i1 %52, label %53, label %55
53: ; preds = %47
%54 = load double, double* %12
store double %54, double* %14
br label %57
55: ; preds = %47
%56 = load double, double* %13
store double %56, double* %14
br label %57
57: ; preds = %55, %53
br label %58
58: ; preds = %57, %45
br label %59
59: ; preds = %58, %32
%60 = load double, double* %7
%61 = load double, double* %14
%62 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %61, double %60)
%63 = load double*, double** %9
store double %62, double* %63
%64 = load double, double* %7
%65 = load double, double* %14
%66 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %65, double %64)
%67 = load double*, double** %10
store double %66, double* %67
ret void
}

LLVM IR (-O2):
define void @linear_mc(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = insertelement <2 x double> poison, double %1, i64 0
%7 = insertelement <2 x double> %6, double %2, i64 1
%8 = insertelement <2 x double> poison, double %0, i64 0
%9 = insertelement <2 x double> %8, double %1, i64 1
%10 = fsub <2 x double> %7, %9
%11 = fmul <2 x double> %10, <double 2.000000e+00, double 2.000000e+00>
%12 = fsub double %2, %0
%13 = fmul double %12, 5.000000e-01
%14 = extractelement <2 x double> %11, i64 0
%15 = extractelement <2 x double> %11, i64 1
%16 = fmul double %14, %15
%17 = fcmp ugt double %16, 0.000000e+00
br i1 %17, label %18, label %31
18: ; preds = %5
%19 = tail call i64 @fabs(double %14)
%20 = tail call i64 @fabs(double %15)
%21 = icmp slt i64 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = tail call i64 @fabs(double %14)
%24 = tail call i64 @fabs(double %13)
%25 = icmp slt i64 %23, %24
br i1 %25, label %31, label %26
26: ; preds = %22, %18
%27 = tail call i64 @fabs(double %15)
%28 = tail call i64 @fabs(double %13)
%29 = icmp slt i64 %27, %28
%30 = select i1 %29, double %15, double %13
br label %31
31: ; preds = %26, %22, %5
%32 = phi double [ 0.000000e+00, %5 ], [ %14, %22 ], [ %30, %26 ]
%33 = tail call double @llvm.fmuladd.f64(double %32, double -5.000000e-01, double %1)
store double %33, double* %3
%34 = tail call double @llvm.fmuladd.f64(double %32, double 5.000000e-01, double %1)
store double %34, double* %4
ret void
}