// File: /workspace/github_cpp_makefile_star2_O2/lagoproject[P]arti/analysis/primaries.cc
// Function: main
int main (int argc, char *argv[]) {
  char nfi[256]; // filename container
  char nfg[256]; // geomagnetic effects file
  char *ifiname=NULL; // input
  char line[256];

  x = y = z = h = 0.;
  // reading arguments from command line
  for (int i=1;i<argc;i++) {
    char *tmparg=argv[i];
    if (*tmparg=='-') {
      switch (*(tmparg+1)) {
        case 'm':
          ianalysis=1;
          if (atof(argv[i+1])) {
            i++;
            resolution = atof(argv[i]);
          }
          break;
        case 'n':
          inorm = 1;
          if (atof(argv[i+1]) && atof(argv[i+2])) {
            i++;
            area=atof(argv[i]);
            i++;
            fluxTime=atof(argv[i]);
          }
          else {
            fprintf(stderr, " Error: for -n option you must provide detector area and flux time\n");
            Usage(argv[0]);
            break;
          }
          break;
        case 'v':
          iverbose++;
          break;
        case 'g':
          igeo=1;
          i++;
          snprintf(nfg,256,"%s",argv[i]);
          i++;
          cGeoC = atoi(argv[i]) - 1;
          if (!(cGeoC>1 && cGeoC<5)) {
            fprintf(stderr, " Error: for -g option you must provide file name and the selected rigidity column (3 to 5)\n");
            Usage(argv[0]);
            break;
          }
          break;
        case '?':
        default:
          Usage(argv[0]);
          break;
      }
    }
    else 
      ifiname=argv[i];
  }
  if (!ifiname) {
    fprintf(stderr, "\n Error: Missing filename\n\n");
    Usage(argv[0]);
  }
  int check = 0;
  int iGeoZ = 0;
  int iGeoA = 0;
  int iGeoN = 0;

  double rGeoZ = 6.;
  double rGeoA = 25.;
  int nGeoZ = int(90. / rGeoZ) + 1;
  int nGeoA = int(360. / rGeoA) + 1; 
  double gGeoC[nGeoZ][nGeoA];
  double g[5];
  if (igeo) {
    FILE *fg; 
    // reading geo file
    if((fg=fopen(nfg,"r")) == NULL) {
      fprintf(stderr, "\nError: Can't open geomagnetic file\n\n");
      Usage(argv[0]);
    }
    while(fgets(line,250,fg)) {
      if (line[0] == '#')
        continue;
      do { // read
        check=sscanf(line, "%le %le %le %le %le\n", &g[0], &g[1], &g[2], &g[3], &g[4]); 
      } while (check != 5);
      iGeoZ = int(g[0]/rGeoZ);
      iGeoA = int(g[1]/rGeoA);
      gGeoC[iGeoZ][iGeoA] = g[cGeoC];
      iGeoN++;
    }
  }
  if (iverbose && igeo)
    fprintf(stderr,"Read %d rigidity cut-off values from column %d of file '%s'\n",iGeoN, cGeoC+1, nfg);
  //open input
  snprintf(nfi,256,"%s",ifiname);
  Open(nfi);
  //open output
  char *ifile2;
  char ifile[256];
  ifile2=ifiname;
  //remove dirs
  if (strrchr(ifile2,'/')!=NULL) {
    ifile2=strrchr(ifile2,'/')+1;
  }
  snprintf(ifile, 256,"%s",ifile2);
  if (strrchr(ifile,'.')!=NULL) {
    if (strncmp(strrchr(ifile,'.'),".bz2",4)==0) { // remove .bz2 if present
      *(strrchr(ifile,'.'))='\0';
    }
  }
  if (strrchr(ifile,'.')!=NULL) {
    if (strncmp(strrchr(ifile,'.'),".dat",4)==0) { // remove .dat if present
      *(strrchr(ifile,'.'))='\0';
    }
  }
  // open output file (.bz2) via popen
  snprintf(nfi,256,"bzip2 -9z > %s.prg.bz2",ifile);
  if ((pri = popen(nfi,"w"))==NULL) {
    fprintf(stderr,"Failed to open compressed output file. Abort.\n");
    exit(1);
  }
  if (ianalysis) {
    fprintf(stderr, "Sorry, it is not yet implemented.\n");
    ianalysis=false;
    /*
    snprintf(nfi, 256, "%s.pri.hst", ifile);
    if ((hst = fopen(nfi,"w"))==NULL) {
      fprintf(stderr,"Failed to open pri.hst (primary energy histogram) file. Abort.\n");
      exit(1);
    }
    */
  }
  fprintf(pri, "# # # prg\n");
  if (igeo)
    fprintf(pri, "# # Geomagnetic effects were included: %d values were read from column %d of file %s\n", iGeoN, cGeoC+1, nfg);
  fprintf(pri, "# # This is the Primaries file including geomagnetic effects - ARTI     %s\n", VERSION);
  fprintf(pri, "# # Include an extra column (#11) indicating geomagnetic status: \n");
  fprintf(pri, "# # 0: not-allowed // 1: allowed\n");
  fprintf(pri, "# # 11 column format is:\n");
  fprintf(pri, "# # prm_Crk_id prm_energy prm_x0 prm_theta prm_phi ph_obs_lev el_obs_lev hd_obs_lev mu_obs_lev tot_obs_lev geo_status\n");
  if (ianalysis) {
    fprintf(hst, "# # # hst\n");
    if (igeo)
      fprintf(hst, "# # Geomagnetic effects were included: %d values were read from file %s\n", iGeoN, nfg);
    fprintf(hst, "# # This is the Histogram of secondary energy file - ARTI     %s\n", VERSION);
    fprintf(hst, "# # Logaritmic energy scale. Resolution used: %d bins per energy decade\n", int(resolution));
    if (inorm)
      fprintf(hst, "# # Number of particles are divided by detector area (%.4f m^2) and flux time (%.2f s)\n", area, fluxTime);
    fprintf(hst, "# # 14 column format is:\n");
    fprintf(hst, "# # p_in_bin(GeV) N_phot N_e+ N_e- N_mu+ N_mu- N_pi0 N_pi+ N_pi- N_n N_p N_pbar N_others Total_per_bin\n");
      //1=foton, 2=e+, 3=e-, 5=mu+, 6=mu-, 7=pi0, 8=pi+, 9=pi-, 13=n, 14=p, 15=bar-p, other
  }
  if (iverbose) {
    fprintf (stderr, "Verbosity level set to: %d.\n", iverbose);
    if (iverbose > 2) 
      fprintf (stderr, "verbosity %d: Send basic information to stderr\nverbosity %d: Discarded particles due to geomagnetic effect to stderr\nverbosity %d: Allowed particles to stdout.\n", iverbose, iverbose, iverbose);
    else if (iverbose > 1) 
      fprintf (stderr, "verbosity %d: Send basic information to stderr\nverbosity %d: Discarded particles due to geomagnetic effect to stderr\n", iverbose, iverbose);
    else
      fprintf (stderr, "verbosity %d: Send basic information to stderr\n", iverbose);
  }
  // stop talking, let's work
  double d[12];
  int nbin=12, nloge=0;
  int nlogd=0;
  nloge = int(log10(GeV2keV*maxPInGeV)*resolution);
  long int histoe[nloge][nbin];
  long int nid[nbin], nle[nloge];
  nlogd = int(log10(maxDInM)*resdist);
  long int histod[nlogd][nbin];
  long int nld[nlogd];
  double histode[nlogd][nbin];
  double nlde[nlogd];
  long int maxDerr = 0, maxEerr = 0;
  int prmId, prmX, prmZ, prmA;
  double prmEn, prmTh, prmPh;
  double prmMa, prmIm;
  double secp = 0.;
  bool prmGeo = true;
  int iprmGeo = 1;
  long int geoDisShw = 0, geoDisSec = 0;
  long int totpart=0, totbin = 0;
  int minbine=10000000, maxbine=0;
  int minbind=10000000, maxbind=0;
  for (int i=0; i<nbin; i++) {
    for (int j=0; j<nloge; j++) {
      histoe[j][i] = 0;
    }
    nid[i] = 0;
  }
  for (int j=0; j<nloge; j++)
    nle[j] = 0;

  long int lines = 0, ps = 0, shower_id = 0;
  while(fgets(line,250,fi)) {
    if (!(++lines % 10000))
      fprintf (stderr, "%12ld\r", lines);
    if (line[0] == '#') {  // comments? meta-data? for now, just skipping
      continue;
    }
    do { // read
      check=sscanf(line, "%lf %le %le %lf %lf %le %le %le %le %le\n", &d[0], &d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7], &d[8], &d[9]);
    } while (check != 10);
    if (d[0]<1)
      continue;

    //checking for geomagnetic effects
    if (igeo) {
      prmId=d[0];
      prmGeo=true;
      iprmGeo=1;
      if (prmId>1) { // only check for charged particles (photons=1)
        prmEn=d[1];
        prmTh=d[3];
        //CORSIKA System: -180 to +180 , 0=N, +90=E, counterclockwise
        //MAGCOS  System: 0 to 360 , 0=N, +90=E, clockwise.
        //Wonderful...
        //So... if CRK>=0, MAGCOS=CORSIKA...
        if (d[4] >= 0.)
          prmPh=d[4];
        //...else, MAGCOS=360+CORSIKA (CRK < 0)
        else
          prmPh=360.+d[4];
        // primary Z and mass
        if (prmId==14) { // protons, special case
          prmA = 1;
          prmZ = 1;
        }
        else if (prmId>100) { // nuclei
          prmA = int(prmId/100.);
          prmZ = int(prmId - prmA * 100.);
        }
        prmX = -1;
        for (int i=0; i<masaN; i++)
          if (prmId==masaI[i])
            prmX = i;
        if (prmX < 0) {
          fprintf(stderr, " Error: Can't find primary. PrmId: %04d. Please check. \nLine: %s\n", prmId, line);
          exit(1);
        }
        prmMa=masas[prmX];
        prmIm = sqrt(prmEn*prmEn - prmMa*prmMa);
        iGeoZ = int(prmTh/rGeoZ);
        iGeoA = int(prmPh/rGeoA);
        if ((prmIm/prmZ) < gGeoC[iGeoZ][iGeoA]) {
          prmGeo = false;
          iprmGeo = 0;
          geoDisShw++;
        }
      }
    }
    do {
      // fprintf(pri, "# # prm_Crk_id prm_energy prm_x0 prm_theta prm_phi ph_obs_lev el_obs_lev hd_obs_lev mu_obs_lev tot_obs_lev geo_status\n");
      check=fprintf(pri, "%04d %+.5E %+.5E %+08.3lf %+08.3lf %+.5E %+.5E %+.5E %+.5E %+.5E %d\n", prmId, prmEn, d[2], prmTh, d[4], d[5], d[6], d[7], d[8], d[9], iprmGeo);
    } while (check<=0);
    totpart++;
  }
  // say goodbye
  cerr << "From " << totpart << " primaries, in " << lines << " lines, " << geoDisShw << " primaries were discarded" << endl;
  fprintf(pri, "# # Total primaries: %ld, Discarded primaries: %ld, Allowed primaries: %ld\n", totpart, geoDisShw, (totpart-geoDisShw));
  pclose(pri);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4e8, %rsp            # imm = 0x4E8
andq $0x0, 0x3cfd(%rip)      # 0x52d8
movq %rsi, %rbx
andq $0x0, 0x3cea(%rip)      # 0x52d0
movl %edi, %r15d
andq $0x0, 0x3cd7(%rip)      # 0x52c8
andq $0x0, 0x3cc7(%rip)      # 0x52c0
pushq $0x1
popq %r12
leaq -0x310(%rbp), %r13
movq $0x0, -0x30(%rbp)
cmpl %r15d, %r12d
jge 0x173c
movslq %r12d, %r14
movq (%rbx,%r14,8), %rax
cmpb $0x2d, (%rax)
jne 0x1672
movzbl 0x1(%rax), %eax
cmpl $0x67, %eax
je 0x16e4
cmpl $0x76, %eax
je 0x1731
cmpl $0x6e, %eax
je 0x167b
cmpl $0x6d, %eax
jne 0x2090
movl $0x1, 0x3c49(%rip)      # 0x5298
movq 0x8(%rbx,%r14,8), %rdi
callq 0x1100
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1665
jnp 0x1676
incl %r12d
movsd %xmm0, 0x3ab8(%rip)     # 0x5128
jmp 0x1676
movq %rax, -0x30(%rbp)
incl %r12d
jmp 0x160c
movl $0x1, 0x3c17(%rip)      # 0x529c
movq 0x8(%rbx,%r14,8), %rdi
callq 0x1100
movsd %xmm0, -0x38(%rbp)
ucomisd 0x19c4(%rip), %xmm0     # 0x3060
jne 0x16a4
jnp 0x2011
movq 0x10(%rbx,%r14,8), %r14
movq %r14, %rdi
callq 0x1100
ucomisd 0x19a7(%rip), %xmm0     # 0x3060
jne 0x16c1
jnp 0x2011
movsd -0x38(%rbp), %xmm0
movsd %xmm0, 0x3c22(%rip)     # 0x52f0
addl $0x2, %r12d
movq %r14, %rdi
callq 0x1100
movsd %xmm0, 0x3c16(%rip)     # 0x52f8
jmp 0x1676
movl $0x1, 0x3bb2(%rip)      # 0x52a0
movq 0x8(%rbx,%r14,8), %rcx
movl $0x100, %esi            # imm = 0x100
movq %r13, %rdi
leaq 0x1a0d(%rip), %rdx      # 0x310f
xorl %eax, %eax
callq 0x1160
movq 0x10(%rbx,%r14,8), %rdi
callq 0x1140
leal -0x1(%rax), %ecx
movl %ecx, 0x3bcc(%rip)      # 0x52e8
addl $-0x3, %eax
cmpl $0x3, %eax
jae 0x2026
addl $0x2, %r12d
jmp 0x1676
incl 0x3b4d(%rip)            # 0x5284
jmp 0x1676
cmpq $0x0, -0x30(%rbp)
je 0x203b
movq %rsp, %rax
movq %rsp, %rcx
addq $-0x780, %rcx           # imm = 0xF880
movq %rcx, -0x50(%rbp)
movq %rcx, %rsp
cmpl $0x0, 0x3b3e(%rip)      # 0x52a0
movq %rax, -0x78(%rbp)
je 0x18a0
leaq 0x199f(%rip), %rsi      # 0x3112
leaq -0x310(%rbp), %rdi
callq 0x10e0
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x2074
leaq -0xf8(%rbp), %r13
leaq -0xf0(%rbp), %r15
leaq -0x210(%rbp), %r12
movl $0x0, -0x40(%rbp)
movq -0x38(%rbp), %rbx
movq %r12, %rdi
movl $0xfa, %esi
movq %rbx, %rdx
callq 0x1150
testq %rax, %rax
je 0x185e
cmpb $0x23, -0x210(%rbp)
je 0x17ac
leaq 0x22cf(%rip), %r14      # 0x3aa4
leaq -0x110(%rbp), %rbx
subq $0x8, %rsp
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
leaq -0x108(%rbp), %rcx
leaq -0x100(%rbp), %r8
movq %r13, %r9
xorl %eax, %eax
pushq %r15
callq 0x10b0
addq $0x10, %rsp
cmpl $0x5, %eax
jne 0x17dc
movsd -0x110(%rbp), %xmm0
divsd 0x1824(%rip), %xmm0     # 0x3040
cvttsd2si %xmm0, %eax
movsd -0x108(%rbp), %xmm0
divsd 0x1818(%rip), %xmm0     # 0x3048
cvttsd2si %xmm0, %ecx
movslq 0x3aad(%rip), %rdx      # 0x52e8
movsd -0x110(%rbp,%rdx,8), %xmm0
cltq
imulq $0x78, %rax, %rax
addq -0x50(%rbp), %rax
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
incl -0x40(%rbp)
jmp 0x17a8
cmpl $0x0, 0x3a1f(%rip)      # 0x5284
je 0x18a5
cmpl $0x0, 0x3a32(%rip)      # 0x52a0
movl -0x40(%rbp), %r15d
je 0x18a9
movq 0x3755(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
movl 0x3a64(%rip), %ecx      # 0x52e8
incl %ecx
leaq 0x1c8f(%rip), %rsi      # 0x351c
leaq -0x310(%rbp), %r8
movl %r15d, %edx
xorl %eax, %eax
callq 0x1120
jmp 0x18a9
xorl %r15d, %r15d
jmp 0x18a9
movl -0x40(%rbp), %r15d
leaq 0x185f(%rip), %rbx      # 0x310f
leaq -0x510(%rbp), %r14
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
movq %rbx, %rdx
movq -0x30(%rbp), %r12
movq %r12, %rcx
xorl %eax, %eax
callq 0x1160
movq %r14, %rdi
callq 0x1363
pushq $0x2f
popq %rsi
movq %r12, %rdi
callq 0x10d0
leaq 0x1(%rax), %rcx
testq %rax, %rax
cmoveq %r12, %rcx
leaq -0x410(%rbp), %r14
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1160
pushq $0x2e
popq %rsi
movq %r14, %rdi
callq 0x10d0
testq %rax, %rax
je 0x1933
movq %rax, %rbx
leaq 0x1c4f(%rip), %rsi      # 0x3570
pushq $0x4
popq %rdx
movq %rax, %rdi
callq 0x1050
testl %eax, %eax
jne 0x1933
movb $0x0, (%rbx)
leaq -0x410(%rbp), %rdi
pushq $0x2e
popq %rsi
callq 0x10d0
testq %rax, %rax
je 0x1963
movq %rax, %rbx
leaq 0x1c08(%rip), %rsi      # 0x3559
pushq $0x4
popq %rdx
movq %rax, %rdi
callq 0x1050
testl %eax, %eax
jne 0x1963
movb $0x0, (%rbx)
leaq 0x1bf4(%rip), %rdx      # 0x355e
leaq -0x510(%rbp), %rbx
leaq -0x410(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1160
leaq 0x1be7(%rip), %rsi      # 0x3575
movq %rbx, %rdi
callq 0x1030
movq %rax, 0x3913(%rip)      # 0x52b0
testq %rax, %rax
je 0x2050
cmpl $0x0, 0x38eb(%rip)      # 0x5298
jne 0x1f71
leaq 0x1c0f(%rip), %rdi      # 0x35c9
pushq $0xa
popq %rsi
pushq $0x1
popq %rdx
movq %rax, %rcx
callq 0x1180
cmpl $0x0, 0x38d1(%rip)      # 0x52a0
je 0x19f8
movq 0x38d8(%rip), %rdi      # 0x52b0
movl 0x390a(%rip), %ecx      # 0x52e8
incl %ecx
leaq 0x1bed(%rip), %rsi      # 0x35d4
leaq -0x310(%rbp), %r8
movl %r15d, %edx
xorl %eax, %eax
callq 0x1120
movq 0x38b1(%rip), %rdi      # 0x52b0
leaq 0x1c24(%rip), %rsi      # 0x362a
leaq 0x1757(%rip), %rdx      # 0x3164
xorl %eax, %eax
callq 0x1120
movq 0x3895(%rip), %rcx      # 0x52b0
leaq 0x1c54(%rip), %rdi      # 0x3676
pushq $0x42
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x1180
movq 0x3879(%rip), %rcx      # 0x52b0
leaq 0x1c7b(%rip), %rdi      # 0x36b9
pushq $0x21
popq %rsi
movq %rbx, %rdx
callq 0x1180
movq 0x3860(%rip), %rcx      # 0x52b0
leaq 0x1c84(%rip), %rdi      # 0x36db
pushq $0x19
popq %rsi
movq %rbx, %rdx
callq 0x1180
movq 0x3847(%rip), %rcx      # 0x52b0
leaq 0x1c85(%rip), %rdi      # 0x36f5
pushq $0x76
popq %rsi
movq %rbx, %rdx
callq 0x1180
cmpl $0x0, 0x3816(%rip)      # 0x5298
je 0x1b62
movq 0x3829(%rip), %rcx      # 0x52b8
leaq 0x1cd6(%rip), %rdi      # 0x376c
pushq $0xa
popq %rsi
pushq $0x1
popq %rdx
callq 0x1180
cmpl $0x0, 0x37f8(%rip)      # 0x52a0
je 0x1ac9
movq 0x3807(%rip), %rdi      # 0x52b8
leaq 0x1cbf(%rip), %rsi      # 0x3777
leaq -0x310(%rbp), %rcx
movl %r15d, %edx
xorl %eax, %eax
callq 0x1120
movq 0x37e8(%rip), %rdi      # 0x52b8
leaq 0x1ce9(%rip), %rsi      # 0x37c0
leaq 0x1686(%rip), %rdx      # 0x3164
xorl %eax, %eax
callq 0x1120
movq 0x37cc(%rip), %rdi      # 0x52b8
cvttsd2si 0x3634(%rip), %edx # 0x5128
leaq 0x1d07(%rip), %rsi      # 0x3802
xorl %eax, %eax
callq 0x1120
cmpl $0x0, 0x3793(%rip)      # 0x529c
je 0x1b30
movq 0x37a6(%rip), %rdi      # 0x52b8
movsd 0x37d6(%rip), %xmm0     # 0x52f0
movsd 0x37d6(%rip), %xmm1     # 0x52f8
leaq 0x1d22(%rip), %rsi      # 0x384b
movb $0x2, %al
callq 0x1120
movq 0x3781(%rip), %rcx      # 0x52b8
leaq 0x1d65(%rip), %rdi      # 0x38a3
pushq $0x19
popq %rsi
movq %rbx, %rdx
callq 0x1180
movq 0x3768(%rip), %rcx      # 0x52b8
leaq 0x1d66(%rip), %rdi      # 0x38bd
pushq $0x67
popq %rsi
movq %rbx, %rdx
callq 0x1180
movl 0x371c(%rip), %edx      # 0x5284
testl %edx, %edx
jne 0x1fa0
movsd 0x3578(%rip), %xmm0     # 0x50f0
mulsd 0x3580(%rip), %xmm0     # 0x5100
callq 0x20bb
movsd 0x3583(%rip), %xmm0     # 0x5110
callq 0x20bb
leaq -0xd0(%rbp), %r12
leaq -0xc8(%rbp), %rbx
leaq -0xc0(%rbp), %r13
leaq -0xb8(%rbp), %r15
pushq $0x1
popq %rax
leaq -0x210(%rbp), %rdi
movq $0x0, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movl %eax, -0x70(%rbp)
movq $0x0, -0x30(%rbp)
movq 0x36ce(%rip), %rdx      # 0x52a8
movl $0xfa, %esi
callq 0x1150
testq %rax, %rax
je 0x1ebd
movq -0x30(%rbp), %rax
incq %rax
movq %rax, -0x30(%rbp)
cqto
movl $0x2710, %ecx           # imm = 0x2710
idivq %rcx
testq %rdx, %rdx
je 0x1d52
cmpb $0x23, -0x210(%rbp)
leaq -0x210(%rbp), %rdi
je 0x1bd3
movq %r13, %r14
leaq -0xe0(%rbp), %r13
leaq -0x210(%rbp), %rdi
leaq 0x1e5d(%rip), %rsi      # 0x3a90
movq %r13, %rdx
leaq -0xd8(%rbp), %rcx
movq %r12, %r8
movq %rbx, %r9
xorl %eax, %eax
leaq -0x98(%rbp), %r10
pushq %r10
leaq -0xa0(%rbp), %r10
pushq %r10
leaq -0xa8(%rbp), %r10
pushq %r10
leaq -0xb0(%rbp), %r10
pushq %r10
pushq %r15
pushq %r14
callq 0x10b0
leaq -0x210(%rbp), %rdi
addq $0x30, %rsp
cmpl $0xa, %eax
jne 0x1c25
movsd -0xe0(%rbp), %xmm0
movsd 0x13a6(%rip), %xmm1     # 0x3038
ucomisd %xmm0, %xmm1
movq %r14, %r13
ja 0x1bd3
cmpl $0x0, 0x35fa(%rip)      # 0x52a0
je 0x1d73
cvttsd2si %xmm0, %esi
cmpl $0x2, %esi
movl -0x44(%rbp), %ecx
movl %esi, -0x48(%rbp)
jl 0x1d7c
movsd -0xc0(%rbp), %xmm1
movapd %xmm1, %xmm0
addsd 0x137d(%rip), %xmm0     # 0x3050
pushq $0x1
popq %r14
cmpl $0xe, %esi
je 0x1d0d
movl %ecx, %r14d
cmpl $0x65, %esi
jb 0x1d0d
cvtsi2sd %esi, %xmm2
movapd %xmm2, %xmm3
movsd 0x1364(%rip), %xmm4     # 0x3058
divsd %xmm4, %xmm3
cvttpd2dq %xmm3, %xmm3
cvtdq2pd %xmm3, %xmm3
mulsd %xmm4, %xmm3
subsd %xmm3, %xmm2
cvttsd2si %xmm2, %r14d
movsd -0xd8(%rbp), %xmm2
movsd -0xc8(%rbp), %xmm3
xorpd %xmm4, %xmm4
cmpnlesd %xmm1, %xmm4
andpd %xmm4, %xmm0
andnpd %xmm1, %xmm4
orpd %xmm0, %xmm4
leaq 0x33f7(%rip), %rcx      # 0x5130
xorl %edx, %edx
pushq $-0x1
popq %rax
cmpq $0x1b, %rdx
je 0x1d84
cmpl %esi, (%rcx)
cmovel %edx, %eax
incq %rdx
addq $0x4, %rcx
jmp 0x1d3e
movq 0x3277(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
leaq 0x1d26(%rip), %rsi      # 0x3a89
movq -0x30(%rbp), %rdx
xorl %eax, %eax
callq 0x1120
jmp 0x1c0b
movl -0x70(%rbp), %r15d
jmp 0x1e26
movl %ecx, -0x44(%rbp)
jmp 0x1e22
testl %eax, %eax
js 0x2098
movl %eax, %eax
leaq 0x340b(%rip), %rcx      # 0x51a0
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
subsd %xmm1, %xmm0
ucomisd 0x12ae(%rip), %xmm0     # 0x3060
movsd %xmm3, -0x38(%rbp)
movsd %xmm2, -0x40(%rbp)
jb 0x1dc4
sqrtsd %xmm0, %xmm0
jmp 0x1dd8
movapd %xmm4, -0x70(%rbp)
callq 0x1070
movapd -0x70(%rbp), %xmm4
movsd -0x38(%rbp), %xmm3
movapd %xmm3, %xmm1
divsd 0x125c(%rip), %xmm1     # 0x3040
cvttsd2si %xmm1, %eax
divsd 0x1258(%rip), %xmm4     # 0x3048
cvttsd2si %xmm4, %ecx
cvtsi2sd %r14d, %xmm1
divsd %xmm1, %xmm0
cltq
imulq $0x78, %rax, %rax
addq -0x50(%rbp), %rax
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
movl %r14d, -0x44(%rbp)
jbe 0x1e22
incq -0x58(%rbp)
xorl %r15d, %r15d
jmp 0x1e26
pushq $0x1
popq %r15
movl -0x48(%rbp), %r13d
leaq 0x1cca(%rip), %r14      # 0x3afb
movq 0x3478(%rip), %rdi      # 0x52b0
movsd -0xd0(%rbp), %xmm1
movsd -0xc0(%rbp), %xmm3
movsd -0xb8(%rbp), %xmm4
movsd -0xb0(%rbp), %xmm5
movsd -0xa8(%rbp), %xmm6
movsd -0xa0(%rbp), %xmm7
movsd -0x98(%rbp), %xmm0
subq $0x10, %rsp
movsd %xmm0, (%rsp)
movq %r14, %rsi
movl %r13d, %edx
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm2
movl %r15d, %ecx
movb $0x8, %al
callq 0x1120
addq $0x10, %rsp
testl %eax, %eax
jle 0x1e31
movl %r15d, -0x70(%rbp)
incq -0x60(%rbp)
leaq -0x210(%rbp), %rdi
leaq -0xc0(%rbp), %r13
leaq -0xb8(%rbp), %r15
jmp 0x1bd3
movq 0x312c(%rip), %rdi      # 0x4ff0
leaq 0x1c75(%rip), %rsi      # 0x3b40
callq 0x10c0
movq %rax, %rdi
movq -0x60(%rbp), %r14
movq %r14, %rsi
callq 0x10a0
leaq 0x1c60(%rip), %rsi      # 0x3b46
movq %rax, %rdi
callq 0x10c0
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x10a0
leaq 0x1c55(%rip), %rsi      # 0x3b56
movq %rax, %rdi
callq 0x10c0
movq %rax, %rdi
movq -0x58(%rbp), %rbx
movq %rbx, %rsi
callq 0x10a0
leaq 0x1c40(%rip), %rsi      # 0x3b5f
movq %rax, %rdi
callq 0x10c0
movq %rax, %rdi
callq 0x1060
movq 0x337a(%rip), %rdi      # 0x52b0
movq %r14, %r8
subq %rbx, %r8
leaq 0x1c36(%rip), %rsi      # 0x3b79
movq %r14, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1120
movq 0x3359(%rip), %rdi      # 0x52b0
callq 0x1110
movq -0x78(%rbp), %rsp
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3058(%rip), %rax      # 0x4fd0
movq (%rax), %rcx
leaq 0x1624(%rip), %rdi      # 0x35a6
pushq $0x22
popq %rsi
pushq $0x1
popq %rdx
callq 0x1180
andl $0x0, 0x3304(%rip)      # 0x5298
movq 0x3315(%rip), %rax      # 0x52b0
jmp 0x19b3
movq 0x3029(%rip), %rbx      # 0x4fd0
movq (%rbx), %rdi
leaq 0x1974(%rip), %rsi      # 0x3925
xorl %eax, %eax
callq 0x1120
movl 0x32c6(%rip), %edx      # 0x5284
cmpl $0x3, %edx
jl 0x1fde
movq (%rbx), %rdi
leaq 0x1975(%rip), %rsi      # 0x3942
movl %edx, %ecx
movl %edx, %r8d
xorl %eax, %eax
callq 0x1120
jmp 0x1b70
movq (%rbx), %rdi
cmpl $0x2, %edx
jne 0x1ffe
leaq 0x19f6(%rip), %rsi      # 0x39e3
pushq $0x2
popq %rcx
movl %ecx, %edx
xorl %eax, %eax
callq 0x1120
jmp 0x1b70
leaq 0x1a54(%rip), %rsi      # 0x3a59
xorl %eax, %eax
callq 0x1120
jmp 0x1b70
movq 0x2fb8(%rip), %rax      # 0x4fd0
movq (%rax), %rcx
leaq 0x1418(%rip), %rdi      # 0x343a
pushq $0x43
jmp 0x2087
movq 0x2fa3(%rip), %rax      # 0x4fd0
movq (%rax), %rcx
leaq 0x1447(%rip), %rdi      # 0x347e
pushq $0x5b
jmp 0x2087
movq 0x2f8e(%rip), %rax      # 0x4fd0
movq (%rax), %rcx
leaq 0x148e(%rip), %rdi      # 0x34da
pushq $0x1b
jmp 0x2087
movq 0x2f79(%rip), %rax      # 0x4fd0
movq (%rax), %rcx
leaq 0x1516(%rip), %rdi      # 0x3577
pushq $0x2e
popq %rsi
pushq $0x1
popq %rdx
callq 0x1180
pushq $0x1
popq %rdi
callq 0x10f0
movq 0x2f55(%rip), %rax      # 0x4fd0
movq (%rax), %rcx
leaq 0x1471(%rip), %rdi      # 0x34f6
pushq $0x25
popq %rsi
pushq $0x1
popq %rdx
callq 0x1180
movq (%rbx), %rdi
callq 0x1446
movq 0x2f31(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
movl %esi, %edx
leaq 0x1a0e(%rip), %rsi      # 0x3ab9
leaq -0x210(%rbp), %rcx
xorl %eax, %eax
callq 0x1120
jmp 0x206c