#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*/ f_coef(double *, int, int, double, double);
double fabs(int);
double overlap_1d(int l1, int l2, double PAx, double PBx, double eta) {
  int i;
  double f[2 * 8 + 2];
  double sum = 0.0;
  double p;
  f_coef(f, l1, l2, PAx, PBx);
  eta = eta / 2.0;
  p = 1.0;
  for (i = 0; i < (l1 + l2) / 2 + 1; i++) {
    p *= fabs(i + i - 1);
    sum += f[i + i] * p;
    p *= eta;
  }
  return sum;
}


x86 assembly (clang, -O0):
<overlap_1d>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
lea    -0xc0(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <f_coef@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xe94(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe7b(%rip),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0xd4(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xd4(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1230 <overlap_1d+0x110>
mov    -0x24(%rbp),%edi
add    -0x24(%rbp),%edi
sub    $0x1,%edi
call   1030 <fabs@plt>
mulsd  -0xd0(%rbp),%xmm0
ff
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0x24(%rbp),%eax
add    -0x24(%rbp),%eax
cltq
movsd  -0xc0(%rbp,%rax,8),%xmm0
ff ff
movsd  -0xd0(%rbp),%xmm2
ff
movsd  -0xc8(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
mulsd  -0xd0(%rbp),%xmm0
ff
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1194 <overlap_1d+0x74>
movsd  -0xc8(%rbp),%xmm0
ff
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<overlap_1d>:
push   %rbp
push   %r14
push   %rbx
sub    $0xb0,%rsp
movsd  %xmm2,0x18(%rsp)
mov    %esi,%ebx
mov    %edi,%ebp
lea    0x20(%rsp),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <f_coef@plt>
add    %ebp,%ebx
xorpd  %xmm0,%xmm0
cmp    $0xffffffff,%ebx
jl     124e <overlap_1d+0x12e>
mov    %ebx,%r14d
shr    $0x1f,%r14d
add    %ebx,%r14d
sar    %r14d
add    $0x1,%r14d
add    $0x1,%ebx
cmp    $0x3,%ebx
jae    117e <overlap_1d+0x5e>
xorpd  %xmm0,%xmm0
movsd  0xe91(%rip),%xmm2
xor    %ebx,%ebx
jmp    121a <overlap_1d+0xfa>
movsd  0x18(%rsp),%xmm1
mulsd  0xe74(%rip),%xmm1
mov    %r14d,%ebp
and    $0xfffffffe,%ebp
xorpd  %xmm0,%xmm0
movsd  0xe6a(%rip),%xmm2
xor    %ebx,%ebx
movsd  %xmm1,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
lea    -0x1(%rbx),%edi
call   1030 <fabs@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  0x20(%rsp,%rbx,8),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0x1(%rbx),%edi
call   1030 <fabs@plt>
movsd  0x18(%rsp),%xmm2
mulsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm2
mulsd  0x30(%rsp,%rbx,8),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x4,%rbx
add    $0xfffffffffffffffe,%rbp
jne    11b0 <overlap_1d+0x90>
test   $0x1,%r14b
je     124e <overlap_1d+0x12e>
lea    -0x1(%rbx),%edi
movsd  %xmm0,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
call   1030 <fabs@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  0x20(%rsp,%rbx,8),%xmm1
addsd  %xmm1,%xmm0
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @overlap_1d(i32 %0, i32 %1, double %2, double %3, double %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca [18 x double]
%13 = alloca double
%14 = alloca double
store i32 %0, i32* %6
store i32 %1, i32* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
store double 0.000000e+00, double* %13
%15 = getelementptr inbounds [18 x double], [18 x double]* %12, i64 0, i64 0
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = load double, double* %8
%19 = load double, double* %9
%20 = call i32 @f_coef(double* %15, i32 %16, i32 %17, double %18, double %19)
%21 = load double, double* %10
%22 = fdiv double %21, 2.000000e+00
store double %22, double* %10
store double 1.000000e+00, double* %14
store i32 0, i32* %11
br label %23
23: ; preds = %51, %5
%24 = load i32, i32* %11
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = add nsw i32 %25, %26
%28 = sdiv i32 %27, 2
%29 = add nsw i32 %28, 1
%30 = icmp slt i32 %24, %29
br i1 %30, label %31, label %54
31: ; preds = %23
%32 = load i32, i32* %11
%33 = load i32, i32* %11
%34 = add nsw i32 %32, %33
%35 = sub nsw i32 %34, 1
%36 = call double @fabs(i32 %35)
%37 = load double, double* %14
%38 = fmul double %37, %36
store double %38, double* %14
%39 = load i32, i32* %11
%40 = load i32, i32* %11
%41 = add nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [18 x double], [18 x double]* %12, i64 0, i64 %42
%44 = load double, double* %43
%45 = load double, double* %14
%46 = load double, double* %13
%47 = call double @llvm.fmuladd.f64(double %44, double %45, double %46)
store double %47, double* %13
%48 = load double, double* %10
%49 = load double, double* %14
%50 = fmul double %49, %48
store double %50, double* %14
br label %51
51: ; preds = %31
%52 = load i32, i32* %11
%53 = add nsw i32 %52, 1
store i32 %53, i32* %11
br label %23
54: ; preds = %23
%55 = load double, double* %13
ret double %55
}

LLVM IR (-O2):
define double @overlap_1d(i32 %0, i32 %1, double %2, double %3, double %4) {
%6 = alloca [18 x double]
%7 = bitcast [18 x double]* %6 to i8*
%8 = getelementptr inbounds [18 x double], [18 x double]* %6, i64 0, i64 0
%9 = call i32 @f_coef(double* %8, i32 %0, i32 %1, double %2, double %3)
%10 = fmul double %4, 5.000000e-01
%11 = add nsw i32 %1, %0
%12 = icmp slt i32 %11, -1
br i1 %12, label %65, label %13
13: ; preds = %5
%14 = sdiv i32 %11, 2
%15 = add nuw nsw i32 %14, 1
%16 = zext i32 %15 to i64
%17 = and i64 %16, 1
%18 = add i32 %11, 1
%19 = icmp ult i32 %18, 3
br i1 %19, label %51, label %20
20: ; preds = %13
%21 = and i64 %16, 4294967294
br label %22
22: ; preds = %22, %20
%23 = phi i64 [ 0, %20 ], [ %46, %22 ]
%24 = phi double [ 1.000000e+00, %20 ], [ %45, %22 ]
%25 = phi double [ 0.000000e+00, %20 ], [ %44, %22 ]
%26 = phi i64 [ 0, %20 ], [ %47, %22 ]
%27 = shl nuw nsw i64 %23, 1
%28 = trunc i64 %27 to i32
%29 = add i32 %28, -1
%30 = call double @fabs(i32 %29)
%31 = fmul double %24, %30
%32 = getelementptr inbounds [18 x double], [18 x double]* %6, i64 0, i64 %27
%33 = load double, double* %32
%34 = call double @llvm.fmuladd.f64(double %33, double %31, double %25)
%35 = fmul double %10, %31
%36 = shl nuw i64 %23, 1
%37 = or i64 %36, 2
%38 = trunc i64 %37 to i32
%39 = add nsw i32 %38, -1
%40 = call double @fabs(i32 %39)
%41 = fmul double %35, %40
%42 = getelementptr inbounds [18 x double], [18 x double]* %6, i64 0, i64 %37
%43 = load double, double* %42
%44 = call double @llvm.fmuladd.f64(double %43, double %41, double %34)
%45 = fmul double %10, %41
%46 = add nuw nsw i64 %23, 2
%47 = add i64 %26, 2
%48 = icmp eq i64 %47, %21
br i1 %48, label %49, label %22
49: ; preds = %22
%50 = shl nuw i64 %46, 1
br label %51
51: ; preds = %49, %13
%52 = phi double [ undef, %13 ], [ %44, %49 ]
%53 = phi i64 [ 0, %13 ], [ %50, %49 ]
%54 = phi double [ 1.000000e+00, %13 ], [ %45, %49 ]
%55 = phi double [ 0.000000e+00, %13 ], [ %44, %49 ]
%56 = icmp eq i64 %17, 0
br i1 %56, label %65, label %57
57: ; preds = %51
%58 = trunc i64 %53 to i32
%59 = add i32 %58, -1
%60 = call double @fabs(i32 %59)
%61 = fmul double %54, %60
%62 = getelementptr inbounds [18 x double], [18 x double]* %6, i64 0, i64 %53
%63 = load double, double* %62
%64 = call double @llvm.fmuladd.f64(double %63, double %61, double %55)
br label %65
65: ; preds = %57, %51, %5
%66 = phi double [ 0.000000e+00, %5 ], [ %52, %51 ], [ %64, %57 ]
ret double %66
}