// File: /workspace/github_c_makefile_star2_O3/PoulinV[P]AxiCLASS/build/../source/distortions.c
// Function: distortions_read_sd_data
int distortions_read_sd_data(struct precision * ppr,
                             struct distortions * psd){

  /** Define local variables */
  FILE * infile;
  DetectorFileName sd_file;
  char line[_LINE_LENGTH_MAX_];
  char * left;
  int headlines = 0;
  int index_x,index_k;

  /** Open file */
  class_sprintf(sd_file,"%s/%s_distortions_shapes.dat",ppr->sd_external_path, psd->sd_detector_name);
  class_open(infile, sd_file, "r", psd->error_message);

  /** Read header */
  psd->PCA_Nnu = 0;
  while (fgets(line,_LINE_LENGTH_MAX_-1,infile) != NULL) {
    headlines++;

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

    if (left[0] > 39) {
      /** Read number of lines, infer size of arrays and allocate them */
      class_test(sscanf(line, "%d %d", &psd->PCA_Nnu, &psd->S_vec_size) != 2,
                 psd->error_message,
                 "could not header (number of lines, number of multipoles) at line %i in file '%s' \n",headlines,sd_file);

      class_alloc(psd->PCA_nu, psd->PCA_Nnu*sizeof(double), psd->error_message);
      class_alloc(psd->PCA_G_T, psd->PCA_Nnu*sizeof(double), psd->error_message);
      class_alloc(psd->PCA_Y_SZ, psd->PCA_Nnu*sizeof(double), psd->error_message);
      class_alloc(psd->PCA_M_mu, psd->PCA_Nnu*sizeof(double), psd->error_message);

      class_alloc(psd->S_vec, psd->PCA_Nnu*psd->S_vec_size*sizeof(double), psd->error_message);
      break;
    }
  }

  /** Read parameters */
  for (index_x=0; index_x<psd->PCA_Nnu; ++index_x){
    class_test(fscanf(infile,"%le",
                      &(psd->PCA_nu[index_x]))!=1,                                                  // [GHz]
               psd->error_message,
               "Could not read z at line %i in file '%s'",index_x+headlines,sd_file);
    class_test(fscanf(infile,"%le",
                      &(psd->PCA_G_T[index_x]))!=1,                                                 // [10^-18 W/(m^2 Hz sr)]
               psd->error_message,
               "Could not read f_g at line %i in file '%s'",index_x+headlines,sd_file);
    psd->PCA_G_T[index_x] /= (psd->DI_units*1.e18);                                                 // [-]
    class_test(fscanf(infile,"%le",
                      &(psd->PCA_Y_SZ[index_x]))!=1,                                                // [10^-18 W/(m^2 Hz sr)]
               psd->error_message,
               "Could not read f_y at line %i in file '%s'",index_x+headlines,sd_file);
    psd->PCA_Y_SZ[index_x] /= (psd->DI_units*1.e18);                                                // [-]
    class_test(fscanf(infile,"%le",
                      &(psd->PCA_M_mu[index_x]))!=1,                                                // [10^-18 W/(m^2 Hz sr)]
               psd->error_message,
               "Could not read f_mu at line %i in file '%s'",index_x+headlines,sd_file);
    psd->PCA_M_mu[index_x] /= (psd->DI_units*1.e18);                                                // [-]
    for (index_k=0; index_k<psd->S_vec_size; ++index_k){
      class_test(fscanf(infile,"%le",
                        &(psd->S_vec[index_k*psd->PCA_Nnu+index_x]))!=1,                            // [10^-18 W/(m^2 Hz sr)]
                 psd->error_message,
                 "Could not read E vector at line %i in file '%s'",index_x+headlines,sd_file);
      psd->S_vec[index_k*psd->PCA_Nnu+index_x] /= (psd->DI_units*1.e18);                            // [-]
    }

  }

  fclose(infile);

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1678, %rsp           # imm = 0x1678
movq %rsi, %rbx
leaq 0x928(%rdi), %r15
leaq 0x26c(%rsi), %r12
leaq 0x5c65a(%rip), %r13     # 0x127b3b
xorl %r14d, %r14d
xorl %edi, %edi
xorl %esi, %esi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %rsp, %rbp
movq %rbp, %rdi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x8550
leaq 0x4188a(%rip), %rsi     # 0x10cda4
movq %rbp, %rdi
callq 0x8400
testq %rax, %rax
je 0xcb67e
movq %rax, %r15
leaq 0xc78(%rbx), %r12
movl $0x0, 0xc78(%rbx)
leaq 0x1270(%rsp), %r13
movq %r13, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq %r15, %rdx
callq 0x8540
testq %rax, %rax
je 0xcb6ca
movq %r13, %rcx
movb (%rcx), %al
incq %rcx
cmpb $0x20, %al
je 0xcb563
incl %r14d
cmpb $0x28, %al
jl 0xcb547
leaq 0xcc0(%rbx), %rcx
leaq 0x42852(%rip), %rsi     # 0x10ddd3
leaq 0x1270(%rsp), %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x8390
cmpl $0x2, %eax
jne 0xcb878
movl 0xc78(%rbx), %ebp
movslq %ebp, %r13
leaq (,%r13,8), %r12
movq %r12, %rdi
callq 0x8460
movq %rax, 0xc70(%rbx)
testq %rax, %rax
je 0xcb943
movq %r12, %rdi
callq 0x8460
movq %rax, 0xc80(%rbx)
testq %rax, %rax
je 0xcb98a
movq %r12, %rdi
callq 0x8460
movq %rax, 0xc90(%rbx)
testq %rax, %rax
je 0xcb9d1
movq %r12, %rdi
callq 0x8460
movq %rax, 0xca0(%rbx)
testq %rax, %rax
je 0xcbbb1
movslq 0xcc0(%rbx), %r12
imulq %r13, %r12
leaq (,%r12,8), %rdi
callq 0x8460
movq %rax, 0xcb0(%rbx)
testq %rax, %rax
jne 0xcb6ce
shll $0x3, %r12d
leaq 0x229c4(%rip), %rsi     # 0xee004
leaq 0x5c59b(%rip), %rdx     # 0x127be2
leaq 0x270(%rsp), %r14
movq %r14, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x229ca(%rip), %rsi     # 0xee034
leaq 0x5c4e7(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x692, %ecx            # imm = 0x692
jmp 0xcbbf3
leaq 0x25363(%rip), %rsi     # 0xf09e8
leaq 0x5b3f6(%rip), %rdx     # 0x126a82
leaq 0x2538a(%rip), %r8      # 0xf0a1d
leaq 0x270(%rsp), %r14
movq %rsp, %rcx
movq %r14, %rdi
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x2297e(%rip), %rsi     # 0xee034
leaq 0x5c49b(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x67a, %ecx            # imm = 0x67A
jmp 0xcbbf3
movl (%r12), %ebp
testl %ebp, %ebp
jle 0xcb869
leaq 0x5b4b5(%rip), %r12     # 0x126b92
xorl %ebp, %ebp
leaq (,%rbp,8), %r13
movq 0xc70(%rbx), %rdx
addq %r13, %rdx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x8690
cmpl $0x1, %eax
jne 0xcba18
movq 0xc80(%rbx), %rdx
addq %r13, %rdx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x8690
cmpl $0x1, %eax
jne 0xcba7f
movsd 0x388(%rbx), %xmm0
movsd 0x5a769(%rip), %xmm1    # 0x125ea0
mulsd %xmm1, %xmm0
movq 0xc80(%rbx), %rax
movsd (%rax,%rbp,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rbp,8)
movq 0xc90(%rbx), %rdx
addq %r13, %rdx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x8690
cmpl $0x1, %eax
jne 0xcbae6
movsd 0x388(%rbx), %xmm0
mulsd 0x5a720(%rip), %xmm0    # 0x125ea0
movq 0xc90(%rbx), %rax
movsd (%rax,%rbp,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rbp,8)
addq 0xca0(%rbx), %r13
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x8690
cmpl $0x1, %eax
jne 0xcbb4d
movsd 0x388(%rbx), %xmm0
mulsd 0x5a6db(%rip), %xmm0    # 0x125ea0
movq 0xca0(%rbx), %rax
movsd (%rax,%rbp,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rbp,8)
cmpl $0x0, 0xcc0(%rbx)
movl 0xc78(%rbx), %eax
jle 0xcb85b
movq 0xcb0(%rbx), %rcx
xorl %r13d, %r13d
imull %r13d, %eax
addl %ebp, %eax
cltq
leaq (%rcx,%rax,8), %rdx
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x8690
cmpl $0x1, %eax
jne 0xcb8dc
movsd 0x388(%rbx), %xmm0
movsd 0x5a67b(%rip), %xmm1    # 0x125ea0
mulsd %xmm1, %xmm0
movq 0xcb0(%rbx), %rcx
movl 0xc78(%rbx), %eax
movl %eax, %edx
imull %r13d, %edx
addl %ebp, %edx
movslq %edx, %rdx
movsd (%rcx,%rdx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incl %r13d
cmpl 0xcc0(%rbx), %r13d
jl 0xcb7f3
incq %rbp
cltq
cmpq %rax, %rbp
jl 0xcb6df
movq %r15, %rdi
callq 0x83a0
xorl %eax, %eax
jmp 0xcbc02
leaq 0x5bd1e(%rip), %rsi     # 0x12759d
leaq 0x270(%rsp), %r15
movq %rsp, %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x30af0
leaq 0x227e4(%rip), %rsi     # 0xee082
leaq 0x5c2cc(%rip), %rdx     # 0x127b71
leaq 0xa70(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x2276c(%rip), %rsi     # 0xee034
leaq 0x5c289(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x68b, %ecx            # imm = 0x68B
jmp 0xcbbf3
addl %ebp, %r14d
leaq 0x5bf12(%rip), %rsi     # 0x1277f8
leaq 0x270(%rsp), %r15
movq %rsp, %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x30af0
leaq 0x2277d(%rip), %rsi     # 0xee082
leaq 0x5c3aa(%rip), %rdx     # 0x127cb6
leaq 0xa70(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x22705(%rip), %rsi     # 0xee034
leaq 0x5c222(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x6b0, %ecx            # imm = 0x6B0
jmp 0xcbbf3
shll $0x3, %ebp
leaq 0x226b7(%rip), %rsi     # 0xee004
leaq 0x5c259(%rip), %rdx     # 0x127bad
leaq 0x270(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x226be(%rip), %rsi     # 0xee034
leaq 0x5c1db(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x68d, %ecx            # imm = 0x68D
jmp 0xcbbf3
shll $0x3, %ebp
leaq 0x22670(%rip), %rsi     # 0xee004
leaq 0x5c21e(%rip), %rdx     # 0x127bb9
leaq 0x270(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x22677(%rip), %rsi     # 0xee034
leaq 0x5c194(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x68e, %ecx            # imm = 0x68E
jmp 0xcbbf3
shll $0x3, %ebp
leaq 0x22629(%rip), %rsi     # 0xee004
leaq 0x5c1e4(%rip), %rdx     # 0x127bc6
leaq 0x270(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x22630(%rip), %rsi     # 0xee034
leaq 0x5c14d(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x68f, %ecx            # imm = 0x68F
jmp 0xcbbf3
addl %ebp, %r14d
leaq 0x5bc56(%rip), %rsi     # 0x127678
leaq 0x270(%rsp), %r15
movq %rsp, %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x30af0
leaq 0x22641(%rip), %rsi     # 0xee082
leaq 0x5c1a5(%rip), %rdx     # 0x127bed
leaq 0xa70(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x225c9(%rip), %rsi     # 0xee034
leaq 0x5c0e6(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x69c, %ecx            # imm = 0x69C
jmp 0xcbbf3
addl %ebp, %r14d
leaq 0x5bc4e(%rip), %rsi     # 0x1276d7
leaq 0x270(%rsp), %r15
movq %rsp, %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x30af0
leaq 0x225da(%rip), %rsi     # 0xee082
leaq 0x5c16f(%rip), %rdx     # 0x127c1e
leaq 0xa70(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x22562(%rip), %rsi     # 0xee034
leaq 0x5c07f(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x6a0, %ecx            # imm = 0x6A0
jmp 0xcbbf3
addl %ebp, %r14d
leaq 0x5bc47(%rip), %rsi     # 0x127737
leaq 0x270(%rsp), %r15
movq %rsp, %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x30af0
leaq 0x22573(%rip), %rsi     # 0xee082
leaq 0x5c13a(%rip), %rdx     # 0x127c50
leaq 0xa70(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x224fb(%rip), %rsi     # 0xee034
leaq 0x5c018(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x6a5, %ecx            # imm = 0x6A5
jmp 0xcbbf3
addl %ebp, %r14d
leaq 0x5bc40(%rip), %rsi     # 0x127797
leaq 0x270(%rsp), %r15
movq %rsp, %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x30af0
leaq 0x2250c(%rip), %rsi     # 0xee082
leaq 0x5c106(%rip), %rdx     # 0x127c83
leaq 0xa70(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x22494(%rip), %rsi     # 0xee034
leaq 0x5bfb1(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x6aa, %ecx            # imm = 0x6AA
jmp 0xcbbf3
shll $0x3, %ebp
leaq 0x22449(%rip), %rsi     # 0xee004
leaq 0x5c012(%rip), %rdx     # 0x127bd4
leaq 0x270(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x30af0
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x22450(%rip), %rsi     # 0xee034
leaq 0x5bf6d(%rip), %rdx     # 0x127b58
movq %rbx, %rdi
movl $0x690, %ecx            # imm = 0x690
movq %r14, %r8
xorl %eax, %eax
callq 0x30af0
movl $0x1, %eax
addq $0x1678, %rsp           # imm = 0x1678
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq