#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 dgl3(double a, double b) {
  static double g = 0.774596669241483;
  static double w1 = 0.555555555555556;
  static double w0 = 0.88888888888889;
  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, 0.)) * w0;
  w += (_f(_Normal(a, b, g)) + _f(_Normal(a, b, -g))) * w1;
  w *= ((b - a) / 2.);
  if (mflag)
    return -w;
  return w;
}


x86 assembly (clang, -O0):
<dgl3>:
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 <dgl3+0x35>
jp     1155 <dgl3+0x35>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128f <dgl3+0x16f>
movl   $0x0,-0x24(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1191 <dgl3+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
xorps  %xmm2,%xmm2
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
mulsd  0x2e8e(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0x2e67(%rip),%xmm2
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0x2e44(%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>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0x2e15(%rip),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xdb9(%rip),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1285 <dgl3+0x165>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    128f <dgl3+0x16f>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dgl3>:
sub    $0x48,%rsp
xorpd  %xmm2,%xmm2
ucomisd %xmm1,%xmm0
jne    1134 <dgl3+0x14>
jnp    120c <dgl3+0xec>
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,0x40(%rsp)
xorpd  %xmm2,%xmm2
movapd %xmm4,%xmm1
movsd  %xmm3,0x38(%rsp)
call   1030 <_Normal@plt>
mov    %eax,%edi
call   1040 <_f@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0xe7e(%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  0xe61(%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  0x30(%rsp),%xmm1
mulsd  0xe32(%rip),%xmm1
addsd  0x28(%rsp),%xmm0
mulsd  0xe2c(%rip),%xmm0
addsd  %xmm1,%xmm0
subsd  0x8(%rsp),%xmm2
mulsd  0xe22(%rip),%xmm2
mulsd  %xmm0,%xmm2
jbe    120c <dgl3+0xec>
xorpd  0xe24(%rip),%xmm2
movapd %xmm2,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
@dgl3.g = internal global double 0x3FE8C97EF43F7244
@dgl3.w1 = internal global double 0x3FE1C71C71C71C76
@dgl3.w0 = internal global double 0x3FEC71C71C71C726
define double @dgl3(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 %55
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 = call i32 @_Normal(double %21, double %22, double 0.000000e+00)
%24 = call double @_f(i32 %23)
%25 = load double, double* @dgl3.w0
%26 = fmul double %24, %25
store double %26, double* %6
%27 = load double, double* %4
%28 = load double, double* %5
%29 = load double, double* @dgl3.g
%30 = call i32 @_Normal(double %27, double %28, double %29)
%31 = call double @_f(i32 %30)
%32 = load double, double* %4
%33 = load double, double* %5
%34 = load double, double* @dgl3.g
%35 = fneg double %34
%36 = call i32 @_Normal(double %32, double %33, double %35)
%37 = call double @_f(i32 %36)
%38 = fadd double %31, %37
%39 = load double, double* @dgl3.w1
%40 = load double, double* %6
%41 = call double @llvm.fmuladd.f64(double %38, double %39, double %40)
store double %41, double* %6
%42 = load double, double* %5
%43 = load double, double* %4
%44 = fsub double %42, %43
%45 = fdiv double %44, 2.000000e+00
%46 = load double, double* %6
%47 = fmul double %46, %45
store double %47, double* %6
%48 = load i32, i32* %7
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %20
%51 = load double, double* %6
%52 = fneg double %51
store double %52, double* %3
br label %55
53: ; preds = %20
%54 = load double, double* %6
store double %54, double* %3
br label %55
55: ; preds = %53, %50, %11
%56 = load double, double* %3
ret double %56
}

LLVM IR (-O2):
define double @dgl3(double %0, double %1) {
%3 = fcmp oeq double %0, %1
br i1 %3, label %22, 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 0.000000e+00)
%9 = tail call double @_f(i32 %8)
%10 = fmul double %9, 0x3FEC71C71C71C726
%11 = tail call i32 @_Normal(double %6, double %7, double 0x3FE8C97EF43F7244)
%12 = tail call double @_f(i32 %11)
%13 = tail call i32 @_Normal(double %6, double %7, double 0xBFE8C97EF43F7244)
%14 = tail call double @_f(i32 %13)
%15 = fadd double %12, %14
%16 = tail call double @llvm.fmuladd.f64(double %15, double 0x3FE1C71C71C71C76, double %10)
%17 = fsub double %7, %6
%18 = fmul double %17, 5.000000e-01
%19 = fmul double %18, %16
br i1 %5, label %20, label %22
20: ; preds = %4
%21 = fneg double %19
br label %22
22: ; preds = %4, %2, %20
%23 = phi double [ %21, %20 ], [ 0.000000e+00, %2 ], [ %19, %4 ]
ret double %23
}