#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 */
float fabs(float);
void envelope(float input[], float prev_in, float output[], int npts) {
  int i;
  float curr_abs, prev_abs;
  prev_abs = fabs(prev_in);
  for (i = 0; i < npts; i++) {
    curr_abs = fabs(input[i]);
    output[i] = curr_abs - prev_abs + (-0.9409) * output[i - 2] +
                1.9266 * output[i - 1];
    prev_abs = curr_abs;
  }
}


x86 assembly (clang, -O0):
<envelope>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fabs@plt>
movss  %xmm0,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11e4 <envelope+0xd4>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1030 <fabs@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
subss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe7b(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe4d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113e <envelope+0x2e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<envelope>:
test   %edx,%edx
jle    117f <envelope+0x7f>
andps  0xef5(%rip),%xmm0
mov    %edx,%eax
movss  -0x8(%rsi),%xmm5
movss  -0x4(%rsi),%xmm4
xor    %ecx,%ecx
movaps 0xee0(%rip),%xmm1
movsd  0xee8(%rip),%xmm2
movsd  0xee8(%rip),%xmm3
cvtss2sd %xmm5,%xmm5
movaps %xmm4,%xmm6
movss  (%rdi,%rcx,4),%xmm7
andps  %xmm1,%xmm7
movaps %xmm7,%xmm4
subss  %xmm0,%xmm4
xorps  %xmm0,%xmm0
cvtss2sd %xmm4,%xmm0
mulsd  %xmm2,%xmm5
addsd  %xmm0,%xmm5
xorps  %xmm0,%xmm0
cvtss2sd %xmm6,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm5,%xmm0
xorps  %xmm4,%xmm4
cvtsd2ss %xmm0,%xmm4
movaps %xmm6,%xmm5
movss  %xmm4,(%rsi,%rcx,4)
add    $0x1,%rcx
movaps %xmm7,%xmm0
cmp    %rcx,%rax
jne    1130 <envelope+0x30>
ret

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

LLVM IR (-O2):
define void @envelope(float* nocapture %0, float %1, float* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %31
6: ; preds = %4
%7 = tail call float @llvm.fabs.f32(float %1)
%8 = zext i32 %3 to i64
%9 = getelementptr inbounds float, float* %2, i64 -2
%10 = load float, float* %9
%11 = getelementptr inbounds float, float* %2, i64 -1
%12 = load float, float* %11
br label %13
13: ; preds = %6, %13
%14 = phi float [ %12, %6 ], [ %27, %13 ]
%15 = phi float [ %10, %6 ], [ %14, %13 ]
%16 = phi i64 [ 0, %6 ], [ %29, %13 ]
%17 = phi float [ %7, %6 ], [ %20, %13 ]
%18 = getelementptr inbounds float, float* %0, i64 %16
%19 = load float, float* %18
%20 = tail call float @llvm.fabs.f32(float %19)
%21 = fsub float %20, %17
%22 = fpext float %21 to double
%23 = fpext float %15 to double
%24 = tail call double @llvm.fmuladd.f64(double %23, double -9.409000e-01, double %22)
%25 = fpext float %14 to double
%26 = tail call double @llvm.fmuladd.f64(double %25, double 1.926600e+00, double %24)
%27 = fptrunc double %26 to float
%28 = getelementptr inbounds float, float* %2, i64 %16
store float %27, float* %28
%29 = add nuw nsw i64 %16, 1
%30 = icmp eq i64 %29, %8
br i1 %30, label %31, label %13
31: ; preds = %13, %4
ret void
}