// File: /workspace/github_c_makefile_star2_O2/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, %rbx
andl $0x0, 0x75c(%rdi)
cmpw $0x1, 0x658(%rdi)
jne 0xa0e2d
leaq 0x65c(%rbx), %r15
leaq 0x6304d(%rip), %rsi     # 0x103c64
movq %r15, %rdi
callq 0x8420
testq %rax, %rax
je 0xa0d0c
movq %rax, %r14
movq %rbx, 0x18(%rsp)
pushq $0x2
popq %rax
pushq $-0x1
popq %rbx
pushq $-0x8
popq %r15
leaq 0x71141(%rip), %r12     # 0x111d82
leaq 0x28(%rsp), %r13
leaq 0x20(%rsp), %rbp
movq %r14, %rdi
cmpl $0x2, %eax
jne 0xa0c6b
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x86c0
incl %ebx
addq $0x8, %r15
jmp 0xa0c4b
callq 0x8060
movq 0x18(%rsp), %rbp
movl %ebx, 0x75c(%rbp)
movq %r15, %rdi
callq 0x8490
movq %rax, 0x760(%rbp)
testq %rax, %rax
je 0xa0d6a
movq %r15, %rdi
callq 0x8490
movq %rax, 0x768(%rbp)
testq %rax, %rax
je 0xa0fbe
movq %r15, %rdi
callq 0x8490
movq %rax, 0x770(%rbp)
testq %rax, %rax
je 0xa1042
leaq 0x710b8(%rip), %r15     # 0x111d82
xorl %r12d, %r12d
xorl %r13d, %r13d
movslq %ebx, %rax
cmpq %rax, %r13
jge 0xa0dac
movq 0x760(%rbp), %rdx
addq %r12, %rdx
movq 0x768(%rbp), %rcx
addq %r12, %rcx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x86c0
incq %r13
movl 0x75c(%rbp), %ebx
addq $0x8, %r12
jmp 0xa0cd0
leaq 0x6193f(%rip), %rsi     # 0x102652
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2e014
leaq 0x44356(%rip), %rsi     # 0xe5082
leaq 0x768ac(%rip), %rdx     # 0x1175df
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x442de(%rip), %rsi     # 0xe5034
leaq 0x76895(%rip), %rdx     # 0x1175f2
movq %rbx, %rdi
movl $0x1139, %ecx           # imm = 0x1139
jmp 0xa0fb6
leaq 0x44293(%rip), %rsi     # 0xe5004
leaq 0x76899(%rip), %rdx     # 0x117611
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbp            # imm = 0x96A
leaq 0x4429c(%rip), %rsi     # 0xe5034
leaq 0x76853(%rip), %rdx     # 0x1175f2
movq %rbp, %rdi
movl $0x1143, %ecx           # imm = 0x1143
jmp 0xa12df
movq %r14, %rdi
callq 0x83c0
movq 0x760(%rbp), %rdi
movl 0x75c(%rbp), %esi
movq 0x768(%rbp), %rdx
movq 0x770(%rbp), %r8
leaq 0x96a(%rbp), %r14
movq %r14, (%rsp)
movq %rbp, %rbx
pushq $0x1
popq %rbp
movl %ebp, %ecx
movl %ebp, %r9d
callq 0x125a5
cmpl $0x1, %eax
jne 0xa0e2d
leaq 0x445fa(%rip), %rsi     # 0xe53f0
leaq 0x76836(%rip), %rdx     # 0x117633
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x4421e(%rip), %rsi     # 0xe5034
leaq 0x767d5(%rip), %rdx     # 0x1175f2
movq %r14, %rdi
movl $0x1157, %ecx           # imm = 0x1157
movq %rbx, %r8
jmp 0xa1250
andl $0x0, 0x87c(%rbx)
cmpw $0x1, 0x778(%rbx)
jne 0xa125c
leaq 0x77c(%rbx), %r15
leaq 0x62e14(%rip), %rsi     # 0x103c64
movq %r15, %rdi
callq 0x8420
testq %rax, %rax
je 0xa0f5d
movq %rax, %r14
movq %rbx, 0x18(%rsp)
pushq $0x2
popq %rax
pushq $-0x1
popq %rbx
pushq $-0x8
popq %r15
leaq 0x70f08(%rip), %r12     # 0x111d82
leaq 0x28(%rsp), %r13
leaq 0x20(%rsp), %rbp
movq %r14, %rdi
cmpl $0x2, %eax
jne 0xa0ea4
movq %r12, %rsi
movq %r13, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x86c0
incl %ebx
addq $0x8, %r15
jmp 0xa0e84
callq 0x8060
movq 0x18(%rsp), %rbp
movl %ebx, 0x87c(%rbp)
movq %r15, %rdi
callq 0x8490
movq %rax, 0x880(%rbp)
testq %rax, %rax
je 0xa1000
movq %r15, %rdi
callq 0x8490
movq %rax, 0x888(%rbp)
testq %rax, %rax
je 0xa1084
movq %r15, %rdi
callq 0x8490
movq %rax, 0x890(%rbp)
testq %rax, %rax
je 0xa1263
movq %r15, %rdi
callq 0x8490
movq %rax, 0x898(%rbp)
testq %rax, %rax
je 0xa12a2
leaq 0x70e67(%rip), %r15     # 0x111d82
xorl %r12d, %r12d
xorl %r13d, %r13d
movslq %ebx, %rax
cmpq %rax, %r13
jge 0xa10c6
movq 0x880(%rbp), %rdx
addq %r12, %rdx
movq 0x888(%rbp), %rcx
addq %r12, %rcx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x86c0
incq %r13
movl 0x87c(%rbp), %ebx
addq $0x8, %r12
jmp 0xa0f21
leaq 0x616ee(%rip), %rsi     # 0x102652
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x2e014
leaq 0x44105(%rip), %rsi     # 0xe5082
leaq 0x7665b(%rip), %rdx     # 0x1175df
leaq 0x830(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbx            # imm = 0x96A
leaq 0x4408d(%rip), %rsi     # 0xe5034
leaq 0x76644(%rip), %rdx     # 0x1175f2
movq %rbx, %rdi
movl $0x1161, %ecx           # imm = 0x1161
movq %r15, %r8
jmp 0xa12e2
leaq 0x4403f(%rip), %rsi     # 0xe5004
leaq 0x7664f(%rip), %rdx     # 0x11761b
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbp            # imm = 0x96A
leaq 0x44048(%rip), %rsi     # 0xe5034
leaq 0x765ff(%rip), %rdx     # 0x1175f2
movq %rbp, %rdi
movl $0x1144, %ecx           # imm = 0x1144
jmp 0xa12df
leaq 0x43ffd(%rip), %rsi     # 0xe5004
leaq 0x7668b(%rip), %rdx     # 0x117699
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbp            # imm = 0x96A
leaq 0x44006(%rip), %rsi     # 0xe5034
leaq 0x765bd(%rip), %rdx     # 0x1175f2
movq %rbp, %rdi
movl $0x116b, %ecx           # imm = 0x116B
jmp 0xa12df
leaq 0x43fbb(%rip), %rsi     # 0xe5004
leaq 0x765d6(%rip), %rdx     # 0x117626
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbp            # imm = 0x96A
leaq 0x43fc4(%rip), %rsi     # 0xe5034
leaq 0x7657b(%rip), %rdx     # 0x1175f2
movq %rbp, %rdi
movl $0x1145, %ecx           # imm = 0x1145
jmp 0xa12df
leaq 0x43f79(%rip), %rsi     # 0xe5004
leaq 0x76615(%rip), %rdx     # 0x1176a7
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbp            # imm = 0x96A
leaq 0x43f82(%rip), %rsi     # 0xe5034
leaq 0x76539(%rip), %rdx     # 0x1175f2
movq %rbp, %rdi
movl $0x116c, %ecx           # imm = 0x116C
jmp 0xa12df
movq %r14, %rdi
callq 0x83c0
movq 0x888(%rbp), %rax
movsd 0x8(%rax), %xmm0
callq 0x82e0
movsd %xmm0, 0x10(%rsp)
movq 0x888(%rbp), %rax
movsd (%rax), %xmm0
callq 0x82e0
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movq 0x880(%rbp), %rax
movsd 0x8(%rax), %xmm0
subsd (%rax), %xmm0
movq 0x890(%rbp), %rax
divsd %xmm0, %xmm1
movsd %xmm1, (%rax)
pushq $0x1
popq %rbx
movslq 0x87c(%rbp), %rax
leaq -0x1(%rax), %rdx
movq 0x888(%rbp), %rcx
cmpq %rdx, %rbx
jge 0xa1191
leaq 0x1(%rbx), %r14
movsd 0x8(%rcx,%rbx,8), %xmm0
callq 0x82e0
movsd %xmm0, 0x10(%rsp)
movq 0x888(%rbp), %rax
movsd -0x8(%rax,%rbx,8), %xmm0
callq 0x82e0
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movq 0x880(%rbp), %rax
movsd 0x8(%rax,%rbx,8), %xmm0
subsd -0x8(%rax,%rbx,8), %xmm0
movq 0x890(%rbp), %rax
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rbx,8)
movq %r14, %rbx
jmp 0xa1121
movsd -0x8(%rcx,%rax,8), %xmm0
callq 0x82e0
movsd %xmm0, 0x10(%rsp)
movq 0x888(%rbp), %rax
movslq 0x87c(%rbp), %rcx
movsd -0x10(%rax,%rcx,8), %xmm0
callq 0x82e0
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movslq 0x87c(%rbp), %rsi
movq 0x880(%rbp), %rdi
movq 0x890(%rbp), %rdx
movsd -0x8(%rdi,%rsi,8), %xmm0
subsd -0x10(%rdi,%rsi,8), %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, -0x8(%rdx,%rsi,8)
movq 0x898(%rbp), %r8
addq $0x96a, %rbp            # imm = 0x96A
movq %rbp, (%rsp)
movq %rbp, %rbx
pushq $0x1
popq %rbp
movl %ebp, %ecx
movl %ebp, %r9d
callq 0x125a5
cmpl $0x1, %eax
jne 0xa125c
leaq 0x441d2(%rip), %rsi     # 0xe53f0
leaq 0x764bc(%rip), %rdx     # 0x1176e1
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x43df6(%rip), %rsi     # 0xe5034
leaq 0x763ad(%rip), %rdx     # 0x1175f2
movq %rbx, %rdi
movl $0x1192, %ecx           # imm = 0x1192
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
jmp 0xa12ec
xorl %ebp, %ebp
jmp 0xa12ec
leaq 0x43d9a(%rip), %rsi     # 0xe5004
leaq 0x76445(%rip), %rdx     # 0x1176b6
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbp            # imm = 0x96A
leaq 0x43da3(%rip), %rsi     # 0xe5034
leaq 0x7635a(%rip), %rdx     # 0x1175f2
movq %rbp, %rdi
movl $0x116d, %ecx           # imm = 0x116D
jmp 0xa12df
leaq 0x43d5b(%rip), %rsi     # 0xe5004
leaq 0x7641a(%rip), %rdx     # 0x1176ca
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x96a, %rbp            # imm = 0x96A
leaq 0x43d64(%rip), %rsi     # 0xe5034
leaq 0x7631b(%rip), %rdx     # 0x1175f2
movq %rbp, %rdi
movl $0x116e, %ecx           # imm = 0x116E
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq