// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_smooth_trg(double*, int, int, int, int, int, char*)
int array_smooth_trg(double * array,
		     int k_size,
		     int starting_k,
		     int eta_size,
		     int index_eta,
		     int radius, /*3, 5 or 7 */
		     ErrorMsg errmsg) {

  double * smooth;
  int i,j,jmin,jmax;
  double weigth;
  double *coeff;

  smooth=(double*)malloc(k_size*sizeof(double));
  if (smooth == NULL) {
    class_sprintf(errmsg,"%s(L:%d) Cannot allocate smooth",__func__,__LINE__);
    return _FAILURE_;
  }

  class_calloc(coeff,2*radius+1,sizeof(double),errmsg);

  switch(radius){
  case 3:
    weigth = 21;

    coeff[0] = -2;
    coeff[1] = 3;
    coeff[2] = 6;
    coeff[3] = 7;
    coeff[4] = 6;
    coeff[5] = 3;
    coeff[6] = -2;

    break;
  case 4:
    weigth = 231;

    coeff[0] = -21;
    coeff[1] = 14;
    coeff[2] = 39;
    coeff[3] = 54;
    coeff[4] = 59;
    coeff[5] = 54;
    coeff[6] = 39;
    coeff[7] = 14;
    coeff[8] = -21;

    break;
  case 5:
    weigth = 429;

    coeff[0] = -36;
    coeff[1] = 9;
    coeff[2] = 44;
    coeff[3] = 69;
    coeff[4] = 84;
    coeff[5] = 89;
    coeff[6] = 84;
    coeff[7] = 69;
    coeff[8] = 44;
    coeff[9] = 9;
    coeff[10] = -36;

    break;
  case 6:
    weigth = 143;

    coeff[0] = -11;
    coeff[1] = 0;
    coeff[2] = 9;
    coeff[3] = 16;
    coeff[4] = 21;
    coeff[5] = 24;
    coeff[6] = 25;
    coeff[7] = 24;
    coeff[8] = 21;
    coeff[9] = 16;
    coeff[10] = 9;
    coeff[11] = 0;
    coeff[12] = -11;

    break;
  case 7:
    weigth = 1105;

    coeff[0] = -78;
    coeff[1] = -13;
    coeff[2] = 42;
    coeff[3] = 87;
    coeff[4] = 122;
    coeff[5] = 147;
    coeff[6] = 162;
    coeff[7] = 167;
    coeff[8] = 162;
    coeff[9] = 147;
    coeff[10] = 122;
    coeff[11] = 87;
    coeff[12] = 42;
    coeff[13] = -13;
    coeff[14] = -78;

    break;

/*   case 8: */


  default:
    class_stop(errmsg,"Non valid radius %d: please chose between 3 4 5 or 6\n",radius);
    weigth=0;
    break;
  }

  for (i=starting_k; i<k_size-radius; i++) {
      smooth[i]=0.;
      jmin = MAX(i-radius,0);
      jmax = MIN(i+radius,k_size-1);
      for (j=jmin; j <= jmax; j++) {
	smooth[i] += coeff[j-jmin]*array[j+k_size*index_eta];
      }
      smooth[i] /= weigth;
  }

  for (i=starting_k; i<k_size-radius; i++)
    array[i+k_size*index_eta] = smooth[i];

  free(smooth);
  free(coeff);

  return _SUCCESS_;

}

// Assembly:
subq $0x1868, %rsp           # imm = 0x1868
movq 0x1870(%rsp), %rax
movq %rdi, 0x1858(%rsp)
movl %esi, 0x1854(%rsp)
movl %edx, 0x1850(%rsp)
movl %ecx, 0x184c(%rsp)
movl %r8d, 0x1848(%rsp)
movl %r9d, 0x1844(%rsp)
movslq 0x1854(%rsp), %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, 0x1838(%rsp)
cmpq $0x0, 0x1838(%rsp)
jne 0x29e4b
jmp 0x29de2
xorl %eax, %eax
movl %eax, %esi
leaq 0x1aa75e(%rip), %rdx    # 0x1d454b
leaq 0x1aa777(%rip), %rcx    # 0x1d456b
movl $0xc47, %r8d            # imm = 0xC47
movq %rsi, %rdi
movb $0x0, %al
callq 0x8540
movl %eax, 0x1814(%rsp)
movq 0x1870(%rsp), %rdi
movl 0x1814(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0x1aa724(%rip), %rdx    # 0x1d454b
leaq 0x1aa73d(%rip), %rcx    # 0x1d456b
movl $0xc47, %r8d            # imm = 0xC47
movb $0x0, %al
callq 0x8540
movl $0x1, 0x1864(%rsp)
jmp 0x2a693
movl 0x1844(%rsp), %eax
shll %eax
addl $0x1, %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x8280
movq %rax, 0x1818(%rsp)
cmpq $0x0, 0x1818(%rsp)
jne 0x29ee0
movl $0x8, 0x1810(%rsp)
leaq 0x1010(%rsp), %rdi
movl 0x1810(%rsp), %ecx
leaq 0x1a816c(%rip), %rsi    # 0x1d2004
leaq 0x1aa6dd(%rip), %rdx    # 0x1d457c
movb $0x0, %al
callq 0x5b9c0
movq 0x1870(%rsp), %rdi
leaq 0x1010(%rsp), %r8
leaq 0x1a8177(%rip), %rsi    # 0x1d2034
leaq 0x1aa6a7(%rip), %rdx    # 0x1d456b
movl $0xc4b, %ecx            # imm = 0xC4B
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x1864(%rsp)
jmp 0x2a693
movl 0x1844(%rsp), %eax
addl $-0x3, %eax
movl %eax, %ecx
movq %rcx, 0x8(%rsp)
subl $0x4, %eax
ja 0x2a3ee
movq 0x8(%rsp), %rax
leaq 0x1a988a(%rip), %rcx    # 0x1d3790
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x1a97f1(%rip), %xmm0   # 0x1d3708
movsd %xmm0, 0x1820(%rsp)
movq 0x1818(%rsp), %rax
movsd 0x1a9850(%rip), %xmm0   # 0x1d3780
movsd %xmm0, (%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9754(%rip), %xmm0   # 0x1d3698
movsd %xmm0, 0x8(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a972f(%rip), %xmm0   # 0x1d3688
movsd %xmm0, 0x10(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a981a(%rip), %xmm0   # 0x1d3788
movsd %xmm0, 0x18(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9705(%rip), %xmm0   # 0x1d3688
movsd %xmm0, 0x20(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9700(%rip), %xmm0   # 0x1d3698
movsd %xmm0, 0x28(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a97d3(%rip), %xmm0   # 0x1d3780
movsd %xmm0, 0x30(%rax)
jmp 0x2a45d
movsd 0x1a97b9(%rip), %xmm0   # 0x1d3778
movsd %xmm0, 0x1820(%rsp)
movq 0x1818(%rsp), %rax
movsd 0x1a9778(%rip), %xmm0   # 0x1d3750
movsd %xmm0, (%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a976c(%rip), %xmm0   # 0x1d3758
movsd %xmm0, 0x8(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a975f(%rip), %xmm0   # 0x1d3760
movsd %xmm0, 0x10(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9752(%rip), %xmm0   # 0x1d3768
movsd %xmm0, 0x18(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9745(%rip), %xmm0   # 0x1d3770
movsd %xmm0, 0x20(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9728(%rip), %xmm0   # 0x1d3768
movsd %xmm0, 0x28(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a970b(%rip), %xmm0   # 0x1d3760
movsd %xmm0, 0x30(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a96ee(%rip), %xmm0   # 0x1d3758
movsd %xmm0, 0x38(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a96d1(%rip), %xmm0   # 0x1d3750
movsd %xmm0, 0x40(%rax)
jmp 0x2a45d
movsd 0x1a96b7(%rip), %xmm0   # 0x1d3748
movsd %xmm0, 0x1820(%rsp)
movq 0x1818(%rsp), %rax
movsd 0x1a9676(%rip), %xmm0   # 0x1d3720
movsd %xmm0, (%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9642(%rip), %xmm0   # 0x1d3700
movsd %xmm0, 0x8(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9655(%rip), %xmm0   # 0x1d3728
movsd %xmm0, 0x10(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9648(%rip), %xmm0   # 0x1d3730
movsd %xmm0, 0x18(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a963b(%rip), %xmm0   # 0x1d3738
movsd %xmm0, 0x20(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a962e(%rip), %xmm0   # 0x1d3740
movsd %xmm0, 0x28(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9611(%rip), %xmm0   # 0x1d3738
movsd %xmm0, 0x30(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a95f4(%rip), %xmm0   # 0x1d3730
movsd %xmm0, 0x38(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a95d7(%rip), %xmm0   # 0x1d3728
movsd %xmm0, 0x40(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a959a(%rip), %xmm0   # 0x1d3700
movsd %xmm0, 0x48(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a95a5(%rip), %xmm0   # 0x1d3720
movsd %xmm0, 0x50(%rax)
jmp 0x2a45d
movsd 0x1a958b(%rip), %xmm0   # 0x1d3718
movsd %xmm0, 0x1820(%rsp)
movq 0x1818(%rsp), %rax
movsd 0x1a9552(%rip), %xmm0   # 0x1d36f8
movsd %xmm0, (%rax)
movq 0x1818(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9536(%rip), %xmm0   # 0x1d3700
movsd %xmm0, 0x10(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a85f9(%rip), %xmm0   # 0x1d27d8
movsd %xmm0, 0x18(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9514(%rip), %xmm0   # 0x1d3708
movsd %xmm0, 0x20(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9487(%rip), %xmm0   # 0x1d3690
movsd %xmm0, 0x28(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a94f2(%rip), %xmm0   # 0x1d3710
movsd %xmm0, 0x30(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a945d(%rip), %xmm0   # 0x1d3690
movsd %xmm0, 0x38(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a94c0(%rip), %xmm0   # 0x1d3708
movsd %xmm0, 0x40(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a857b(%rip), %xmm0   # 0x1d27d8
movsd %xmm0, 0x48(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a948e(%rip), %xmm0   # 0x1d3700
movsd %xmm0, 0x50(%rax)
movq 0x1818(%rsp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x58(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9461(%rip), %xmm0   # 0x1d36f8
movsd %xmm0, 0x60(%rax)
jmp 0x2a45d
movsd 0x1a9447(%rip), %xmm0   # 0x1d36f0
movsd %xmm0, 0x1820(%rsp)
movq 0x1818(%rsp), %rax
movsd 0x1a93ee(%rip), %xmm0   # 0x1d36b0
movsd %xmm0, (%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a93e2(%rip), %xmm0   # 0x1d36b8
movsd %xmm0, 0x8(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a93d5(%rip), %xmm0   # 0x1d36c0
movsd %xmm0, 0x10(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a93c8(%rip), %xmm0   # 0x1d36c8
movsd %xmm0, 0x18(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a93bb(%rip), %xmm0   # 0x1d36d0
movsd %xmm0, 0x20(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a93ae(%rip), %xmm0   # 0x1d36d8
movsd %xmm0, 0x28(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a93a1(%rip), %xmm0   # 0x1d36e0
movsd %xmm0, 0x30(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9394(%rip), %xmm0   # 0x1d36e8
movsd %xmm0, 0x38(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9377(%rip), %xmm0   # 0x1d36e0
movsd %xmm0, 0x40(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a935a(%rip), %xmm0   # 0x1d36d8
movsd %xmm0, 0x48(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a933d(%rip), %xmm0   # 0x1d36d0
movsd %xmm0, 0x50(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9320(%rip), %xmm0   # 0x1d36c8
movsd %xmm0, 0x58(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a9303(%rip), %xmm0   # 0x1d36c0
movsd %xmm0, 0x60(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a92e6(%rip), %xmm0   # 0x1d36b8
movsd %xmm0, 0x68(%rax)
movq 0x1818(%rsp), %rax
movsd 0x1a92c9(%rip), %xmm0   # 0x1d36b0
movsd %xmm0, 0x70(%rax)
jmp 0x2a45d
leaq 0x810(%rsp), %rdi
movl 0x1844(%rsp), %edx
leaq 0x1aa17e(%rip), %rsi    # 0x1d4582
movb $0x0, %al
callq 0x5b9c0
leaq 0x10(%rsp), %rdi
leaq 0x810(%rsp), %rdx
leaq 0x1a814e(%rip), %rsi    # 0x1d256d
movb $0x0, %al
callq 0x5b9c0
movq 0x1870(%rsp), %rdi
leaq 0x10(%rsp), %r8
leaq 0x1a7bfa(%rip), %rsi    # 0x1d2034
leaq 0x1aa12a(%rip), %rdx    # 0x1d456b
movl $0xca3, %ecx            # imm = 0xCA3
movb $0x0, %al
callq 0x5b9c0
movl $0x1, 0x1864(%rsp)
jmp 0x2a693
movl 0x1850(%rsp), %eax
movl %eax, 0x1834(%rsp)
movl 0x1834(%rsp), %eax
movl 0x1854(%rsp), %ecx
subl 0x1844(%rsp), %ecx
cmpl %ecx, %eax
jge 0x2a5f7
movq 0x1838(%rsp), %rax
movslq 0x1834(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x1834(%rsp), %eax
subl 0x1844(%rsp), %eax
cmpl $0x0, %eax
jge 0x2a4bb
xorl %eax, %eax
movl %eax, 0x4(%rsp)
jmp 0x2a4cd
movl 0x1834(%rsp), %eax
subl 0x1844(%rsp), %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x182c(%rsp)
movl 0x1834(%rsp), %eax
addl 0x1844(%rsp), %eax
movl 0x1854(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2a507
movl 0x1834(%rsp), %eax
addl 0x1844(%rsp), %eax
movl %eax, (%rsp)
jmp 0x2a514
movl 0x1854(%rsp), %eax
subl $0x1, %eax
movl %eax, (%rsp)
movl (%rsp), %eax
movl %eax, 0x1828(%rsp)
movl 0x182c(%rsp), %eax
movl %eax, 0x1830(%rsp)
movl 0x1830(%rsp), %eax
cmpl 0x1828(%rsp), %eax
jg 0x2a5ba
movq 0x1818(%rsp), %rax
movl 0x1830(%rsp), %ecx
subl 0x182c(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1858(%rsp), %rax
movl 0x1830(%rsp), %ecx
movl 0x1854(%rsp), %edx
imull 0x1848(%rsp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0x1838(%rsp), %rax
movslq 0x1834(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x1830(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1830(%rsp)
jmp 0x2a52c
movsd 0x1820(%rsp), %xmm1
movq 0x1838(%rsp), %rax
movslq 0x1834(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x1834(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1834(%rsp)
jmp 0x2a46b
movl 0x1850(%rsp), %eax
movl %eax, 0x1834(%rsp)
movl 0x1834(%rsp), %eax
movl 0x1854(%rsp), %ecx
subl 0x1844(%rsp), %ecx
cmpl %ecx, %eax
jge 0x2a66e
movq 0x1838(%rsp), %rax
movslq 0x1834(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x1858(%rsp), %rax
movl 0x1834(%rsp), %ecx
movl 0x1854(%rsp), %edx
imull 0x1848(%rsp), %edx
addl %edx, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x1834(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1834(%rsp)
jmp 0x2a605
movq 0x1838(%rsp), %rdi
callq 0x8420
movq 0x1818(%rsp), %rdi
callq 0x8420
movl $0x0, 0x1864(%rsp)
movl 0x1864(%rsp), %eax
addq $0x1868, %rsp           # imm = 0x1868
retq
nopw %cs:(%rax,%rax)