#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 cheb4(double a, double b) {
  static double g[2] = {0.7946544722917661, 0.1875924740850799};
  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 *= ((b - a) / 4.);
  if (mflag)
    return -w;
  return w;
}


x86 assembly (clang, -O0):
<cheb4>:
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 <cheb4+0x35>
jp     1155 <cheb4+0x35>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b4 <cheb4+0x194>
movl   $0x0,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1191 <cheb4+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  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xd94(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     12aa <cheb4+0x18a>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12b4 <cheb4+0x194>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cheb4>:
sub    $0x48,%rsp
xorpd  %xmm2,%xmm2
ucomisd %xmm1,%xmm0
jne    1134 <cheb4+0x14>
jnp    122b <cheb4+0x10b>
movapd %xmm1,%xmm3
minsd  %xmm0,%xmm3
movsd  %xmm3,0x8(%rsp)
movapd %xmm0,%xmm4
maxsd  %xmm1,%xmm4
movapd %xmm4,0x10(%rsp)
movsd  %xmm1,0x40(%rsp)
movsd  0xea2(%rip),%xmm2
movsd  %xmm0,0x38(%rsp)
movapd %xmm3,%xmm0
movapd %xmm4,%xmm1
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
movsd  %xmm0,0x30(%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,0x28(%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,0x20(%rsp)
movsd  0xe48(%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  0x38(%rsp),%xmm1
ucomisd 0x40(%rsp),%xmm1
movsd  0x28(%rsp),%xmm1
addsd  0x30(%rsp),%xmm1
addsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
subsd  0x8(%rsp),%xmm2
mulsd  0xe03(%rip),%xmm2
mulsd  %xmm1,%xmm2
jbe    122b <cheb4+0x10b>
xorpd  0xe05(%rip),%xmm2
movapd %xmm2,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
@cheb4.g = internal global [2 x double] [double 0x3FE96DCF37439FF0, double 0x3FC80307BA95E81A]
define double @cheb4(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 %62
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 ([2 x double], [2 x double]* @cheb4.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 ([2 x double], [2 x double]* @cheb4.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 ([2 x double], [2 x double]* @cheb4.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 ([2 x double], [2 x double]* @cheb4.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* %5
%50 = load double, double* %4
%51 = fsub double %49, %50
%52 = fdiv double %51, 4.000000e+00
%53 = load double, double* %6
%54 = fmul double %53, %52
store double %54, double* %6
%55 = load i32, i32* %7
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %20
%58 = load double, double* %6
%59 = fneg double %58
store double %59, double* %3
br label %62
60: ; preds = %20
%61 = load double, double* %6
store double %61, double* %3
br label %62
62: ; preds = %60, %57, %11
%63 = load double, double* %3
ret double %63
}

LLVM IR (-O2):
define double @cheb4(double %0, double %1) {
%3 = fcmp oeq double %0, %1
br i1 %3, label %24, 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 0x3FE96DCF37439FF0)
%9 = tail call double @_f(i32 %8)
%10 = tail call i32 @_Normal(double %6, double %7, double 0xBFE96DCF37439FF0)
%11 = tail call double @_f(i32 %10)
%12 = fadd double %9, %11
%13 = tail call i32 @_Normal(double %6, double %7, double 0x3FC80307BA95E81A)
%14 = tail call double @_f(i32 %13)
%15 = fadd double %12, %14
%16 = tail call i32 @_Normal(double %6, double %7, double 0xBFC80307BA95E81A)
%17 = tail call double @_f(i32 %16)
%18 = fadd double %15, %17
%19 = fsub double %7, %6
%20 = fmul double %19, 2.500000e-01
%21 = fmul double %20, %18
br i1 %5, label %22, label %24
22: ; preds = %4
%23 = fneg double %21
br label %24
24: ; preds = %4, %2, %22
%25 = phi double [ %23, %22 ], [ 0.000000e+00, %2 ], [ %21, %4 ]
ret double %25
}