#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 */
typedef double int8_t;
typedef int int32_t;

/* Variables and functions */
void correctEnvelope(int8_t **buffer, int32_t size) {
  int32_t i;
  for (i = 1; i < size - 1; i++)
    (*buffer)[i] =
        (0.5 * (*buffer)[i - 1] + 1.0 * (*buffer)[i] + 2.0 * (*buffer)[i + 1]) /
        3.5;
}


x86 assembly (clang, -O0):
<correctEnvelope>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a7 <correctEnvelope+0xa7>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x10(%rbp),%rcx
movsd  0xec5(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
movsd  0xeb0(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe7b(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <correctEnvelope+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<correctEnvelope>:
cmp    $0x3,%esi
jl     11d9 <correctEnvelope+0xd9>
add    $0xffffffff,%esi
mov    (%rdi),%rax
movsd  (%rax),%xmm1
movsd  0x8(%rax),%xmm0
lea    -0x1(%rsi),%r8
mov    $0x1,%edi
cmp    $0x2,%esi
je     11ac <correctEnvelope+0xac>
mov    %r8,%rdx
and    $0xfffffffffffffffe,%rdx
neg    %rdx
mov    $0x1,%esi
movsd  0xebf(%rip),%xmm2
movsd  0xebf(%rip),%xmm3
nopl   0x0(%rax)
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0x8(%rax,%rsi,8),%xmm4
movsd  0x10(%rax,%rsi,8),%xmm0
movapd %xmm4,%xmm5
addsd  %xmm4,%xmm5
addsd  %xmm1,%xmm5
divsd  %xmm3,%xmm5
movsd  %xmm5,(%rax,%rsi,8)
mulsd  %xmm2,%xmm5
addsd  %xmm4,%xmm5
lea    0x2(%rsi),%rdi
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm5,%xmm1
divsd  %xmm3,%xmm1
movsd  %xmm1,0x8(%rax,%rsi,8)
lea    (%rdx,%rsi,1),%rcx
add    $0x2,%rcx
mov    %rdi,%rsi
cmp    $0x1,%rcx
jne    1150 <correctEnvelope+0x50>
test   $0x1,%r8b
je     11d9 <correctEnvelope+0xd9>
mulsd  0xe46(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0x8(%rax,%rdi,8),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe34(%rip),%xmm0
movsd  %xmm0,(%rax,%rdi,8)
ret

LLVM IR (-O0):
define void @correctEnvelope(double** %0, i32 %1) {
%3 = alloca double**
%4 = alloca i32
%5 = alloca i32
store double** %0, double*** %3
store i32 %1, i32* %4
store i32 1, i32* %5
br label %6
6: ; preds = %41, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 1
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %44
11: ; preds = %6
%12 = load double**, double*** %3
%13 = load double*, double** %12
%14 = load i32, i32* %5
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %13, i64 %16
%18 = load double, double* %17
%19 = load double**, double*** %3
%20 = load double*, double** %19
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = fmul double 1.000000e+00, %24
%26 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %18, double %25)
%27 = load double**, double*** %3
%28 = load double*, double** %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %28, i64 %31
%33 = load double, double* %32
%34 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %33, double %26)
%35 = fdiv double %34, 3.500000e+00
%36 = load double**, double*** %3
%37 = load double*, double** %36
%38 = load i32, i32* %5
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
store double %35, double* %40
br label %41
41: ; preds = %11
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %6
44: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @correctEnvelope(double** nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 2
br i1 %3, label %4, label %50
4: ; preds = %2
%5 = add nsw i32 %1, -1
%6 = load double*, double** %0
%7 = zext i32 %5 to i64
%8 = load double, double* %6
%9 = getelementptr inbounds double, double* %6, i64 1
%10 = load double, double* %9
%11 = add nsw i64 %7, -1
%12 = and i64 %11, 1
%13 = icmp eq i32 %5, 2
br i1 %13, label %37, label %14
14: ; preds = %4
%15 = and i64 %11, -2
br label %16
16: ; preds = %16, %14
%17 = phi double [ %10, %14 ], [ %32, %16 ]
%18 = phi double [ %8, %14 ], [ %34, %16 ]
%19 = phi i64 [ 1, %14 ], [ %30, %16 ]
%20 = phi i64 [ 0, %14 ], [ %35, %16 ]
%21 = getelementptr inbounds double, double* %6, i64 %19
%22 = tail call double @llvm.fmuladd.f64(double %18, double 5.000000e-01, double %17)
%23 = add nuw nsw i64 %19, 1
%24 = getelementptr inbounds double, double* %6, i64 %23
%25 = load double, double* %24
%26 = tail call double @llvm.fmuladd.f64(double %25, double 2.000000e+00, double %22)
%27 = fdiv double %26, 3.500000e+00
store double %27, double* %21
%28 = getelementptr inbounds double, double* %6, i64 %23
%29 = tail call double @llvm.fmuladd.f64(double %27, double 5.000000e-01, double %25)
%30 = add nuw nsw i64 %19, 2
%31 = getelementptr inbounds double, double* %6, i64 %30
%32 = load double, double* %31
%33 = tail call double @llvm.fmuladd.f64(double %32, double 2.000000e+00, double %29)
%34 = fdiv double %33, 3.500000e+00
store double %34, double* %28
%35 = add i64 %20, 2
%36 = icmp eq i64 %35, %15
br i1 %36, label %37, label %16
37: ; preds = %16, %4
%38 = phi double [ %10, %4 ], [ %32, %16 ]
%39 = phi double [ %8, %4 ], [ %34, %16 ]
%40 = phi i64 [ 1, %4 ], [ %30, %16 ]
%41 = icmp eq i64 %12, 0
br i1 %41, label %50, label %42
42: ; preds = %37
%43 = getelementptr inbounds double, double* %6, i64 %40
%44 = tail call double @llvm.fmuladd.f64(double %39, double 5.000000e-01, double %38)
%45 = add nuw nsw i64 %40, 1
%46 = getelementptr inbounds double, double* %6, i64 %45
%47 = load double, double* %46
%48 = tail call double @llvm.fmuladd.f64(double %47, double 2.000000e+00, double %44)
%49 = fdiv double %48, 3.500000e+00
store double %49, double* %43
br label %50
50: ; preds = %42, %37, %2
ret void
}