// File: /workspace/github_c_makefile_star2_O2/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 $0x1688, %rsp           # imm = 0x1688
movq %rsi, %rbx
leaq 0x928(%rdi), %r15
leaq 0x26c(%rsi), %r12
leaq 0x5ab5f(%rip), %r13     # 0x11e9eb
xorl %r14d, %r14d
xorl %edi, %edi
xorl %esi, %esi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x8580
incl %eax
movslq %eax, %rsi
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x8580
leaq 0x3fd9d(%rip), %rsi     # 0x103c64
movq %rbp, %rdi
callq 0x8420
testq %rax, %rax
je 0xc417c
movq %rax, %r15
leaq 0xc78(%rbx), %r12
andl $0x0, 0xc78(%rbx)
leaq 0x1280(%rsp), %r13
movq %r13, %rdi
movl $0x3ff, %esi            # imm = 0x3FF
movq %r15, %rdx
callq 0x8570
testq %rax, %rax
je 0xc3fdd
movq %r13, %rcx
movb (%rcx), %al
incq %rcx
cmpb $0x20, %al
je 0xc3f0d
incl %r14d
cmpb $0x28, %al
jl 0xc3ef1
leaq 0xcc0(%rbx), %rcx
leaq 0x40d48(%rip), %rsi     # 0x104c73
leaq 0x1280(%rsp), %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x83b0
cmpl $0x2, %eax
jne 0xc4233
movslq 0xc78(%rbx), %r13
leaq (,%r13,8), %rbp
movq %rbp, %rdi
callq 0x8490
movq %rax, 0xc70(%rbx)
testq %rax, %rax
je 0xc4299
movq %rbp, %rdi
callq 0x8490
movq %rax, 0xc80(%rbx)
testq %rax, %rax
je 0xc42e2
movq %rbp, %rdi
callq 0x8490
movq %rax, 0xc90(%rbx)
testq %rax, %rax
je 0xc432b
movq %rbp, %rdi
callq 0x8490
movq %rax, 0xca0(%rbx)
testq %rax, %rax
je 0xc4527
movslq 0xcc0(%rbx), %rbp
imulq %r13, %rbp
leaq (,%rbp,8), %rdi
callq 0x8490
movq %rax, 0xcb0(%rbx)
testq %rax, %rax
je 0xc456d
movq %r12, 0x8(%rsp)
leaq 0x59a59(%rip), %r13     # 0x11da42
xorl %r12d, %r12d
movq 0x8(%rsp), %rax
movslq (%rax), %rax
cmpq %rax, %r12
jge 0xc4374
leaq (,%r12,8), %rbp
movq 0xc70(%rbx), %rdx
addq %rbp, %rdx
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x86c0
cmpl $0x1, %eax
jne 0xc4383
movq 0xc80(%rbx), %rdx
addq %rbp, %rdx
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x86c0
cmpl $0x1, %eax
jne 0xc43ec
movsd 0x388(%rbx), %xmm0
movsd 0x58cfb(%rip), %xmm1    # 0x11cd50
mulsd %xmm1, %xmm0
movq 0xc80(%rbx), %rax
movsd (%rax,%r12,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%r12,8)
movq 0xc90(%rbx), %rdx
addq %rbp, %rdx
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x86c0
cmpl $0x1, %eax
jne 0xc4455
movsd 0x388(%rbx), %xmm0
mulsd 0x58cb0(%rip), %xmm0    # 0x11cd50
movq 0xc90(%rbx), %rax
movsd (%rax,%r12,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%r12,8)
addq 0xca0(%rbx), %rbp
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x86c0
cmpl $0x1, %eax
jne 0xc44be
movsd 0x388(%rbx), %xmm0
mulsd 0x58c69(%rip), %xmm0    # 0x11cd50
movq 0xca0(%rbx), %rax
movsd (%rax,%r12,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%r12,8)
xorl %ebp, %ebp
cmpl 0xcc0(%rbx), %ebp
jge 0xc4174
movl 0xc78(%rbx), %eax
imull %ebp, %eax
addl %r12d, %eax
movslq %eax, %rdx
shlq $0x3, %rdx
addq 0xcb0(%rbx), %rdx
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x86c0
cmpl $0x1, %eax
jne 0xc41ca
movsd 0x388(%rbx), %xmm0
movsd 0x58c08(%rip), %xmm1    # 0x11cd50
mulsd %xmm1, %xmm0
movq 0xcb0(%rbx), %rax
movl 0xc78(%rbx), %ecx
imull %ebp, %ecx
addl %r12d, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rcx,8)
incl %ebp
jmp 0xc4100
incq %r12
jmp 0xc3fec
leaq 0x23825(%rip), %rsi     # 0xe79a8
leaq 0x597a8(%rip), %rdx     # 0x11d932
leaq 0x2384c(%rip), %r8      # 0xe79dd
leaq 0x280(%rsp), %r14
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20e7e(%rip), %rsi     # 0xe5034
leaq 0x5a84b(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x67a, %ecx            # imm = 0x67A
jmp 0xc45af
addl %r12d, %r14d
leaq 0x5a4d4(%rip), %rsi     # 0x11e6a8
leaq 0x280(%rsp), %r15
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2e014
leaq 0x20e8d(%rip), %rsi     # 0xe5082
leaq 0x5a96a(%rip), %rdx     # 0x11eb66
leaq 0xa80(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20e15(%rip), %rsi     # 0xe5034
leaq 0x5a7e2(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x6b0, %ecx            # imm = 0x6B0
jmp 0xc45af
leaq 0x5a213(%rip), %rsi     # 0x11e44d
leaq 0x280(%rsp), %r15
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2e014
leaq 0x20e27(%rip), %rsi     # 0xe5082
leaq 0x5a7bf(%rip), %rdx     # 0x11ea21
leaq 0xa80(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20daf(%rip), %rsi     # 0xe5034
leaq 0x5a77c(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x68b, %ecx            # imm = 0x68B
jmp 0xc45af
shll $0x3, %r13d
leaq 0x20d60(%rip), %rsi     # 0xe5004
leaq 0x5a7b2(%rip), %rdx     # 0x11ea5d
leaq 0x280(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20d66(%rip), %rsi     # 0xe5034
leaq 0x5a733(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x68d, %ecx            # imm = 0x68D
jmp 0xc45af
shll $0x3, %r13d
leaq 0x20d17(%rip), %rsi     # 0xe5004
leaq 0x5a775(%rip), %rdx     # 0x11ea69
leaq 0x280(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20d1d(%rip), %rsi     # 0xe5034
leaq 0x5a6ea(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x68e, %ecx            # imm = 0x68E
jmp 0xc45af
shll $0x3, %r13d
leaq 0x20cce(%rip), %rsi     # 0xe5004
leaq 0x5a739(%rip), %rdx     # 0x11ea76
leaq 0x280(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20cd4(%rip), %rsi     # 0xe5034
leaq 0x5a6a1(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x68f, %ecx            # imm = 0x68F
jmp 0xc45af
movq %r15, %rdi
callq 0x83c0
xorl %eax, %eax
jmp 0xc45bc
addl %r12d, %r14d
leaq 0x5a19b(%rip), %rsi     # 0x11e528
leaq 0x280(%rsp), %r15
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2e014
leaq 0x20cd4(%rip), %rsi     # 0xe5082
leaq 0x5a6e8(%rip), %rdx     # 0x11ea9d
leaq 0xa80(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20c5c(%rip), %rsi     # 0xe5034
leaq 0x5a629(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x69c, %ecx            # imm = 0x69C
jmp 0xc45af
addl %r12d, %r14d
leaq 0x5a191(%rip), %rsi     # 0x11e587
leaq 0x280(%rsp), %r15
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2e014
leaq 0x20c6b(%rip), %rsi     # 0xe5082
leaq 0x5a6b0(%rip), %rdx     # 0x11eace
leaq 0xa80(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20bf3(%rip), %rsi     # 0xe5034
leaq 0x5a5c0(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x6a0, %ecx            # imm = 0x6A0
jmp 0xc45af
addl %r12d, %r14d
leaq 0x5a188(%rip), %rsi     # 0x11e5e7
leaq 0x280(%rsp), %r15
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2e014
leaq 0x20c02(%rip), %rsi     # 0xe5082
leaq 0x5a679(%rip), %rdx     # 0x11eb00
leaq 0xa80(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20b8a(%rip), %rsi     # 0xe5034
leaq 0x5a557(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x6a5, %ecx            # imm = 0x6A5
jmp 0xc45af
addl %r12d, %r14d
leaq 0x5a17f(%rip), %rsi     # 0x11e647
leaq 0x280(%rsp), %r15
leaq 0x10(%rsp), %rcx
movq %r15, %rdi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2e014
leaq 0x20b99(%rip), %rsi     # 0xe5082
leaq 0x5a643(%rip), %rdx     # 0x11eb33
leaq 0xa80(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20b21(%rip), %rsi     # 0xe5034
leaq 0x5a4ee(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x6aa, %ecx            # imm = 0x6AA
jmp 0xc45af
shll $0x3, %r13d
leaq 0x20ad2(%rip), %rsi     # 0xe5004
leaq 0x5a54b(%rip), %rdx     # 0x11ea84
leaq 0x280(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20ad8(%rip), %rsi     # 0xe5034
leaq 0x5a4a5(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x690, %ecx            # imm = 0x690
jmp 0xc45af
shll $0x3, %ebp
leaq 0x20a8d(%rip), %rsi     # 0xe5004
leaq 0x5a514(%rip), %rdx     # 0x11ea92
leaq 0x280(%rsp), %r14
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2e014
addq $0x1602, %rbx           # imm = 0x1602
leaq 0x20a94(%rip), %rsi     # 0xe5034
leaq 0x5a461(%rip), %rdx     # 0x11ea08
movq %rbx, %rdi
movl $0x692, %ecx            # imm = 0x692
movq %r14, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rax
addq $0x1688, %rsp           # imm = 0x1688
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq