// File: /workspace/github_c_makefile_star2_O0/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_smooth
int array_smooth(double * array,
		 int n_columns,
		 int n_lines,
		 int index, /** from 0 to (n_columns-1) */
		 int radius,
		 ErrorMsg errmsg) {

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

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

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

  for (i=0; i<n_lines; i++)
    array[i*n_columns+index] = smooth[i];

  free(smooth);

  return _SUCCESS_;

}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movl %esi, 0x44(%rsp)
movl %edx, 0x40(%rsp)
movl %ecx, 0x3c(%rsp)
movl %r8d, 0x38(%rsp)
movq %r9, 0x30(%rsp)
movslq 0x40(%rsp), %rdi
shlq $0x3, %rdi
callq 0x8460
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x2a749
jmp 0x2a6ec
xorl %eax, %eax
movl %eax, %esi
leaq 0x1a9e54(%rip), %rdx    # 0x1d454b
leaq 0x1a9eba(%rip), %rcx    # 0x1d45b8
movl $0xcc9, %r8d            # imm = 0xCC9
movq %rsi, %rdi
movb $0x0, %al
callq 0x8540
movl %eax, 0xc(%rsp)
movq 0x30(%rsp), %rdi
movl 0xc(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0x1a9e23(%rip), %rdx    # 0x1d454b
leaq 0x1a9e89(%rip), %rcx    # 0x1d45b8
movl $0xcc9, %r8d            # imm = 0xCC9
movb $0x0, %al
callq 0x8540
movl $0x1, 0x54(%rsp)
jmp 0x2a8c0
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x40(%rsp), %eax
jge 0x2a866
movq 0x28(%rsp), %rax
movslq 0x24(%rsp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x24(%rsp), %eax
subl 0x38(%rsp), %eax
cmpl $0x0, %eax
jge 0x2a78f
xorl %eax, %eax
movl %eax, 0x8(%rsp)
jmp 0x2a79b
movl 0x24(%rsp), %eax
subl 0x38(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x1c(%rsp)
movl 0x24(%rsp), %eax
addl 0x38(%rsp), %eax
movl 0x40(%rsp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x2a7c4
movl 0x24(%rsp), %eax
addl 0x38(%rsp), %eax
movl %eax, 0x4(%rsp)
jmp 0x2a7cf
movl 0x40(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x20(%rsp), %eax
cmpl 0x18(%rsp), %eax
jg 0x2a838
movq 0x48(%rsp), %rax
movl 0x20(%rsp), %ecx
imull 0x44(%rsp), %ecx
addl 0x3c(%rsp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x28(%rsp), %rax
movslq 0x24(%rsp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movsd 0x1a7a29(%rip), %xmm0   # 0x1d2248
addsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
jmp 0x2a7df
movsd 0x10(%rsp), %xmm1
movq 0x28(%rsp), %rax
movslq 0x24(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x2a751
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
cmpl 0x40(%rsp), %eax
jge 0x2a8ae
movq 0x28(%rsp), %rax
movslq 0x24(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x48(%rsp), %rax
movl 0x24(%rsp), %ecx
imull 0x44(%rsp), %ecx
addl 0x3c(%rsp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x24(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
jmp 0x2a86e
movq 0x28(%rsp), %rdi
callq 0x8420
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nopl (%rax)