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

  int i;
  double sum;

  if ((index_int_y1_over_y2_dx == index_x) || (index_int_y1_over_y2_dx == index_y1) || (index_int_y1_over_y2_dx == index_y2)) {
    class_sprintf(errmsg,"%s(L:%d) : Output column %d must differ from input columns %d, %d and %d",__func__,__LINE__,index_int_y1_over_y2_dx,index_x,index_y1,index_y2);
    return _FAILURE_;
  }

  sum=0.;

  *(array+0*n_columns+index_int_y1_over_y2_dx)=sum;

  for (i=1; i<n_lines; i++) {

    sum += 0.5 * (*(array+i*n_columns+index_y1) / *(array+i*n_columns+index_y2)
		  + *(array+(i-1)*n_columns+index_y1) / *(array+(i-1)*n_columns+index_y2))
      * (*(array+i*n_columns+index_x) - *(array+(i-1)*n_columns+index_x));

    *(array+i*n_columns+index_int_y1_over_y2_dx)=sum;
  }


  return _SUCCESS_;
}

// Assembly:
subq $0x58, %rsp
movq 0x68(%rsp), %rax
movl 0x60(%rsp), %eax
movq %rdi, 0x48(%rsp)
movl %esi, 0x44(%rsp)
movl %edx, 0x40(%rsp)
movl %ecx, 0x3c(%rsp)
movl %r8d, 0x38(%rsp)
movl %r9d, 0x34(%rsp)
movl 0x60(%rsp), %eax
cmpl 0x3c(%rsp), %eax
je 0x2339a
movl 0x60(%rsp), %eax
cmpl 0x38(%rsp), %eax
je 0x2339a
movl 0x60(%rsp), %eax
cmpl 0x34(%rsp), %eax
jne 0x23439
jmp 0x2339c
movl 0x60(%rsp), %r9d
movl 0x3c(%rsp), %r11d
movl 0x38(%rsp), %r10d
movl 0x34(%rsp), %eax
xorl %ecx, %ecx
movl %ecx, %esi
leaq 0x1b0ced(%rip), %rdx    # 0x1d40a7
leaq 0x1b0d2f(%rip), %rcx    # 0x1d40f0
movl $0x653, %r8d            # imm = 0x653
movq %rsi, %rdi
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x8540
movl %eax, 0x24(%rsp)
movq 0x68(%rsp), %rdi
movl 0x24(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
movl 0x60(%rsp), %r9d
movl 0x3c(%rsp), %r11d
movl 0x38(%rsp), %r10d
movl 0x34(%rsp), %eax
leaq 0x1b0c9c(%rip), %rdx    # 0x1d40a7
leaq 0x1b0cde(%rip), %rcx    # 0x1d40f0
movl $0x653, %r8d            # imm = 0x653
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x8540
movl $0x1, 0x54(%rsp)
jmp 0x235b5
xorps %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
movq 0x48(%rsp), %rax
imull $0x0, 0x44(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x60(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x1, 0x30(%rsp)
movl 0x30(%rsp), %eax
cmpl 0x40(%rsp), %eax
jge 0x235ad
movq 0x48(%rsp), %rax
movl 0x30(%rsp), %ecx
imull 0x44(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq 0x48(%rsp), %rax
movl 0x30(%rsp), %ecx
imull 0x44(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x34(%rsp), %rcx
divsd (%rax,%rcx,8), %xmm1
movq 0x48(%rsp), %rax
movl 0x30(%rsp), %ecx
subl $0x1, %ecx
imull 0x44(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x38(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x48(%rsp), %rax
movl 0x30(%rsp), %ecx
subl $0x1, %ecx
imull 0x44(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x34(%rsp), %rcx
divsd (%rax,%rcx,8), %xmm0
addsd %xmm0, %xmm1
movsd 0x1af772(%rip), %xmm0   # 0x1d2c88
mulsd %xmm1, %xmm0
movq 0x48(%rsp), %rax
movl 0x30(%rsp), %ecx
imull 0x44(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x3c(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm2
movq 0x48(%rsp), %rax
movl 0x30(%rsp), %ecx
subl $0x1, %ecx
imull 0x44(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x3c(%rsp), %rcx
subsd (%rax,%rcx,8), %xmm2
movsd 0x28(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
movq 0x48(%rsp), %rax
movl 0x30(%rsp), %ecx
imull 0x44(%rsp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq 0x60(%rsp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
jmp 0x2346e
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nop