#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 */
int /*<<< orphan*/ _Normal(double, double, double);
double _f(int /*<<< orphan*/);
double cheb6(double a, double b) {
  static double g[3] = {0.2666354015167047, 0.4225186537611115,
                        0.8662468181078206};
  double w;
  int mflag;
  if (a == b)
    return 0.;
  mflag = 0;
  if (a > b) {
    mflag = 1;
    w = a;
    a = b;
    b = w;
  }
  w = _f(_Normal(a, b, g[0]));
  w += _f(_Normal(a, b, -g[0]));
  w += _f(_Normal(a, b, g[1]));
  w += _f(_Normal(a, b, -g[1]));
  w += _f(_Normal(a, b, g[2]));
  w += _f(_Normal(a, b, -g[2]));
  w *= ((b - a) / 6.);
  if (mflag)
    return -w;
  return w;
}


x86 assembly (clang, -O0):
<cheb6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1155 <cheb6+0x35>
jp     1155 <cheb6+0x35>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    131b <cheb6+0x1fb>
movl   $0x0,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1191 <cheb6+0x71>
movl   $0x1,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0x2e9d(%rip),%xmm2
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0x2e7a(%rip),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0x2e43(%rip),%xmm2
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0x2e1b(%rip),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0x2de4(%rip),%xmm2
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0x2dbc(%rip),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xd2d(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1311 <cheb6+0x1f1>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    131b <cheb6+0x1fb>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cheb6>:
sub    $0x58,%rsp
xorpd  %xmm2,%xmm2
ucomisd %xmm1,%xmm0
jne    1134 <cheb6+0x14>
jnp    1281 <cheb6+0x161>
movapd %xmm0,%xmm3
movapd %xmm1,%xmm0
minsd  %xmm3,%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm3,%xmm4
maxsd  %xmm1,%xmm4
movapd %xmm4,0x10(%rsp)
movsd  %xmm1,0x50(%rsp)
movsd  0xe9e(%rip),%xmm2
movapd %xmm4,%xmm1
movsd  %xmm3,0x48(%rsp)
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0xe82(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0xe65(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0xe48(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0xe2b(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0xe0e(%rip),%xmm2
movsd  0x8(%rsp),%xmm0
movaps 0x10(%rsp),%xmm1
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
movapd 0x10(%rsp),%xmm2
movsd  0x48(%rsp),%xmm1
ucomisd 0x50(%rsp),%xmm1
movsd  0x38(%rsp),%xmm1
addsd  0x40(%rsp),%xmm1
addsd  0x30(%rsp),%xmm1
addsd  0x28(%rsp),%xmm1
addsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
subsd  0x8(%rsp),%xmm2
divsd  0xdbd(%rip),%xmm2
mulsd  %xmm1,%xmm2
jbe    1281 <cheb6+0x161>
xorpd  0xdbf(%rip),%xmm2
movapd %xmm2,%xmm0
add    $0x58,%rsp
ret

LLVM IR (-O0):
@cheb6.g = internal global [3 x double] [double 0x3FD1108DEE5E15B7, double 0x3FDB0A8BADF6A6A5, double 0x3FEBB84B3F413055]
define double @cheb6(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = load double, double* %5
%10 = fcmp oeq double %8, %9
br i1 %10, label %11, label %12
11: ; preds = %2
store double 0.000000e+00, double* %3
br label %77
12: ; preds = %2
store i32 0, i32* %7
%13 = load double, double* %4
%14 = load double, double* %5
%15 = fcmp ogt double %13, %14
br i1 %15, label %16, label %20
16: ; preds = %12
store i32 1, i32* %7
%17 = load double, double* %4
store double %17, double* %6
%18 = load double, double* %5
store double %18, double* %4
%19 = load double, double* %6
store double %19, double* %5
br label %20
20: ; preds = %16, %12
%21 = load double, double* %4
%22 = load double, double* %5
%23 = load double, double* getelementptr inbounds ([3 x double], [3 x double]* @cheb6.g, i64 0, i64 0)
%24 = call i32 @_Normal(double %21, double %22, double %23)
%25 = call double @_f(i32 %24)
store double %25, double* %6
%26 = load double, double* %4
%27 = load double, double* %5
%28 = load double, double* getelementptr inbounds ([3 x double], [3 x double]* @cheb6.g, i64 0, i64 0)
%29 = fneg double %28
%30 = call i32 @_Normal(double %26, double %27, double %29)
%31 = call double @_f(i32 %30)
%32 = load double, double* %6
%33 = fadd double %32, %31
store double %33, double* %6
%34 = load double, double* %4
%35 = load double, double* %5
%36 = load double, double* getelementptr inbounds ([3 x double], [3 x double]* @cheb6.g, i64 0, i64 1)
%37 = call i32 @_Normal(double %34, double %35, double %36)
%38 = call double @_f(i32 %37)
%39 = load double, double* %6
%40 = fadd double %39, %38
store double %40, double* %6
%41 = load double, double* %4
%42 = load double, double* %5
%43 = load double, double* getelementptr inbounds ([3 x double], [3 x double]* @cheb6.g, i64 0, i64 1)
%44 = fneg double %43
%45 = call i32 @_Normal(double %41, double %42, double %44)
%46 = call double @_f(i32 %45)
%47 = load double, double* %6
%48 = fadd double %47, %46
store double %48, double* %6
%49 = load double, double* %4
%50 = load double, double* %5
%51 = load double, double* getelementptr inbounds ([3 x double], [3 x double]* @cheb6.g, i64 0, i64 2)
%52 = call i32 @_Normal(double %49, double %50, double %51)
%53 = call double @_f(i32 %52)
%54 = load double, double* %6
%55 = fadd double %54, %53
store double %55, double* %6
%56 = load double, double* %4
%57 = load double, double* %5
%58 = load double, double* getelementptr inbounds ([3 x double], [3 x double]* @cheb6.g, i64 0, i64 2)
%59 = fneg double %58
%60 = call i32 @_Normal(double %56, double %57, double %59)
%61 = call double @_f(i32 %60)
%62 = load double, double* %6
%63 = fadd double %62, %61
store double %63, double* %6
%64 = load double, double* %5
%65 = load double, double* %4
%66 = fsub double %64, %65
%67 = fdiv double %66, 6.000000e+00
%68 = load double, double* %6
%69 = fmul double %68, %67
store double %69, double* %6
%70 = load i32, i32* %7
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %20
%73 = load double, double* %6
%74 = fneg double %73
store double %74, double* %3
br label %77
75: ; preds = %20
%76 = load double, double* %6
store double %76, double* %3
br label %77
77: ; preds = %75, %72, %11
%78 = load double, double* %3
ret double %78
}

LLVM IR (-O2):
define double @cheb6(double %0, double %1) {
%3 = fcmp oeq double %0, %1
br i1 %3, label %30, label %4
4: ; preds = %2
%5 = fcmp ogt double %0, %1
%6 = select i1 %5, double %1, double %0
%7 = select i1 %5, double %0, double %1
%8 = tail call i32 @_Normal(double %6, double %7, double 0x3FD1108DEE5E15B7)
%9 = tail call double @_f(i32 %8)
%10 = tail call i32 @_Normal(double %6, double %7, double 0xBFD1108DEE5E15B7)
%11 = tail call double @_f(i32 %10)
%12 = fadd double %9, %11
%13 = tail call i32 @_Normal(double %6, double %7, double 0x3FDB0A8BADF6A6A5)
%14 = tail call double @_f(i32 %13)
%15 = fadd double %12, %14
%16 = tail call i32 @_Normal(double %6, double %7, double 0xBFDB0A8BADF6A6A5)
%17 = tail call double @_f(i32 %16)
%18 = fadd double %15, %17
%19 = tail call i32 @_Normal(double %6, double %7, double 0x3FEBB84B3F413055)
%20 = tail call double @_f(i32 %19)
%21 = fadd double %18, %20
%22 = tail call i32 @_Normal(double %6, double %7, double 0xBFEBB84B3F413055)
%23 = tail call double @_f(i32 %22)
%24 = fadd double %21, %23
%25 = fsub double %7, %6
%26 = fdiv double %25, 6.000000e+00
%27 = fmul double %26, %24
br i1 %5, label %28, label %30
28: ; preds = %4
%29 = fneg double %27
br label %30
30: ; preds = %4, %2, %28
%31 = phi double [ %29, %28 ], [ 0.000000e+00, %2 ], [ %27, %4 ]
ret double %31
}