#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 /*<<< orphan*/ WebRtcIsac_AllpassFilterForDec(double *, double const *,
                                                  size_t, double *);
int /*<<< orphan*/ memcpy(double *, double const *, int);
void WebRtcIsac_DecimateAllpass(const double *in, double *state_in, size_t N,
                                double *out) {
  static const double APupper[2] = {0.0347, 0.3826};
  static const double APlower[2] = {0.1544, 0.744};
  size_t n;
  double data_vec[(240)];
  memcpy(data_vec + 1, in, sizeof(double) * (N - 1));
  data_vec[0] = state_in[2 * 2];
  state_in[2 * 2] = in[N - 1];
  WebRtcIsac_AllpassFilterForDec(data_vec + 1, APupper, N, state_in);
  WebRtcIsac_AllpassFilterForDec(data_vec, APlower, N, state_in + 2);
  for (n = 0; n < N / 2; n++)
    out[n] = data_vec[2 * n] + data_vec[2 * n + 1];
}


x86 assembly (clang, -O0):
<WebRtcIsac_DecimateAllpass>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x7b0(%rbp),%rdi
add    $0x8,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rax
sub    $0x1,%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1030 <memcpy@plt>
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
movsd  %xmm0,-0x7b0(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x20(%rax)
lea    -0x7b0(%rbp),%rdi
add    $0x8,%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe5e(%rip),%rsi
call   1040 <WebRtcIsac_AllpassFilterForDec@plt>
lea    -0x7b0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
add    $0x10,%rcx
lea    0xe4f(%rip),%rsi
call   1040 <WebRtcIsac_AllpassFilterForDec@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
shr    $0x1,%rcx
cmp    %rcx,%rax
jae    1223 <WebRtcIsac_DecimateAllpass+0x103>
mov    -0x28(%rbp),%rax
shl    $0x1,%rax
movsd  -0x7b0(%rbp,%rax,8),%xmm0
ff ff
mov    -0x28(%rbp),%rax
shl    $0x1,%rax
addsd  -0x7a8(%rbp,%rax,8),%xmm0
ff ff
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11ce <WebRtcIsac_DecimateAllpass+0xae>
add    $0x7b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WebRtcIsac_DecimateAllpass>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x780,%rsp
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
lea    0x8(%rsp),%r13
add    $0xffffffffffffffff,%rdx
shl    $0x3,%edx
mov    %r13,%rdi
mov    %r14,%rsi
call   1030 <memcpy@plt>
movsd  0x20(%r12),%xmm0
movsd  %xmm0,(%rsp)
movsd  -0x8(%r14,%r15,8),%xmm0
movsd  %xmm0,0x20(%r12)
lea    0xe8c(%rip),%rsi
mov    %r13,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <WebRtcIsac_AllpassFilterForDec@plt>
add    $0x10,%r12
lea    0xe83(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <WebRtcIsac_AllpassFilterForDec@plt>
cmp    $0x2,%r15
jb     124b <WebRtcIsac_DecimateAllpass+0x12b>
mov    %r15,%rax
shr    %rax
cmp    $0x8,%r15
jae    11b8 <WebRtcIsac_DecimateAllpass+0x98>
xor    %ecx,%ecx
jmp    1220 <WebRtcIsac_DecimateAllpass+0x100>
mov    %rax,%rcx
and    $0xfffffffffffffffc,%rcx
lea    0x20(%rsp),%rdx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
movapd -0x20(%rdx),%xmm0
movapd -0x10(%rdx),%xmm1
movapd (%rdx),%xmm2
movapd 0x10(%rdx),%xmm3
movapd %xmm0,%xmm4
unpcklpd %xmm1,%xmm4
movapd %xmm2,%xmm5
unpcklpd %xmm3,%xmm5
unpckhpd %xmm1,%xmm0
addpd  %xmm4,%xmm0
unpckhpd %xmm3,%xmm2
addpd  %xmm5,%xmm2
movupd %xmm0,(%rbx,%rsi,8)
movupd %xmm2,0x10(%rbx,%rsi,8)
add    $0x4,%rsi
add    $0x40,%rdx
cmp    %rsi,%rcx
jne    11d0 <WebRtcIsac_DecimateAllpass+0xb0>
cmp    %rcx,%rax
je     124b <WebRtcIsac_DecimateAllpass+0x12b>
mov    %rcx,%rdx
shl    $0x4,%rdx
add    %r14,%rdx
add    $0x8,%rdx
xchg   %ax,%ax
movsd  -0x8(%rdx),%xmm0
addsd  (%rdx),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
add    $0x1,%rcx
add    $0x10,%rdx
cmp    %rcx,%rax
jne    1230 <WebRtcIsac_DecimateAllpass+0x110>
add    $0x780,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@WebRtcIsac_DecimateAllpass.APupper = internal constant [2 x double] [double 3.470000e-02, double 3.826000e-01]
@WebRtcIsac_DecimateAllpass.APlower = internal constant [2 x double] [double 1.544000e-01, double 0x3FE7CED916872B02]
define void @WebRtcIsac_DecimateAllpass(double* %0, double* %1, i64 %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i64
%8 = alloca double*
%9 = alloca i64
%10 = alloca [240 x double]
store double* %0, double** %5
store double* %1, double** %6
store i64 %2, i64* %7
store double* %3, double** %8
%11 = getelementptr inbounds [240 x double], [240 x double]* %10, i64 0, i64 0
%12 = getelementptr inbounds double, double* %11, i64 1
%13 = load double*, double** %5
%14 = load i64, i64* %7
%15 = sub i64 %14, 1
%16 = mul i64 8, %15
%17 = trunc i64 %16 to i32
%18 = call i32 @memcpy(double* %12, double* %13, i32 %17)
%19 = load double*, double** %6
%20 = getelementptr inbounds double, double* %19, i64 4
%21 = load double, double* %20
%22 = getelementptr inbounds [240 x double], [240 x double]* %10, i64 0, i64 0
store double %21, double* %22
%23 = load double*, double** %5
%24 = load i64, i64* %7
%25 = sub i64 %24, 1
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = load double*, double** %6
%29 = getelementptr inbounds double, double* %28, i64 4
store double %27, double* %29
%30 = getelementptr inbounds [240 x double], [240 x double]* %10, i64 0, i64 0
%31 = getelementptr inbounds double, double* %30, i64 1
%32 = load i64, i64* %7
%33 = load double*, double** %6
%34 = call i32 @WebRtcIsac_AllpassFilterForDec(double* %31, double* getelementptr inbounds ([2 x double], [2 x double]* @WebRtcIsac_DecimateAllpass.APupper, i64 0, i64 0), i64 %32, double* %33)
%35 = getelementptr inbounds [240 x double], [240 x double]* %10, i64 0, i64 0
%36 = load i64, i64* %7
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i64 2
%39 = call i32 @WebRtcIsac_AllpassFilterForDec(double* %35, double* getelementptr inbounds ([2 x double], [2 x double]* @WebRtcIsac_DecimateAllpass.APlower, i64 0, i64 0), i64 %36, double* %38)
store i64 0, i64* %9
br label %40
40: ; preds = %59, %4
%41 = load i64, i64* %9
%42 = load i64, i64* %7
%43 = udiv i64 %42, 2
%44 = icmp ult i64 %41, %43
br i1 %44, label %45, label %62
45: ; preds = %40
%46 = load i64, i64* %9
%47 = mul i64 2, %46
%48 = getelementptr inbounds [240 x double], [240 x double]* %10, i64 0, i64 %47
%49 = load double, double* %48
%50 = load i64, i64* %9
%51 = mul i64 2, %50
%52 = add i64 %51, 1
%53 = getelementptr inbounds [240 x double], [240 x double]* %10, i64 0, i64 %52
%54 = load double, double* %53
%55 = fadd double %49, %54
%56 = load double*, double** %8
%57 = load i64, i64* %9
%58 = getelementptr inbounds double, double* %56, i64 %57
store double %55, double* %58
br label %59
59: ; preds = %45
%60 = load i64, i64* %9
%61 = add i64 %60, 1
store i64 %61, i64* %9
br label %40
62: ; preds = %40
ret void
}

LLVM IR (-O2):
@WebRtcIsac_DecimateAllpass.APupper = internal constant [2 x double] [double 3.470000e-02, double 3.826000e-01]
@WebRtcIsac_DecimateAllpass.APlower = internal constant [2 x double] [double 1.544000e-01, double 0x3FE7CED916872B02]
define void @WebRtcIsac_DecimateAllpass(double* %0, double* %1, i64 %2, double* nocapture writeonly %3) {
%5 = alloca [240 x double]
%6 = bitcast [240 x double]* %5 to i8*
%7 = getelementptr inbounds [240 x double], [240 x double]* %5, i64 0, i64 0
%8 = getelementptr inbounds [240 x double], [240 x double]* %5, i64 0, i64 1
%9 = add i64 %2, -1
%10 = trunc i64 %9 to i32
%11 = shl i32 %10, 3
%12 = call i32 @memcpy(double* %8, double* %0, i32 %11)
%13 = getelementptr inbounds double, double* %1, i64 4
%14 = load double, double* %13
store double %14, double* %7
%15 = getelementptr inbounds double, double* %0, i64 %9
%16 = load double, double* %15
store double %16, double* %13
%17 = call i32 @WebRtcIsac_AllpassFilterForDec(double* %8, double* getelementptr inbounds ([2 x double], [2 x double]* @WebRtcIsac_DecimateAllpass.APupper, i64 0, i64 0), i64 %2, double* %1)
%18 = getelementptr inbounds double, double* %1, i64 2
%19 = call i32 @WebRtcIsac_AllpassFilterForDec(double* %7, double* getelementptr inbounds ([2 x double], [2 x double]* @WebRtcIsac_DecimateAllpass.APlower, i64 0, i64 0), i64 %2, double* %18)
%20 = icmp ult i64 %2, 2
br i1 %20, label %65, label %21
21: ; preds = %4
%22 = lshr i64 %2, 1
%23 = icmp ult i64 %2, 8
br i1 %23, label %51, label %24
24: ; preds = %21
%25 = and i64 %22, 9223372036854775804
br label %26
26: ; preds = %26, %24
%27 = phi i64 [ 0, %24 ], [ %47, %26 ]
%28 = shl nuw i64 %27, 1
%29 = shl i64 %27, 1
%30 = or i64 %29, 4
%31 = getelementptr inbounds [240 x double], [240 x double]* %5, i64 0, i64 %28
%32 = getelementptr inbounds [240 x double], [240 x double]* %5, i64 0, i64 %30
%33 = bitcast double* %31 to <4 x double>*
%34 = bitcast double* %32 to <4 x double>*
%35 = load <4 x double>, <4 x double>* %33
%36 = load <4 x double>, <4 x double>* %34
%37 = shufflevector <4 x double> %35, <4 x double> poison, <2 x i32> <i32 0, i32 2>
%38 = shufflevector <4 x double> %36, <4 x double> poison, <2 x i32> <i32 0, i32 2>
%39 = shufflevector <4 x double> %35, <4 x double> poison, <2 x i32> <i32 1, i32 3>
%40 = shufflevector <4 x double> %36, <4 x double> poison, <2 x i32> <i32 1, i32 3>
%41 = fadd <2 x double> %37, %39
%42 = fadd <2 x double> %38, %40
%43 = getelementptr inbounds double, double* %3, i64 %27
%44 = bitcast double* %43 to <2 x double>*
store <2 x double> %41, <2 x double>* %44
%45 = getelementptr inbounds double, double* %43, i64 2
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> %42, <2 x double>* %46
%47 = add nuw i64 %27, 4
%48 = icmp eq i64 %47, %25
br i1 %48, label %49, label %26
49: ; preds = %26
%50 = icmp eq i64 %22, %25
br i1 %50, label %65, label %51
51: ; preds = %21, %49
%52 = phi i64 [ 0, %21 ], [ %25, %49 ]
br label %53
53: ; preds = %51, %53
%54 = phi i64 [ %63, %53 ], [ %52, %51 ]
%55 = shl nuw i64 %54, 1
%56 = getelementptr inbounds [240 x double], [240 x double]* %5, i64 0, i64 %55
%57 = load double, double* %56
%58 = or i64 %55, 1
%59 = getelementptr inbounds [240 x double], [240 x double]* %5, i64 0, i64 %58
%60 = load double, double* %59
%61 = fadd double %57, %60
%62 = getelementptr inbounds double, double* %3, i64 %54
store double %61, double* %62
%63 = add nuw nsw i64 %54, 1
%64 = icmp eq i64 %63, %22
br i1 %64, label %65, label %53
65: ; preds = %53, %49, %4
ret void
}