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

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

  pin->chix_size = 0;

  /** - Read file header */
  /* 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_x_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->chix_size)) != 1,
                 pin->error_message,
                 "could not read the initial integer of number of lines in line %i in file '%s' \n",
                 headlines, chi_x_file);

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

  /** - Read file */
  for(index_x = 0; index_x < pin->chix_size;++index_x){
    /* Read coefficients */
    class_test(fscanf(fA,"%lg %lg %lg %lg %lg %lg",
                      &(pin->chix_table[index_x*(2*pin->dep_size+1)+0]), //x
                      &(pin->chix_table[index_x*(2*pin->dep_size+1)+1+pin->index_dep_heat]), //heat
                      &(pin->chix_table[index_x*(2*pin->dep_size+1)+1+pin->index_dep_lya]), //lya
                      &(pin->chix_table[index_x*(2*pin->dep_size+1)+1+pin->index_dep_ionH]), //ionH
                      &(pin->chix_table[index_x*(2*pin->dep_size+1)+1+pin->index_dep_ionHe]), //ionHe
                      &(pin->chix_table[index_x*(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_x+headlines,chi_x_file);
  }

  fclose(fA);

  /** - Spline file contents */
  /* Spline in one dimension */
  for(index_dep=0;index_dep<pin->dep_size;++index_dep){
    class_call(array_spline(pin->chix_table,
                            2*pin->dep_size+1,
                            pin->chix_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
movl $0x0, 0x520(%rsi)
leaq 0x3c489(%rip), %rsi     # 0x10fd84
movq %rdx, %rdi
callq 0x8400
testq %rax, %rax
je 0xd3af3
movq %rax, %r15
leaq 0x520(%rbx), %r12
xorl %ebp, %ebp
leaq 0x810(%rsp), %r13
movq %r13, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq %r15, %rdx
callq 0x8540
testq %rax, %rax
je 0xd39a0
movq %r13, %rcx
movb (%rcx), %al
incq %rcx
cmpb $0x20, %al
je 0xd3938
incl %ebp
cmpb $0x28, %al
jl 0xd3920
leaq 0x2c7d1(%rip), %rsi     # 0x10011f
leaq 0x810(%rsp), %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x8390
cmpl $0x1, %eax
jne 0xd3b3f
movslq 0x54c(%rbx), %rax
leaq 0x1(,%rax,2), %rax
movslq 0x520(%rbx), %r13
imulq %rax, %r13
leaq (,%r13,8), %rdi
callq 0x8460
movq %rax, 0x518(%rbx)
testq %rax, %rax
je 0xd3c01
movq %r14, 0x8(%rsp)
cmpl $0x0, (%r12)
jle 0xd3a58
leaq 0x58bf8(%rip), %r13     # 0x12c5af
xorl %r14d, %r14d
movq 0x518(%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 0x8690
addq $0x10, %rsp
cmpl $0x6, %eax
jne 0xd3b9f
incl %r14d
cmpl (%r12), %r14d
jl 0xd39ba
movq %r15, %rdi
callq 0x83a0
leaq 0x570(%rbx), %r14
movl $0x1, %r15d
xorl %ebp, %ebp
leal -0x1(%r15), %eax
movl 0x54c(%rbx), %r9d
cmpl %r9d, %eax
jge 0xd3c51
movq 0x518(%rbx), %rdi
leal 0x1(,%r9,2), %esi
movl 0x520(%rbx), %edx
addl %r15d, %r9d
xorl %ecx, %ecx
movl %r15d, %r8d
pushq %r14
pushq $0x0
callq 0x136a5
addq $0x10, %rsp
incl %r15d
cmpl $0x1, %eax
jne 0xd3a6f
leaq 0x1d934(%rip), %rsi     # 0xf13f0
leaq 0x58f5f(%rip), %rdx     # 0x12ca22
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x1d558(%rip), %rsi     # 0xf1034
leaq 0x58d27(%rip), %rdx     # 0x12c80a
movq %r14, %rdi
movl $0x573, %ecx            # imm = 0x573
movq %rbx, %r8
jmp 0xd3c45
leaq 0x1fede(%rip), %rsi     # 0xf39d8
leaq 0x3d27f(%rip), %rdx     # 0x110d80
leaq 0x1ff05(%rip), %r8      # 0xf3a0d
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x570, %rbx            # imm = 0x570
leaq 0x1d50c(%rip), %rsi     # 0xf1034
leaq 0x58cdb(%rip), %rdx     # 0x12c80a
movq %rbx, %rdi
movl $0x535, %ecx            # imm = 0x535
movq %r15, %r8
jmp 0xd3c45
leaq 0x5888d(%rip), %rsi     # 0x12c3d3
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl %ebp, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x1d521(%rip), %rsi     # 0xf1082
leaq 0x58cc1(%rip), %rdx     # 0x12c829
leaq 0xc10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x570, %rbx            # imm = 0x570
leaq 0x1d4a9(%rip), %rsi     # 0xf1034
leaq 0x58c78(%rip), %rdx     # 0x12c80a
movq %rbx, %rdi
movl $0x54b, %ecx            # imm = 0x54B
jmp 0xd3c42
addl %r14d, %ebp
leaq 0x588b5(%rip), %rsi     # 0x12c45e
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x1d4bc(%rip), %rsi     # 0xf1082
leaq 0x58c95(%rip), %rdx     # 0x12c862
leaq 0xc10(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x570, %rbx            # imm = 0x570
leaq 0x1d444(%rip), %rsi     # 0xf1034
leaq 0x58c13(%rip), %rdx     # 0x12c80a
movq %rbx, %rdi
movl $0x562, %ecx            # imm = 0x562
jmp 0xd3c42
shll $0x3, %r13d
leaq 0x1d3f8(%rip), %rsi     # 0xf1004
leaq 0x58c3f(%rip), %rdx     # 0x12c852
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x570, %rbx            # imm = 0x570
leaq 0x1d401(%rip), %rsi     # 0xf1034
leaq 0x58bd0(%rip), %rdx     # 0x12c80a
movq %rbx, %rdi
movl $0x550, %ecx            # imm = 0x550
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %ebp
movl %ebp, %eax
addq $0x1418, %rsp           # imm = 0x1418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq