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


x86 assembly (clang, -O0):
<band_phi4_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%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)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    126c <band_phi4_bin+0x13c>
cvtsi2sdl -0x34(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xe4d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11c2 <band_phi4_bin+0x92>
jmp    126c <band_phi4_bin+0x13c>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe32(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  -0x48(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm3
movsd  0xe0f(%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  0xddb(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1171 <band_phi4_bin+0x41>
movsd  -0x50(%rbp),%xmm0
imul   $0x3,-0x38(%rbp),%eax
cvtsi2sd %eax,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x38(%rbp),%ecx
sub    $0x1,%ecx
imul   %ecx,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xd71(%rip),%xmm1
call   1040 <pow@plt>
mov    %eax,%ecx
mov    -0x6c(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x5c(%rbp)
mov    $0x6,%edi
call   1050 <sqrt@plt>
movsd  -0x68(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<band_phi4_bin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r15
mov    (%rdi),%r13d
mov    (%rsi),%ebp
test   %ebp,%ebp
mov    %r9,0x8(%rsp)
jle    11de <band_phi4_bin+0xae>
mov    %rcx,%r12
mov    %rdx,%rbx
xorpd  %xmm1,%xmm1
xor    %r14d,%r14d
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  (%rbx),%xmm0
divsd  (%r15),%xmm0
mulsd  %xmm0,%xmm0
ucomisd 0xe83(%rip),%xmm0
jae    11e2 <band_phi4_bin+0xb2>
movsd  %xmm0,0x10(%rsp)
mulsd  0xe7b(%rip),%xmm0
movsd  %xmm1,(%rsp)
call   1030 <exp@plt>
movsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm1
mulsd  0xe67(%rip),%xmm1
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  (%rsp),%xmm1
addsd  0xe5a(%rip),%xmm2
mulsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sdl (%r12,%r14,4),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm0,%xmm1
add    $0x1,%r14
cmp    %r14,%rbp
jne    1160 <band_phi4_bin+0x30>
jmp    11e2 <band_phi4_bin+0xb2>
xorpd  %xmm1,%xmm1
lea    0x0(%r13,%r13,2),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
lea    -0x1(%r13),%ebp
imul   %r13d,%ebp
movsd  (%r15),%xmm0
movsd  0xe10(%rip),%xmm1
call   1040 <pow@plt>
mov    %eax,%ebx
mov    $0x6,%edi
call   1050 <sqrt@plt>
imul   %ebx,%eax
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
mov    0x8(%rsp),%rax
movsd  %xmm1,(%rax)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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