// File: Sleepwalking[P]world-octave/matlabfunctions.cpp
// Function: (anonymous namespace)::FilterForDecimate(double*, int, int, double*)
void FilterForDecimate(double *x, int x_length, int r, double *y) {
  double a[3], b[2];  // filter Coefficients
  switch (r) {
    case 11:  // fs : 44100 (default)
      a[0] = 2.450743295230728;
      a[1] = -2.06794904601978;
      a[2] = 0.59574774438332101;
      b[0] = 0.0026822508007163792;
      b[1] = 0.0080467524021491377;
      break;
    case 12:  // fs : 48000
      a[0] = 2.4981398605924205;
      a[1] = -2.1368928194784025;
      a[2] = 0.62187513816221485;
      b[0] = 0.0021097275904709001;
      b[1] = 0.0063291827714127002;
      break;
    case 10:
      a[0] = 2.3936475118069387;
      a[1] = -1.9873904075111861;
      a[2] = 0.5658879979027055;
      b[0] = 0.0034818622251927556;
      b[1] = 0.010445586675578267;
      break;
    case 9:
      a[0] = 2.3236003491759578;
      a[1] = -1.8921545617463598;
      a[2] = 0.53148928133729068;
      b[0] = 0.0046331164041389372;
      b[1] = 0.013899349212416812;
      break;
    case 8:  // fs : 32000
      a[0] = 2.2357462340187593;
      a[1] = -1.7780899984041358;
      a[2] = 0.49152555365968692;
      b[0] = 0.0063522763407111993;
      b[1] = 0.019056829022133598;
      break;
    case 7:
      a[0] = 2.1225239019534703;
      a[1] = -1.6395144861046302;
      a[2] = 0.44469707800587366;
      b[0] = 0.0090366882681608418;
      b[1] = 0.027110064804482525;
      break;
    case 6:  // fs : 24000 and 22050
      a[0] = 1.9715352749512141;
      a[1] = -1.4686795689225347;
      a[2] = 0.3893908434965701;
      b[0] = 0.013469181309343825;
      b[1] = 0.040407543928031475;
      break;
    case 5:
      a[0] = 1.7610939654280557;
      a[1] = -1.2554914843859768;
      a[2] = 0.3237186507788215;
      b[0] = 0.021334858522387423;
      b[1] = 0.06400457556716227;
      break;
    case 4:  // fs : 16000
      a[0] = 1.4499664446880227;
      a[1] = -0.98943497080950582;
      a[2] = 0.24578252340690215;
      b[0] = 0.036710750339322612;
      b[1] = 0.11013225101796784;
      break;
    case 3:
      a[0] = 0.95039378983237421;
      a[1] = -0.67429146741526791;
      a[2] = 0.15412211621346475;
      b[0] = 0.071221945171178636;
      b[1] = 0.21366583551353591;
      break;
    case 2:  // fs : 8000
      a[0] = 0.041156734567757189;
      a[1] = -0.42599112459189636;
      a[2] = 0.041037215479961225;
      b[0] = 0.16797464681802227;
      b[1] = 0.50392394045406674;
      break;
    default:
      a[0] = 0.0;
      a[1] = 0.0;
      a[2] = 0.0;
      b[0] = 0.0;
      b[1] = 0.0;
  }

  // Filtering on time domain.
  double w[3] = {0.0, 0.0, 0.0};
  double wt;
  for (int i = 0; i < x_length; ++i) {
    wt = x[i] + a[0] * w[0] + a[1] * w[1] + a[2] * w[2];
    y[i] = b[0] * wt + b[1] * w[0] + b[1] * w[1] + b[0] * w[2];
    w[2] = w[1];
    w[1] = w[0];
    w[0] = wt;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl -0x10(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x78(%rbp)
subl $0xa, %eax
ja 0x71be
movq -0x78(%rbp), %rax
leaq 0x15417(%rip), %rcx     # 0x1c2d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x153de(%rip), %xmm0    # 0x1c2a8
movsd %xmm0, -0x30(%rbp)
movsd 0x153c9(%rip), %xmm0    # 0x1c2a0
movsd %xmm0, -0x28(%rbp)
movsd 0x153b4(%rip), %xmm0    # 0x1c298
movsd %xmm0, -0x20(%rbp)
movsd 0x1539f(%rip), %xmm0    # 0x1c290
movsd %xmm0, -0x40(%rbp)
movsd 0x1538a(%rip), %xmm0    # 0x1c288
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
movsd 0x15370(%rip), %xmm0    # 0x1c280
movsd %xmm0, -0x30(%rbp)
movsd 0x1535b(%rip), %xmm0    # 0x1c278
movsd %xmm0, -0x28(%rbp)
movsd 0x15346(%rip), %xmm0    # 0x1c270
movsd %xmm0, -0x20(%rbp)
movsd 0x15331(%rip), %xmm0    # 0x1c268
movsd %xmm0, -0x40(%rbp)
movsd 0x1531c(%rip), %xmm0    # 0x1c260
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
movsd 0x15302(%rip), %xmm0    # 0x1c258
movsd %xmm0, -0x30(%rbp)
movsd 0x152ed(%rip), %xmm0    # 0x1c250
movsd %xmm0, -0x28(%rbp)
movsd 0x152d8(%rip), %xmm0    # 0x1c248
movsd %xmm0, -0x20(%rbp)
movsd 0x152c3(%rip), %xmm0    # 0x1c240
movsd %xmm0, -0x40(%rbp)
movsd 0x152ae(%rip), %xmm0    # 0x1c238
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
movsd 0x15294(%rip), %xmm0    # 0x1c230
movsd %xmm0, -0x30(%rbp)
movsd 0x1527f(%rip), %xmm0    # 0x1c228
movsd %xmm0, -0x28(%rbp)
movsd 0x1526a(%rip), %xmm0    # 0x1c220
movsd %xmm0, -0x20(%rbp)
movsd 0x15255(%rip), %xmm0    # 0x1c218
movsd %xmm0, -0x40(%rbp)
movsd 0x15240(%rip), %xmm0    # 0x1c210
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
movsd 0x15226(%rip), %xmm0    # 0x1c208
movsd %xmm0, -0x30(%rbp)
movsd 0x15211(%rip), %xmm0    # 0x1c200
movsd %xmm0, -0x28(%rbp)
movsd 0x151fc(%rip), %xmm0    # 0x1c1f8
movsd %xmm0, -0x20(%rbp)
movsd 0x151e7(%rip), %xmm0    # 0x1c1f0
movsd %xmm0, -0x40(%rbp)
movsd 0x151d2(%rip), %xmm0    # 0x1c1e8
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
movsd 0x151b8(%rip), %xmm0    # 0x1c1e0
movsd %xmm0, -0x30(%rbp)
movsd 0x151a3(%rip), %xmm0    # 0x1c1d8
movsd %xmm0, -0x28(%rbp)
movsd 0x1518e(%rip), %xmm0    # 0x1c1d0
movsd %xmm0, -0x20(%rbp)
movsd 0x15179(%rip), %xmm0    # 0x1c1c8
movsd %xmm0, -0x40(%rbp)
movsd 0x15164(%rip), %xmm0    # 0x1c1c0
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
movsd 0x1514a(%rip), %xmm0    # 0x1c1b8
movsd %xmm0, -0x30(%rbp)
movsd 0x15135(%rip), %xmm0    # 0x1c1b0
movsd %xmm0, -0x28(%rbp)
movsd 0x15120(%rip), %xmm0    # 0x1c1a8
movsd %xmm0, -0x20(%rbp)
movsd 0x1510b(%rip), %xmm0    # 0x1c1a0
movsd %xmm0, -0x40(%rbp)
movsd 0x150f6(%rip), %xmm0    # 0x1c198
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
movsd 0x150dc(%rip), %xmm0    # 0x1c190
movsd %xmm0, -0x30(%rbp)
movsd 0x150c7(%rip), %xmm0    # 0x1c188
movsd %xmm0, -0x28(%rbp)
movsd 0x150b2(%rip), %xmm0    # 0x1c180
movsd %xmm0, -0x20(%rbp)
movsd 0x1509d(%rip), %xmm0    # 0x1c178
movsd %xmm0, -0x40(%rbp)
movsd 0x15088(%rip), %xmm0    # 0x1c170
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
movsd 0x1506e(%rip), %xmm0    # 0x1c168
movsd %xmm0, -0x30(%rbp)
movsd 0x15059(%rip), %xmm0    # 0x1c160
movsd %xmm0, -0x28(%rbp)
movsd 0x15044(%rip), %xmm0    # 0x1c158
movsd %xmm0, -0x20(%rbp)
movsd 0x1502f(%rip), %xmm0    # 0x1c150
movsd %xmm0, -0x40(%rbp)
movsd 0x1501a(%rip), %xmm0    # 0x1c148
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
movsd 0x15000(%rip), %xmm0    # 0x1c140
movsd %xmm0, -0x30(%rbp)
movsd 0x14feb(%rip), %xmm0    # 0x1c138
movsd %xmm0, -0x28(%rbp)
movsd 0x14fd6(%rip), %xmm0    # 0x1c130
movsd %xmm0, -0x20(%rbp)
movsd 0x14fc1(%rip), %xmm0    # 0x1c128
movsd %xmm0, -0x40(%rbp)
movsd 0x14fac(%rip), %xmm0    # 0x1c120
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
movsd 0x14f95(%rip), %xmm0    # 0x1c118
movsd %xmm0, -0x30(%rbp)
movsd 0x14f80(%rip), %xmm0    # 0x1c110
movsd %xmm0, -0x28(%rbp)
movsd 0x14f6b(%rip), %xmm0    # 0x1c108
movsd %xmm0, -0x20(%rbp)
movsd 0x14f56(%rip), %xmm0    # 0x1c100
movsd %xmm0, -0x40(%rbp)
movsd 0x14f41(%rip), %xmm0    # 0x1c0f8
movsd %xmm0, -0x38(%rbp)
jmp 0x71e6
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
leaq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x1080
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x72ca
movq -0x8(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x30(%rbp), %xmm0
movsd -0x60(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd -0x28(%rbp), %xmm1
movsd -0x58(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x20(%rbp), %xmm0
movsd -0x50(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x68(%rbp), %xmm2
movsd -0x38(%rbp), %xmm1
mulsd -0x60(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd -0x38(%rbp), %xmm1
movsd -0x58(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd -0x40(%rbp), %xmm0
movsd -0x50(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x71fd
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)