#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 */
scalar_t__ ceil(double);
double hat(double);
int maxi(int /*<<< orphan*/, int);
int /*<<< orphan*/ mini(int, int);
void fe_mu_at(double *mu, double *y, int N, int L) {
  int n = 1 << (L - 1);
  int t;
  int i, j;
  double yn;
  for (t = 0; t < N - 1; t++) {
    yn = y[t] * (double)n;
    i = maxi(mini(((int)ceil(yn)), n), 1);
    j = maxi(mini(((int)ceil(yn - 0.5)), n - 1), 1);
    mu[2 * i - 2] += hat(y[t] * n - i + 1) * (y[t + 1] - y[t]);
    mu[2 * j - 1] += hat(y[t] * n - j + .5) * (y[t + 1] - y[t]);
  }
}


x86 assembly (clang, -O0):
<fe_mu_at>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    130c <fe_mu_at+0x1cc>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <ceil@plt>
mov    %eax,%edi
mov    -0x1c(%rbp),%esi
call   1040 <mini@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1060 <maxi@plt>
mov    %eax,-0x24(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe37(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,%edi
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
call   1040 <mini@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1060 <maxi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm2
cvtsi2sdl -0x24(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xddc(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <hat@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm2
cvtsi2sdl -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd4c(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1050 <hat@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116d <fe_mu_at+0x2d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fe_mu_at>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
add    $0xff,%cl
mov    $0x1,%eax
shl    %cl,%eax
mov    %rax,0x18(%rsp)
mov    %rdx,(%rsp)
cmp    $0x2,%edx
jl     12a1 <fe_mu_at+0x161>
mov    %rsi,%r12
mov    %rdi,%r15
mov    (%rsp),%rax
add    $0xffffffff,%eax
mov    %rax,(%rsp)
mov    0x18(%rsp),%rax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
add    $0xffffffff,%eax
mov    %eax,0x14(%rsp)
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r12,%r14,8),%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
call   1030 <ceil@plt>
mov    %eax,%edi
mov    0x18(%rsp),%rsi
call   1040 <mini@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1060 <maxi@plt>
mov    %eax,%r13d
movsd  0x20(%rsp),%xmm0
addsd  0xe20(%rip),%xmm0
call   1030 <ceil@plt>
mov    %eax,%edi
mov    0x14(%rsp),%esi
call   1040 <mini@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1060 <maxi@plt>
mov    %eax,%ebp
xorps  %xmm1,%xmm1
cvtsi2sd %r13d,%xmm1
movsd  (%r12,%r14,8),%xmm0
mulsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
addsd  0xdea(%rip),%xmm0
call   1050 <hat@plt>
movsd  0x8(%r12,%r14,8),%xmm1
subsd  (%r12,%r14,8),%xmm1
add    %r13d,%r13d
movslq %r13d,%rax
mulsd  %xmm0,%xmm1
addsd  -0x10(%r15,%rax,8),%xmm1
lea    0x1(%r14),%rbx
movsd  %xmm1,-0x10(%r15,%rax,8)
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  (%r12,%r14,8),%xmm0
mulsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
addsd  0xda5(%rip),%xmm0
call   1050 <hat@plt>
movsd  0x8(%r12,%r14,8),%xmm1
subsd  (%r12,%r14,8),%xmm1
add    %ebp,%ebp
movslq %ebp,%rax
mulsd  %xmm0,%xmm1
addsd  -0x8(%r15,%rax,8),%xmm1
movsd  %xmm1,-0x8(%r15,%rax,8)
mov    %rbx,%r14
cmp    %rbx,(%rsp)
jne    11a0 <fe_mu_at+0x60>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @fe_mu_at(double* %0, double* %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%14 = load i32, i32* %8
%15 = sub nsw i32 %14, 1
%16 = shl i32 1, %15
store i32 %16, i32* %9
store i32 0, i32* %10
br label %17
17: ; preds = %111, %4
%18 = load i32, i32* %10
%19 = load i32, i32* %7
%20 = sub nsw i32 %19, 1
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %114
22: ; preds = %17
%23 = load double*, double** %6
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load i32, i32* %9
%29 = sitofp i32 %28 to double
%30 = fmul double %27, %29
store double %30, double* %13
%31 = load double, double* %13
%32 = call i64 @ceil(double %31)
%33 = trunc i64 %32 to i32
%34 = load i32, i32* %9
%35 = call i32 @mini(i32 %33, i32 %34)
%36 = call i32 @maxi(i32 %35, i32 1)
store i32 %36, i32* %11
%37 = load double, double* %13
%38 = fsub double %37, 5.000000e-01
%39 = call i64 @ceil(double %38)
%40 = trunc i64 %39 to i32
%41 = load i32, i32* %9
%42 = sub nsw i32 %41, 1
%43 = call i32 @mini(i32 %40, i32 %42)
%44 = call i32 @maxi(i32 %43, i32 1)
store i32 %44, i32* %12
%45 = load double*, double** %6
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
%50 = load i32, i32* %9
%51 = sitofp i32 %50 to double
%52 = load i32, i32* %11
%53 = sitofp i32 %52 to double
%54 = fneg double %53
%55 = call double @llvm.fmuladd.f64(double %49, double %51, double %54)
%56 = fadd double %55, 1.000000e+00
%57 = call double @hat(double %56)
%58 = load double*, double** %6
%59 = load i32, i32* %10
%60 = add nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %58, i64 %61
%63 = load double, double* %62
%64 = load double*, double** %6
%65 = load i32, i32* %10
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
%69 = fsub double %63, %68
%70 = load double*, double** %5
%71 = load i32, i32* %11
%72 = mul nsw i32 2, %71
%73 = sub nsw i32 %72, 2
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %70, i64 %74
%76 = load double, double* %75
%77 = call double @llvm.fmuladd.f64(double %57, double %69, double %76)
store double %77, double* %75
%78 = load double*, double** %6
%79 = load i32, i32* %10
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
%82 = load double, double* %81
%83 = load i32, i32* %9
%84 = sitofp i32 %83 to double
%85 = load i32, i32* %12
%86 = sitofp i32 %85 to double
%87 = fneg double %86
%88 = call double @llvm.fmuladd.f64(double %82, double %84, double %87)
%89 = fadd double %88, 5.000000e-01
%90 = call double @hat(double %89)
%91 = load double*, double** %6
%92 = load i32, i32* %10
%93 = add nsw i32 %92, 1
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %91, i64 %94
%96 = load double, double* %95
%97 = load double*, double** %6
%98 = load i32, i32* %10
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %97, i64 %99
%101 = load double, double* %100
%102 = fsub double %96, %101
%103 = load double*, double** %5
%104 = load i32, i32* %12
%105 = mul nsw i32 2, %104
%106 = sub nsw i32 %105, 1
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds double, double* %103, i64 %107
%109 = load double, double* %108
%110 = call double @llvm.fmuladd.f64(double %90, double %102, double %109)
store double %110, double* %108
br label %111
111: ; preds = %22
%112 = load i32, i32* %10
%113 = add nsw i32 %112, 1
store i32 %113, i32* %10
br label %17
114: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @fe_mu_at(double* nocapture %0, double* nocapture %1, i32 %2, i32 %3) {
%5 = add nsw i32 %3, -1
%6 = shl nuw i32 1, %5
%7 = icmp sgt i32 %2, 1
br i1 %7, label %8, label %60
8: ; preds = %4
%9 = add nsw i32 %2, -1
%10 = sitofp i32 %6 to double
%11 = add nsw i32 %6, -1
%12 = zext i32 %9 to i64
br label %13
13: ; preds = %8, %13
%14 = phi i64 [ 0, %8 ], [ %33, %13 ]
%15 = getelementptr inbounds double, double* %1, i64 %14
%16 = load double, double* %15
%17 = fmul double %16, %10
%18 = tail call i64 @ceil(double %17)
%19 = trunc i64 %18 to i32
%20 = tail call i32 @mini(i32 %19, i32 %6)
%21 = tail call i32 @maxi(i32 %20, i32 1)
%22 = fadd double %17, -5.000000e-01
%23 = tail call i64 @ceil(double %22)
%24 = trunc i64 %23 to i32
%25 = tail call i32 @mini(i32 %24, i32 %11)
%26 = tail call i32 @maxi(i32 %25, i32 1)
%27 = load double, double* %15
%28 = sitofp i32 %21 to double
%29 = fneg double %28
%30 = tail call double @llvm.fmuladd.f64(double %27, double %10, double %29)
%31 = fadd double %30, 1.000000e+00
%32 = tail call double @hat(double %31)
%33 = add nuw nsw i64 %14, 1
%34 = getelementptr inbounds double, double* %1, i64 %33
%35 = load double, double* %34
%36 = load double, double* %15
%37 = fsub double %35, %36
%38 = shl nsw i32 %21, 1
%39 = add nsw i32 %38, -2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %0, i64 %40
%42 = load double, double* %41
%43 = tail call double @llvm.fmuladd.f64(double %32, double %37, double %42)
store double %43, double* %41
%44 = load double, double* %15
%45 = sitofp i32 %26 to double
%46 = fneg double %45
%47 = tail call double @llvm.fmuladd.f64(double %44, double %10, double %46)
%48 = fadd double %47, 5.000000e-01
%49 = tail call double @hat(double %48)
%50 = load double, double* %34
%51 = load double, double* %15
%52 = fsub double %50, %51
%53 = shl nsw i32 %26, 1
%54 = add nsw i32 %53, -1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %0, i64 %55
%57 = load double, double* %56
%58 = tail call double @llvm.fmuladd.f64(double %49, double %52, double %57)
store double %58, double* %56
%59 = icmp eq i64 %33, %12
br i1 %59, label %60, label %13
60: ; preds = %13, %4
ret void
}