// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/transfer.c
// Function: transfer_global_selection_read
int transfer_global_selection_read(
                                   struct transfer * ptr
                                   ) {

  /* for reading selection function */
  FILE * input_file;
  int row,status;
  double tmp1,tmp2;

  ptr->nz_size = 0;

  if (ptr->has_nz_file == _TRUE_) {

    input_file = fopen(ptr->nz_file_name,"r");
    class_test(input_file == NULL,
               ptr->error_message,
               "Could not open file %s!",ptr->nz_file_name);

    /* Find size of table */
    for (row=0,status=2; status==2; row++){
      status = fscanf(input_file,"%lf %lf",&tmp1,&tmp2);
    }
    rewind(input_file);
    ptr->nz_size = row-1;

    /* Allocate room for interpolation table */
    class_alloc(ptr->nz_z,sizeof(double)*ptr->nz_size,ptr->error_message);
    class_alloc(ptr->nz_nz,sizeof(double)*ptr->nz_size,ptr->error_message);
    class_alloc(ptr->nz_ddnz,sizeof(double)*ptr->nz_size,ptr->error_message);

    for (row=0; row<ptr->nz_size; row++){
      status = fscanf(input_file,"%lf %lf",
                      &ptr->nz_z[row],&ptr->nz_nz[row]);
      //printf("%d: (z,dNdz) = (%g,%g)\n",row,ptr->nz_z[row],ptr->nz_nz[row]);
    }
    fclose(input_file);

    /* Call spline interpolation: */
    class_call(array_spline_table_lines(ptr->nz_z,
                                        ptr->nz_size,
                                        ptr->nz_nz,
                                        1,
                                        ptr->nz_ddnz,
                                        _SPLINE_EST_DERIV_,
                                        ptr->error_message),
               ptr->error_message,
               ptr->error_message);
  }

  ptr->nz_evo_size = 0;

  if (ptr->has_nz_evo_file == _TRUE_) {

    input_file = fopen(ptr->nz_evo_file_name,"r");
    class_test(input_file == NULL,
               ptr->error_message,
               "Could not open file %s!",ptr->nz_evo_file_name);

    /* Find size of table */
    for (row=0,status=2; status==2; row++){
      status = fscanf(input_file,"%lf %lf",&tmp1,&tmp2);
    }
    rewind(input_file);
    ptr->nz_evo_size = row-1;

    /* Allocate room for interpolation table */
    class_alloc(ptr->nz_evo_z,sizeof(double)*ptr->nz_evo_size,ptr->error_message);
    class_alloc(ptr->nz_evo_nz,sizeof(double)*ptr->nz_evo_size,ptr->error_message);
    class_alloc(ptr->nz_evo_dlog_nz,sizeof(double)*ptr->nz_evo_size,ptr->error_message);
    class_alloc(ptr->nz_evo_dd_dlog_nz,sizeof(double)*ptr->nz_evo_size,ptr->error_message);

    for (row=0; row<ptr->nz_evo_size; row++){
      status = fscanf(input_file,"%lf %lf",
                      &ptr->nz_evo_z[row],&ptr->nz_evo_nz[row]);
    }
    fclose(input_file);

    /* infer dlog(dN/dz)/dz from dN/dz */
    ptr->nz_evo_dlog_nz[0] =
      (log(ptr->nz_evo_nz[1])-log(ptr->nz_evo_nz[0]))
      /(ptr->nz_evo_z[1]-ptr->nz_evo_z[0]);
    for (row=1; row<ptr->nz_evo_size-1; row++){
      ptr->nz_evo_dlog_nz[row] =
        (log(ptr->nz_evo_nz[row+1])-log(ptr->nz_evo_nz[row-1]))
        /(ptr->nz_evo_z[row+1]-ptr->nz_evo_z[row-1]);
    }
    ptr->nz_evo_dlog_nz[ptr->nz_evo_size-1] =
      (log(ptr->nz_evo_nz[ptr->nz_evo_size-1])-log(ptr->nz_evo_nz[ptr->nz_evo_size-2]))
      /(ptr->nz_evo_z[ptr->nz_evo_size-1]-ptr->nz_evo_z[ptr->nz_evo_size-2]);

    /* to test that the file is read:
       for (row=0; row<ptr->nz_evo_size; row++){
       fprintf(stdout,"%d: (z,dNdz,dlndNdzdz) = (%g,%g,%g)\n",row,ptr->nz_evo_z[row],ptr->nz_evo_nz[row],ptr->nz_evo_dlog_nz[row]);
       }
    */

    /* Call spline interpolation: */
    class_call(array_spline_table_lines(ptr->nz_evo_z,
                                        ptr->nz_evo_size,
                                        ptr->nz_evo_dlog_nz,
                                        1,
                                        ptr->nz_evo_dd_dlog_nz,
                                        _SPLINE_EST_DERIV_,
                                        ptr->error_message),
               ptr->error_message,
               ptr->error_message);
  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1038, %rsp           # imm = 0x1038
movq %rdi, %r13
movl $0x0, 0x75c(%rdi)
cmpw $0x1, 0x658(%rdi)
jne 0xa5d91
leaq 0x65c(%r13), %r15
leaq 0x67192(%rip), %rsi     # 0x10cda4
movq %r15, %rdi
callq 0x8400
testq %rax, %rax
je 0xa5fa9
movq %rax, %r14
movq %r13, 0x18(%rsp)
movl $0x1, %ebx
movq $-0x8, %r15
leaq 0x752a4(%rip), %r12     # 0x11aee2
leaq 0x28(%rsp), %r13
leaq 0x20(%rsp), %rbp
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x8690
decl %ebx
addq $0x8, %r15
cmpl $0x2, %eax
je 0xa5c48
movq %r14, %rdi
callq 0x8060
movl %ebx, %eax
negl %eax
movq 0x18(%rsp), %r13
movl %eax, 0x75c(%r13)
movq %r15, %rdi
callq 0x8460
movq %rax, 0x760(%r13)
testq %rax, %rax
je 0xa6007
movq %r15, %rdi
callq 0x8460
movq %rax, 0x768(%r13)
testq %rax, %rax
je 0xa60aa
movq %r15, %rdi
callq 0x8460
movq %rax, 0x770(%r13)
testq %rax, %rax
je 0xa612e
testl %ebx, %ebx
je 0xa5d0a
leaq 0x75211(%rip), %r15     # 0x11aee2
xorl %ebx, %ebx
xorl %r12d, %r12d
movq 0x760(%r13), %rdx
addq %rbx, %rdx
movq 0x768(%r13), %rcx
addq %rbx, %rcx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x8690
incq %r12
movslq 0x75c(%r13), %rax
addq $0x8, %rbx
cmpq %rax, %r12
jl 0xa5cd6
movq %r14, %rdi
callq 0x83a0
movq 0x760(%r13), %rdi
movl 0x75c(%r13), %esi
movq 0x768(%r13), %rdx
movq 0x770(%r13), %r8
leaq 0x96a(%r13), %r14
movq %r14, (%rsp)
movl $0x1, %ebp
movl $0x1, %ecx
movl $0x1, %r9d
callq 0x142a8
cmpl $0x1, %eax
jne 0xa5d91
leaq 0x48696(%rip), %rsi     # 0xee3f0
leaq 0x7aa42(%rip), %rdx     # 0x1207a3
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x482ba(%rip), %rsi     # 0xee034
leaq 0x7a9e1(%rip), %rdx     # 0x120762
movq %r14, %rdi
movl $0x1157, %ecx           # imm = 0x1157
movq %rbx, %r8
jmp 0xa630c
movl $0x0, 0x87c(%r13)
cmpw $0x1, 0x778(%r13)
jne 0xa6315
leaq 0x77c(%r13), %r15
leaq 0x66feb(%rip), %rsi     # 0x10cda4
movq %r15, %rdi
callq 0x8400
testq %rax, %rax
je 0xa6049
movq %rax, %r14
movq %r13, 0x18(%rsp)
movl $0x1, %ebx
movq $-0x8, %r15
leaq 0x750fd(%rip), %r12     # 0x11aee2
leaq 0x28(%rsp), %r13
leaq 0x20(%rsp), %rbp
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x8690
decl %ebx
addq $0x8, %r15
cmpl $0x2, %eax
je 0xa5def
movq %r14, %rdi
callq 0x8060
movl %ebx, %eax
negl %eax
movq 0x18(%rsp), %r13
movl %eax, 0x87c(%r13)
movq %r15, %rdi
callq 0x8460
movq %rax, 0x880(%r13)
testq %rax, %rax
je 0xa60ec
movq %r15, %rdi
callq 0x8460
movq %rax, 0x888(%r13)
testq %rax, %rax
je 0xa6170
movq %r15, %rdi
callq 0x8460
movq %rax, 0x890(%r13)
testq %rax, %rax
je 0xa61af
movq %r15, %rdi
callq 0x8460
movq %rax, 0x898(%r13)
testq %rax, %rax
je 0xa61ee
testl %ebx, %ebx
je 0xa5ec9
leaq 0x75052(%rip), %r15     # 0x11aee2
xorl %ebx, %ebx
xorl %r12d, %r12d
movq 0x880(%r13), %rdx
addq %rbx, %rdx
movq 0x888(%r13), %rcx
addq %rbx, %rcx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x8690
incq %r12
movslq 0x87c(%r13), %rax
addq $0x8, %rbx
cmpq %rax, %r12
jl 0xa5e95
movq %r14, %rdi
callq 0x83a0
movq 0x888(%r13), %rax
movsd 0x8(%rax), %xmm0
callq 0x82c0
movsd %xmm0, 0x10(%rsp)
movq 0x888(%r13), %rax
movsd (%rax), %xmm0
callq 0x82c0
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movq 0x880(%r13), %rax
movq 0x890(%r13), %rcx
movsd 0x8(%rax), %xmm0
subsd (%rax), %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, (%rcx)
movslq 0x87c(%r13), %rax
cmpq $0x3, %rax
jl 0xa623f
movl $0x1, %ebx
movq 0x888(%r13), %rax
leaq 0x1(%rbx), %r14
movsd 0x8(%rax,%rbx,8), %xmm0
callq 0x82c0
movsd %xmm0, 0x10(%rsp)
movq 0x888(%r13), %rax
movsd -0x8(%rax,%rbx,8), %xmm0
callq 0x82c0
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movq 0x880(%r13), %rax
movq 0x890(%r13), %rcx
movsd 0x8(%rax,%rbx,8), %xmm0
subsd -0x8(%rax,%rbx,8), %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rbx,8)
movslq 0x87c(%r13), %rax
decq %rax
movq %r14, %rbx
cmpq %rax, %r14
jl 0xa5f37
jmp 0xa6242
leaq 0x657e2(%rip), %rsi     # 0x10b792
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x30af0
leaq 0x480b9(%rip), %rsi     # 0xee082
leaq 0x7a77f(%rip), %rdx     # 0x12074f
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %r13            # imm = 0x96A
leaq 0x48041(%rip), %rsi     # 0xee034
leaq 0x7a768(%rip), %rdx     # 0x120762
movq %r13, %rdi
movl $0x1139, %ecx           # imm = 0x1139
jmp 0xa60a2
leaq 0x47ff6(%rip), %rsi     # 0xee004
leaq 0x7a76c(%rip), %rdx     # 0x120781
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47fff(%rip), %rsi     # 0xee034
leaq 0x7a726(%rip), %rdx     # 0x120762
movq %r13, %rdi
movl $0x1143, %ecx           # imm = 0x1143
jmp 0xa622b
leaq 0x65742(%rip), %rsi     # 0x10b792
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x30af0
leaq 0x48019(%rip), %rsi     # 0xee082
leaq 0x7a6df(%rip), %rdx     # 0x12074f
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47fa1(%rip), %rsi     # 0xee034
leaq 0x7a6c8(%rip), %rdx     # 0x120762
movq %r13, %rdi
movl $0x1161, %ecx           # imm = 0x1161
movq %r15, %r8
jmp 0xa622e
leaq 0x47f53(%rip), %rsi     # 0xee004
leaq 0x7a6d3(%rip), %rdx     # 0x12078b
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47f5c(%rip), %rsi     # 0xee034
leaq 0x7a683(%rip), %rdx     # 0x120762
movq %r13, %rdi
movl $0x1144, %ecx           # imm = 0x1144
jmp 0xa622b
leaq 0x47f11(%rip), %rsi     # 0xee004
leaq 0x7a70f(%rip), %rdx     # 0x120809
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47f1a(%rip), %rsi     # 0xee034
leaq 0x7a641(%rip), %rdx     # 0x120762
movq %r13, %rdi
movl $0x116b, %ecx           # imm = 0x116B
jmp 0xa622b
leaq 0x47ecf(%rip), %rsi     # 0xee004
leaq 0x7a65a(%rip), %rdx     # 0x120796
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47ed8(%rip), %rsi     # 0xee034
leaq 0x7a5ff(%rip), %rdx     # 0x120762
movq %r13, %rdi
movl $0x1145, %ecx           # imm = 0x1145
jmp 0xa622b
leaq 0x47e8d(%rip), %rsi     # 0xee004
leaq 0x7a699(%rip), %rdx     # 0x120817
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47e96(%rip), %rsi     # 0xee034
leaq 0x7a5bd(%rip), %rdx     # 0x120762
movq %r13, %rdi
movl $0x116c, %ecx           # imm = 0x116C
jmp 0xa622b
leaq 0x47e4e(%rip), %rsi     # 0xee004
leaq 0x7a669(%rip), %rdx     # 0x120826
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47e57(%rip), %rsi     # 0xee034
leaq 0x7a57e(%rip), %rdx     # 0x120762
movq %r13, %rdi
movl $0x116d, %ecx           # imm = 0x116D
jmp 0xa622b
leaq 0x47e0f(%rip), %rsi     # 0xee004
leaq 0x7a63e(%rip), %rdx     # 0x12083a
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47e18(%rip), %rsi     # 0xee034
leaq 0x7a53f(%rip), %rdx     # 0x120762
movq %r13, %rdi
movl $0x116e, %ecx           # imm = 0x116E
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %ebp
jmp 0xa6317
decq %rax
movq 0x888(%r13), %rcx
movsd (%rcx,%rax,8), %xmm0
callq 0x82c0
movsd %xmm0, 0x10(%rsp)
movq 0x888(%r13), %rax
movslq 0x87c(%r13), %rcx
movsd -0x10(%rax,%rcx,8), %xmm0
callq 0x82c0
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movslq 0x87c(%r13), %rsi
movq 0x880(%r13), %rdi
movq 0x890(%r13), %rdx
movsd -0x8(%rdi,%rsi,8), %xmm0
subsd -0x10(%rdi,%rsi,8), %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, -0x8(%rdx,%rsi,8)
movq 0x898(%r13), %r8
addq $0x96a, %r13            # imm = 0x96A
movq %r13, (%rsp)
movl $0x1, %ebp
movl $0x1, %ecx
movl $0x1, %r9d
callq 0x142a8
cmpl $0x1, %eax
jne 0xa6315
leaq 0x48116(%rip), %rsi     # 0xee3f0
leaq 0x7a570(%rip), %rdx     # 0x120851
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30af0
leaq 0x47d3a(%rip), %rsi     # 0xee034
leaq 0x7a461(%rip), %rdx     # 0x120762
movq %r13, %rdi
movl $0x1192, %ecx           # imm = 0x1192
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
jmp 0xa6317
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq