#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 */
double exp(double);
int sqrt(double);
void band_bcv_bin(int *n, int *nb, double *d, int *x, double *h, double *u) {
  int i, nn = *n, nbin = *nb;
  double delta, hh = (*h), sum, term;
  sum = 0.0;
  for (i = 0; i < nbin; i++) {
    delta = i * (*d) / hh;
    delta *= delta;
    if (delta >= 1000)
      break;
    term = exp(-delta / 4) * (delta * delta - 12 * delta + 12);
    sum += term * x[i];
  }
  *u = 1 / (2 * nn * hh * sqrt(3.14159265)) +
       sum / (64 * nn * nn * hh * sqrt(3.14159265));
}


x86 assembly (clang, -O0):
<band_bcv_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1269 <band_bcv_bin+0x149>
cvtsi2sdl -0x34(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xe50(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11bf <band_bcv_bin+0x9f>
jmp    1269 <band_bcv_bin+0x149>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe2d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  -0x48(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm3
movsd  0xe0a(%rip),%xmm2
mulsd  -0x48(%rbp),%xmm2
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xdde(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1171 <band_bcv_bin+0x51>
mov    -0x38(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xd93(%rip),%xmm0
call   1040 <sqrt@plt>
movsd  -0x80(%rbp),%xmm1
cvtsi2sd %eax,%xmm0
mulsd  %xmm0,%xmm1
movsd  0xd81(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x38(%rbp),%eax
shl    $0x6,%eax
imul   -0x38(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xd46(%rip),%xmm0
call   1040 <sqrt@plt>
movsd  -0x78(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<band_bcv_bin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r14
mov    (%rdi),%r12d
mov    (%rsi),%ebx
movsd  (%r8),%xmm0
movsd  %xmm0,(%rsp)
test   %ebx,%ebx
jle    11e1 <band_bcv_bin+0xc1>
mov    %rcx,%r15
mov    %rdx,%r13
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x0(%r13),%xmm0
divsd  (%rsp),%xmm0
mulsd  %xmm0,%xmm0
ucomisd 0xe82(%rip),%xmm0
jae    11eb <band_bcv_bin+0xcb>
movsd  %xmm0,0x8(%rsp)
mulsd  0xe7a(%rip),%xmm0
call   1030 <exp@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm1
mulsd  0xe6b(%rip),%xmm1
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
addsd  0xe63(%rip),%xmm2
mulsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sdl (%r15,%rbp,4),%xmm0
mulsd  %xmm2,%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1160 <band_bcv_bin+0x40>
jmp    11eb <band_bcv_bin+0xcb>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    (%r12,%r12,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe17(%rip),%xmm0
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  0xe05(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
imul   %r12d,%r12d
shl    $0x6,%r12d
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdd1(%rip),%xmm0
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @band_bcv_bin(i32* %0, i32* %1, double* %2, i32* %3, double* %4, double* %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca double*
%10 = alloca i32*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
store i32* %0, i32** %7
store i32* %1, i32** %8
store double* %2, double** %9
store i32* %3, i32** %10
store double* %4, double** %11
store double* %5, double** %12
%20 = load i32*, i32** %7
%21 = load i32, i32* %20
store i32 %21, i32* %14
%22 = load i32*, i32** %8
%23 = load i32, i32* %22
store i32 %23, i32* %15
%24 = load double*, double** %11
%25 = load double, double* %24
store double %25, double* %17
store double 0.000000e+00, double* %18
store i32 0, i32* %13
br label %26
26: ; preds = %66, %6
%27 = load i32, i32* %13
%28 = load i32, i32* %15
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %69
30: ; preds = %26
%31 = load i32, i32* %13
%32 = sitofp i32 %31 to double
%33 = load double*, double** %9
%34 = load double, double* %33
%35 = fmul double %32, %34
%36 = load double, double* %17
%37 = fdiv double %35, %36
store double %37, double* %16
%38 = load double, double* %16
%39 = load double, double* %16
%40 = fmul double %39, %38
store double %40, double* %16
%41 = load double, double* %16
%42 = fcmp oge double %41, 1.000000e+03
br i1 %42, label %43, label %44
43: ; preds = %30
br label %69
44: ; preds = %30
%45 = load double, double* %16
%46 = fneg double %45
%47 = fdiv double %46, 4.000000e+00
%48 = call double @exp(double %47)
%49 = load double, double* %16
%50 = load double, double* %16
%51 = load double, double* %16
%52 = fmul double 1.200000e+01, %51
%53 = fneg double %52
%54 = call double @llvm.fmuladd.f64(double %49, double %50, double %53)
%55 = fadd double %54, 1.200000e+01
%56 = fmul double %48, %55
store double %56, double* %19
%57 = load double, double* %19
%58 = load i32*, i32** %10
%59 = load i32, i32* %13
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32, i32* %58, i64 %60
%62 = load i32, i32* %61
%63 = sitofp i32 %62 to double
%64 = load double, double* %18
%65 = call double @llvm.fmuladd.f64(double %57, double %63, double %64)
store double %65, double* %18
br label %66
66: ; preds = %44
%67 = load i32, i32* %13
%68 = add nsw i32 %67, 1
store i32 %68, i32* %13
br label %26
69: ; preds = %43, %26
%70 = load i32, i32* %14
%71 = mul nsw i32 2, %70
%72 = sitofp i32 %71 to double
%73 = load double, double* %17
%74 = fmul double %72, %73
%75 = call i32 @sqrt(double 0x400921FB53C8D4F1)
%76 = sitofp i32 %75 to double
%77 = fmul double %74, %76
%78 = fdiv double 1.000000e+00, %77
%79 = load double, double* %18
%80 = load i32, i32* %14
%81 = mul nsw i32 64, %80
%82 = load i32, i32* %14
%83 = mul nsw i32 %81, %82
%84 = sitofp i32 %83 to double
%85 = load double, double* %17
%86 = fmul double %84, %85
%87 = call i32 @sqrt(double 0x400921FB53C8D4F1)
%88 = sitofp i32 %87 to double
%89 = fmul double %86, %88
%90 = fdiv double %79, %89
%91 = fadd double %78, %90
%92 = load double*, double** %12
store double %91, double* %92
ret void
}

LLVM IR (-O2):
define void @band_bcv_bin(i32* nocapture %0, i32* nocapture %1, double* nocapture %2, i32* nocapture %3, double* nocapture %4, double* nocapture writeonly %5) {
%7 = load i32, i32* %0
%8 = load i32, i32* %1
%9 = load double, double* %4
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %36
11: ; preds = %6
%12 = zext i32 %8 to i64
br label %13
13: ; preds = %11, %23
%14 = phi i64 [ 0, %11 ], [ %34, %23 ]
%15 = phi double [ 0.000000e+00, %11 ], [ %33, %23 ]
%16 = trunc i64 %14 to i32
%17 = sitofp i32 %16 to double
%18 = load double, double* %2
%19 = fmul double %18, %17
%20 = fdiv double %19, %9
%21 = fmul double %20, %20
%22 = fcmp ult double %21, 1.000000e+03
br i1 %22, label %23, label %36
23: ; preds = %13
%24 = fmul double %21, -2.500000e-01
%25 = tail call double @exp(double %24)
%26 = fmul double %21, -1.200000e+01
%27 = tail call double @llvm.fmuladd.f64(double %21, double %21, double %26)
%28 = fadd double %27, 1.200000e+01
%29 = fmul double %28, %25
%30 = getelementptr inbounds i32, i32* %3, i64 %14
%31 = load i32, i32* %30
%32 = sitofp i32 %31 to double
%33 = tail call double @llvm.fmuladd.f64(double %29, double %32, double %15)
%34 = add nuw nsw i64 %14, 1
%35 = icmp eq i64 %34, %12
br i1 %35, label %36, label %13
36: ; preds = %23, %13, %6
%37 = phi double [ 0.000000e+00, %6 ], [ %15, %13 ], [ %33, %23 ]
%38 = shl nsw i32 %7, 1
%39 = sitofp i32 %38 to double
%40 = fmul double %9, %39
%41 = tail call i32 @sqrt(double 0x400921FB53C8D4F1)
%42 = sitofp i32 %41 to double
%43 = fmul double %40, %42
%44 = fdiv double 1.000000e+00, %43
%45 = shl nsw i32 %7, 6
%46 = mul nsw i32 %45, %7
%47 = sitofp i32 %46 to double
%48 = fmul double %9, %47
%49 = tail call i32 @sqrt(double 0x400921FB53C8D4F1)
%50 = sitofp i32 %49 to double
%51 = fmul double %48, %50
%52 = fdiv double %37, %51
%53 = fadd double %44, %52
store double %53, double* %5
ret void
}