// File: /workspace/github_c_makefile_star2_O2/PoulinV[P]AxiCLASS/build/../external/heating/injection.c
// Function: injection_read_chi_z_from_file
int injection_read_chi_z_from_file(struct precision* ppr,
                                   struct injection* pin,
                                   char* chi_z_file){

  /** Define local variables */
  FILE * fA;
  char line[_LINE_LENGTH_MAX_];
  char * left;
  int headlines = 0;
  int index_z,index_dep;

  pin->chiz_size = 0;

  /* The file is assumed to contain:
   *    - The number of lines of the file
   *    - The columns (xe , chi_heat, chi_Lya, chi_H, chi_He, chi_lowE) where chi_i represents the
   *      branching ratio at redshift z into different injection/ionization channels i */

  class_open(fA, chi_z_file, "r", pin->error_message);

  while (fgets(line,_LINE_LENGTH_MAX_-1,fA) != NULL) {
    headlines++;

    /* Eliminate blank spaces at beginning of line */
    left=line;
    while (left[0]==' ') {
      left++;
    }

    /* Check that the line is neither blank nor a comment. In ASCII, left[0]>39 means that first non-blank charachter might
       be the beginning of some data (it is not a newline, a #, a %, etc.) */
    if (left[0] > 39) {

      /* If the line contains data, we must interprete it. If num_lines == 0 , the current line must contain
         its value. Otherwise, it must contain (xe , chi_heat, chi_Lya, chi_H, chi_He, chi_lowE). */

      /* Read num_lines, infer size of arrays and allocate them */
      class_test(sscanf(line,"%d",&(pin->chiz_size)) != 1,
                 pin->error_message,
                 "could not read the initial integer of number of lines in line %i in file '%s' \n",
                 headlines,chi_z_file);

      /* (z, chi_i)*/
      class_alloc(pin->chiz_table,
                  (2*pin->dep_size+1)*pin->chiz_size*sizeof(double),
                  pin->error_message);
      break;
    }
  }

  for(index_z=0;index_z<pin->chiz_size;++index_z){
    /* Read coefficients */
    class_test(fscanf(fA,"%lg %lg %lg %lg %lg %lg",
                      &(pin->chiz_table[index_z*(2*pin->dep_size+1)+0]), //z
                      &(pin->chiz_table[index_z*(2*pin->dep_size+1)+1+pin->index_dep_heat]), //heat
                      &(pin->chiz_table[index_z*(2*pin->dep_size+1)+1+pin->index_dep_lya]), //lya
                      &(pin->chiz_table[index_z*(2*pin->dep_size+1)+1+pin->index_dep_ionH]), //ionH
                      &(pin->chiz_table[index_z*(2*pin->dep_size+1)+1+pin->index_dep_ionHe]), //ionHe
                      &(pin->chiz_table[index_z*(2*pin->dep_size+1)+1+pin->index_dep_lowE])  //lowE
                     )!= 6,
               pin->error_message,
               "could not read value of parameters coefficients in line %i in file '%s'\n",
               index_z+headlines,chi_z_file);
  }

  fclose(fA);

  /* Spline in one dimension */
  for(index_dep=0;index_dep<pin->dep_size;++index_dep){
    class_call(array_spline(pin->chiz_table,
                            2*pin->dep_size+1,
                            pin->chiz_size,
                            0,
                            1+index_dep,
                            1+index_dep+pin->dep_size,
                            _SPLINE_NATURAL_,
                            pin->error_message),
               pin->error_message,
               pin->error_message);
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1418, %rsp           # imm = 0x1418
movq %rdx, %r14
movq %rsi, %rbx
andl $0x0, 0x510(%rsi)
leaq 0x3afa8(%rip), %rsi     # 0x103c64
movq %rdx, %rdi
callq 0x8420
testq %rax, %rax
je 0xc8e11
movq %rax, %r15
leaq 0x510(%rbx), %r12
xorl %ebp, %ebp
leaq 0x810(%rsp), %r13
movq %r13, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq %r15, %rdx
callq 0x8570
testq %rax, %rax
je 0xc8d61
movq %r13, %rcx
movb (%rcx), %al
incq %rcx
cmpb $0x20, %al
je 0xc8cf9
incl %ebp
cmpb $0x28, %al
jl 0xc8ce1
leaq 0x2b300(%rip), %rsi     # 0xf400f
leaq 0x810(%rsp), %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x83b0
cmpl $0x1, %eax
jne 0xc8f59
movslq 0x54c(%rbx), %rax
leaq 0x1(,%rax,2), %rax
movslq 0x510(%rbx), %r13
imulq %rax, %r13
leaq (,%r13,8), %rdi
callq 0x8490
movq %rax, 0x508(%rbx)
testq %rax, %rax
je 0xc8fb6
movq %r14, 0x8(%rsp)
leaq 0x57722(%rip), %r13     # 0x12048f
xorl %r14d, %r14d
cmpl (%r12), %r14d
jge 0xc8e5d
movq 0x508(%rbx), %rax
movslq 0x54c(%rbx), %rcx
leaq 0x1(,%rcx,2), %rcx
movslq %r14d, %rsi
imulq %rcx, %rsi
leaq (%rax,%rsi,8), %rdx
movslq %esi, %rsi
movslq 0x538(%rbx), %rcx
addq %rsi, %rcx
incq %rcx
incq %rsi
leaq (%rax,%rcx,8), %rcx
movslq 0x544(%rbx), %rdi
movslq %esi, %rsi
addq %rsi, %rdi
leaq (%rax,%rdi,8), %r8
movslq 0x53c(%rbx), %rdi
addq %rsi, %rdi
leaq (%rax,%rdi,8), %r9
movslq 0x540(%rbx), %rdi
addq %rsi, %rdi
leaq (%rax,%rdi,8), %r10
movslq 0x548(%rbx), %rdi
addq %rsi, %rdi
leaq (%rax,%rdi,8), %r11
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x86c0
popq %rcx
popq %rdx
cmpl $0x6, %eax
jne 0xc8ef4
incl %r14d
jmp 0xc8d70
leaq 0x1eb90(%rip), %rsi     # 0xe79a8
leaq 0x3be51(%rip), %rdx     # 0x104c70
leaq 0x1ebb7(%rip), %r8      # 0xe79dd
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x570, %rbx            # imm = 0x570
leaq 0x1c1ee(%rip), %rsi     # 0xe5034
leaq 0x575ea(%rip), %rdx     # 0x120437
movq %rbx, %rdi
movl $0x4d7, %ecx            # imm = 0x4D7
movq %r15, %r8
jmp 0xc8ffa
movq %r15, %rdi
callq 0x83c0
leaq 0x570(%rbx), %r14
pushq $0x1
popq %r15
xorl %ebp, %ebp
leal -0x1(%r15), %eax
movl 0x54c(%rbx), %r9d
cmpl %r9d, %eax
jge 0xc9004
movq 0x508(%rbx), %rdi
leal 0x1(,%r9,2), %esi
movl 0x510(%rbx), %edx
addl %r15d, %r9d
xorl %ecx, %ecx
movl %r15d, %r8d
pushq %r14
pushq $0x0
callq 0x11b09
popq %rcx
popq %rdx
incl %r15d
cmpl $0x1, %eax
jne 0xc8e72
leaq 0x1c533(%rip), %rsi     # 0xe53f0
leaq 0x577a3(%rip), %rdx     # 0x120667
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x1c157(%rip), %rsi     # 0xe5034
leaq 0x57553(%rip), %rdx     # 0x120437
movq %r14, %rdi
movl $0x513, %ecx            # imm = 0x513
movq %rbx, %r8
jmp 0xc8ffa
addl %r14d, %ebp
leaq 0x57440(%rip), %rsi     # 0x12033e
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x1c167(%rip), %rsi     # 0xe5082
leaq 0x57585(%rip), %rdx     # 0x1204a7
leaq 0xc10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x570, %rbx            # imm = 0x570
leaq 0x1c0ef(%rip), %rsi     # 0xe5034
leaq 0x574eb(%rip), %rdx     # 0x120437
movq %rbx, %rdi
movl $0x503, %ecx            # imm = 0x503
jmp 0xc8ff7
leaq 0x57353(%rip), %rsi     # 0x1202b3
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl %ebp, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x1c107(%rip), %rsi     # 0xe5082
leaq 0x574d4(%rip), %rdx     # 0x120456
leaq 0xc10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x570, %rbx            # imm = 0x570
leaq 0x1c08f(%rip), %rsi     # 0xe5034
leaq 0x5748b(%rip), %rdx     # 0x120437
movq %rbx, %rdi
movl $0x4ed, %ecx            # imm = 0x4ED
jmp 0xc8ff7
shll $0x3, %r13d
leaq 0x1c043(%rip), %rsi     # 0xe5004
leaq 0x574b7(%rip), %rdx     # 0x12047f
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x570, %rbx            # imm = 0x570
leaq 0x1c04c(%rip), %rsi     # 0xe5034
leaq 0x57448(%rip), %rdx     # 0x120437
movq %rbx, %rdi
movl $0x4f2, %ecx            # imm = 0x4F2
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x1418, %rsp           # imm = 0x1418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq