// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rsi, %rbx
xorl %eax, %eax
movq %rax, 0x4b55(%rip)      # 0x62f8
movq %rax, 0x4b46(%rip)      # 0x62f0
movq %rax, 0x4b37(%rip)      # 0x62e8
movq %rax, 0x4b28(%rip)      # 0x62e0
cmpl $0x2, %edi
jl 0x229c
movl %edi, %r15d
movl $0x1, %r12d
leaq -0x310(%rbp), %r13
movq $0x0, -0x38(%rbp)
movslq %r12d, %r14
movq (%rbx,%r14,8), %rax
cmpb $0x2d, (%rax)
jne 0x1829
movzbl 0x1(%rax), %eax
cmpl $0x6d, %eax
jg 0x183a
cmpl $0x67, %eax
je 0x1850
cmpl $0x6d, %eax
jne 0x228c
movl $0x1, 0x4ab2(%rip)      # 0x62b8
movq 0x8(%rbx,%r14,8), %rdi
callq 0x1140
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x181c
jnp 0x182d
incl %r12d
movsd %xmm0, 0x4921(%rip)     # 0x6148
jmp 0x182d
movq %rax, -0x38(%rbp)
incl %r12d
cmpl %r15d, %r12d
jl 0x17d9
jmp 0x1906
cmpl $0x6e, %eax
je 0x189a
cmpl $0x76, %eax
jne 0x228c
incl 0x4a56(%rip)            # 0x62a4
jmp 0x182d
movl $0x1, 0x4a66(%rip)      # 0x62c0
movq 0x8(%rbx,%r14,8), %rcx
movl $0x100, %esi            # imm = 0x100
movq %r13, %rdi
leaq 0x1899(%rip), %rdx      # 0x3107
xorl %eax, %eax
callq 0x11a0
movq 0x10(%rbx,%r14,8), %rdi
callq 0x1180
leal -0x1(%rax), %ecx
movl %ecx, 0x4a80(%rip)      # 0x6308
addl $-0x3, %eax
cmpl $0x3, %eax
jae 0x2294
addl $0x2, %r12d
jmp 0x182d
movl $0x1, 0x4a18(%rip)      # 0x62bc
movq 0x8(%rbx,%r14,8), %rdi
callq 0x1140
movsd %xmm0, -0x30(%rbp)
ucomisd 0x17a5(%rip), %xmm0     # 0x3060
jne 0x18c3
jnp 0x2284
movq 0x10(%rbx,%r14,8), %r14
movq %r14, %rdi
callq 0x1140
ucomisd 0x1788(%rip), %xmm0     # 0x3060
jne 0x18e0
jnp 0x2284
movsd -0x30(%rbp), %xmm0
movsd %xmm0, 0x4a23(%rip)     # 0x6310
addl $0x2, %r12d
movq %r14, %rdi
callq 0x1140
movsd %xmm0, 0x4a17(%rip)     # 0x6318
jmp 0x182d
cmpq $0x0, -0x38(%rbp)
je 0x229c
movq %rsp, -0xe8(%rbp)
movq %rsp, %rax
addq $-0x780, %rax           # imm = 0xF880
movq %rax, -0x68(%rbp)
movq %rax, %rsp
cmpl $0x0, 0x4991(%rip)      # 0x62c0
je 0x1a69
leaq 0x17ce(%rip), %rsi      # 0x310a
leaq -0x310(%rbp), %rdi
callq 0x1110
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x22a9
leaq -0xf8(%rbp), %r13
leaq -0xf0(%rbp), %r15
leaq -0x210(%rbp), %r12
movl $0x0, -0x40(%rbp)
movq -0x30(%rbp), %rbx
movq %r12, %rdi
movl $0xfa, %esi
movq %rbx, %rdx
callq 0x1190
testq %rax, %rax
je 0x1a27
cmpb $0x23, -0x210(%rbp)
je 0x1975
leaq 0x20fe(%rip), %r14      # 0x3a9c
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 0x10e0
addq $0x10, %rsp
cmpl $0x5, %eax
jne 0x19a5
movsd -0x110(%rbp), %xmm0
divsd 0x165b(%rip), %xmm0     # 0x3040
cvttsd2si %xmm0, %eax
movsd -0x108(%rbp), %xmm0
divsd 0x164f(%rip), %xmm0     # 0x3048
cvttsd2si %xmm0, %ecx
movslq 0x4904(%rip), %rdx      # 0x6308
movsd -0x110(%rbp,%rdx,8), %xmm0
cltq
imulq $0x78, %rax, %rax
addq -0x68(%rbp), %rax
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
incl -0x40(%rbp)
jmp 0x1971
cmpl $0x0, 0x4876(%rip)      # 0x62a4
je 0x1a6e
cmpl $0x0, 0x4889(%rip)      # 0x62c0
movl -0x40(%rbp), %r15d
je 0x1a72
movq 0x458c(%rip), %rax      # 0x5fd0
movq (%rax), %rdi
movl 0x48bb(%rip), %ecx      # 0x6308
incl %ecx
leaq 0x1abe(%rip), %rsi      # 0x3514
leaq -0x310(%rbp), %r8
movl %r15d, %edx
xorl %eax, %eax
callq 0x1160
jmp 0x1a72
xorl %r15d, %r15d
jmp 0x1a72
movl -0x40(%rbp), %r15d
leaq 0x168e(%rip), %rbx      # 0x3107
leaq -0x510(%rbp), %r14
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
movq %rbx, %rdx
movq -0x38(%rbp), %r12
movq %r12, %rcx
xorl %eax, %eax
callq 0x11a0
movq %r14, %rdi
callq 0x1521
movq %r12, %rdi
movl $0x2f, %esi
callq 0x1100
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 0x11a0
movq %r14, %rdi
movl $0x2e, %esi
callq 0x1100
testq %rax, %rax
je 0x1b02
movq %rax, %rbx
leaq 0x1a7a(%rip), %rsi      # 0x3568
movl $0x4, %edx
movq %rax, %rdi
callq 0x1060
testl %eax, %eax
jne 0x1b02
movb $0x0, (%rbx)
leaq -0x410(%rbp), %rdi
movl $0x2e, %esi
callq 0x1100
testq %rax, %rax
je 0x1b36
movq %rax, %rbx
leaq 0x1a2f(%rip), %rsi      # 0x3551
movl $0x4, %edx
movq %rax, %rdi
callq 0x1060
testl %eax, %eax
jne 0x1b36
movb $0x0, (%rbx)
leaq 0x1a19(%rip), %rdx      # 0x3556
leaq -0x510(%rbp), %rbx
leaq -0x410(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11a0
leaq 0x1a0c(%rip), %rsi      # 0x356d
movq %rbx, %rdi
callq 0x1040
movq %rax, 0x4760(%rip)      # 0x62d0
testq %rax, %rax
je 0x22a4
cmpl $0x0, 0x4738(%rip)      # 0x62b8
jne 0x2263
leaq 0x1a34(%rip), %rdi      # 0x35c1
movl $0xa, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x11c0
cmpl $0x0, 0x471a(%rip)      # 0x62c0
je 0x1bcf
movq 0x4721(%rip), %rdi      # 0x62d0
movl 0x4753(%rip), %ecx      # 0x6308
incl %ecx
leaq 0x1a0e(%rip), %rsi      # 0x35cc
leaq -0x310(%rbp), %r8
movl %r15d, %edx
xorl %eax, %eax
callq 0x1160
movq 0x46fa(%rip), %rdi      # 0x62d0
leaq 0x1a45(%rip), %rsi      # 0x3622
leaq 0x1578(%rip), %rdx      # 0x315c
xorl %eax, %eax
callq 0x1160
movq 0x46de(%rip), %rcx      # 0x62d0
leaq 0x1a75(%rip), %rdi      # 0x366e
movl $0x42, %esi
movl $0x1, %edx
callq 0x11c0
movq 0x46c1(%rip), %rcx      # 0x62d0
leaq 0x1a9b(%rip), %rdi      # 0x36b1
movl $0x21, %esi
movl $0x1, %edx
callq 0x11c0
movq 0x46a4(%rip), %rcx      # 0x62d0
leaq 0x1aa0(%rip), %rdi      # 0x36d3
movl $0x19, %esi
movl $0x1, %edx
callq 0x11c0
movq 0x4687(%rip), %rcx      # 0x62d0
leaq 0x1a9d(%rip), %rdi      # 0x36ed
movl $0x76, %esi
movl $0x1, %edx
callq 0x11c0
cmpl $0x0, 0x4652(%rip)      # 0x62b8
je 0x1d52
movq 0x4665(%rip), %rcx      # 0x62d8
leaq 0x1aea(%rip), %rdi      # 0x3764
movl $0xa, %esi
movl $0x1, %edx
callq 0x11c0
cmpl $0x0, 0x4630(%rip)      # 0x62c0
je 0x1cb1
movq 0x463f(%rip), %rdi      # 0x62d8
leaq 0x1acf(%rip), %rsi      # 0x376f
leaq -0x310(%rbp), %rcx
movl %r15d, %edx
xorl %eax, %eax
callq 0x1160
movq 0x4620(%rip), %rdi      # 0x62d8
leaq 0x1af9(%rip), %rsi      # 0x37b8
leaq 0x1496(%rip), %rdx      # 0x315c
xorl %eax, %eax
callq 0x1160
movq 0x4604(%rip), %rdi      # 0x62d8
cvttsd2si 0x446c(%rip), %edx # 0x6148
leaq 0x1b17(%rip), %rsi      # 0x37fa
xorl %eax, %eax
callq 0x1160
cmpl $0x0, 0x45cb(%rip)      # 0x62bc
je 0x1d18
movq 0x45de(%rip), %rdi      # 0x62d8
movsd 0x460e(%rip), %xmm0     # 0x6310
movsd 0x460e(%rip), %xmm1     # 0x6318
leaq 0x1b32(%rip), %rsi      # 0x3843
movb $0x2, %al
callq 0x1160
movq 0x45b9(%rip), %rcx      # 0x62d8
leaq 0x1b75(%rip), %rdi      # 0x389b
movl $0x19, %esi
movl $0x1, %edx
callq 0x11c0
movq 0x459c(%rip), %rcx      # 0x62d8
leaq 0x1b72(%rip), %rdi      # 0x38b5
movl $0x67, %esi
movl $0x1, %edx
callq 0x11c0
movl 0x454c(%rip), %edi      # 0x62a4
testl %edi, %edi
jne 0x227a
movsd 0x43a8(%rip), %xmm0     # 0x6110
mulsd 0x43b0(%rip), %xmm0     # 0x6120
callq 0x10a0
movsd 0x43b3(%rip), %xmm0     # 0x6130
callq 0x10a0
movq 0x453f(%rip), %rdx      # 0x62c8
leaq -0x210(%rbp), %rdi
movl $0xfa, %esi
callq 0x1190
testq %rax, %rax
je 0x215b
leaq -0xc8(%rbp), %rcx
leaq -0xb0(%rbp), %r10
leaq -0xa8(%rbp), %r11
movl $0x1, %r13d
xorl %r14d, %r14d
movq $0x0, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movl %r13d, -0xe0(%rbp)
incq %r14
movq %r14, %rax
movabsq $-0x2d77318fc504816f, %rdx # imm = 0xD288CE703AFB7E91
imulq %rdx, %rax
movabsq $0x346dc5d6388650, %rdx # imm = 0x346DC5D6388650
addq %rdx, %rax
rorq $0x4, %rax
movabsq $0x68db8bac710ca, %rdx  # imm = 0x68DB8BAC710CA
cmpq %rdx, %rax
jbe 0x1ee7
movq %r14, -0x38(%rbp)
cmpb $0x23, -0x210(%rbp)
leaq -0x88(%rbp), %r13
leaq -0x210(%rbp), %r14
leaq 0x1c58(%rip), %r15      # 0x3a88
leaq -0xd0(%rbp), %rbx
je 0x1eac
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
leaq -0xc0(%rbp), %r8
leaq -0xb8(%rbp), %r9
xorl %eax, %eax
pushq %r13
leaq -0x90(%rbp), %r12
pushq %r12
leaq -0x98(%rbp), %r12
pushq %r12
leaq -0xa0(%rbp), %r12
pushq %r12
pushq %r11
pushq %r10
callq 0x10e0
leaq -0xa8(%rbp), %r11
leaq -0xb0(%rbp), %r10
leaq -0xc8(%rbp), %rcx
addq $0x30, %rsp
cmpl $0xa, %eax
jne 0x1e39
movsd -0xd0(%rbp), %xmm0
movsd 0x1192(%rip), %xmm1     # 0x3038
ucomisd %xmm0, %xmm1
jbe 0x1f1c
movq 0x4415(%rip), %rdx      # 0x62c8
movq %r14, %rdi
movl $0xfa, %esi
callq 0x1190
leaq -0xa8(%rbp), %r11
leaq -0xb0(%rbp), %r10
leaq -0xc8(%rbp), %rcx
testq %rax, %rax
movq -0x38(%rbp), %r14
jne 0x1dd8
jmp 0x216e
movq 0x40e2(%rip), %rax      # 0x5fd0
movq (%rax), %rdi
leaq 0x1b89(%rip), %rsi      # 0x3a81
movq %r14, %rdx
xorl %eax, %eax
callq 0x1160
leaq -0xa8(%rbp), %r11
leaq -0xb0(%rbp), %r10
leaq -0xc8(%rbp), %rcx
jmp 0x1e10
cmpl $0x0, 0x439d(%rip)      # 0x62c0
je 0x2027
cvttsd2si %xmm0, %r12d
movl $0x1, %r13d
cmpl $0x2, %r12d
movq -0x38(%rbp), %r14
leaq -0x210(%rbp), %rbx
leaq 0x1ba9(%rip), %r15      # 0x3af3
jl 0x20b5
movsd -0xb0(%rbp), %xmm1
movapd %xmm1, %xmm0
addsd 0x10ec(%rip), %xmm0     # 0x3050
movl $0x1, %esi
cmpl $0xe, %r12d
je 0x1fa1
movl -0x44(%rbp), %esi
cmpl $0x65, %r12d
jb 0x1fa1
cvtsi2sd %r12d, %xmm2
movapd %xmm2, %xmm3
movsd 0x10cf(%rip), %xmm4     # 0x3058
divsd %xmm4, %xmm3
cvttpd2dq %xmm3, %xmm3
cvtdq2pd %xmm3, %xmm3
mulsd %xmm4, %xmm3
subsd %xmm3, %xmm2
cvttsd2si %xmm2, %esi
movsd -0xc8(%rbp), %xmm2
movsd -0xb8(%rbp), %xmm3
xorpd %xmm4, %xmm4
cmpnlesd %xmm1, %xmm4
andpd %xmm4, %xmm0
andnpd %xmm1, %xmm4
orpd %xmm0, %xmm4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x417e(%rip), %rcx      # 0x6150
xorl %edx, %edx
cmpl %r12d, (%rcx)
cmovel %edx, %eax
incq %rdx
addq $0x4, %rcx
cmpq $0x1b, %rdx
jne 0x1fd4
testl %eax, %eax
js 0x22b1
movl %eax, %eax
leaq 0x41c8(%rip), %rcx      # 0x61c0
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
subsd %xmm1, %xmm0
ucomisd 0x104b(%rip), %xmm0     # 0x3060
movsd %xmm3, -0x30(%rbp)
movsd %xmm2, -0x40(%rbp)
jb 0x2046
sqrtsd %xmm0, %xmm0
jmp 0x2066
movq -0x38(%rbp), %r14
leaq -0x210(%rbp), %rbx
leaq 0x1aba(%rip), %r15      # 0x3af3
movl -0x5c(%rbp), %r12d
movl -0xe0(%rbp), %r13d
jmp 0x20b5
movl %esi, %r13d
movapd %xmm4, -0xe0(%rbp)
callq 0x1090
movapd -0xe0(%rbp), %xmm4
movl %r13d, %esi
movsd -0x30(%rbp), %xmm3
movapd %xmm3, %xmm1
divsd 0xfce(%rip), %xmm1      # 0x3040
cvttsd2si %xmm1, %eax
divsd 0xfca(%rip), %xmm4      # 0x3048
cvttsd2si %xmm4, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %esi, %xmm1
divsd %xmm1, %xmm0
cltq
imulq $0x78, %rax, %rax
addq -0x68(%rbp), %rax
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movl $0x1, %r13d
ucomisd %xmm0, %xmm1
jbe 0x20b2
incq -0x50(%rbp)
xorl %r13d, %r13d
movl %esi, -0x44(%rbp)
movq 0x4214(%rip), %rdi      # 0x62d0
movsd -0xc0(%rbp), %xmm1
movsd -0xb0(%rbp), %xmm3
movsd -0xa8(%rbp), %xmm4
movsd -0xa0(%rbp), %xmm5
movsd -0x98(%rbp), %xmm6
movsd -0x90(%rbp), %xmm7
movsd -0x88(%rbp), %xmm0
subq $0x10, %rsp
movsd %xmm0, (%rsp)
movq %r15, %rsi
movl %r12d, %edx
movsd -0x40(%rbp), %xmm0
movsd -0x30(%rbp), %xmm2
movl %r13d, %ecx
movb $0x8, %al
callq 0x1160
addq $0x10, %rsp
testl %eax, %eax
jle 0x20b5
movl %r12d, -0x5c(%rbp)
incq -0x58(%rbp)
movq 0x419a(%rip), %rdx      # 0x62c8
movq %rbx, %rdi
movl $0xfa, %esi
callq 0x1190
testq %rax, %rax
leaq -0xc8(%rbp), %rcx
leaq -0xb0(%rbp), %r10
leaq -0xa8(%rbp), %r11
jne 0x1dd1
jmp 0x216e
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
xorl %r14d, %r14d
movq 0x3e7b(%rip), %rbx      # 0x5ff0
leaq 0x19bc(%rip), %rsi      # 0x3b38
movl $0x5, %edx
movq %rbx, %rdi
callq 0x1120
movq %rbx, %rdi
movq -0x58(%rbp), %r15
movq %r15, %rsi
callq 0x10c0
movq %rax, %rbx
leaq 0x199c(%rip), %rsi      # 0x3b3e
movl $0xf, %edx
movq %rax, %rdi
callq 0x1120
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10c0
movq %rax, %rbx
leaq 0x198a(%rip), %rsi      # 0x3b4e
movl $0x8, %edx
movq %rax, %rdi
callq 0x1120
movq %rbx, %rdi
movq -0x50(%rbp), %r14
movq %r14, %rsi
callq 0x10c0
movq %rax, %rbx
leaq 0x196d(%rip), %rsi      # 0x3b57
movl $0x19, %edx
movq %rax, %rdi
callq 0x1120
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1080
movq 0x40ab(%rip), %rdi      # 0x62d0
movq %r15, %r8
subq %r14, %r8
leaq 0x193f(%rip), %rsi      # 0x3b71
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1160
movq 0x408a(%rip), %rdi      # 0x62d0
callq 0x1150
movq -0xe8(%rbp), %rsp
xorl %eax, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0xd0(%rbp), %rbx
movq %rbx, %rdi
callq 0x1258
movq (%rbx), %rax
jmp 0x1b86
callq 0x128b
jmp 0x1d60
movq %rbx, %rdi
callq 0x1208
movq (%rbx), %rdi
callq 0x1608
movq %rbx, %rdi
callq 0x11e0
movq %rbx, %rdi
callq 0x1341
callq 0x131c
movq %rbx, %rdi
callq 0x1230
leaq -0x210(%rbp), %rsi
movl %r12d, %edi
callq 0x12f6