// File: /workspace/github_c_makefile_star2_O2/lesgourg[P]class_public/build/../source/input.c
// Function: input_shooting
int input_shooting(struct file_content * pfc,
                   struct precision * ppr,
                   struct background *pba,
                   struct thermodynamics *pth,
                   struct perturbations *ppt,
                   struct transfer *ptr,
                   struct primordial *ppm,
                   struct harmonic *phr,
                   struct fourier * pfo,
                   struct lensing *ple,
                   struct distortions *psd,
                   struct output *pop,
                   int input_verbose,
                   int * has_shooting,
                   ErrorMsg errmsg){

  /** Summary: */

  /** Define local variables */
  int flag1, flag2;
  double param1, param2;
  double * unknown_parameter;
  int unknown_parameters_size;
  int counter, index_target;
  int fevals=0;
  double xzero;
  double *dxdF, *x_inout;
  int target_indices[_NUM_TARGETS_];
  int needs_shooting;
  int shooting_failed=_FALSE_;

  /* array of parameters passed by the user for which we need shooting (= target parameters) */
  char * const target_namestrings[] = {"100*theta_s",
                                       "theta_s_100",
                                       "Neff",
                                       "Omega_dcdmdr",
                                       "omega_dcdmdr",
                                       "Omega_scf",
                                       "Omega_ini_dcdm",
                                       "omega_ini_dcdm"};

  /* array of corresponding parameters that must be adjusted in order to meet the target (= unknown parameters) */
  char * const unknown_namestrings[] = {"h",                        /* unknown param for target '100*theta_s' */
                                        "h",                        /* unknown param for target 'theta_s_100' */
                                        "N_ur",                     /* unknown param for target 'Neff' */
                                        "Omega_ini_dcdm",           /* unknown param for target 'Omega_dcdmd' */
                                        "omega_ini_dcdm",           /* unknown param for target 'omega_dcdmdr' */
                                        "scf_shooting_parameter",   /* unknown param for target 'Omega_scf' */
                                        "Omega_dcdmdr",             /* unknown param for target 'Omega_ini_dcdm' */
                                        "omega_dcdmdr"};             /* unknown param for target 'omega_ini_dcdm' */

  /* for each target, module up to which we need to run CLASS in order
     to compute the targetted quantities (not running the whole code
     each time to saves a lot of time) */
  enum computation_stage target_cs[] = {cs_thermodynamics, /* computation stage for target '100*theta_s' */
                                        cs_thermodynamics, /* computation stage for target 'theta_s_100' */
                                        cs_background,     /* computation stage for target 'Neff' */
                                        cs_background,     /* computation stage for target 'Omega_dcdmdr' */
                                        cs_background,     /* computation stage for target 'omega_dcdmdr' */
                                        cs_background,     /* computation stage for target 'Omega_scf' */
                                        cs_background,     /* computation stage for target 'Omega_ini_dcdm' */
                                        cs_background};     /* computation stage for target 'omega_ini_dcdm' */

  struct fzerofun_workspace fzw;

  *has_shooting=_FALSE_;

  /** Do we need to fix unknown parameters? */
  unknown_parameters_size = 0;
  fzw.required_computation_stage = 0;
  for (index_target = 0; index_target < _NUM_TARGETS_; index_target++){
    class_call(parser_read_double(pfc,target_namestrings[index_target],&param1,&flag1,errmsg),
               errmsg,
               errmsg);
    if (flag1 == _TRUE_){
      /* input_needs_shoting_for_target takes care of the case where, for
         instance, Omega_dcdmdr is set to 0.0, and we don't need shooting */
      class_call(input_needs_shooting_for_target(pfc,
                                                 index_target,
                                                 param1,
                                                 &needs_shooting,
                                                 errmsg),
                 errmsg,
                 errmsg);

      if (needs_shooting == _TRUE_){
        target_indices[unknown_parameters_size] = index_target;
        fzw.required_computation_stage = MAX(fzw.required_computation_stage,target_cs[index_target]);
        unknown_parameters_size++;
      }

    }
  }

  /** In the case of unknown parameters, start shooting... */
  if (unknown_parameters_size > 0) {

    /* We need to remember that we shot so we can clean up properly */
    *has_shooting=_TRUE_;

    /* Create file content structure with additional entries */
    class_call(parser_extend(pfc, unknown_parameters_size, errmsg),
               errmsg,errmsg);

    class_call(parser_init_from_pfc(pfc, &(fzw.fc), errmsg),
               errmsg,errmsg);

    class_alloc(unknown_parameter,
                unknown_parameters_size*sizeof(double),
                errmsg);
    class_alloc(fzw.unknown_parameters_index,
                unknown_parameters_size*sizeof(int),
                errmsg);

    fzw.target_size = unknown_parameters_size;
    class_alloc(fzw.target_name,
                fzw.target_size*sizeof(enum target_names),
                errmsg);
    class_alloc(fzw.target_value,
                fzw.target_size*sizeof(double),
                errmsg);

    /** Go through all cases with unknown parameters */
    for (counter = 0; counter < unknown_parameters_size; counter++){
      index_target = target_indices[counter];
      class_call(parser_read_double(pfc,
                                    target_namestrings[index_target],
                                    &param1,
                                    &flag1,
                                    errmsg),
                 errmsg,
                 errmsg);

      /* store name of target parameter */
      fzw.target_name[counter] = index_target;
      /* store target value of target parameter */
      fzw.target_value[counter] = param1;
      fzw.unknown_parameters_index[counter]=pfc->size+counter-unknown_parameters_size;
      /* substitute the name of the target parameter with the name of the
         corresponding unknown parameter */
      strcpy(fzw.fc.name[fzw.unknown_parameters_index[counter]],unknown_namestrings[index_target]);
    }

    /** If there is only one parameter, we use a more efficient Newton method for 1D cases */
    if (unknown_parameters_size == 1){

      /* We can do 1 dimensional root finding */
      if (input_verbose > 0) {
        printf("Computing unknown input parameter '%s' using input parameter '%s'\n",
               fzw.fc.name[fzw.unknown_parameters_index[0]],
               target_namestrings[fzw.target_name[0]]);
      }

      /* If shooting fails, postpone error to background module to play nice with MontePython. */
      class_call_try(input_find_root(&xzero,
                                     &fevals,
                                     ppr->tol_shooting_deltax_rel,
                                     &fzw,
                                     errmsg),
                     errmsg,
                     pba->shooting_error,
                     shooting_failed=_TRUE_);

      /* Store xzero */
      // This needs to be done with enough accuracy. A standard double has a relative
      // precision of around 1e-16, so 1e-20 should be good enough for the shooting
      class_sprintf(fzw.fc.value[fzw.unknown_parameters_index[0]],"%.20e",xzero);
      if (input_verbose > 0) {
        if (shooting_failed == _FALSE_){
          printf(" -> found '%s = %s'\n",
                  fzw.fc.name[fzw.unknown_parameters_index[0]],
                  fzw.fc.value[fzw.unknown_parameters_index[0]]);
        }
        else{
          printf("Shooting failed! Aborting...\n");
        }
      }

    }
    /** Otherwise we do multidimensional shooting */
    else{

      /* We need to do multidimensional root finding */
      if (input_verbose > 0) {
        printf("Computing unknown input parameters\n");
      }

      /* Allocate local variables */
      class_alloc(x_inout,
                  sizeof(double)*unknown_parameters_size,
                  errmsg);
      class_alloc(dxdF,
                  sizeof(double)*unknown_parameters_size,
                  errmsg);

      /* Get the guess for the initial variables */
      class_call(input_get_guess(x_inout, dxdF, &fzw, errmsg),
                 errmsg,
                 errmsg);

      /* Use multi-dimensional Newton method */
      class_call_try(fzero_Newton(input_try_unknown_parameters,
                                  x_inout,
                                  dxdF,
                                  unknown_parameters_size,
                                  ppr->tol_shooting_deltax,
                                  ppr->tol_shooting_deltaF,
                                  &fzw,
                                  &fevals,
                                  errmsg),
                     errmsg,
                     pba->shooting_error,
                     shooting_failed=_TRUE_);

      /* Store xzero */
      // This needs to be done with enough accuracy. A standard double has a relative
      // precision of around 1e-16, so 1e-20 should be good enough for the shooting
      for (counter = 0; counter < unknown_parameters_size; counter++){
        class_sprintf(fzw.fc.value[fzw.unknown_parameters_index[counter]],
                "%.20e",x_inout[counter]);
        if (input_verbose > 0) {
          if (shooting_failed == _FALSE_){
            printf(" -> found '%s = %s'\n",
                    fzw.fc.name[fzw.unknown_parameters_index[counter]],
                    fzw.fc.value[fzw.unknown_parameters_index[counter]]);
          }
          else{
            printf("Shooting failed! Aborting...\n");
          }
        }
      }

      /* Free local variables */
      free(x_inout);
      free(dxdF);
    }

    if (input_verbose > 1 && shooting_failed == _FALSE_) {
      printf("Shooting completed using %d function evaluations\n",fevals);
    }

    /** Set status of shooting */
    pba->shooting_failed = shooting_failed;

    parser_copy(&(fzw.fc), pfc, pfc->size - unknown_parameters_size, pfc->size);

    /** Free arrays allocated */
    class_call(parser_free(&(fzw.fc)),
               errmsg, errmsg);
    free(unknown_parameter);
    free(fzw.unknown_parameters_index);
    free(fzw.target_name);
    free(fzw.target_value);
  }


  /** After the 'normal' shooting is done, do special shooting just for sigma8 if needed*/
  class_call(parser_read_double(pfc,"sigma8",&param1,&flag1,errmsg),
             errmsg,
             errmsg);
  class_call(parser_read_double(pfc,"S8",&param2,&flag2,errmsg),
             errmsg,
             errmsg);
  class_test((flag1 == _TRUE_) && (flag2 == _TRUE_),
             errmsg,
             "You can only enter one of 'sigma8' or 'S8'.");
  if (flag1 == _TRUE_ || flag2 == _TRUE_) {
    /* Tell the main function that shooting indeed has occured */
    *has_shooting=_TRUE_;

    /* Create file content structure with additional entries */
    class_call(parser_extend(pfc, 1, errmsg),
               errmsg,errmsg);

    class_call(parser_init_from_pfc(pfc, &(fzw.fc), errmsg),
               errmsg,errmsg);

    fzw.target_size = 1;
    class_alloc(fzw.unknown_parameters_index,
                1*sizeof(int),
                errmsg);
    class_alloc(fzw.target_name,
                1*sizeof(enum target_names),
                errmsg);
    class_alloc(fzw.target_value,
                1*sizeof(double),
                errmsg);

    /* store name of target parameter */
    if (flag1 == _TRUE_) {
      fzw.target_name[0] = sigma8;
      fzw.target_value[0] = param1;
    }
    else if (flag2 == _TRUE_) {
      fzw.target_name[0] = S8;
      fzw.target_value[0] = param2;
    }
    /* store target value of target parameter */
    fzw.unknown_parameters_index[0]=pfc->size - 1;
    fzw.required_computation_stage = cs_nonlinear;
    /* substitute the name of the target parameter with the name of the
       corresponding unknown parameter */
    strcpy(fzw.fc.name[pfc->size - 1],"A_s");

    /* Print to the user */
    if (input_verbose > 0) {
      printf("Computing unknown input parameter '%s' using input parameter '%s'\n",
             (flag1 ==_TRUE_?"sigma8":"S8"),
             "A_s");
    }

    /* Set a guess for A_s from LCDM (doesn't need to be super accurate) */
    double A_s;
    if (flag1 == _TRUE_) {
      A_s = param1 * 2.43e-9/0.87659;
    }
    else if (flag2 == _TRUE_) {
      A_s = param2 *2.43e-9/0.891;
    }
    double sigma8_or_S8;

    /* Now run for a single time, get the value of sigma8 (or S8) for the guess*/
    class_call(input_try_unknown_parameters(&A_s,
                                            1,
                                            &fzw,
                                            &sigma8_or_S8,
                                            errmsg),
               errmsg,
               errmsg);

    A_s = (fzw.target_value[0]/sigma8_or_S8) *(fzw.target_value[0]/sigma8_or_S8) * A_s; //(truesigma/sigma_for_guess)^2 *A_s_for_guess

    /* Store the derived value with high enough accuracy */
    class_sprintf(fzw.fc.value[pfc->size - 1],"%.20e",A_s);
    if (input_verbose > 0) {
      printf(" -> found '%s = %s'\n",
             fzw.fc.name[pfc->size - 1],
             fzw.fc.value[pfc->size - 1]);
    }

    parser_copy(&(fzw.fc), pfc, pfc->size - 1, pfc->size);

    /** Free arrays allocated */
    class_call(parser_free(&(fzw.fc)),
               errmsg, errmsg);
    free(fzw.unknown_parameters_index);
    free(fzw.target_name);
    free(fzw.target_value);
  }

  return _SUCCESS_;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10d8, %rsp           # imm = 0x10D8
movq %rdx, 0x90(%rsp)
movq %rsi, 0x28(%rsp)
movq 0x1148(%rsp), %rax
andl $0x0, 0x20(%rsp)
andl $0x0, (%rax)
movl $0xfffffff8, %eax       # imm = 0xFFFFFFF8
andl $0x0, 0x7c(%rsp)
xorl %r15d, %r15d
leaq 0xb9131(%rip), %r12     # 0xef270
leaq 0xf756a(%rip), %rbx     # 0x12d6b0
leaq 0xc(%rsp), %rbp
leaq 0x3(%rax), %r14
movq $0x0, 0x10(%rsp)
cmpq $0x8, %r15
je 0x361e6
movq (%rbx), %rsi
movq %rdi, %r13
leaq 0x30(%rsp), %rdx
movq %rbp, %rcx
movq 0x1150(%rsp), %r8
callq 0x1c775
cmpl $0x1, %eax
je 0x3625c
cmpl $0x1, 0xc(%rsp)
jne 0x361d3
movl $0xfffffff8, %eax       # imm = 0xFFFFFFF8
addq %r15, %rax
cmpq %r14, %rax
jb 0x361ac
movsd 0x30(%rsp), %xmm0
ucomisd 0xa00b0(%rip), %xmm0    # 0xd6258
jne 0x361ac
jnp 0x361d3
movl 0x7c(%rsp), %eax
movl (%r12), %ecx
cmpl %ecx, %eax
cmoval %eax, %ecx
movq 0x10(%rsp), %rax
cltq
movl %r15d, 0xb0(%rsp,%rax,4)
movl %ecx, 0x7c(%rsp)
incl %eax
movq %rax, 0x10(%rsp)
incq %r15
addq $0x4, %r12
addq $0x8, %rbx
movq %r13, %rdi
jmp 0x36158
movq 0x10(%rsp), %r12
testl %r12d, %r12d
movq 0x1150(%rsp), %r14
jle 0x369f6
movq 0x1148(%rsp), %rax
movl $0x1, (%rax)
movl %r12d, %esi
movq %r14, %rdx
movq %rdi, %rbx
callq 0x1dae8
cmpl $0x1, %eax
jne 0x362be
leaq 0xa01c8(%rip), %rsi     # 0xd63f0
leaq 0xa50cd(%rip), %rdx     # 0xdb2fc
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9fde9(%rip), %rsi     # 0xd6034
leaq 0xa509b(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x259, %ecx            # imm = 0x259
jmp 0x3629d
leaq 0xa018d(%rip), %rsi     # 0xd63f0
leaq 0xa5034(%rip), %rdx     # 0xdb29e
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq 0x1150(%rsp), %rbx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9fda6(%rip), %rsi     # 0xd6034
leaq 0xa5058(%rip), %rdx     # 0xdb2ed
movq %rbx, %rdi
movl $0x23c, %ecx            # imm = 0x23C
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x10d8, %rsp           # imm = 0x10D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40(%rsp), %rsi
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1dce4
cmpl $0x1, %eax
jne 0x36313
leaq 0xa0111(%rip), %rsi     # 0xd63f0
leaq 0xa504a(%rip), %rdx     # 0xdb330
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9fd32(%rip), %rsi     # 0xd6034
leaq 0xa4fe4(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x25c, %ecx            # imm = 0x25C
jmp 0x3629d
movl %r12d, %eax
movq %rax, 0x80(%rsp)
leaq (,%rax,4), %r13
movq %r13, %rdi
callq 0x8490
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x3642e
movl %r12d, 0x78(%rsp)
movq %r13, %rdi
callq 0x8490
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x3646c
movq 0x80(%rsp), %rax
leaq (,%rax,8), %rbx
movq %rbx, %rdi
callq 0x8490
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x364ae
movq %rbx, 0x88(%rsp)
movl %r12d, %r14d
negl %r14d
xorl %r15d, %r15d
leaq 0xc(%rsp), %r13
leaq 0xa47b6(%rip), %r12     # 0xdab50
movq 0x18(%rsp), %rbp
cmpq %r15, 0x80(%rsp)
je 0x364f0
movl 0xb0(%rsp,%r15,4), %eax
movslq %eax, %rbx
leaq 0xf72f1(%rip), %rax     # 0x12d6b0
movq (%rax,%rbx,8), %rsi
movq %rbp, %rdi
leaq 0x30(%rsp), %rdx
movq %r13, %rcx
movq 0x1150(%rsp), %r8
callq 0x1c775
cmpl $0x1, %eax
je 0x365cd
movq 0x68(%rsp), %rax
movl %ebx, (%rax,%r15,4)
movsd 0x30(%rsp), %xmm0
movq 0x70(%rsp), %rax
movsd %xmm0, (%rax,%r15,8)
leal (%r14,%r15), %eax
addl 0x8(%rbp), %eax
movq 0x38(%rsp), %rcx
movl %eax, (%rcx,%r15,4)
movslq %eax, %rdi
shlq $0xa, %rdi
addq 0x50(%rsp), %rdi
movslq (%r12,%rbx,4), %rsi
addq %r12, %rsi
callq 0x8370
incq %r15
jmp 0x3639f
leaq 0x9fbcf(%rip), %rsi     # 0xd6004
leaq 0xa4f21(%rip), %rdx     # 0xdb35d
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
leaq 0x9fbdc(%rip), %rsi     # 0xd6034
leaq 0xa4e8e(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x263, %ecx            # imm = 0x263
jmp 0x3629d
shll $0x2, %r12d
leaq 0x9fb8d(%rip), %rsi     # 0xd6004
leaq 0xa4efc(%rip), %rdx     # 0xdb37a
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2e014
leaq 0x9fb9a(%rip), %rsi     # 0xd6034
leaq 0xa4e4c(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x268, %ecx            # imm = 0x268
jmp 0x3629d
shll $0x3, %r12d
leaq 0x9fb4b(%rip), %rsi     # 0xd6004
leaq 0xa4eca(%rip), %rdx     # 0xdb38a
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2e014
leaq 0x9fb58(%rip), %rsi     # 0xd6034
leaq 0xa4e0a(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x26b, %ecx            # imm = 0x26B
jmp 0x3629d
movq 0x10(%rsp), %r12
movl 0x1140(%rsp), %r15d
cmpl $0x1, %r12d
jne 0x36613
testl %r15d, %r15d
movq 0x1150(%rsp), %r14
jle 0x36545
movq 0x38(%rsp), %rax
movq 0x68(%rsp), %rcx
movslq (%rax), %rsi
shlq $0xa, %rsi
addq 0x50(%rsp), %rsi
movl (%rcx), %eax
leaq 0xf717d(%rip), %rcx     # 0x12d6b0
movq (%rcx,%rax,8), %rdx
leaq 0xa4eb0(%rip), %rdi     # 0xdb3ee
xorl %eax, %eax
callq 0x8030
movq %r12, %r15
movq 0x28(%rsp), %rax
movsd 0x78(%rax), %xmm0
leaq 0xa8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %r14, %rcx
callq 0x38488
movl %eax, %ebp
testl %eax, %eax
je 0x366b5
leaq 0x9fe73(%rip), %rsi     # 0xd63f0
leaq 0xa4ead(%rip), %rdx     # 0xdb431
leaq 0xd0(%rsp), %r13
movq %r13, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
movq 0x90(%rsp), %rax
leaq 0x382(%rax), %rdi
leaq 0x9fa85(%rip), %rsi     # 0xd6034
leaq 0xa4d37(%rip), %rdx     # 0xdb2ed
movl $0x294, %ecx            # imm = 0x294
movq %r13, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rbx
jmp 0x366b7
leaq 0x9fe1c(%rip), %rsi     # 0xd63f0
leaq 0xa4dc0(%rip), %rdx     # 0xdb39b
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq 0x1150(%rsp), %rbx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9fa35(%rip), %rsi     # 0xd6034
leaq 0xa4ce7(%rip), %rdx     # 0xdb2ed
movq %rbx, %rdi
movl $0x276, %ecx            # imm = 0x276
jmp 0x3629d
testl %r15d, %r15d
movq 0x1150(%rsp), %r14
jle 0x3662c
leaq 0xb8ab6(%rip), %rdi     # 0xef0dd
callq 0x8540
movq 0x88(%rsp), %r13
movq %r13, %rdi
callq 0x8490
testq %rax, %rax
je 0x3672b
movq %rax, %rbx
movq %r13, %rdi
callq 0x8490
testq %rax, %rax
je 0x36769
movq %rax, %r13
leaq 0x38(%rsp), %rdx
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rcx
callq 0x38721
testl %eax, %eax
je 0x367d5
leaq 0x9fd72(%rip), %rsi     # 0xd63f0
leaq 0xa4e1b(%rip), %rdx     # 0xdb4a0
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9f993(%rip), %rsi     # 0xd6034
leaq 0xa4c45(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x2b9, %ecx            # imm = 0x2B9
jmp 0x3629d
xorl %ebx, %ebx
movsd 0xa8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
leaq 0xa1ca7(%rip), %r13     # 0xd8374
xorl %edi, %edi
xorl %esi, %esi
movq %r13, %rdx
movb $0x1, %al
callq 0x8580
movq 0x38(%rsp), %rcx
movslq (%rcx), %rdi
shlq $0xa, %rdi
addq 0x58(%rsp), %rdi
incl %eax
movslq %eax, %rsi
movq %r13, %rdx
movsd 0x28(%rsp), %xmm0
movb $0x1, %al
callq 0x8580
cmpl $0x0, 0x1140(%rsp)
jle 0x3695f
testl %ebp, %ebp
je 0x367a7
leaq 0xb89e2(%rip), %rdi     # 0xef100
callq 0x8540
pushq $0x1
popq %rbx
jmp 0x3695f
leaq 0x9f8d2(%rip), %rsi     # 0xd6004
leaq 0xa4d5a(%rip), %rdx     # 0xdb493
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2e014
leaq 0x9f8df(%rip), %rsi     # 0xd6034
leaq 0xa4b91(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x2b1, %ecx            # imm = 0x2B1
jmp 0x3629d
movq %r13, %rcx
leaq 0x9f891(%rip), %rsi     # 0xd6004
leaq 0xa4d21(%rip), %rdx     # 0xdb49b
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x9f8a1(%rip), %rsi     # 0xd6034
leaq 0xa4b53(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x2b4, %ecx            # imm = 0x2B4
jmp 0x3629d
movq 0x38(%rsp), %rax
movslq (%rax), %rdx
shlq $0xa, %rdx
movq 0x50(%rsp), %rsi
addq %rdx, %rsi
addq 0x58(%rsp), %rdx
leaq 0xa4cb7(%rip), %rdi     # 0xdb47e
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x8030
jmp 0x3693a
movq %r12, 0x10(%rsp)
movq 0x28(%rsp), %rax
movsd 0x68(%rax), %xmm0
movsd 0x70(%rax), %xmm1
movq %r14, (%rsp)
leaq 0x2549(%rip), %rdi      # 0x38d3d
leaq 0x38(%rsp), %r8
leaq 0x20(%rsp), %r9
movq %rbx, %r15
movq %rbx, %rsi
movq %r13, 0x28(%rsp)
movq %r13, %rdx
movq 0x80(%rsp), %rcx
callq 0x1050c
xorl %ecx, %ecx
movl %eax, %r13d
cmpl $0x1, %eax
jne 0x36875
leaq 0x9fbc6(%rip), %rsi     # 0xd63f0
leaq 0xa4c9c(%rip), %rdx     # 0xdb4cd
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
movq 0x90(%rsp), %rax
leaq 0x382(%rax), %rdi
leaq 0x9f7d8(%rip), %rsi     # 0xd6034
leaq 0xa4a8a(%rip), %rdx     # 0xdb2ed
movl $0x2c7, %ecx            # imm = 0x2C7
movq %rbx, %r8
xorl %eax, %eax
callq 0x2e014
pushq $0x1
popq %rcx
movl %ecx, 0x88(%rsp)
leaq 0xa1af1(%rip), %rbp     # 0xd8374
xorl %ebx, %ebx
cmpq %rbx, 0x80(%rsp)
je 0x3691c
movsd (%r15,%rbx,8), %xmm0
xorl %edi, %edi
xorl %esi, %esi
movq %rbp, %rdx
movb $0x1, %al
callq 0x8580
movq 0x38(%rsp), %rcx
movslq (%rcx,%rbx,4), %rdi
shlq $0xa, %rdi
addq 0x58(%rsp), %rdi
incl %eax
movslq %eax, %rsi
movsd (%r15,%rbx,8), %xmm0
movq %rbp, %rdx
movb $0x1, %al
callq 0x8580
cmpl $0x0, 0x1140(%rsp)
jle 0x36914
cmpl $0x1, %r13d
jne 0x368ec
leaq 0xb881b(%rip), %rdi     # 0xef100
callq 0x8540
jmp 0x36914
movq 0x38(%rsp), %rax
movslq (%rax,%rbx,4), %rdx
shlq $0xa, %rdx
movq 0x50(%rsp), %rsi
addq %rdx, %rsi
addq 0x58(%rsp), %rdx
leaq 0xa4b71(%rip), %rdi     # 0xdb47e
xorl %eax, %eax
callq 0x8030
incq %rbx
jmp 0x36885
movq %r15, %rdi
callq 0x8430
movq 0x28(%rsp), %rdi
callq 0x8430
movl 0x88(%rsp), %ebx
movq 0x10(%rsp), %r15
cmpl $0x2, 0x1140(%rsp)
setl %al
movl %ebx, %ecx
orb %al, %cl
jne 0x3695f
movl 0x20(%rsp), %esi
leaq 0xa4c15(%rip), %rdi     # 0xdb56b
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x8030
movq 0x90(%rsp), %rax
movw %bx, 0x380(%rax)
movq 0x18(%rsp), %rsi
movl 0x8(%rsi), %ecx
movl %ecx, %edx
subl %r15d, %edx
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x1dc64
movq %rbx, %rdi
callq 0x1c593
cmpl $0x1, %eax
jne 0x369d3
leaq 0x9fa54(%rip), %rsi     # 0xd63f0
leaq 0xa4bfa(%rip), %rdx     # 0xdb59d
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9f675(%rip), %rsi     # 0xd6034
leaq 0xa4927(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x2eb, %ecx            # imm = 0x2EB
jmp 0x3629d
movq 0x38(%rsp), %rdi
callq 0x8430
movq 0x68(%rsp), %rdi
callq 0x8430
movq 0x70(%rsp), %rdi
callq 0x8430
movq 0x18(%rsp), %rdi
leaq 0xcaae1(%rip), %r13     # 0x1014de
leaq 0x30(%rsp), %r12
leaq 0xc(%rsp), %rcx
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %r8
movq %rdi, %rbx
callq 0x1c775
cmpl $0x1, %eax
jne 0x36a5b
leaq 0x9f9cc(%rip), %rsi     # 0xd63f0
leaq 0xa4b89(%rip), %rdx     # 0xdb5b4
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9f5ed(%rip), %rsi     # 0xd6034
leaq 0xa489f(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x2f6, %ecx            # imm = 0x2F6
jmp 0x3629d
leaq 0xa4b89(%rip), %rbp     # 0xdb5eb
leaq 0x98(%rsp), %rdx
leaq 0x24(%rsp), %rcx
movq %rbx, 0x18(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %r8
callq 0x1c775
cmpl $0x1, %eax
jne 0x36ac5
leaq 0x9f962(%rip), %rsi     # 0xd63f0
leaq 0xa4b59(%rip), %rdx     # 0xdb5ee
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9f583(%rip), %rsi     # 0xd6034
leaq 0xa4835(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x2f9, %ecx            # imm = 0x2F9
jmp 0x3629d
movl 0xc(%rsp), %eax
movl %eax, %edx
xorl $0x1, %edx
movl 0x24(%rsp), %ecx
movl %ecx, %esi
xorl $0x1, %esi
orl %edx, %esi
jne 0x36b35
leaq 0xa4b3f(%rip), %rsi     # 0xdb621
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x9f587(%rip), %rsi     # 0xd6082
leaq 0xa4b4b(%rip), %rdx     # 0xdb64d
leaq 0x8d0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9f516(%rip), %rsi     # 0xd6034
leaq 0xa47c8(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x2fc, %ecx            # imm = 0x2FC
movq %r12, %r8
jmp 0x362a0
cmpl $0x1, %ecx
sete %cl
cmpl $0x1, %eax
sete %al
orb %cl, %al
xorl %ebx, %ebx
cmpb $0x1, %al
jne 0x362aa
movq 0x1148(%rsp), %rax
movl $0x1, (%rax)
pushq $0x1
popq %rbx
movq 0x18(%rsp), %r15
movq %r15, %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0x1dae8
cmpl $0x1, %eax
jne 0x36bb3
leaq 0x9f874(%rip), %rsi     # 0xd63f0
leaq 0xa4af1(%rip), %rdx     # 0xdb674
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9f495(%rip), %rsi     # 0xd6034
leaq 0xa4747(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x303, %ecx            # imm = 0x303
jmp 0x36f46
leaq 0x40(%rsp), %rsi
movq %r15, %rdi
movq %r14, %rdx
callq 0x1dce4
cmpl $0x1, %eax
jne 0x36c06
leaq 0x9f821(%rip), %rsi     # 0xd63f0
leaq 0xa475a(%rip), %rdx     # 0xdb330
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9f442(%rip), %rsi     # 0xd6034
leaq 0xa46f4(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x306, %ecx            # imm = 0x306
jmp 0x36f46
movl $0x1, 0x78(%rsp)
pushq $0x4
popq %rdi
callq 0x8490
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x36c63
movq %rax, %r15
pushq $0x4
popq %rdi
callq 0x8490
movq %rax, 0x68(%rsp)
testq %rax, %rax
je 0x36ca1
movq %rax, 0x10(%rsp)
pushq $0x8
popq %rdi
callq 0x8490
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x36cdf
cmpl $0x1, 0xc(%rsp)
jne 0x36d1d
pushq $0x8
popq %rcx
jmp 0x36d2f
leaq 0x9f39a(%rip), %rsi     # 0xd6004
leaq 0xa46ec(%rip), %rdx     # 0xdb35d
leaq 0xd0(%rsp), %r15
pushq $0x4
popq %rcx
movq %r15, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x9f3a7(%rip), %rsi     # 0xd6034
leaq 0xa4659(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x30b, %ecx            # imm = 0x30B
jmp 0x36f46
leaq 0x9f35c(%rip), %rsi     # 0xd6004
leaq 0xa46cb(%rip), %rdx     # 0xdb37a
leaq 0xd0(%rsp), %r15
pushq $0x4
popq %rcx
movq %r15, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x9f369(%rip), %rsi     # 0xd6034
leaq 0xa461b(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x30e, %ecx            # imm = 0x30E
jmp 0x36f46
leaq 0x9f31e(%rip), %rsi     # 0xd6004
leaq 0xa469d(%rip), %rdx     # 0xdb38a
leaq 0xd0(%rsp), %r15
pushq $0x8
popq %rcx
movq %r15, %rdi
xorl %eax, %eax
callq 0x2e014
leaq 0x9f32b(%rip), %rsi     # 0xd6034
leaq 0xa45dd(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x311, %ecx            # imm = 0x311
jmp 0x36f46
cmpl $0x1, 0x24(%rsp)
jne 0x36d40
pushq $0x9
popq %rcx
leaq 0x98(%rsp), %r12
movq 0x10(%rsp), %rdx
movl %ecx, (%rdx)
movsd (%r12), %xmm0
movsd %xmm0, (%rax)
movq 0x18(%rsp), %rax
movslq 0x8(%rax), %rax
leal -0x1(%rax), %ecx
movl %ecx, (%r15)
movl $0x4, 0x7c(%rsp)
movq 0x50(%rsp), %rcx
shlq $0xa, %rax
movl $0x735f41, -0x400(%rcx,%rax) # imm = 0x735F41
movl 0x1140(%rsp), %r15d
testl %r15d, %r15d
jle 0x36d99
cmpl $0x1, 0xc(%rsp)
cmoveq %r13, %rbp
leaq 0xa4666(%rip), %rdi     # 0xdb3ee
leaq 0xb1d76(%rip), %rdx     # 0xe8b05
movq %rbp, %rsi
xorl %eax, %eax
callq 0x8030
cmpl $0x1, 0xc(%rsp)
jne 0x36db8
movsd 0x30(%rsp), %xmm0
mulsd 0xa3bb2(%rip), %xmm0    # 0xda960
divsd 0xa3bba(%rip), %xmm0    # 0xda970
jmp 0x36dd8
cmpl $0x1, 0x24(%rsp)
jne 0x36de7
movsd 0x98(%rsp), %xmm0
mulsd 0xa3b90(%rip), %xmm0    # 0xda960
divsd 0xa3b90(%rip), %xmm0    # 0xda968
movsd %xmm0, 0x10(%rsp)
movsd %xmm0, 0x8d0(%rsp)
leaq 0x8d0(%rsp), %rdi
pushq $0x1
popq %rbx
leaq 0x38(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
movl %ebx, %esi
movq %r14, %r8
callq 0x38d3d
testl %eax, %eax
je 0x36e4b
leaq 0x9f5dc(%rip), %rsi     # 0xd63f0
leaq 0xa4877(%rip), %rdx     # 0xdb692
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9f1fd(%rip), %rsi     # 0xd6034
leaq 0xa44af(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x33b, %ecx            # imm = 0x33B
jmp 0x36f46
movq 0x70(%rsp), %rax
movsd (%rax), %xmm1
divsd 0xa0(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movl %r15d, %ebp
leaq 0xa14f9(%rip), %r12     # 0xd8374
xorl %edi, %edi
xorl %esi, %esi
movq %r12, %rdx
movb $0x1, %al
callq 0x8580
movq 0x58(%rsp), %rcx
movq 0x18(%rsp), %r15
movslq 0x8(%r15), %rdx
shlq $0xa, %rdx
leaq (%rcx,%rdx), %rdi
addq $-0x400, %rdi           # imm = 0xFC00
incl %eax
movslq %eax, %rsi
movq %r12, %rdx
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x8580
testl %ebp, %ebp
jle 0x36ee9
movslq 0x8(%r15), %rdx
shlq $0xa, %rdx
addq $-0x400, %rdx           # imm = 0xFC00
movq 0x50(%rsp), %rsi
addq %rdx, %rsi
addq 0x58(%rsp), %rdx
leaq 0xa459c(%rip), %rdi     # 0xdb47e
xorl %eax, %eax
callq 0x8030
movl 0x8(%r15), %ecx
leal -0x1(%rcx), %edx
leaq 0x40(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x1dc64
movq %r12, %rdi
callq 0x1c593
cmpl $0x1, %eax
jne 0x36f55
leaq 0x9f4dc(%rip), %rsi     # 0xd63f0
leaq 0xa4682(%rip), %rdx     # 0xdb59d
leaq 0xd0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2e014
leaq 0x9f0fd(%rip), %rsi     # 0xd6034
leaq 0xa43af(%rip), %rdx     # 0xdb2ed
movq %r14, %rdi
movl $0x34b, %ecx            # imm = 0x34B
movq %r15, %r8
xorl %eax, %eax
callq 0x2e014
jmp 0x362aa
movq 0x38(%rsp), %rdi
callq 0x8430
movq 0x68(%rsp), %rdi
callq 0x8430
movq 0x70(%rsp), %rdi
callq 0x8430
xorl %ebx, %ebx
jmp 0x362aa