// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../source/input.c
// Function: input_set_root
int input_set_root(char* input_file,
                   struct file_content** ppfc_input,
                   struct file_content * pfc_setroot,
                   ErrorMsg errmsg) {

  /** Define local variables */
  int flag1, filenum, iextens;
  int index_root_in_fc_input = -1;
  int overwrite_root;
  int found_filenum;

  /* The filename of the output root INCLUDING 'output/' */
  FileArg outfname;

  /* Temporary variables for parser reading etc. */
  char tmp_file[_ARGUMENT_LENGTH_MAX_+26]; // 26 is enough to extend the file name [...] with the
                                           // characters "output/[...]%02d_parameters.ini" (as done below)
  struct file_content fc_root;             // Temporary structure with only the root name

  FileArg string1;                         //Is ignored

  int n_extensions = 7;                    //Keep this as the length of the below list
  char* output_extensions[7] = {"cl.dat","pk.dat","tk.dat","parameters.ini","background.dat","thermodynamics.dat","perturbations_k0.dat"};

  /* Shorthand notation */
  struct file_content * pfc = *ppfc_input;


  /** Check whether a root name has been set, and wether overwrite_root is true */
  class_call(parser_read_string(pfc,"root",&string1,&flag1,errmsg),
             errmsg, errmsg);

  /* Set overwrite_root */
  overwrite_root = _FALSE_;
  class_read_flag("overwrite_root",overwrite_root);

  /** If root has not been set, use the default of 'output/<this-filename>' */
  if (flag1 == _FALSE_){
    memcpy(outfname, "output/", 7);
    memcpy(outfname+7, input_file, strlen(input_file)-4);
    outfname[7+strlen(input_file)-4] = '\0';
  }
  /* Check here for the index of the 'root' field in case it was set in fc_input */
  else{
    for (index_root_in_fc_input=0;index_root_in_fc_input<pfc->size;++index_root_in_fc_input){
      if (strcmp(pfc->name[index_root_in_fc_input],"root") == 0){
        strcpy(outfname,pfc->value[index_root_in_fc_input]);
        break;
      }
    }
  }

  /** If we don't want to overwrite the root name, check now for the existence of output for the given root name + N */
  if (overwrite_root == _FALSE_){

    /* Assume files exist, until proven otherwise */
    found_filenum = _TRUE_;
    /** For each 'filenum', test if it exists. Only stop if it has not been found. */
    for (filenum = 0; filenum < _N_FILEROOT_ && found_filenum; filenum++){
      /* No file has been found yet */
      found_filenum = _FALSE_;
      for (iextens = 0; iextens < n_extensions; ++iextens){
        class_sprintf(tmp_file,"%s%02d_%s", outfname, filenum, output_extensions[iextens]);
        if (file_exists(tmp_file) == _TRUE_){
          /* Found a file, the outer loop is forced to keep searching */
          found_filenum = _TRUE_;
        }
      }
      /* Didn't find a file. This is the correct number. Break the loop. */
      if (found_filenum == _FALSE_){
        break;
      }
    }
    /* If no root was found, add root through the parser routine */
    if (flag1 == _FALSE_){
      class_call(parser_init(&fc_root,
                             1,
                             pfc->filename,
                             errmsg),
                 errmsg,errmsg);
      class_sprintf(fc_root.name[0],"root");
      class_sprintf(fc_root.value[0],"%s%02d_",outfname,filenum);
      fc_root.read[0] = _FALSE_;
      class_call(parser_cat(pfc,
                            &fc_root,
                            pfc_setroot,
                            errmsg),
                 errmsg,
                 errmsg);
      class_call(parser_free(pfc),
                 errmsg,
                 errmsg);
      class_call(parser_free(&fc_root),
                 errmsg,
                 errmsg);
      (*ppfc_input) = pfc_setroot;
    }
    /* If root was found, set the index in the fc_input struct */
    else{
      class_sprintf(pfc->value[index_root_in_fc_input],"%s%02d_",outfname,filenum);
      (*ppfc_input) = pfc;
    }
  }

  /** If we do want to overwrite, just take the given root name */
  else{
    /* If no root was found, add root through the parser routine */
    if (flag1 == _FALSE_){
      class_call(parser_init(&fc_root,
                             1,
                             pfc->filename,
                             errmsg),
                 errmsg,errmsg);
      class_sprintf(fc_root.name[0],"root");
      class_sprintf(fc_root.value[0],"%s_",outfname);
      fc_root.read[0] = _FALSE_;
      class_call(parser_cat(pfc,
                            &fc_root,
                            pfc_setroot,
                            errmsg),
                 errmsg,
                 errmsg);
      class_call(parser_free(pfc),
                 errmsg,
                 errmsg);
      class_call(parser_free(&fc_root),
                 errmsg,
                 errmsg);
      (*ppfc_input) = pfc_setroot;
    }
    /* If root was found, set the index in the fc_input struct */
    else{
      class_sprintf(pfc->value[index_root_in_fc_input],"%s_",outfname);
      (*ppfc_input) = pfc;
    }
  }

  return _SUCCESS_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1868, %rsp           # imm = 0x1868
movq %rcx, %r15
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %r13
movq (%rsi), %r12
leaq 0xc561c(%rip), %rsi     # 0xf73d4
leaq 0x1460(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
movq %r12, %rdi
movq %r15, %r8
callq 0x1ec10
cmpl $0x1, %eax
jne 0x31e23
leaq 0xbf614(%rip), %rsi     # 0xf13f0
leaq 0xc42dd(%rip), %rdx     # 0xf60c0
leaq 0x460(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbf235(%rip), %rsi     # 0xf1034
leaq 0xc42f0(%rip), %rdx     # 0xf60f6
movq %r15, %rdi
movl $0xf9, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl $0x1, %r12d
jmp 0x321f7
leaq 0xc42db(%rip), %rsi     # 0xf6105
leaq 0x60(%rsp), %rbx
leaq 0x38(%rsp), %rcx
movq %r12, %rdi
movq %rbx, %rdx
movq %r15, %r8
callq 0x1ec10
cmpl $0x1, %eax
movq %r12, 0x8(%rsp)
movq %r14, 0x28(%rsp)
movq %rbp, 0x30(%rsp)
jne 0x31e9f
leaq 0xbf593(%rip), %rsi     # 0xf13f0
leaq 0xc42b0(%rip), %rdx     # 0xf6114
xorl %ebp, %ebp
leaq 0x460(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbf1b2(%rip), %rsi     # 0xf1034
leaq 0xc426d(%rip), %rdx     # 0xf60f6
movq %r15, %rdi
movl $0xfd, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movb $0x1, %cl
jmp 0x31ed7
movb $0x1, %cl
cmpl $0x1, 0x38(%rsp)
jne 0x31ed4
leaq 0x60(%rsp), %rdi
movl $0x79, %esi
callq 0x30ddf
testl %eax, %eax
jne 0x31ed2
leaq 0x60(%rsp), %rdi
movl $0x59, %esi
callq 0x30ddf
testl %eax, %eax
je 0x32372
xorl %ecx, %ecx
movb $0x1, %bpl
movl $0x1, %r12d
testb %bpl, %bpl
je 0x321f7
movl 0x1c(%rsp), %eax
movl %eax, 0x4(%rsp)
testl %eax, %eax
je 0x31f4f
movq 0x8(%rsp), %rax
movslq 0x8(%rax), %rbx
testq %rbx, %rbx
jle 0x31f95
movl %ecx, 0x20(%rsp)
movq %r15, 0x10(%rsp)
movq 0x10(%rax), %r14
movq %rbx, %r13
shlq $0xa, %r13
xorl %ebp, %ebp
leaq 0xc54b3(%rip), %r12     # 0xf73d4
xorl %r15d, %r15d
movq %r14, %rdi
movq %r12, %rsi
callq 0x84b0
testl %eax, %eax
je 0x31f99
addq $-0x400, %r15           # imm = 0xFC00
incl %ebp
addq $0x400, %r14            # imm = 0x400
movq %r13, %rax
addq %r15, %rax
jne 0x31f24
movl %ebx, %ebp
jmp 0x31faf
leaq 0x67(%rsp), %r14
movl $0x2f747570, -0x4(%r14) # imm = 0x2F747570
movl $0x7074756f, -0x7(%r14) # imm = 0x7074756F
movq %r13, %rdi
movl %ecx, %r12d
callq 0x8180
leaq -0x4(%rax), %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x82d0
movq %r13, %rdi
callq 0x8180
movl %r12d, %ecx
movb $0x0, 0x3(%rax,%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x31fb8
xorl %ebp, %ebp
jmp 0x31fb8
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
subq %r15, %rsi
leaq 0x60(%rsp), %rdi
callq 0x8350
movq 0x10(%rsp), %r15
movl 0x20(%rsp), %ecx
testb %cl, %cl
je 0x3206b
movq %rbp, 0x20(%rsp)
movq %r15, 0x10(%rsp)
leaq 0x11864f(%rip), %rax    # 0x14a620
leaq 0xc41bc(%rip), %r14     # 0xf6194
leaq 0x60(%rsp), %rbp
movl $0x0, 0x4(%rsp)
xorl %r12d, %r12d
xorl %ebx, %ebx
movq (%r12,%rax), %r15
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %rbp, %rcx
movl 0x4(%rsp), %r13d
movl %r13d, %r8d
movq %r15, %r9
xorl %eax, %eax
callq 0x8550
incl %eax
movslq %eax, %rsi
leaq 0xc60(%rsp), %rdi
movq %r14, %rdx
movq %rbp, %rcx
movl %r13d, %r8d
movq %r15, %r9
leaq 0xc60(%rsp), %r15
xorl %eax, %eax
callq 0x8550
movq %r15, %rdi
callq 0x30d9c
cmpl $0x1, %eax
cmovel %eax, %ebx
leaq 0x1185d9(%rip), %rax    # 0x14a620
addq $0x8, %r12
cmpq $0x38, %r12
jne 0x31fea
testl %ebx, %ebx
je 0x320ba
movl 0x4(%rsp), %ecx
incl %ecx
movl %ecx, 0x4(%rsp)
cmpl $0x64, %ecx
jne 0x31fe5
movl $0x64, %ebp
jmp 0x320be
cmpl $0x0, 0x4(%rsp)
je 0x32125
leaq 0xc41af(%rip), %r15     # 0xf622c
xorl %r12d, %r12d
leaq 0x60(%rsp), %r14
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x8550
movslq %ebp, %rdi
shlq $0xa, %rdi
movq 0x8(%rsp), %rbx
addq 0x18(%rbx), %rdi
incl %eax
movslq %eax, %rsi
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x8550
jmp 0x32118
movl 0x4(%rsp), %ebp
cmpl $0x0, 0x1c(%rsp)
movq 0x10(%rsp), %rbx
je 0x3218a
leaq 0xc40f9(%rip), %r15     # 0xf61ce
xorl %r12d, %r12d
leaq 0x60(%rsp), %r14
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r14, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x8550
movslq 0x20(%rsp), %rdi
shlq $0xa, %rdi
movq 0x8(%rsp), %rbx
addq 0x18(%rbx), %rdi
incl %eax
movslq %eax, %rsi
movq %r15, %rdx
movq %r14, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x8550
movq 0x28(%rsp), %rax
movq %rbx, (%rax)
jmp 0x321f7
movq 0x8(%rsp), %r13
movq (%r13), %rdx
leaq 0x38(%rsp), %rdi
movl $0x1, %r12d
movl $0x1, %esi
movq %r15, %rcx
callq 0x1e4f1
cmpl $0x1, %eax
jne 0x3220c
leaq 0xbf29a(%rip), %rsi     # 0xf13f0
leaq 0xc4041(%rip), %rdx     # 0xf619e
leaq 0x460(%rsp), %r14
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbeebb(%rip), %rsi     # 0xf1034
leaq 0xc3f76(%rip), %rdx     # 0xf60f6
movq %r15, %rdi
movl $0x14b, %ecx            # imm = 0x14B
jmp 0x321ed
movq 0x8(%rsp), %r13
movq (%r13), %rdx
leaq 0x38(%rsp), %rdi
movl $0x1, %r12d
movl $0x1, %esi
movq %rbx, %rcx
callq 0x1e4f1
cmpl $0x1, %eax
jne 0x322bb
leaq 0xbf235(%rip), %rsi     # 0xf13f0
leaq 0xc3fdc(%rip), %rdx     # 0xf619e
leaq 0x460(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbee56(%rip), %rsi     # 0xf1034
leaq 0xc3f11(%rip), %rdx     # 0xf60f6
movq %rbx, %rdi
movl $0x12a, %ecx            # imm = 0x12A
movq %r14, %r8
xorl %eax, %eax
callq 0x30c2c
movl %r12d, %eax
addq $0x1868, %rsp           # imm = 0x1868
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x38(%rsp), %r14
movq 0x10(%r14), %rax
movb $0x0, 0x4(%rax)
movl $0x746f6f72, (%rax)     # imm = 0x746F6F72
movq %r15, %rbx
leaq 0xc4003(%rip), %r15     # 0xf622c
leaq 0x60(%rsp), %r12
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x8550
movq 0x18(%r14), %rdi
incl %eax
movslq %eax, %rsi
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x8550
movq 0x20(%r14), %rax
movw $0x0, (%rax)
movq %r13, %rdi
movq %r14, %rsi
movq 0x30(%rsp), %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x1f57a
cmpl $0x1, %eax
jne 0x323a4
leaq 0xbf16c(%rip), %rsi     # 0xf13f0
leaq 0xc3f4b(%rip), %rdx     # 0xf61d6
leaq 0x460(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbed8d(%rip), %rsi     # 0xf1034
leaq 0xc3e48(%rip), %rdx     # 0xf60f6
movq %rbx, %rdi
movl $0x154, %ecx            # imm = 0x154
jmp 0x31e0e
leaq 0x38(%rsp), %r14
movq 0x10(%r14), %rax
movb $0x0, 0x4(%rax)
movl $0x746f6f72, (%rax)     # imm = 0x746F6F72
leaq 0xc3ef9(%rip), %r15     # 0xf61ce
leaq 0x60(%rsp), %r12
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x8550
movq 0x18(%r14), %rdi
incl %eax
movslq %eax, %rsi
movq %r15, %rdx
movq 0x10(%rsp), %rbx
movq %r12, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x8550
movq 0x20(%r14), %rax
movw $0x0, (%rax)
movq %r13, %rdi
movq %r14, %rsi
movq 0x30(%rsp), %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x1f57a
cmpl $0x1, %eax
jne 0x323f3
leaq 0xbf0b5(%rip), %rsi     # 0xf13f0
leaq 0xc3e94(%rip), %rdx     # 0xf61d6
leaq 0x460(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbecd6(%rip), %rsi     # 0xf1034
leaq 0xc3d91(%rip), %rdx     # 0xf60f6
movq %rbx, %rdi
movl $0x133, %ecx            # imm = 0x133
jmp 0x31e0e
leaq 0x60(%rsp), %rdi
movl $0x6e, %esi
callq 0x30ddf
testl %eax, %eax
jne 0x3239c
leaq 0x60(%rsp), %rdi
movl $0x4e, %esi
callq 0x30ddf
testl %eax, %eax
je 0x324f0
movb $0x1, %bpl
jmp 0x31e9b
movq %r13, %rdi
callq 0x1e68f
cmpl $0x1, %eax
jne 0x32442
leaq 0xbf034(%rip), %rsi     # 0xf13f0
leaq 0xc3e42(%rip), %rdx     # 0xf6205
leaq 0x460(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbec55(%rip), %rsi     # 0xf1034
leaq 0xc3d10(%rip), %rdx     # 0xf60f6
movq %rbx, %rdi
movl $0x157, %ecx            # imm = 0x157
jmp 0x31e0e
movq %r13, %rdi
callq 0x1e68f
cmpl $0x1, %eax
jne 0x32493
leaq 0xbefe5(%rip), %rsi     # 0xf13f0
leaq 0xc3df3(%rip), %rdx     # 0xf6205
leaq 0x460(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbec06(%rip), %rsi     # 0xf1034
leaq 0xc3cc1(%rip), %rdx     # 0xf60f6
movq %rbx, %rdi
movl $0x136, %ecx            # imm = 0x136
jmp 0x31e0e
leaq 0x38(%rsp), %rdi
callq 0x1e68f
cmpl $0x1, %eax
jne 0x324e0
leaq 0xbef94(%rip), %rsi     # 0xf13f0
leaq 0xc3db3(%rip), %rdx     # 0xf6216
leaq 0x460(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbebb5(%rip), %rsi     # 0xf1034
leaq 0xc3c70(%rip), %rdx     # 0xf60f6
movq %rbx, %rdi
movl $0x15a, %ecx            # imm = 0x15A
jmp 0x31e0e
leaq 0x38(%rsp), %rdi
callq 0x1e68f
cmpl $0x1, %eax
jne 0x324e0
leaq 0xbef47(%rip), %rsi     # 0xf13f0
leaq 0xc3d66(%rip), %rdx     # 0xf6216
leaq 0x460(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbeb68(%rip), %rsi     # 0xf1034
leaq 0xc3c23(%rip), %rdx     # 0xf60f6
movq %rbx, %rdi
movl $0x139, %ecx            # imm = 0x139
jmp 0x31e0e
movq 0x28(%rsp), %rax
movq %r14, (%rax)
xorl %r12d, %r12d
jmp 0x321f7
leaq 0xc3c65(%rip), %rsi     # 0xf615c
leaq 0xc3c07(%rip), %rcx     # 0xf6105
xorl %ebp, %ebp
leaq 0x460(%rsp), %r14
leaq 0x60(%rsp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x30c2c
leaq 0xbf067(%rip), %rsi     # 0xf1585
leaq 0xc60(%rsp), %r12
movq %r12, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x30c2c
leaq 0xbeafa(%rip), %rsi     # 0xf1034
leaq 0xc3bb5(%rip), %rdx     # 0xf60f6
movq %r15, %rdi
movl $0xfd, %ecx
movq %r12, %r8
jmp 0x31e94