// File: lagoproject[P]arti/analysis/cherenkov.cc
// Function: main
int main(int argc, char *argv[]) {

  char nfi[256]; // filename container
  char *ifiname=NULL; // input
  // reading arguments from command line
  for (int i=1;i<argc;i++) {
    char *tmparg=argv[i];
    if (*tmparg=='-') {
      switch (*(tmparg+1)) {
        case 'v':
          iverbose=1;
          break;
        case 'c':
          iline=1;
          i++; // discard "CERARY"
          nx=atoi(argv[++i]);
          ny=atoi(argv[++i]);
          dx=atof(argv[++i]);
          dy=atof(argv[++i]);
          rx=atof(argv[++i]);
          ry=atof(argv[++i]);
          break;
        case 'h':
        default:
          Usage(argv[0]);
          break;
      }
    }
    else {
      ifiname=argv[i];
    }
  }
  if (!ifiname) {
    cerr << endl << "Error: Missing filename" << endl << endl;
    Usage(argv[0]);
  }
  if (!iline) {
    cerr << endl << "Error: CERARY line is mandatory" << endl << endl;
    Usage(argv[0]);
  }

  // determine primary offsets...
  const double ext_mirr=2.; // some photons laid outside the mirror... bug in corsika? Asume 10% to avoid problems... Actually if should be lower than min(Dx/Rx,Dy/Ry)
  if (iverbose)
    cerr << "Array characteristics: " << endl << "Nx= " << nx << "; Ny= " << ny << "; Dx= "<< dx*cmtom << " m; Dy= "<< dy*cmtom << " m; Rx= "<< rx*cmtom << " m; Ry= "<< ry*cmtom << " m" << endl;
  if (ny>1) // one row is not 2d :P
    i2d=1;
  else // just in case ny=0
    ny=1;
  xMirrOff = rx/2. * ext_mirr;
  if (nx%2)
    xOff = dx * (nx - 1.) / 2.;
  else
    xOff = dx * nx  / 2.;

  yMirrOff = ry/2. * ext_mirr;
  if (ny%2)
    yOff = dy * (ny - 1.) / 2.;
  else
    yOff = dy * ny  / 2.;
  if (!dy)
    dy = 1.; // just to avoid problems 


  //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 (.hst) via fopen
  //secondaries
  snprintf(nfi,256,"%s.hst",ifile);
  if ((sec = fopen(nfi,"w"))==NULL) {
    fprintf(stderr,"Failed to open histogram file. Abort.\n");
    exit(1);
  }
  fprintf(sec, "# # # hst\n");
  fprintf(sec, "# # This is the histogram of radial distribution of cherenkov phontons - ARTI     %s\n", VERSION);
  fprintf(sec, "# # Array characteristics: Nx= %d columns; Ny= %d rows; Dx= %.3f m; Dy= %.3f m; Rx= %.3f m; Ry= %.3f m\n", nx, ny, dx*cmtom, dy*cmtom, rx*cmtom, ry*cmtom);
  fprintf(sec, "# # 4 column format is:\n");
  fprintf(sec, "# # x y photons hits\n");

  // stop talking, let's work
  // histograms...
  double data[block_cols];
  int read_line_error = 0, check = 0;
  for (int k=0; k<block_cols; k++)
    data[k] = 0.;
  long double photons[nx][ny];
  long int hits[nx][ny];
  long int badx=0, bady=0;
  int i=0, j=0;
  for (i=0; i<nx; i++) {
    for (j=0; j<ny; j++) {
      photons[i][j]=0.;
      hits[i][j]=0;
    }
  }
  if (iverbose)
    cerr << "Files opened. Reading cherenkov data blocks" << endl;
  while (fgets(line,250,fi)!=NULL) {
    read_line_error=0;
    do {
      check=sscanf(line, "%le %le %le %le %le %le %le\n", &data[0], &data[1], &data[2], &data[3], &data[4], &data[5], &data[6]);
    } while (check != block_cols && read_line_error++ < read_tries);
    lines++;
    if (iverbose)
      if (!(lines%100000))
        fprintf(stderr, "%ld lines processed up to now\r", lines);
    if (data[0]>0) {
      i=getXbin(data[1]);
      if (i>nx) {
        if (iverbose)
          fprintf(stderr, "\nWarning: skipping photon hitting outside the array (index %d) at line %ld (%s)\n",i,lines,ifile);
        badx++;
        continue;
      }
      j=getYbin(data[2]);
      if (j>ny) {
        if (iverbose)
          fprintf(stderr, "\nWarning: skipping photon hitting outside the array (index %d) at line %ld (%s)\n",j,lines,ifile);
        bady++;
        continue;
      }
      photons[i][j] += data[0];
      hits[i][j]++;
      pht_cter+=data[0];
      hit_cter++;
    }
  }
  if (iverbose)
    fprintf(stderr,"\nDone... printing histograms...\n");
  for (int j=0;j<ny;j++) {
    for (i=0;i<nx;i++) {
      fprintf (sec, "%.3lf %.3lf %Lf %ld\n", getXpos(i), getYpos(j), photons[i][j], hits[i][j]);
    }
    fprintf (sec,"\n");
  }
  fprintf (sec, "# In %ld lines, we found %ld hits corresponding to %Lf photons, and %ld photons laid outside the array(x=%ld, y=%ld)\n", lines, hit_cter, pht_cter,badx+bady,badx,bady);
  fclose(sec);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x118(%rbp)
movl $0x1, -0x11c(%rbp)
movl -0x11c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x176e
movq -0x10(%rbp), %rax
movslq -0x11c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x1742
movq -0x128(%rbp), %rax
movsbl 0x1(%rax), %eax
movl %eax, -0x2d8(%rbp)
subl $0x63, %eax
je 0x162f
jmp 0x15fe
movl -0x2d8(%rbp), %eax
subl $0x68, %eax
je 0x1730
jmp 0x160f
movl -0x2d8(%rbp), %eax
subl $0x76, %eax
jne 0x1732
jmp 0x1620
movl $0x1, 0x3afa(%rip)      # 0x5124
jmp 0x1740
movl $0x1, 0x3c07(%rip)      # 0x5240
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
movq -0x10(%rbp), %rax
movl -0x11c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1110
movl %eax, 0x3bdb(%rip)      # 0x5248
movq -0x10(%rbp), %rax
movl -0x11c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1110
movl %eax, 0x3bba(%rip)      # 0x524c
movq -0x10(%rbp), %rax
movl -0x11c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x10e0
movsd %xmm0, 0x3b97(%rip)     # 0x5250
movq -0x10(%rbp), %rax
movl -0x11c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x10e0
movsd %xmm0, 0x3b78(%rip)     # 0x5258
movq -0x10(%rbp), %rax
movl -0x11c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x10e0
movsd %xmm0, 0x3b59(%rip)     # 0x5260
movq -0x10(%rbp), %rax
movl -0x11c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x11c(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x10e0
movsd %xmm0, 0x3b3a(%rip)     # 0x5268
jmp 0x1740
jmp 0x1732
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x13b0
jmp 0x1758
movq -0x10(%rbp), %rax
movslq -0x11c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x118(%rbp)
jmp 0x175a
movl -0x11c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x11c(%rbp)
jmp 0x15ae
cmpq $0x0, -0x118(%rbp)
jne 0x17c6
movq 0x3871(%rip), %rdi      # 0x4ff0
movq 0x382a(%rip), %rsi      # 0x4fb0
callq 0x10a0
movq %rax, %rdi
leaq 0x1ad1(%rip), %rsi      # 0x3266
callq 0x1080
movq %rax, %rdi
movq 0x380c(%rip), %rsi      # 0x4fb0
callq 0x10a0
movq %rax, %rdi
movq 0x37fd(%rip), %rsi      # 0x4fb0
callq 0x10a0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x13b0
cmpl $0x0, 0x3a73(%rip)      # 0x5240
jne 0x181d
movq 0x381a(%rip), %rdi      # 0x4ff0
movq 0x37d3(%rip), %rsi      # 0x4fb0
callq 0x10a0
movq %rax, %rdi
leaq 0x1a92(%rip), %rsi      # 0x327e
callq 0x1080
movq %rax, %rdi
movq 0x37b5(%rip), %rsi      # 0x4fb0
callq 0x10a0
movq %rax, %rdi
movq 0x37a6(%rip), %rsi      # 0x4fb0
callq 0x10a0
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %esi, %esi
callq 0x13b0
movsd 0x17e3(%rip), %xmm0     # 0x3008
movsd %xmm0, -0x130(%rbp)
cmpl $0x0, 0x38f0(%rip)      # 0x5124
je 0x1950
movq 0x37af(%rip), %rdi      # 0x4ff0
leaq 0x1a56(%rip), %rsi      # 0x329e
callq 0x1080
movq %rax, %rdi
movq 0x3759(%rip), %rsi      # 0x4fb0
callq 0x10a0
movq %rax, %rdi
leaq 0x1a50(%rip), %rsi      # 0x32b6
callq 0x1080
movq %rax, %rdi
movl 0x39d4(%rip), %esi      # 0x5248
callq 0x1140
movq %rax, %rdi
leaq 0x1a38(%rip), %rsi      # 0x32bb
callq 0x1080
movq %rax, %rdi
movl 0x39bb(%rip), %esi      # 0x524c
callq 0x1140
movq %rax, %rdi
leaq 0x1a22(%rip), %rsi      # 0x32c2
callq 0x1080
movq %rax, %rdi
movsd 0x1760(%rip), %xmm0     # 0x3010
mulsd 0x3998(%rip), %xmm0     # 0x5250
callq 0x1150
movq %rax, %rdi
leaq 0x1a02(%rip), %rsi      # 0x32c9
callq 0x1080
movq %rax, %rdi
movsd 0x1739(%rip), %xmm0     # 0x3010
mulsd 0x3979(%rip), %xmm0     # 0x5258
callq 0x1150
movq %rax, %rdi
leaq 0x19e4(%rip), %rsi      # 0x32d2
callq 0x1080
movq %rax, %rdi
movsd 0x1712(%rip), %xmm0     # 0x3010
mulsd 0x395a(%rip), %xmm0     # 0x5260
callq 0x1150
movq %rax, %rdi
leaq 0x19c6(%rip), %rsi      # 0x32db
callq 0x1080
movq %rax, %rdi
movsd 0x16eb(%rip), %xmm0     # 0x3010
mulsd 0x393b(%rip), %xmm0     # 0x5268
callq 0x1150
movq %rax, %rdi
leaq 0x19a8(%rip), %rsi      # 0x32e4
callq 0x1080
movq %rax, %rdi
movq 0x3665(%rip), %rsi      # 0x4fb0
callq 0x10a0
cmpl $0x1, 0x38f5(%rip)      # 0x524c
jle 0x1965
movl $0x1, 0x38e1(%rip)      # 0x5244
jmp 0x196f
movl $0x1, 0x38dd(%rip)      # 0x524c
movsd 0x38e9(%rip), %xmm0     # 0x5260
movsd 0x1689(%rip), %xmm1     # 0x3008
divsd %xmm1, %xmm0
movsd 0x167d(%rip), %xmm1     # 0x3008
mulsd %xmm1, %xmm0
movsd %xmm0, 0x38e1(%rip)     # 0x5278
movl 0x38ab(%rip), %eax      # 0x5248
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x19e0
movsd 0x389e(%rip), %xmm0     # 0x5250
cvtsi2sdl 0x388e(%rip), %xmm1 # 0x5248
movsd 0x1656(%rip), %xmm2     # 0x3018
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd 0x1636(%rip), %xmm1     # 0x3008
divsd %xmm1, %xmm0
movsd %xmm0, 0x3892(%rip)     # 0x5270
jmp 0x1a08
movsd 0x3868(%rip), %xmm0     # 0x5250
cvtsi2sdl 0x3858(%rip), %xmm1 # 0x5248
mulsd %xmm1, %xmm0
movsd 0x160c(%rip), %xmm1     # 0x3008
divsd %xmm1, %xmm0
movsd %xmm0, 0x3868(%rip)     # 0x5270
movsd 0x3858(%rip), %xmm0     # 0x5268
movsd 0x15f0(%rip), %xmm1     # 0x3008
divsd %xmm1, %xmm0
movsd 0x15e4(%rip), %xmm1     # 0x3008
mulsd %xmm1, %xmm0
movsd %xmm0, 0x3858(%rip)     # 0x5288
movl 0x3816(%rip), %eax      # 0x524c
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x1a79
movsd 0x380d(%rip), %xmm0     # 0x5258
cvtsi2sdl 0x37f9(%rip), %xmm1 # 0x524c
movsd 0x15bd(%rip), %xmm2     # 0x3018
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd 0x159d(%rip), %xmm1     # 0x3008
divsd %xmm1, %xmm0
movsd %xmm0, 0x3809(%rip)     # 0x5280
jmp 0x1aa1
movsd 0x37d7(%rip), %xmm0     # 0x5258
cvtsi2sdl 0x37c3(%rip), %xmm1 # 0x524c
mulsd %xmm1, %xmm0
movsd 0x1573(%rip), %xmm1     # 0x3008
divsd %xmm1, %xmm0
movsd %xmm0, 0x37df(%rip)     # 0x5280
movsd 0x37af(%rip), %xmm0     # 0x5258
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1ac4
jp 0x1ac4
movsd 0x155c(%rip), %xmm0     # 0x3018
movsd %xmm0, 0x3794(%rip)     # 0x5258
leaq -0x110(%rbp), %rdi
movq -0x118(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
leaq 0x1582(%rip), %rdx      # 0x3060
movb $0x0, %al
callq 0x1130
leaq -0x110(%rbp), %rdi
callq 0x12a0
movq -0x118(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rdi
movl $0x2f, %esi
callq 0x10b0
cmpq $0x0, %rax
je 0x1b32
movq -0x138(%rbp), %rdi
movl $0x2f, %esi
callq 0x10b0
addq $0x1, %rax
movq %rax, -0x138(%rbp)
leaq -0x240(%rbp), %rdi
movq -0x138(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
leaq 0x1514(%rip), %rdx      # 0x3060
movb $0x0, %al
callq 0x1130
leaq -0x240(%rbp), %rdi
movl $0x2e, %esi
callq 0x10b0
cmpq $0x0, %rax
je 0x1baa
leaq -0x240(%rbp), %rdi
movl $0x2e, %esi
callq 0x10b0
movq %rax, %rdi
leaq 0x149b(%rip), %rsi      # 0x3020
movl $0x4, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x1ba8
leaq -0x240(%rbp), %rdi
movl $0x2e, %esi
callq 0x10b0
movb $0x0, (%rax)
jmp 0x1baa
leaq -0x240(%rbp), %rdi
movl $0x2e, %esi
callq 0x10b0
cmpq $0x0, %rax
je 0x1c01
leaq -0x240(%rbp), %rdi
movl $0x2e, %esi
callq 0x10b0
movq %rax, %rdi
leaq 0x170b(%rip), %rsi      # 0x32e7
movl $0x4, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x1bff
leaq -0x240(%rbp), %rdi
movl $0x2e, %esi
callq 0x10b0
movb $0x0, (%rax)
jmp 0x1c01
leaq -0x110(%rbp), %rdi
leaq -0x240(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
leaq 0x16d1(%rip), %rdx      # 0x32ec
movb $0x0, %al
callq 0x1130
leaq -0x110(%rbp), %rdi
leaq 0x16c3(%rip), %rsi      # 0x32f3
callq 0x10c0
movq %rax, 0x34b4(%rip)      # 0x50f0
cmpq $0x0, %rax
jne 0x1c64
movq 0x3387(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
leaq 0x16a2(%rip), %rsi      # 0x32f5
movb $0x0, %al
callq 0x10f0
movl $0x1, %edi
callq 0x10d0
movq 0x3485(%rip), %rdi      # 0x50f0
leaq 0x16aa(%rip), %rsi      # 0x331c
movb $0x0, %al
callq 0x10f0
movq 0x3470(%rip), %rdi      # 0x50f0
leaq 0x16a0(%rip), %rsi      # 0x3327
leaq 0x1426(%rip), %rdx      # 0x30b4
movb $0x0, %al
callq 0x10f0
movq 0x3454(%rip), %rdi      # 0x50f0
movl 0x35a6(%rip), %edx      # 0x5248
movl 0x35a4(%rip), %ecx      # 0x524c
movsd 0x1360(%rip), %xmm0     # 0x3010
mulsd 0x3598(%rip), %xmm0     # 0x5250
movsd 0x1350(%rip), %xmm1     # 0x3010
mulsd 0x3590(%rip), %xmm1     # 0x5258
movsd 0x1340(%rip), %xmm2     # 0x3010
mulsd 0x3588(%rip), %xmm2     # 0x5260
movsd 0x1330(%rip), %xmm3     # 0x3010
mulsd 0x3580(%rip), %xmm3     # 0x5268
leaq 0x168e(%rip), %rsi      # 0x337d
movb $0x4, %al
callq 0x10f0
movq 0x33f3(%rip), %rdi      # 0x50f0
leaq 0x16e1(%rip), %rsi      # 0x33e5
movb $0x0, %al
callq 0x10f0
movq 0x33de(%rip), %rdi      # 0x50f0
leaq 0x16e5(%rip), %rsi      # 0x33fe
movb $0x0, %al
callq 0x10f0
movl $0x0, -0x284(%rbp)
movl $0x0, -0x288(%rbp)
movl $0x0, -0x28c(%rbp)
cmpl $0x7, -0x28c(%rbp)
jge 0x1d6b
movslq -0x28c(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, -0x280(%rbp,%rax,8)
movl -0x28c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28c(%rbp)
jmp 0x1d3e
movl 0x34d7(%rip), %eax      # 0x5248
movl %eax, %ecx
movl 0x34d3(%rip), %eax      # 0x524c
movq %rax, -0x2f8(%rbp)
movq %rsp, %rdx
movq %rdx, -0x298(%rbp)
movq %rcx, %rsi
imulq %rax, %rsi
shlq $0x4, %rsi
movq %rsp, %rdx
subq %rsi, %rdx
movq %rdx, -0x2f0(%rbp)
movq %rdx, %rsp
movq %rcx, -0x2a0(%rbp)
movq %rax, -0x2a8(%rbp)
movl 0x348f(%rip), %eax      # 0x5248
movl %eax, %ecx
movl 0x348b(%rip), %eax      # 0x524c
movq %rax, -0x2e8(%rbp)
movq %rcx, %rdx
imulq %rax, %rdx
leaq 0xf(,%rdx,8), %rsi
andq $-0x10, %rsi
movq %rsp, %rdx
subq %rsi, %rdx
movq %rdx, -0x2e0(%rbp)
movq %rdx, %rsp
movq %rcx, -0x2b0(%rbp)
movq %rax, -0x2b8(%rbp)
movq $0x0, -0x2c0(%rbp)
movq $0x0, -0x2c8(%rbp)
movl $0x0, -0x2cc(%rbp)
movl $0x0, -0x2d0(%rbp)
movl $0x0, -0x2cc(%rbp)
movl -0x2cc(%rbp), %eax
cmpl 0x340f(%rip), %eax      # 0x5248
jge 0x1edd
movl $0x0, -0x2d0(%rbp)
movl -0x2d0(%rbp), %eax
cmpl 0x33f7(%rip), %eax      # 0x524c
jge 0x1ec7
movq -0x2e0(%rbp), %rax
movq -0x2e8(%rbp), %rdx
movq -0x2f0(%rbp), %rsi
movq -0x2f8(%rbp), %rdi
movslq -0x2cc(%rbp), %rcx
imulq %rdi, %rcx
shlq $0x4, %rcx
addq %rcx, %rsi
movslq -0x2d0(%rbp), %rcx
shlq $0x4, %rcx
fldz
fstpt (%rcx,%rsi)
movslq -0x2cc(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x2d0(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x2d0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2d0(%rbp)
jmp 0x1e49
jmp 0x1ec9
movl -0x2cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2cc(%rbp)
jmp 0x1e2d
cmpl $0x0, 0x3240(%rip)      # 0x5124
je 0x1f08
movq 0x3103(%rip), %rdi      # 0x4ff0
leaq 0x1520(%rip), %rsi      # 0x3414
callq 0x1080
movq %rax, %rdi
movq 0x30ad(%rip), %rsi      # 0x4fb0
callq 0x10a0
jmp 0x1f0a
movq 0x31d7(%rip), %rdx      # 0x50e8
leaq 0x3228(%rip), %rdi      # 0x5140
movl $0xfa, %esi
callq 0x1120
cmpq $0x0, %rax
je 0x21c1
movl $0x0, -0x284(%rbp)
leaq -0x280(%rbp), %rdx
leaq -0x280(%rbp), %rcx
addq $0x8, %rcx
leaq -0x280(%rbp), %r8
addq $0x10, %r8
leaq -0x280(%rbp), %r9
addq $0x18, %r9
leaq -0x280(%rbp), %r11
addq $0x20, %r11
leaq -0x280(%rbp), %r10
addq $0x28, %r10
leaq -0x280(%rbp), %rax
addq $0x30, %rax
leaq 0x31ba(%rip), %rdi      # 0x5140
leaq 0x14b3(%rip), %rsi      # 0x3440
subq $0x20, %rsp
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movb $0x0, %al
callq 0x1070
addq $0x20, %rsp
movl %eax, -0x288(%rbp)
xorl %eax, %eax
cmpl $0x7, -0x288(%rbp)
movb %al, -0x2f9(%rbp)
je 0x1fde
movl -0x284(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x284(%rbp)
cmpl $0xa, %eax
setl %al
movb %al, -0x2f9(%rbp)
movb -0x2f9(%rbp), %al
testb $0x1, %al
jne 0x1f36
movq 0x310d(%rip), %rax      # 0x5100
addq $0x1, %rax
movq %rax, 0x3102(%rip)      # 0x5100
cmpl $0x0, 0x311f(%rip)      # 0x5124
je 0x203f
movq 0x30f2(%rip), %rax      # 0x5100
movl $0x186a0, %ecx          # imm = 0x186A0
cqto
idivq %rcx
cmpq $0x0, %rdx
jne 0x203d
movq 0x2fab(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
movq 0x30d1(%rip), %rdx      # 0x5100
leaq 0x1427(%rip), %rsi      # 0x345d
movb $0x0, %al
callq 0x10f0
jmp 0x203f
movsd -0x280(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x21bc
movsd -0x278(%rbp), %xmm0
callq 0x2380
movl %eax, -0x2cc(%rbp)
movl -0x2cc(%rbp), %eax
cmpl 0x31d5(%rip), %eax      # 0x5248
jle 0x20c1
cmpl $0x0, 0x30a8(%rip)      # 0x5124
je 0x20aa
movq 0x2f4b(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
movl -0x2cc(%rbp), %edx
movq 0x306b(%rip), %rcx      # 0x5100
leaq -0x240(%rbp), %r8
leaq 0x13d9(%rip), %rsi      # 0x347c
movb $0x0, %al
callq 0x10f0
movq -0x2c0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2c0(%rbp)
jmp 0x1f0a
movsd -0x270(%rbp), %xmm0
callq 0x23b0
movl %eax, -0x2d0(%rbp)
movl -0x2d0(%rbp), %eax
cmpl 0x316c(%rip), %eax      # 0x524c
jle 0x212e
cmpl $0x0, 0x303b(%rip)      # 0x5124
je 0x2117
movq 0x2ede(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
movl -0x2d0(%rbp), %edx
movq 0x2ffe(%rip), %rcx      # 0x5100
leaq -0x240(%rbp), %r8
leaq 0x136c(%rip), %rsi      # 0x347c
movb $0x0, %al
callq 0x10f0
movq -0x2c8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2c8(%rbp)
jmp 0x1f0a
movq -0x2e0(%rbp), %rax
movq -0x2e8(%rbp), %rdx
movq -0x2f0(%rbp), %rsi
movq -0x2f8(%rbp), %rdi
fldl -0x280(%rbp)
movslq -0x2cc(%rbp), %rcx
imulq %rdi, %rcx
shlq $0x4, %rcx
addq %rcx, %rsi
movslq -0x2d0(%rbp), %rcx
shlq $0x4, %rcx
fldt (%rcx,%rsi)
faddp %st, %st(1)
fstpt (%rcx,%rsi)
movslq -0x2cc(%rbp), %rcx
imulq %rdx, %rcx
leaq (%rax,%rcx,8), %rax
movslq -0x2d0(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
incq %rdx
movq %rdx, (%rax,%rcx,8)
fldl -0x280(%rbp)
fldt 0x2f6e(%rip)            # 0x5110
faddp %st, %st(1)
fstpt 0x2f66(%rip)            # 0x5110
movq 0x2f57(%rip), %rax      # 0x5108
addq $0x1, %rax
movq %rax, 0x2f4c(%rip)      # 0x5108
jmp 0x1f0a
cmpl $0x0, 0x2f5c(%rip)      # 0x5124
je 0x21e2
movq 0x2dff(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
leaq 0x12f2(%rip), %rsi      # 0x34cd
movb $0x0, %al
callq 0x10f0
movl $0x0, -0x2d4(%rbp)
movl -0x2d4(%rbp), %eax
cmpl 0x3054(%rip), %eax      # 0x524c
jge 0x2309
movl $0x0, -0x2cc(%rbp)
movl -0x2cc(%rbp), %eax
cmpl 0x3034(%rip), %eax      # 0x5248
jge 0x22e0
movq 0x2ecf(%rip), %rax      # 0x50f0
movq %rax, -0x310(%rbp)
movl -0x2cc(%rbp), %edi
callq 0x23e0
movsd %xmm0, -0x308(%rbp)
movl -0x2d4(%rbp), %edi
callq 0x2430
movq -0x2f8(%rbp), %r8
movq -0x2f0(%rbp), %rsi
movq -0x2e8(%rbp), %rdx
movq -0x2e0(%rbp), %rax
movq -0x310(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x308(%rbp), %xmm0
movslq -0x2cc(%rbp), %rcx
imulq %r8, %rcx
shlq $0x4, %rcx
addq %rcx, %rsi
movslq -0x2d4(%rbp), %rcx
shlq $0x4, %rcx
fldt (%rcx,%rsi)
movslq -0x2cc(%rbp), %rcx
imulq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movslq -0x2d4(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
subq $0x10, %rsp
movq %rsp, %rax
fstpt (%rax)
leaq 0x122d(%rip), %rsi      # 0x34ee
movb $0x2, %al
callq 0x10f0
addq $0x10, %rsp
movl -0x2cc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2cc(%rbp)
jmp 0x2208
movq 0x2e09(%rip), %rdi      # 0x50f0
leaq 0x1289(%rip), %rsi      # 0x3577
movb $0x0, %al
callq 0x10f0
movl -0x2d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2d4(%rbp)
jmp 0x21ec
movq 0x2de0(%rip), %rdi      # 0x50f0
movq 0x2de9(%rip), %rdx      # 0x5100
movq 0x2dea(%rip), %rcx      # 0x5108
fldt 0x2dec(%rip)            # 0x5110
movq -0x2c0(%rbp), %r8
addq -0x2c8(%rbp), %r8
movq -0x2c0(%rbp), %r9
movq -0x2c8(%rbp), %rsi
subq $0x20, %rsp
movq %rsp, %rax
movq %rsi, 0x10(%rax)
fstpt (%rax)
leaq 0x11af(%rip), %rsi      # 0x3503
xorl %eax, %eax
callq 0x10f0
addq $0x20, %rsp
movq 0x2d8a(%rip), %rdi      # 0x50f0
callq 0x1090
movq -0x298(%rbp), %rax
movq %rax, %rsp
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax)