// File: /workspace/github_cpp_makefile_star2_O1/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 $0x0, -0x30(%rbp)
movq %rax, 0x4b20(%rip)      # 0x62e0
cmpl $0x2, %edi
jl 0x190d
movl %edi, %r15d
movl $0x1, %r14d
leaq -0x310(%rbp), %r13
movq $0x0, -0x30(%rbp)
movslq %r14d, %r12
movq (%rbx,%r12,8), %rax
cmpb $0x2d, (%rax)
jne 0x1831
movzbl 0x1(%rax), %eax
cmpl $0x6d, %eax
jg 0x1842
cmpl $0x67, %eax
je 0x1858
cmpl $0x6d, %eax
jne 0x228d
movl $0x1, 0x4aaa(%rip)      # 0x62b8
movq 0x8(%rbx,%r12,8), %rdi
callq 0x1140
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1824
jnp 0x1835
incl %r14d
movsd %xmm0, 0x4919(%rip)     # 0x6148
jmp 0x1835
movq %rax, -0x30(%rbp)
incl %r14d
cmpl %r15d, %r14d
jl 0x17e1
jmp 0x190d
cmpl $0x6e, %eax
je 0x18a2
cmpl $0x76, %eax
jne 0x228d
incl 0x4a4e(%rip)            # 0x62a4
jmp 0x1835
movl $0x1, 0x4a5e(%rip)      # 0x62c0
movq 0x8(%rbx,%r12,8), %rcx
movl $0x100, %esi            # imm = 0x100
movq %r13, %rdi
leaq 0x1891(%rip), %rdx      # 0x3107
xorl %eax, %eax
callq 0x11a0
movq 0x10(%rbx,%r12,8), %rdi
callq 0x1180
leal -0x1(%rax), %ecx
movl %ecx, 0x4a78(%rip)      # 0x6308
addl $-0x3, %eax
cmpl $0x3, %eax
jae 0x2295
addl $0x2, %r14d
jmp 0x1835
movl $0x1, 0x4a10(%rip)      # 0x62bc
movq 0x8(%rbx,%r12,8), %rdi
callq 0x1140
movsd %xmm0, -0x38(%rbp)
ucomisd 0x179d(%rip), %xmm0     # 0x3060
jne 0x18cb
jnp 0x2285
movq 0x10(%rbx,%r12,8), %rdi
callq 0x1140
ucomisd 0x1783(%rip), %xmm0     # 0x3060
jne 0x18e5
jnp 0x2285
movsd -0x38(%rbp), %xmm0
movsd %xmm0, 0x4a1e(%rip)     # 0x6310
addl $0x2, %r14d
movq 0x10(%rbx,%r12,8), %rdi
callq 0x1140
movsd %xmm0, 0x4a10(%rip)     # 0x6318
jmp 0x1835
cmpq $0x0, -0x30(%rbp)
je 0x229d
movq %rsp, -0xe8(%rbp)
movq %rsp, %rax
addq $-0x780, %rax           # imm = 0xF880
movq %rax, -0x68(%rbp)
movq %rax, %rsp
cmpl $0x0, 0x498a(%rip)      # 0x62c0
je 0x1a34
leaq 0x17c7(%rip), %rsi      # 0x310a
leaq -0x310(%rbp), %rdi
callq 0x1110
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x22aa
leaq -0xf8(%rbp), %r13
leaq -0xf0(%rbp), %r15
leaq -0x210(%rbp), %r12
movl $0x0, -0x48(%rbp)
movq -0x38(%rbp), %rbx
movq %r12, %rdi
movl $0xfa, %esi
movq %rbx, %rdx
callq 0x1190
testq %rax, %rax
je 0x1a2e
cmpb $0x23, -0x210(%rbp)
je 0x197c
leaq 0x20f7(%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 0x19ac
movsd -0x110(%rbp), %xmm0
divsd 0x1654(%rip), %xmm0     # 0x3040
cvttsd2si %xmm0, %eax
movsd -0x108(%rbp), %xmm0
divsd 0x1648(%rip), %xmm0     # 0x3048
cvttsd2si %xmm0, %ecx
movslq 0x48fd(%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 -0x48(%rbp)
jmp 0x1978
movl -0x48(%rbp), %r15d
jmp 0x1a37
xorl %r15d, %r15d
cmpl $0x0, 0x4866(%rip)      # 0x62a4
je 0x1a4d
cmpl $0x0, 0x4879(%rip)      # 0x62c0
jne 0x2242
leaq 0x16b3(%rip), %rbx      # 0x3107
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 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 0x1add
movq %rax, %rbx
leaq 0x1a9f(%rip), %rsi      # 0x3568
movl $0x4, %edx
movq %rax, %rdi
callq 0x1060
testl %eax, %eax
jne 0x1add
movb $0x0, (%rbx)
leaq -0x410(%rbp), %rdi
movl $0x2e, %esi
callq 0x1100
testq %rax, %rax
je 0x1b11
movq %rax, %rbx
leaq 0x1a54(%rip), %rsi      # 0x3551
movl $0x4, %edx
movq %rax, %rdi
callq 0x1060
testl %eax, %eax
jne 0x1b11
movb $0x0, (%rbx)
leaq 0x1a3e(%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 0x1a31(%rip), %rsi      # 0x356d
movq %rbx, %rdi
callq 0x1040
movq %rax, 0x4785(%rip)      # 0x62d0
testq %rax, %rax
je 0x22a5
cmpl $0x0, 0x475d(%rip)      # 0x62b8
jne 0x2271
movq 0x4768(%rip), %rcx      # 0x62d0
leaq 0x1a52(%rip), %rdi      # 0x35c1
movl $0xa, %esi
movl $0x1, %edx
callq 0x11c0
cmpl $0x0, 0x473b(%rip)      # 0x62c0
je 0x1bae
movq 0x4742(%rip), %rdi      # 0x62d0
movl 0x4774(%rip), %ecx      # 0x6308
incl %ecx
leaq 0x1a2f(%rip), %rsi      # 0x35cc
leaq -0x310(%rbp), %r8
movl %r15d, %edx
xorl %eax, %eax
callq 0x1160
movq 0x471b(%rip), %rdi      # 0x62d0
leaq 0x1a66(%rip), %rsi      # 0x3622
leaq 0x1599(%rip), %rdx      # 0x315c
xorl %eax, %eax
callq 0x1160
movq 0x46ff(%rip), %rcx      # 0x62d0
leaq 0x1a96(%rip), %rdi      # 0x366e
movl $0x42, %esi
movl $0x1, %edx
callq 0x11c0
movq 0x46e2(%rip), %rcx      # 0x62d0
leaq 0x1abc(%rip), %rdi      # 0x36b1
movl $0x21, %esi
movl $0x1, %edx
callq 0x11c0
movq 0x46c5(%rip), %rcx      # 0x62d0
leaq 0x1ac1(%rip), %rdi      # 0x36d3
movl $0x19, %esi
movl $0x1, %edx
callq 0x11c0
movq 0x46a8(%rip), %rcx      # 0x62d0
leaq 0x1abe(%rip), %rdi      # 0x36ed
movl $0x76, %esi
movl $0x1, %edx
callq 0x11c0
cmpl $0x0, 0x4673(%rip)      # 0x62b8
je 0x1d31
movq 0x4686(%rip), %rcx      # 0x62d8
leaq 0x1b0b(%rip), %rdi      # 0x3764
movl $0xa, %esi
movl $0x1, %edx
callq 0x11c0
cmpl $0x0, 0x4651(%rip)      # 0x62c0
je 0x1c90
movq 0x4660(%rip), %rdi      # 0x62d8
leaq 0x1af0(%rip), %rsi      # 0x376f
leaq -0x310(%rbp), %rcx
movl %r15d, %edx
xorl %eax, %eax
callq 0x1160
movq 0x4641(%rip), %rdi      # 0x62d8
leaq 0x1b1a(%rip), %rsi      # 0x37b8
leaq 0x14b7(%rip), %rdx      # 0x315c
xorl %eax, %eax
callq 0x1160
movq 0x4625(%rip), %rdi      # 0x62d8
cvttsd2si 0x448d(%rip), %edx # 0x6148
leaq 0x1b38(%rip), %rsi      # 0x37fa
xorl %eax, %eax
callq 0x1160
cmpl $0x0, 0x45ec(%rip)      # 0x62bc
je 0x1cf7
movq 0x45ff(%rip), %rdi      # 0x62d8
movsd 0x462f(%rip), %xmm0     # 0x6310
movsd 0x462f(%rip), %xmm1     # 0x6318
leaq 0x1b53(%rip), %rsi      # 0x3843
movb $0x2, %al
callq 0x1160
movq 0x45da(%rip), %rcx      # 0x62d8
leaq 0x1b96(%rip), %rdi      # 0x389b
movl $0x19, %esi
movl $0x1, %edx
callq 0x11c0
movq 0x45bd(%rip), %rcx      # 0x62d8
leaq 0x1b93(%rip), %rdi      # 0x38b5
movl $0x67, %esi
movl $0x1, %edx
callq 0x11c0
movl 0x456d(%rip), %edi      # 0x62a4
testl %edi, %edi
jne 0x227b
movsd 0x43c9(%rip), %xmm0     # 0x6110
mulsd 0x43d1(%rip), %xmm0     # 0x6120
callq 0x10a0
movsd 0x43d4(%rip), %xmm0     # 0x6130
callq 0x10a0
movq 0x4560(%rip), %rdx      # 0x62c8
leaq -0x210(%rbp), %rdi
movl $0xfa, %esi
callq 0x1190
testq %rax, %rax
je 0x213a
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 0x1ec6
movq %r14, -0x30(%rbp)
cmpb $0x23, -0x210(%rbp)
leaq -0x88(%rbp), %r13
leaq -0x210(%rbp), %r14
leaq 0x1c79(%rip), %r15      # 0x3a88
leaq -0xd0(%rbp), %rbx
je 0x1e8b
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 0x1e18
movsd -0xd0(%rbp), %xmm0
movsd 0x11b3(%rip), %xmm1     # 0x3038
ucomisd %xmm0, %xmm1
jbe 0x1efb
movq 0x4436(%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 -0x30(%rbp), %r14
jne 0x1db7
jmp 0x214d
movq 0x4103(%rip), %rax      # 0x5fd0
movq (%rax), %rdi
leaq 0x1baa(%rip), %rsi      # 0x3a81
movq %r14, %rdx
xorl %eax, %eax
callq 0x1160
leaq -0xa8(%rbp), %r11
leaq -0xb0(%rbp), %r10
leaq -0xc8(%rbp), %rcx
jmp 0x1def
cmpl $0x0, 0x43be(%rip)      # 0x62c0
je 0x2006
cvttsd2si %xmm0, %r12d
movl $0x1, %r13d
cmpl $0x2, %r12d
movq -0x30(%rbp), %r14
leaq -0x210(%rbp), %rbx
leaq 0x1bca(%rip), %r15      # 0x3af3
jl 0x2094
movsd -0xb0(%rbp), %xmm1
movapd %xmm1, %xmm0
addsd 0x110d(%rip), %xmm0     # 0x3050
movl $0x1, %esi
cmpl $0xe, %r12d
je 0x1f80
movl -0x3c(%rbp), %esi
cmpl $0x65, %r12d
jl 0x1f80
cvtsi2sd %r12d, %xmm2
movapd %xmm2, %xmm3
movsd 0x10f0(%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 0x419f(%rip), %rcx      # 0x6150
xorl %edx, %edx
cmpl %r12d, (%rcx)
cmovel %edx, %eax
incq %rdx
addq $0x4, %rcx
cmpq $0x1b, %rdx
jne 0x1fb3
testl %eax, %eax
js 0x22b2
movl %eax, %eax
leaq 0x41e9(%rip), %rcx      # 0x61c0
movsd (%rcx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
subsd %xmm1, %xmm0
ucomisd 0x106c(%rip), %xmm0     # 0x3060
movsd %xmm3, -0x38(%rbp)
movsd %xmm2, -0x48(%rbp)
jb 0x2025
sqrtsd %xmm0, %xmm0
jmp 0x2045
movq -0x30(%rbp), %r14
leaq -0x210(%rbp), %rbx
leaq 0x1adb(%rip), %r15      # 0x3af3
movl -0x5c(%rbp), %r12d
movl -0xe0(%rbp), %r13d
jmp 0x2094
movl %esi, %r13d
movapd %xmm4, -0xe0(%rbp)
callq 0x1090
movapd -0xe0(%rbp), %xmm4
movl %r13d, %esi
movsd -0x38(%rbp), %xmm3
movapd %xmm3, %xmm1
divsd 0xfef(%rip), %xmm1      # 0x3040
cvttsd2si %xmm1, %eax
divsd 0xfeb(%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 0x2091
incq -0x50(%rbp)
xorl %r13d, %r13d
movl %esi, -0x3c(%rbp)
movq 0x4235(%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 -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm2
movl %r13d, %ecx
movb $0x8, %al
callq 0x1160
addq $0x10, %rsp
testl %eax, %eax
jle 0x2094
movl %r12d, -0x5c(%rbp)
incq -0x58(%rbp)
movq 0x41bb(%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 0x1db0
jmp 0x214d
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
xorl %r14d, %r14d
movq 0x3e9c(%rip), %rbx      # 0x5ff0
leaq 0x19dd(%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 0x19bd(%rip), %rsi      # 0x3b3e
movl $0xf, %edx
movq %rax, %rdi
callq 0x1120
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10c0
movq %rax, %rbx
leaq 0x19ab(%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 0x198e(%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 0x40cc(%rip), %rdi      # 0x62d0
movq %r15, %r8
subq %r14, %r8
leaq 0x1960(%rip), %rsi      # 0x3b71
movq %r15, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1160
movq 0x40ab(%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
movq 0x3d87(%rip), %rax      # 0x5fd0
movq (%rax), %rdi
movl 0x40b6(%rip), %ecx      # 0x6308
incl %ecx
leaq 0x12b9(%rip), %rsi      # 0x3514
leaq -0x310(%rbp), %r8
movl %r15d, %edx
xorl %eax, %eax
callq 0x1160
jmp 0x1a4d
callq 0x1258
jmp 0x1b61
callq 0x1281
jmp 0x1d3f
movq %rbx, %rdi
callq 0x1208
movq (%rbx), %rdi
callq 0x1608
movq %rbx, %rdi
callq 0x11e0
movq %rbx, %rdi
callq 0x1337
callq 0x1312
movq %rbx, %rdi
callq 0x1230
leaq -0x210(%rbp), %rsi
movl %r12d, %edi
callq 0x12ec