#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);
double minmod(double a, double b, double c) {
  double m = a;
  if (a * b < 0.0)
    m = 0.0;
  if (fabs(b) < fabs(m))
    m = b;
  if (b * c < 0.0)
    m = 0.0;
  if (fabs(c) < fabs(m))
    m = c;
  return (m);
}


x86 assembly (clang, -O0):
<minmod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1150 <minmod+0x40>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jge    1182 <minmod+0x72>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11a1 <minmod+0x91>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jge    11d3 <minmod+0xc3>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minmod>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm2,0x8(%rsp)
movapd %xmm1,%xmm2
movapd %xmm1,0x10(%rsp)
movapd %xmm0,%xmm3
mulsd  %xmm1,%xmm3
xorpd  %xmm1,%xmm1
cmpltsd %xmm1,%xmm3
andnpd %xmm0,%xmm3
movapd %xmm3,0x20(%rsp)
movapd %xmm2,%xmm0
call   1030 <fabs@plt>
mov    %rax,%rbx
movaps 0x20(%rsp),%xmm0
call   1030 <fabs@plt>
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm2
cmp    %rax,%rbx
jl     116b <minmod+0x5b>
movapd 0x20(%rsp),%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm1
cmpltsd 0xe82(%rip),%xmm1
andnpd %xmm2,%xmm1
movapd %xmm1,0x10(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movaps 0x10(%rsp),%xmm0
call   1030 <fabs@plt>
movsd  0x8(%rsp),%xmm0
cmp    %rax,%rbx
jl     11aa <minmod+0x9a>
movaps 0x10(%rsp),%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @minmod(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%8 = load double, double* %4
store double %8, double* %7
%9 = load double, double* %4
%10 = load double, double* %5
%11 = fmul double %9, %10
%12 = fcmp olt double %11, 0.000000e+00
br i1 %12, label %13, label %14
13: ; preds = %3
store double 0.000000e+00, double* %7
br label %14
14: ; preds = %13, %3
%15 = load double, double* %5
%16 = call i64 @fabs(double %15)
%17 = load double, double* %7
%18 = call i64 @fabs(double %17)
%19 = icmp slt i64 %16, %18
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = load double, double* %5
store double %21, double* %7
br label %22
22: ; preds = %20, %14
%23 = load double, double* %5
%24 = load double, double* %6
%25 = fmul double %23, %24
%26 = fcmp olt double %25, 0.000000e+00
br i1 %26, label %27, label %28
27: ; preds = %22
store double 0.000000e+00, double* %7
br label %28
28: ; preds = %27, %22
%29 = load double, double* %6
%30 = call i64 @fabs(double %29)
%31 = load double, double* %7
%32 = call i64 @fabs(double %31)
%33 = icmp slt i64 %30, %32
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = load double, double* %6
store double %35, double* %7
br label %36
36: ; preds = %34, %28
%37 = load double, double* %7
ret double %37
}

LLVM IR (-O2):
define double @minmod(double %0, double %1, double %2) {
%4 = fmul double %0, %1
%5 = fcmp olt double %4, 0.000000e+00
%6 = select i1 %5, double 0.000000e+00, double %0
%7 = tail call i64 @fabs(double %1)
%8 = tail call i64 @fabs(double %6)
%9 = icmp slt i64 %7, %8
%10 = select i1 %9, double %1, double %6
%11 = fmul double %1, %2
%12 = fcmp olt double %11, 0.000000e+00
%13 = select i1 %12, double 0.000000e+00, double %10
%14 = tail call i64 @fabs(double %2)
%15 = tail call i64 @fabs(double %13)
%16 = icmp slt i64 %14, %15
%17 = select i1 %16, double %2, double %13
ret double %17
}