#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 exp(double);
int sqrt(double);
void band_ucv_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) - sqrt(8.0) * exp(-delta / 2);
    sum += term * x[i];
  }
  *u = 1 / (2 * nn * hh * sqrt(3.14159265)) +
       sum / (nn * nn * hh * sqrt(3.14159265));
}


x86 assembly (clang, -O0):
<band_ucv_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%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    1274 <band_ucv_bin+0x154>
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_ucv_bin+0x9f>
jmp    1274 <band_ucv_bin+0x154>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe35(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
mov    %eax,-0x64(%rbp)
movsd  0xe19(%rip),%xmm0
call   1040 <sqrt@plt>
mov    %eax,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xde5(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
mov    -0x68(%rbp),%ecx
mov    %eax,%edx
mov    -0x64(%rbp),%eax
imul   %edx,%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%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_ucv_bin+0x51>
mov    -0x38(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xd8d(%rip),%xmm0
call   1040 <sqrt@plt>
movsd  -0x88(%rbp),%xmm1
ff
cvtsi2sd %eax,%xmm0
mulsd  %xmm0,%xmm1
movsd  0xd78(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x38(%rbp),%eax
imul   -0x38(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xd40(%rip),%xmm0
call   1040 <sqrt@plt>
movsd  -0x80(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm0
cvtsi2sd %eax,%xmm3
mulsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<band_ucv_bin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    (%rdi),%eax
mov    (%rsi),%r14d
movsd  (%r8),%xmm0
movsd  %xmm0,(%rsp)
test   %r14d,%r14d
mov    %r9,0x20(%rsp)
mov    %rax,0x18(%rsp)
jle    1200 <band_ucv_bin+0xe0>
mov    %rcx,%r15
mov    %rdx,%r12
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %r13d,%xmm0
mulsd  (%r12),%xmm0
divsd  (%rsp),%xmm0
mulsd  %xmm0,%xmm0
ucomisd 0xe71(%rip),%xmm0
jae    120a <band_ucv_bin+0xea>
movsd  %xmm0,0x8(%rsp)
mulsd  0xe69(%rip),%xmm0
call   1030 <exp@plt>
mov    %eax,%ebp
movsd  0xe62(%rip),%xmm0
call   1040 <sqrt@plt>
mov    %eax,%ebx
movsd  0x8(%rsp),%xmm0
mulsd  0xe55(%rip),%xmm0
call   1030 <exp@plt>
imul   %ebx,%eax
sub    %eax,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdl (%r15,%r13,4),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
add    $0x1,%r13
cmp    %r13,%r14
jne    1170 <band_ucv_bin+0x50>
jmp    120a <band_ucv_bin+0xea>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x18(%rsp),%rbx
lea    (%rbx,%rbx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xdf4(%rip),%xmm0
call   1040 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  0xde2(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
imul   %ebx,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xdb4(%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
mov    0x20(%rsp),%rax
movsd  %xmm1,(%rax)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @band_ucv_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 i32 @exp(double %47)
%49 = call i32 @sqrt(double 8.000000e+00)
%50 = load double, double* %16
%51 = fneg double %50
%52 = fdiv double %51, 2.000000e+00
%53 = call i32 @exp(double %52)
%54 = mul nsw i32 %49, %53
%55 = sub nsw i32 %48, %54
%56 = sitofp i32 %55 to double
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 = load i32, i32* %14
%82 = mul nsw i32 %80, %81
%83 = sitofp i32 %82 to double
%84 = load double, double* %17
%85 = fmul double %83, %84
%86 = call i32 @sqrt(double 0x400921FB53C8D4F1)
%87 = sitofp i32 %86 to double
%88 = fmul double %85, %87
%89 = fdiv double %79, %88
%90 = fadd double %78, %89
%91 = load double*, double** %12
store double %90, double* %91
ret void
}

LLVM IR (-O2):
define void @band_ucv_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 %38
11: ; preds = %6
%12 = zext i32 %8 to i64
br label %13
13: ; preds = %11, %23
%14 = phi i64 [ 0, %11 ], [ %36, %23 ]
%15 = phi double [ 0.000000e+00, %11 ], [ %35, %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 %38
23: ; preds = %13
%24 = fmul double %21, -2.500000e-01
%25 = tail call i32 @exp(double %24)
%26 = tail call i32 @sqrt(double 8.000000e+00)
%27 = fmul double %21, -5.000000e-01
%28 = tail call i32 @exp(double %27)
%29 = mul nsw i32 %28, %26
%30 = sub nsw i32 %25, %29
%31 = sitofp i32 %30 to double
%32 = getelementptr inbounds i32, i32* %3, i64 %14
%33 = load i32, i32* %32
%34 = sitofp i32 %33 to double
%35 = tail call double @llvm.fmuladd.f64(double %31, double %34, double %15)
%36 = add nuw nsw i64 %14, 1
%37 = icmp eq i64 %36, %12
br i1 %37, label %38, label %13
38: ; preds = %23, %13, %6
%39 = phi double [ 0.000000e+00, %6 ], [ %15, %13 ], [ %35, %23 ]
%40 = shl nsw i32 %7, 1
%41 = sitofp i32 %40 to double
%42 = fmul double %9, %41
%43 = tail call i32 @sqrt(double 0x400921FB53C8D4F1)
%44 = sitofp i32 %43 to double
%45 = fmul double %42, %44
%46 = fdiv double 1.000000e+00, %45
%47 = mul nsw i32 %7, %7
%48 = sitofp i32 %47 to double
%49 = fmul double %9, %48
%50 = tail call i32 @sqrt(double 0x400921FB53C8D4F1)
%51 = sitofp i32 %50 to double
%52 = fmul double %49, %51
%53 = fdiv double %39, %52
%54 = fadd double %46, %53
store double %54, double* %5
ret void
}