#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;
  if (a * b < 0)
    m = 0;
  else if (fabs(a) < fabs(b))
    m = a;
  else
    m = b;
  if (m * c < 0)
    m = 0;
  else 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),%xmm1
mulsd  -0x10(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    114b <minmod+0x3b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1191 <minmod+0x81>
movsd  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jge    1182 <minmod+0x72>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    118c <minmod+0x7c>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1191 <minmod+0x81>
movsd  -0x20(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11b5 <minmod+0xa5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11ec <minmod+0xdc>
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    11e7 <minmod+0xd7>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11ec <minmod+0xdc>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minmod>:
push   %rbx
sub    $0x20,%rsp
movapd %xmm0,%xmm4
movapd %xmm0,%xmm3
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm1,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm3,%xmm0
xorpd  %xmm3,%xmm3
movsd  %xmm2,0x10(%rsp)
ja     1173 <minmod+0x63>
movapd %xmm4,%xmm0
movsd  %xmm4,0x18(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
movsd  0x18(%rsp),%xmm3
cmp    %rax,%rbx
jl     1169 <minmod+0x59>
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
xorpd  %xmm0,%xmm0
movapd %xmm3,%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
ja     11af <minmod+0x9f>
movapd %xmm2,%xmm0
movsd  %xmm3,0x8(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
movsd  0x10(%rsp),%xmm0
cmp    %rax,%rbx
jl     11af <minmod+0x9f>
movsd  0x8(%rsp),%xmm0
add    $0x20,%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
%9 = load double, double* %5
%10 = fmul double %8, %9
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %3
store double 0.000000e+00, double* %7
br label %24
13: ; preds = %3
%14 = load double, double* %4
%15 = call i64 @fabs(double %14)
%16 = load double, double* %5
%17 = call i64 @fabs(double %16)
%18 = icmp slt i64 %15, %17
br i1 %18, label %19, label %21
19: ; preds = %13
%20 = load double, double* %4
store double %20, double* %7
br label %23
21: ; preds = %13
%22 = load double, double* %5
store double %22, double* %7
br label %23
23: ; preds = %21, %19
br label %24
24: ; preds = %23, %12
%25 = load double, double* %7
%26 = load double, double* %6
%27 = fmul double %25, %26
%28 = fcmp olt double %27, 0.000000e+00
br i1 %28, label %29, label %30
29: ; preds = %24
store double 0.000000e+00, double* %7
br label %39
30: ; preds = %24
%31 = load double, double* %6
%32 = call i64 @fabs(double %31)
%33 = load double, double* %7
%34 = call i64 @fabs(double %33)
%35 = icmp slt i64 %32, %34
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = load double, double* %6
store double %37, double* %7
br label %38
38: ; preds = %36, %30
br label %39
39: ; preds = %38, %29
%40 = load double, double* %7
ret double %40
}

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
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i64 @fabs(double %0)
%8 = tail call i64 @fabs(double %1)
%9 = icmp slt i64 %7, %8
%10 = select i1 %9, double %0, double %1
br label %11
11: ; preds = %6, %3
%12 = phi double [ 0.000000e+00, %3 ], [ %10, %6 ]
%13 = fmul double %12, %2
%14 = fcmp olt double %13, 0.000000e+00
br i1 %14, label %20, label %15
15: ; preds = %11
%16 = tail call i64 @fabs(double %2)
%17 = tail call i64 @fabs(double %12)
%18 = icmp slt i64 %16, %17
%19 = select i1 %18, double %2, double %12
br label %20
20: ; preds = %15, %11
%21 = phi double [ 0.000000e+00, %11 ], [ %19, %15 ]
ret double %21
}