#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__ isnan(double);
int /*<<< orphan*/ rangeIncludingZero(double, double, double *, double *);
void rangeFromMinMaxMeanStd(double minVal, double maxVal, double mean,
                            double std, double *retStart, double *retEnd) {
  double start, end;
  if (isnan(std)) {
    start = mean - 5;
    end = mean + 5;
    if (start < minVal)
      start = minVal;
    if (end > maxVal)
      end = maxVal;
  } else if (std == 0) {
    start = end = mean;
    rangeIncludingZero(start, end, &start, &end);
  } else {
    start = mean - 5 * std;
    end = mean + 5 * std;
    if (start < minVal)
      start = minVal;
    if (end > maxVal)
      end = maxVal;
  }
  *retStart = start;
  *retEnd = end;
}


x86 assembly (clang, -O0):
<rangeFromMinMaxMeanStd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     11bd <rangeFromMinMaxMeanStd+0x9d>
movsd  -0x18(%rbp),%xmm0
movsd  0xe9b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe8a(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    119e <rangeFromMinMaxMeanStd+0x7e>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11b8 <rangeFromMinMaxMeanStd+0x98>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1280 <rangeFromMinMaxMeanStd+0x160>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1200 <rangeFromMinMaxMeanStd+0xe0>
jp     1200 <rangeFromMinMaxMeanStd+0xe0>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
lea    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <rangeIncludingZero@plt>
jmp    127b <rangeFromMinMaxMeanStd+0x15b>
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xdf6(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xdcf(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    125c <rangeFromMinMaxMeanStd+0x13c>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1276 <rangeFromMinMaxMeanStd+0x156>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    127b <rangeFromMinMaxMeanStd+0x15b>
jmp    1280 <rangeFromMinMaxMeanStd+0x160>
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rangeFromMinMaxMeanStd>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movsd  %xmm3,0x30(%rsp)
movapd %xmm3,%xmm0
call   1040 <isnan@plt>
test   %rax,%rax
je     1194 <rangeFromMinMaxMeanStd+0x74>
movsd  0xea5(%rip),%xmm0
movsd  0x18(%rsp),%xmm2
addsd  %xmm2,%xmm0
addsd  0xe9b(%rip),%xmm2
movsd  0x8(%rsp),%xmm3
maxsd  %xmm0,%xmm3
movsd  0x10(%rsp),%xmm1
ucomisd %xmm1,%xmm2
movapd %xmm3,%xmm0
ja     121b <rangeFromMinMaxMeanStd+0xfb>
movapd %xmm2,%xmm1
jmp    121b <rangeFromMinMaxMeanStd+0xfb>
movsd  0x18(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
movsd  0x30(%rsp),%xmm4
ucomisd %xmm0,%xmm4
jne    11e9 <rangeFromMinMaxMeanStd+0xc9>
jp     11e9 <rangeFromMinMaxMeanStd+0xc9>
movapd %xmm3,%xmm0
movsd  %xmm3,0x20(%rsp)
movsd  %xmm3,0x28(%rsp)
lea    0x28(%rsp),%rdi
lea    0x20(%rsp),%rsi
movapd %xmm3,%xmm1
call   1030 <rangeIncludingZero@plt>
movsd  0x28(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
jmp    121b <rangeFromMinMaxMeanStd+0xfb>
movsd  0xe0f(%rip),%xmm0
mulsd  %xmm4,%xmm0
addsd  %xmm3,%xmm0
mulsd  0xe07(%rip),%xmm4
addsd  %xmm3,%xmm4
maxsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ucomisd %xmm2,%xmm4
ja     118b <rangeFromMinMaxMeanStd+0x6b>
movapd %xmm4,%xmm1
movsd  %xmm0,(%rbx)
movsd  %xmm1,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @rangeFromMinMaxMeanStd(double %0, double %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = alloca double
%8 = alloca double
%9 = bitcast double* %7 to i8*
%10 = bitcast double* %8 to i8*
%11 = tail call i64 @isnan(double %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %6
%14 = fadd double %2, -5.000000e+00
%15 = fadd double %2, 5.000000e+00
%16 = fcmp olt double %14, %0
%17 = select i1 %16, double %0, double %14
%18 = fcmp ogt double %15, %1
br i1 %18, label %19, label %33
19: ; preds = %13
br label %33
20: ; preds = %6
%21 = fcmp oeq double %3, 0.000000e+00
br i1 %21, label %22, label %26
22: ; preds = %20
store double %2, double* %8
store double %2, double* %7
%23 = call i32 @rangeIncludingZero(double %2, double %2, double* %7, double* %8)
%24 = load double, double* %7
%25 = load double, double* %8
br label %33
26: ; preds = %20
%27 = tail call double @llvm.fmuladd.f64(double %3, double -5.000000e+00, double %2)
%28 = tail call double @llvm.fmuladd.f64(double %3, double 5.000000e+00, double %2)
%29 = fcmp olt double %27, %0
%30 = select i1 %29, double %0, double %27
%31 = fcmp ogt double %28, %1
br i1 %31, label %32, label %33
32: ; preds = %26
br label %33
33: ; preds = %22, %32, %26, %13, %19
%34 = phi double [ %25, %22 ], [ %1, %32 ], [ %28, %26 ], [ %15, %13 ], [ %1, %19 ]
%35 = phi double [ %24, %22 ], [ %30, %32 ], [ %30, %26 ], [ %17, %13 ], [ %17, %19 ]
store double %35, double* %4
store double %34, double* %5
ret void
}