// File: /workspace/github_c_makefile_star2_O1/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 0xa8d0b
leaq 0x65c(%r13), %r15
leaq 0x671fa(%rip), %rsi     # 0x10fd84
movq %r15, %rdi
callq 0x8400
testq %rax, %rax
je 0xa8f24
movq %rax, %r14
movq %r13, 0x18(%rsp)
movq $-0x8, %r15
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x752ec(%rip), %r12     # 0x11dea2
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
addq $0x8, %r15
incl %ebx
cmpl $0x2, %eax
je 0xa8bc0
movq %r14, %rdi
callq 0x8060
movq 0x18(%rsp), %r13
movl %ebx, 0x75c(%r13)
movq %r15, %rdi
callq 0x8460
movq %rax, 0x760(%r13)
testq %rax, %rax
je 0xa8f82
movq %r15, %rdi
callq 0x8460
movq %rax, 0x768(%r13)
testq %rax, %rax
je 0xa9025
movq %r15, %rdi
callq 0x8460
movq %rax, 0x770(%r13)
testq %rax, %rax
je 0xa90a9
cmpl $0x0, 0x75c(%r13)
jle 0xa8c84
leaq 0x75257(%rip), %r15     # 0x11dea2
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 0xa8c50
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 0x14191
cmpl $0x1, %eax
jne 0xa8d0b
leaq 0x4871c(%rip), %rsi     # 0xf13f0
leaq 0x7aa88(%rip), %rdx     # 0x123763
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x48340(%rip), %rsi     # 0xf1034
leaq 0x7aa27(%rip), %rdx     # 0x123722
movq %r14, %rdi
movl $0x1157, %ecx           # imm = 0x1157
movq %rbx, %r8
jmp 0xa9288
movl $0x0, 0x87c(%r13)
cmpw $0x1, 0x778(%r13)
jne 0xa9291
leaq 0x77c(%r13), %r15
leaq 0x67051(%rip), %rsi     # 0x10fd84
movq %r15, %rdi
callq 0x8400
testq %rax, %rax
je 0xa8fc4
movq %rax, %r14
movq %r13, 0x18(%rsp)
movq $-0x8, %r15
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x75143(%rip), %r12     # 0x11dea2
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
addq $0x8, %r15
incl %ebx
cmpl $0x2, %eax
je 0xa8d69
movq %r14, %rdi
callq 0x8060
movq 0x18(%rsp), %r13
movl %ebx, 0x87c(%r13)
movq %r15, %rdi
callq 0x8460
movq %rax, 0x880(%r13)
testq %rax, %rax
je 0xa9067
movq %r15, %rdi
callq 0x8460
movq %rax, 0x888(%r13)
testq %rax, %rax
je 0xa90eb
movq %r15, %rdi
callq 0x8460
movq %rax, 0x890(%r13)
testq %rax, %rax
je 0xa912a
movq %r15, %rdi
callq 0x8460
movq %rax, 0x898(%r13)
testq %rax, %rax
je 0xa9169
cmpl $0x0, 0x87c(%r13)
jle 0xa8e45
leaq 0x75096(%rip), %r15     # 0x11dea2
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 0xa8e11
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)
movl 0x87c(%r13), %eax
cmpl $0x3, %eax
jl 0xa91ba
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 0xa8eb2
jmp 0xa91bc
leaq 0x65847(%rip), %rsi     # 0x10e772
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x30c2c
leaq 0x4813e(%rip), %rsi     # 0xf1082
leaq 0x7a7c4(%rip), %rdx     # 0x12370f
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %r13            # imm = 0x96A
leaq 0x480c6(%rip), %rsi     # 0xf1034
leaq 0x7a7ad(%rip), %rdx     # 0x123722
movq %r13, %rdi
movl $0x1139, %ecx           # imm = 0x1139
jmp 0xa901d
leaq 0x4807b(%rip), %rsi     # 0xf1004
leaq 0x7a7b1(%rip), %rdx     # 0x123741
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %r13            # imm = 0x96A
leaq 0x48084(%rip), %rsi     # 0xf1034
leaq 0x7a76b(%rip), %rdx     # 0x123722
movq %r13, %rdi
movl $0x1143, %ecx           # imm = 0x1143
jmp 0xa91a6
leaq 0x657a7(%rip), %rsi     # 0x10e772
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x30c2c
leaq 0x4809e(%rip), %rsi     # 0xf1082
leaq 0x7a724(%rip), %rdx     # 0x12370f
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %r13            # imm = 0x96A
leaq 0x48026(%rip), %rsi     # 0xf1034
leaq 0x7a70d(%rip), %rdx     # 0x123722
movq %r13, %rdi
movl $0x1161, %ecx           # imm = 0x1161
movq %r15, %r8
jmp 0xa91a9
leaq 0x47fd8(%rip), %rsi     # 0xf1004
leaq 0x7a718(%rip), %rdx     # 0x12374b
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47fe1(%rip), %rsi     # 0xf1034
leaq 0x7a6c8(%rip), %rdx     # 0x123722
movq %r13, %rdi
movl $0x1144, %ecx           # imm = 0x1144
jmp 0xa91a6
leaq 0x47f96(%rip), %rsi     # 0xf1004
leaq 0x7a754(%rip), %rdx     # 0x1237c9
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47f9f(%rip), %rsi     # 0xf1034
leaq 0x7a686(%rip), %rdx     # 0x123722
movq %r13, %rdi
movl $0x116b, %ecx           # imm = 0x116B
jmp 0xa91a6
leaq 0x47f54(%rip), %rsi     # 0xf1004
leaq 0x7a69f(%rip), %rdx     # 0x123756
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47f5d(%rip), %rsi     # 0xf1034
leaq 0x7a644(%rip), %rdx     # 0x123722
movq %r13, %rdi
movl $0x1145, %ecx           # imm = 0x1145
jmp 0xa91a6
leaq 0x47f12(%rip), %rsi     # 0xf1004
leaq 0x7a6de(%rip), %rdx     # 0x1237d7
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47f1b(%rip), %rsi     # 0xf1034
leaq 0x7a602(%rip), %rdx     # 0x123722
movq %r13, %rdi
movl $0x116c, %ecx           # imm = 0x116C
jmp 0xa91a6
leaq 0x47ed3(%rip), %rsi     # 0xf1004
leaq 0x7a6ae(%rip), %rdx     # 0x1237e6
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47edc(%rip), %rsi     # 0xf1034
leaq 0x7a5c3(%rip), %rdx     # 0x123722
movq %r13, %rdi
movl $0x116d, %ecx           # imm = 0x116D
jmp 0xa91a6
leaq 0x47e94(%rip), %rsi     # 0xf1004
leaq 0x7a683(%rip), %rdx     # 0x1237fa
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x96a, %r13            # imm = 0x96A
leaq 0x47e9d(%rip), %rsi     # 0xf1034
leaq 0x7a584(%rip), %rdx     # 0x123722
movq %r13, %rdi
movl $0x116e, %ecx           # imm = 0x116E
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %ebp
jmp 0xa9293
decl %eax
movq 0x888(%r13), %rcx
cltq
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 0x14191
cmpl $0x1, %eax
jne 0xa9291
leaq 0x4819a(%rip), %rsi     # 0xf13f0
leaq 0x7a5b4(%rip), %rdx     # 0x123811
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r13, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0x47dbe(%rip), %rsi     # 0xf1034
leaq 0x7a4a5(%rip), %rdx     # 0x123722
movq %r13, %rdi
movl $0x1192, %ecx           # imm = 0x1192
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
jmp 0xa9293
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq