// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../source/output.c
// Function: output_distortions
int output_distortions(
                       struct distortions * psd,
                       struct output * pop
                       ) {

  /** Local variables*/
  FileName file_name_heat, file_name_distortion;
  FILE * out_heat, * out_distortion;

  char titles_heat[_MAXTITLESTRINGLENGTH_]={0};
  char titles_distortion[_MAXTITLESTRINGLENGTH_]={0};

  double * data_heat, * data_distortion;
  int size_data_heat, size_data_distortion;
  int number_of_titles_heat, number_of_titles_distortion;

  if (pop->write_distortions==_TRUE_ && psd->has_distortions == _TRUE_){

    /* File name */
    class_sprintf(file_name_heat,"%s%s",pop->root,"sd_heating.dat");

    /* Titles */
    class_call(distortions_output_heat_titles(psd,titles_heat),
               psd->error_message,
               pop->error_message);
    number_of_titles_heat = get_number_of_titles(titles_heat);

    /* Data array */
    size_data_heat = number_of_titles_heat*psd->z_size;
    class_alloc(data_heat,
                sizeof(double)*size_data_heat,
                pop->error_message);
    class_call(distortions_output_heat_data(psd,
                                            number_of_titles_heat,
                                            data_heat),
               psd->error_message,
               pop->error_message);

    /* File IO */
    class_open(out_heat,
               file_name_heat,
               "w",
               pop->error_message);

    if (pop->write_header == _TRUE_){
      fprintf(out_heat,"# Heat is d(Q/rho)/dz\n");
      fprintf(out_heat,"# LHeat is d(Q/rho)/dlnz\n");
      fprintf(out_heat,"#\n");
    }

    output_print_data(out_heat,
                      titles_heat,
                      data_heat,
                      size_data_heat);
    free(data_heat);
    fclose(out_heat);

    /* File name */
    class_sprintf(file_name_distortion,"%s%s",pop->root,"sd_distortions.dat");

    /* Titles */
    class_call(distortions_output_sd_titles(psd,titles_distortion),
               psd->error_message,
               pop->error_message);
    number_of_titles_distortion = get_number_of_titles(titles_distortion);

    /* Data array */
    size_data_distortion = number_of_titles_distortion*psd->x_size;
    class_alloc(data_distortion,
                sizeof(double)*size_data_distortion,
                pop->error_message);
    class_call(distortions_output_sd_data(psd,
                                          number_of_titles_distortion,
                                          data_distortion),
               psd->error_message,
               pop->error_message);

    /* File IO */
    class_open(out_distortion,
               file_name_distortion,
               "w",
               pop->error_message);

    if (pop->write_header == _TRUE_){
      fprintf(out_distortion,"# SD_tot is the amplitude of the overall spectral distortion (SD)\n");
      fprintf(out_distortion,"# The SD[i] are the amplitudes of the individual SDs\n");
      fprintf(out_distortion,"# The SDs are given in units [10^-26 W m^-2 Hz^-1 sr^-1] \n");
      fprintf(out_distortion,"#\n");
    }

    output_print_data(out_distortion,
                      titles_distortion,
                      data_distortion,
                      size_data_distortion);
    free(data_distortion);
    fclose(out_distortion);
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4888, %rsp           # imm = 0x4888
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x2940(%rsp), %rdi
xorl %ebp, %ebp
movl $0x1f40, %edx           # imm = 0x1F40
xorl %esi, %esi
callq 0x8200
leaq 0xa00(%rsp), %rdi
movl $0x1f40, %edx           # imm = 0x1F40
xorl %esi, %esi
callq 0x8200
cmpw $0x1, 0x41c(%rbx)
jne 0xef3b8
cmpl $0x1, 0xcd0(%r14)
jne 0xef3b8
leaq 0x43990(%rip), %r15     # 0x132860
leaq 0x447a2(%rip), %r12     # 0x133679
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %rbx, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
leaq 0x100(%rsp), %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x8550
leaq 0x2940(%rsp), %rsi
movq %r14, %rdi
callq 0xd0f21
cmpl $0x1, %eax
jne 0xeef69
addq $0x1602, %r14           # imm = 0x1602
leaq 0x24c5(%rip), %rsi      # 0xf13f0
leaq 0x44756(%rip), %rdx     # 0x133688
leaq 0x200(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x420, %rbx            # imm = 0x420
leaq 0x20df(%rip), %rsi      # 0xf1034
leaq 0x4475c(%rip), %rdx     # 0x1336b8
movq %rbx, %rdi
movl $0x5e5, %ecx            # imm = 0x5E5
jmp 0xef262
leaq 0x2940(%rsp), %rdi
callq 0x30d6e
movl %eax, %ebp
movslq 0x330(%r14), %rax
movslq %ebp, %r15
imulq %rax, %r15
leaq (,%r15,8), %r13
movq %r13, %rdi
callq 0x8460
testq %rax, %rax
je 0xef000
movq %rax, %r12
movq %r14, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0xd0fb2
cmpl $0x1, %eax
jne 0xef045
addq $0x1602, %r14           # imm = 0x1602
leaq 0x242e(%rip), %rsi      # 0xf13f0
leaq 0x4470c(%rip), %rdx     # 0x1336d5
leaq 0x200(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x420, %rbx            # imm = 0x420
leaq 0x2048(%rip), %rsi      # 0xf1034
leaq 0x446c5(%rip), %rdx     # 0x1336b8
movq %rbx, %rdi
movl $0x5f1, %ecx            # imm = 0x5F1
jmp 0xef262
leaq 0x1ffd(%rip), %rsi      # 0xf1004
leaq 0x446bd(%rip), %rdx     # 0x1336cb
leaq 0x200(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x420, %rbx            # imm = 0x420
leaq 0x2003(%rip), %rsi      # 0xf1034
leaq 0x44680(%rip), %rdx     # 0x1336b8
movq %rbx, %rdi
movl $0x5ec, %ecx            # imm = 0x5EC
jmp 0xef3a9
leaq 0x53c5(%rip), %rsi      # 0xf4411
leaq 0x100(%rsp), %rdi
callq 0x8400
testq %rax, %rax
je 0xef17f
movq %rax, %r13
cmpw $0x1, 0x408(%rbx)
jne 0xef0ba
leaq 0x446ac(%rip), %rdi     # 0x133722
movl $0x16, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x86d0
leaq 0x446aa(%rip), %rdi     # 0x133739
movl $0x19, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x86d0
leaq 0x1e405(%rip), %rdi     # 0x10d4ad
movl $0x2, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x86d0
leaq 0x2940(%rsp), %rsi
movq %r13, %rdi
movq %r12, %rdx
movl %r15d, %ecx
callq 0xf0579
movq %r12, %rdi
callq 0x8410
movq %r13, %rdi
callq 0x83a0
leaq 0x43779(%rip), %r15     # 0x132860
leaq 0x44665(%rip), %r12     # 0x133753
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %rbx, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %rsp, %rdi
movq %r15, %rdx
movq %rbx, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x8550
leaq 0xa00(%rsp), %rsi
movq %r14, %rdi
callq 0xd101a
cmpl $0x1, %eax
jne 0xef1d0
addq $0x1602, %r14           # imm = 0x1602
leaq 0x22af(%rip), %rsi      # 0xf13f0
leaq 0x4461e(%rip), %rdx     # 0x133766
leaq 0x200(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x420, %rbx            # imm = 0x420
leaq 0x1ec9(%rip), %rsi      # 0xf1034
leaq 0x44546(%rip), %rdx     # 0x1336b8
movq %rbx, %rdi
movl $0x60c, %ecx            # imm = 0x60C
jmp 0xef262
leaq 0x4852(%rip), %rsi      # 0xf39d8
leaq 0x4458c(%rip), %rdx     # 0x133719
leaq 0x1e270(%rip), %r8      # 0x10d404
leaq 0x200(%rsp), %r14
leaq 0x100(%rsp), %rcx
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x420, %rbx            # imm = 0x420
leaq 0x1e78(%rip), %rsi      # 0xf1034
leaq 0x444f5(%rip), %rdx     # 0x1336b8
movq %rbx, %rdi
movl $0x5f7, %ecx            # imm = 0x5F7
jmp 0xef3a9
leaq 0xa00(%rsp), %rdi
callq 0x30d6e
movl %eax, %ebp
movslq 0x368(%r14), %rax
movslq %ebp, %r15
imulq %rax, %r15
leaq (,%r15,8), %r13
movq %r13, %rdi
callq 0x8460
testq %rax, %rax
je 0xef26a
movq %rax, %r12
movq %r14, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0xd1176
cmpl $0x1, %eax
jne 0xef2af
addq $0x1602, %r14           # imm = 0x1602
leaq 0x21c7(%rip), %rsi      # 0xf13f0
leaq 0x4457a(%rip), %rdx     # 0x1337aa
leaq 0x200(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x30c2c
addq $0x420, %rbx            # imm = 0x420
leaq 0x1de1(%rip), %rsi      # 0xf1034
leaq 0x4445e(%rip), %rdx     # 0x1336b8
movq %rbx, %rdi
movl $0x618, %ecx            # imm = 0x618
movq %r15, %r8
jmp 0xef3ac
leaq 0x1d93(%rip), %rsi      # 0xf1004
leaq 0x44522(%rip), %rdx     # 0x13379a
leaq 0x200(%rsp), %r14
movq %r14, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x30c2c
addq $0x420, %rbx            # imm = 0x420
leaq 0x1d99(%rip), %rsi      # 0xf1034
leaq 0x44416(%rip), %rdx     # 0x1336b8
movq %rbx, %rdi
movl $0x613, %ecx            # imm = 0x613
jmp 0xef3a9
leaq 0x515b(%rip), %rsi      # 0xf4411
movq %rsp, %rdi
callq 0x8400
testq %rax, %rax
je 0xef362
movq %rax, %r14
cmpw $0x1, 0x408(%rbx)
jne 0xef338
leaq 0x4452c(%rip), %rdi     # 0x133807
movl $0x42, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x86d0
leaq 0x44556(%rip), %rdi     # 0x13384a
movl $0x35, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x86d0
leaq 0x44573(%rip), %rdi     # 0x133880
movl $0x3a, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x86d0
leaq 0x1e187(%rip), %rdi     # 0x10d4ad
movl $0x2, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x86d0
leaq 0xa00(%rsp), %rsi
movq %r14, %rdi
movq %r12, %rdx
movl %r15d, %ecx
callq 0xf0579
movq %r12, %rdi
callq 0x8410
movq %r14, %rdi
callq 0x83a0
xorl %ebp, %ebp
jmp 0xef3b8
leaq 0x466f(%rip), %rsi      # 0xf39d8
leaq 0x44488(%rip), %rdx     # 0x1337f8
leaq 0x1e08d(%rip), %r8      # 0x10d404
leaq 0x200(%rsp), %r14
movq %rsp, %rcx
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
addq $0x420, %rbx            # imm = 0x420
leaq 0x1c9a(%rip), %rsi      # 0xf1034
leaq 0x44317(%rip), %rdx     # 0x1336b8
movq %rbx, %rdi
movl $0x61e, %ecx            # imm = 0x61E
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %ebp
movl %ebp, %eax
addq $0x4888, %rsp           # imm = 0x4888
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq