// File: /workspace/github_c_makefile_star2_O0/DVaronos[P]AnLogProject1/main.c
// Function: main
int main( int argc, char *argv[] ){

    double t1, t2,time,ticspersec;
    struct tms tb1, tb2;

    ticspersec = (double) sysconf(_SC_CLK_TCK);
    t1 = (double) times(&tb1);

   JobSheduler* Sheduler= JSInit(32);
   DIR* directory;
   DIR* indirectory;
   struct dirent* new_directory;
   struct dirent* curfile;
   FILE *dataw;
   FILE *scsv;
   FILE *dcsv;
   FILE *testing;
   FILE* validation;
   char* wfile;
   char* dd;
   char* token=NULL;
   char line[300];
   int inputexist=0,dexist=0;
   char c;

   for(int i=1 ; i<argc ; i++){//Elegxos gia to an iparxei arxio eisodou
     if(strcmp(argv[i],"-w")==0){//Efoson iparxi inputfile apothikefsi tou onomatos tou
       wfile=malloc(sizeof(char)*(strlen(argv[i+1])+1));
       strcpy(wfile,argv[i+1]);
       inputexist=1;
     }else if(strcmp(argv[i],"-d")==0){//Efoson iparxi inputfile apothikefsi tou onomatos tou
       dd=malloc(sizeof(char)*(strlen(argv[i+1])+1));
       strcpy(dd,argv[i+1]);
       dexist=1;
     }
   }

   if(inputexist){//Elegxos gia an iparxi input file
     if((dataw=fopen(wfile,"r"))==NULL){//ean den iparxei to arxeio pou dothike san input file vgenei error kai termatizei h efarmogh
       printf("ERROR:There no such wfile\n");
       free(dataw);
       return 0;
     }
   }else{//Ean den iparxei kan kapoio inputfile vgeneierror kai termatizei h efarmogh
     printf("ERROR:There is no inputfile\n");
     return 0;
   }

   if(dexist){//Elegxos gia an iparxi input file
     if((directory=opendir(dd))==NULL){//ean den iparxei to arxeio pou dothike san input file vgenei error kai termatizei h efarmogh
       printf("ERROR:There no such directory\n");
       free(dd);
       free(wfile);
       fclose(dataw);
       return 0;
     }
   }else{//Ean den iparxei kan kapoio inputfile vgeneierror kai termatizei h efarmogh
     printf("ERROR:There is no input directory\n");
     free(wfile);
     fclose(dataw);
     return 0;
   }

   char* newfile;
   char* newdir;
   char* newid;
   char word[15];
   Hash* H=HashCreate(1000);  //Domh hash gia apotikefsh tou dataset x
   LHash* LEK=LHashCreate(1000);  //Domh LHash gia to leksilogio
   LHash* Common=LHashCreate(200);  //Domh LHash gia tis koines lekeis
   char* temp=strdup("start");
   int charcount=0;
   FILE *com;
   WHash* S;

   if( (com=fopen("common.txt","r"))==NULL){//Anigma tou common.tx pou periexei tis koines leksis
     perror("Fopen");
     return 0;
   }

   while((c = fgetc(com))!= EOF){//Apothikevo tis common leksis se ena Lhash
 		if(c ==',' || c== '\n'){

       word[charcount]='\0';

       free(temp);
       temp=malloc(sizeof(char)*(strlen(word)+1));
       strcpy(temp,word);
       Common=LHashInsert(Common,temp);

 			charcount=0;
     }else{
 			word[charcount]=c;
       charcount++;
 		}
 	}

  fclose(com);

   while( (new_directory=readdir(directory)) ){ //Diavazw to periexomeno tou fakelou pou dothike(diladi tous ipofakelous)

        if(strcmp(new_directory->d_name,".") && strcmp(new_directory->d_name,"..")){ //Ean den einai o eaftos rou h o proigoumenos

            newdir=malloc(sizeof(char)*( strlen(dd)+strlen(new_directory->d_name) +2)); //To newdir einai to path tou neou ipofakelou
            strcpy(newdir,dd);
            strcat(newdir,"/");
            strcat(newdir,new_directory->d_name);

            if( (indirectory=opendir(newdir))==NULL){
                perror("ERORR\n");
                return 0;
            }else{
                while( (curfile=readdir(indirectory)) ){ //Divazo to periexomenotou ypofakelou(Diladi ta json files pou einai messa se afton ton fakelo)

                    if(strcmp(curfile->d_name,".") && strcmp(curfile->d_name,"..")){  //Ean den einai o eaftos rou h o proigoumenos

                      newid=malloc(sizeof(char)*( strlen(curfile->d_name)+strlen(new_directory->d_name) +3)); //To newid tha exei to id ths cameras pou antistixei se afto to json file
                      strcpy(newid,new_directory->d_name);
                      strcat(newid,"//");
                      strcat(newid,curfile->d_name);
                      newid[strlen(newid)-5]='\0'; //Den theloume thn katalhksh ".json"

                      newfile=malloc(sizeof(char)*( strlen(curfile->d_name)+strlen(new_directory->d_name)+strlen(dd) +3)); //To newfile tha exei to path tou sigekrimenou json arxeiou
                      strcpy(newfile,dd);
                      strcat(newfile,"/");
                      strcat(newfile,new_directory->d_name);
                      strcat(newfile,"/");
                      strcat(newfile,curfile->d_name);

                      H=HashInsert(H,newid); //Apothikevo to id ths cameras sthn domh
                      LEK=Readjson(newfile,LEK,Common,&S); //Diavazo to json file kai apothikevo ta dedomena sto leksilogio kai se ena WHash
                      //jcount++;
                      H=HashReplaceSpear(H,newid,S);  //Eisago to whash sthn atnisthxh thesh sthn domh
                      free(newfile);
                      free(newid);

                    }
                }
                closedir(indirectory); // klinw ton ipofakelo
            }
            free(newdir);
        }
    }
   printf("The storage of datasetX  just finished\n");

   LHashTfIdf(LEK,H->count); //Ipologizo to IDF twn leksewn tou leksilogiou
   LEK=NMostLHash(LEK,1000);  //Pairnw tis 1000 pio simantikes leksi
   H=HashVectorts(H,LEK); //Dimiourgw gia kathe kamera ena vector simfona me to leksilogio
   FreeLHash(Common); //Apodesmevw to leksilogio kai to Common hash giati pleon den ta xriazome
   FreeLHash(LEK);
   printf("The creation of vectors just finished\n");
   char* first;
   char* second;
   int match=0,tcount,z=0,a=0;

   while (fgets(line,sizeof(line),dataw)){//Diavazei to csv file grami grami
     token=strtok(line,",");
     token=strtok(NULL,",");
     token=strtok(NULL,",");
     match=atoi(token);
     if(match){
       a++; //arithmos twn thetikwn sisxetisewn
     }else{
       z++; //arithmos twn arnitikwn sisxetisewn
     }
	 }
   fclose(dataw);
   int sa,ta,sz,tz,trz=0,tra=0,tez=0,tea=0;

   sa=a*0.6;  //to 60% twn thetikwn sisxetisewn tou dataw
   ta=(a-sa)/2; ////to 20% twn thetikwn sisxetisewn tou dataw
   sz=z*0.6; //to 60% twn arnitikwn sisxetisewn tou dataw
   tz=(z-sz)/2; //to 20% twn arnitikwn sisxetisewn tou dataw
   if((dataw=fopen(wfile,"r"))==NULL){//ean den iparxei to arxeio pou dothike san input file vgenei error kai termatizei h efarmogh
     printf("ERROR:There no such wfile\n");
     free(dataw);
     return 0;
   }

   if( (testing=fopen("Testing.csv","w"))==NULL){
     perror("Fopen");
     return 0;
   }
   if( (validation=fopen("Validation.csv","w"))==NULL){
     perror("Fopen");
     return 0;
   }
	 while (fgets(line,sizeof(line),dataw)){//Diavazei to csv file grami grami
     token=strtok(line,",");
     if(!strcmp(token,"left_spec_id"))  continue;
     tcount=0;
     while(token!=NULL){//apothikefsi tou kathe stixoiou ths gramhs se metavlites
      tcount++;
      switch(tcount){
        case 1://ean tcount==1 tote to token isoute me to proto proion
          first=malloc(sizeof(char)*(strlen(token)+1));
          strcpy(first,token);
          break;
        case 2://ean tcount==2 tote to token isoute me to deftero proion
          second=malloc(sizeof(char)*(strlen(token)+1));
          strcpy(second,token);
          break;
        case 3://Ean tcount==3 tote to token einai 0 h 1 analoga to an teriazoun ta proionta
          match=atoi(token);
          break;
      }
      token=strtok(NULL,",");
    }

    if(match){ //Ean einai thetikh sisxetish
      if(tra<sa){ //Ean den exw isagei to 60% twn thetikwn sisxetisewn sto trainig set
        HashConect(H,first,second,match);
        tra++;
      }else if(tea<ta){ //Ean den exw isagei to 20% twn thetikwn sisxetisewn sto testing set
        fprintf(testing,"%s,%s,%d\n",first,second,match );
        tea++;
      }else{ //To ipolipo 20% twn thetikwn sisxetisewn paei sto validation set
        fprintf(validation,"%s,%s,%d\n",first,second,match );
      }
    }else{  //Ean einai arnitilh sisxetish
      if(trz<sz){  //Ean den exw isagei to 60% twn arnitikwn sisxetisewn sto trainig set
        HashConect(H,first,second,match);
        trz++;
      }else if(tez<tz){ //Ean den exw isagei to 20% twn arnitikwn sisxetisewn sto testing set
        fprintf(testing,"%s,%s,%d\n",first,second,match );
        tez++;
      }else{  //To ipolipo 20% twn arnitikwn sisxetisewn paei sto validation set
        fprintf(validation,"%s,%s,%d\n",first,second,match );
      }
    }
    free(first);
    free(second);
	}
  fclose(dataw);
  fclose(testing);
  fclose(validation);
  printf("The reading of the datasetW just finished\n");

  scsv=fopen("Same.csv","w+"); //Dimiourgw ena neo csv arxio
  fprintf(scsv,"left_spec_id, right_spec_id\n");

  dcsv=fopen("Diffrend.csv","w+"); //Dimiourgw ena neo csv arxio
  fprintf(dcsv,"left_spec_id, right_spec_id\n");

  HashTransfer(H,scsv); //Pernaw ta teriasmata sto csv arxio
  HashDiff(H,dcsv);

  fclose(scsv);
  fclose(dcsv);
  printf("The creation of the Same.csv and Diffrend.csv files just finished\n");
  Input* input=InputMake("Same.csv","Diffrend.csv", H);
  Model* model;
  model=RepetitiveTaining(input,H,Sheduler);
  printf("The training of the model just finished\n");

  Testing("Testing.csv",model,H);


  //apodesmefsh twn domwn
  FreeInput(input);
  JSDestroy(Sheduler);
  FreeHash(H);
  free(temp);
  FreeModel(model);
  free(wfile);
  free(dd);
  closedir(directory);
  remove("Testing.csv");
  remove("Validation.csv");

  t2 = (double) times(&tb2);
  time=((t2 - t1) / ticspersec);  //O xrronos pou perase gia na vrethei o arithmos
  printf("Time was %f secs\n",time);


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x300, %rsp            # imm = 0x300
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x2, %edi
callq 0x1220
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x30(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x11e0
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x18(%rbp)
movl $0x20, %edi
callq 0x75f0
movq %rax, -0x78(%rbp)
movq $0x0, -0xd8(%rbp)
movl $0x0, -0x214(%rbp)
movl $0x0, -0x218(%rbp)
movl $0x1, -0x220(%rbp)
movl -0x220(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x1524
movq -0x10(%rbp), %rax
movslq -0x220(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6be4(%rip), %rsi      # 0x8010
callq 0x1120
cmpl $0x0, %eax
jne 0x1492
movq -0x10(%rbp), %rax
movl -0x220(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x10a0
movq %rax, %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x1190
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x220(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1050
movl $0x1, -0x214(%rbp)
jmp 0x150e
movq -0x10(%rbp), %rax
movslq -0x220(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x6b6b(%rip), %rsi      # 0x8013
callq 0x1120
cmpl $0x0, %eax
jne 0x150c
movq -0x10(%rbp), %rax
movl -0x220(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x10a0
movq %rax, %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x1190
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x220(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1050
movl $0x1, -0x218(%rbp)
jmp 0x150e
jmp 0x1510
movl -0x220(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x220(%rbp)
jmp 0x1407
cmpl $0x0, -0x214(%rbp)
je 0x1575
movq -0xc8(%rbp), %rdi
leaq 0x6adb(%rip), %rsi      # 0x8016
callq 0x11f0
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
jne 0x1573
leaq 0x6ac4(%rip), %rdi      # 0x8018
movb $0x0, %al
callq 0x10b0
movq -0xa0(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
jmp 0x2282
jmp 0x158f
leaq 0x6ab7(%rip), %rdi      # 0x8033
movb $0x0, %al
callq 0x10b0
movl $0x0, -0x4(%rbp)
jmp 0x2282
cmpl $0x0, -0x218(%rbp)
je 0x15ee
movq -0xd0(%rbp), %rdi
callq 0x1090
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
jne 0x15ec
leaq 0x6a9b(%rip), %rdi      # 0x8050
movb $0x0, %al
callq 0x10b0
movq -0xd0(%rbp), %rdi
callq 0x1030
movq -0xc8(%rbp), %rdi
callq 0x1030
movq -0xa0(%rbp), %rdi
callq 0x1080
movl $0x0, -0x4(%rbp)
jmp 0x2282
jmp 0x1620
leaq 0x6a7a(%rip), %rdi      # 0x806f
movb $0x0, %al
callq 0x10b0
movq -0xc8(%rbp), %rdi
callq 0x1030
movq -0xa0(%rbp), %rdi
callq 0x1080
movl $0x0, -0x4(%rbp)
jmp 0x2282
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x59b0
movq %rax, -0x250(%rbp)
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x65b0
movq %rax, -0x258(%rbp)
movl $0xc8, %edi
callq 0x65b0
movq %rax, -0x260(%rbp)
leaq 0x6a38(%rip), %rdi      # 0x8092
callq 0x1250
movq %rax, -0x268(%rbp)
movl $0x0, -0x26c(%rbp)
leaq 0x6a21(%rip), %rdi      # 0x8098
leaq 0x6998(%rip), %rsi      # 0x8016
callq 0x11f0
movq %rax, -0x278(%rbp)
cmpq $0x0, %rax
jne 0x16a8
leaq 0x6a0c(%rip), %rdi      # 0x80a3
callq 0x1200
movl $0x0, -0x4(%rbp)
jmp 0x2282
jmp 0x16aa
movq -0x278(%rbp), %rdi
callq 0x10e0
movb %al, -0x219(%rbp)
movsbl %al, %eax
cmpl $-0x1, %eax
je 0x177f
movsbl -0x219(%rbp), %eax
cmpl $0x2c, %eax
je 0x16e0
movsbl -0x219(%rbp), %eax
cmpl $0xa, %eax
jne 0x1757
movslq -0x26c(%rbp), %rax
movb $0x0, -0x247(%rbp,%rax)
movq -0x268(%rbp), %rdi
callq 0x1030
leaq -0x247(%rbp), %rdi
callq 0x10a0
movq %rax, %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x1190
movq %rax, -0x268(%rbp)
movq -0x268(%rbp), %rdi
leaq -0x247(%rbp), %rsi
callq 0x1050
movq -0x260(%rbp), %rdi
movq -0x268(%rbp), %rsi
callq 0x6660
movq %rax, -0x260(%rbp)
movl $0x0, -0x26c(%rbp)
jmp 0x177a
movb -0x219(%rbp), %cl
movslq -0x26c(%rbp), %rax
movb %cl, -0x247(%rbp,%rax)
movl -0x26c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x26c(%rbp)
jmp 0x16aa
movq -0x278(%rbp), %rdi
callq 0x1080
movq -0x80(%rbp), %rdi
callq 0x1170
movq %rax, -0x90(%rbp)
cmpq $0x0, %rax
je 0x1b0e
movq -0x90(%rbp), %rdi
addq $0x13, %rdi
leaq 0x68f3(%rip), %rsi      # 0x80aa
callq 0x1120
cmpl $0x0, %eax
je 0x1b09
movq -0x90(%rbp), %rdi
addq $0x13, %rdi
leaq 0x68d2(%rip), %rsi      # 0x80a9
callq 0x1120
cmpl $0x0, %eax
je 0x1b09
movq -0xd0(%rbp), %rdi
callq 0x10a0
movq %rax, -0x2d8(%rbp)
movq -0x90(%rbp), %rdi
addq $0x13, %rdi
callq 0x10a0
movq -0x2d8(%rbp), %rdi
addq %rax, %rdi
addq $0x2, %rdi
shlq $0x0, %rdi
callq 0x1190
movq %rax, -0x230(%rbp)
movq -0x230(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x1050
movq -0x230(%rbp), %rdi
leaq 0x686d(%rip), %rsi      # 0x80b4
callq 0x1240
movq -0x230(%rbp), %rdi
movq -0x90(%rbp), %rsi
addq $0x13, %rsi
callq 0x1240
movq -0x230(%rbp), %rdi
callq 0x1090
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
jne 0x1894
leaq 0x6829(%rip), %rdi      # 0x80ac
callq 0x1200
movl $0x0, -0x4(%rbp)
jmp 0x2282
jmp 0x1896
movq -0x88(%rbp), %rdi
callq 0x1170
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
je 0x1af1
movq -0x98(%rbp), %rdi
addq $0x13, %rdi
leaq 0x67e5(%rip), %rsi      # 0x80aa
callq 0x1120
cmpl $0x0, %eax
je 0x1aec
movq -0x98(%rbp), %rdi
addq $0x13, %rdi
leaq 0x67c4(%rip), %rsi      # 0x80a9
callq 0x1120
cmpl $0x0, %eax
je 0x1aec
movq -0x98(%rbp), %rdi
addq $0x13, %rdi
callq 0x10a0
movq %rax, -0x2f8(%rbp)
movq -0x90(%rbp), %rdi
addq $0x13, %rdi
callq 0x10a0
movq -0x2f8(%rbp), %rdi
addq %rax, %rdi
addq $0x3, %rdi
shlq $0x0, %rdi
callq 0x1190
movq %rax, -0x238(%rbp)
movq -0x238(%rbp), %rdi
movq -0x90(%rbp), %rsi
addq $0x13, %rsi
callq 0x1050
movq -0x238(%rbp), %rdi
leaq 0x6756(%rip), %rsi      # 0x80b3
callq 0x1240
movq -0x238(%rbp), %rdi
movq -0x98(%rbp), %rsi
addq $0x13, %rsi
callq 0x1240
movq -0x238(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movq -0x238(%rbp), %rdi
callq 0x10a0
movq %rax, %rcx
movq -0x2f0(%rbp), %rax
subq $0x5, %rcx
movb $0x0, (%rax,%rcx)
movq -0x98(%rbp), %rdi
addq $0x13, %rdi
callq 0x10a0
movq %rax, -0x2e8(%rbp)
movq -0x90(%rbp), %rdi
addq $0x13, %rdi
callq 0x10a0
movq %rax, %rcx
movq -0x2e8(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x2e0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x10a0
movq -0x2e0(%rbp), %rdi
addq %rax, %rdi
addq $0x3, %rdi
shlq $0x0, %rdi
callq 0x1190
movq %rax, -0x228(%rbp)
movq -0x228(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x1050
movq -0x228(%rbp), %rdi
leaq 0x6689(%rip), %rsi      # 0x80b4
callq 0x1240
movq -0x228(%rbp), %rdi
movq -0x90(%rbp), %rsi
addq $0x13, %rsi
callq 0x1240
movq -0x228(%rbp), %rdi
leaq 0x665f(%rip), %rsi      # 0x80b4
callq 0x1240
movq -0x228(%rbp), %rdi
movq -0x98(%rbp), %rsi
addq $0x13, %rsi
callq 0x1240
movq -0x250(%rbp), %rdi
movq -0x238(%rbp), %rsi
callq 0x5aa0
movq %rax, -0x250(%rbp)
movq -0x228(%rbp), %rdi
movq -0x258(%rbp), %rsi
movq -0x260(%rbp), %rdx
leaq -0x280(%rbp), %rcx
callq 0x7210
movq %rax, -0x258(%rbp)
movq -0x250(%rbp), %rdi
movq -0x238(%rbp), %rsi
movq -0x280(%rbp), %rdx
callq 0x5d50
movq %rax, -0x250(%rbp)
movq -0x228(%rbp), %rdi
callq 0x1030
movq -0x238(%rbp), %rdi
callq 0x1030
jmp 0x1896
movq -0x88(%rbp), %rdi
callq 0x10f0
movq -0x230(%rbp), %rdi
callq 0x1030
jmp 0x178b
leaq 0x65a1(%rip), %rdi      # 0x80b6
movb $0x0, %al
callq 0x10b0
movq -0x258(%rbp), %rdi
movq -0x250(%rbp), %rax
cvtsi2sdl 0x4(%rax), %xmm0
callq 0x6b10
movq -0x258(%rbp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x6cf0
movq %rax, -0x258(%rbp)
movq -0x250(%rbp), %rdi
movq -0x258(%rbp), %rsi
callq 0x62f0
movq %rax, -0x250(%rbp)
movq -0x260(%rbp), %rdi
callq 0x6a10
movq -0x258(%rbp), %rdi
callq 0x6a10
leaq 0x6559(%rip), %rdi      # 0x80de
movb $0x0, %al
callq 0x10b0
movl $0x0, -0x294(%rbp)
movl $0x0, -0x29c(%rbp)
movl $0x0, -0x2a0(%rbp)
leaq -0x210(%rbp), %rdi
movq -0xa0(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x1100
cmpq $0x0, %rax
je 0x1c54
leaq -0x210(%rbp), %rdi
leaq 0x6713(%rip), %rsi      # 0x82ed
callq 0x1210
movq %rax, -0xd8(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x66fc(%rip), %rsi      # 0x82ed
callq 0x1210
movq %rax, -0xd8(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x66e5(%rip), %rsi      # 0x82ed
callq 0x1210
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rdi
callq 0x1230
movl %eax, -0x294(%rbp)
cmpl $0x0, -0x294(%rbp)
je 0x1c40
movl -0x2a0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2a0(%rbp)
jmp 0x1c4f
movl -0x29c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x29c(%rbp)
jmp 0x1baa
movq -0xa0(%rbp), %rdi
callq 0x1080
movl $0x0, -0x2b4(%rbp)
movl $0x0, -0x2b8(%rbp)
movl $0x0, -0x2bc(%rbp)
movl $0x0, -0x2c0(%rbp)
cvtsi2sdl -0x2a0(%rbp), %xmm0
movsd 0x6370(%rip), %xmm1     # 0x8008
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x2a4(%rbp)
movl -0x2a0(%rbp), %eax
subl -0x2a4(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x2a8(%rbp)
cvtsi2sdl -0x29c(%rbp), %xmm0
movsd 0x6338(%rip), %xmm1     # 0x8008
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x2ac(%rbp)
movl -0x29c(%rbp), %eax
subl -0x2ac(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x2b0(%rbp)
movq -0xc8(%rbp), %rdi
leaq 0x6310(%rip), %rsi      # 0x8016
callq 0x11f0
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
jne 0x1d3e
leaq 0x62f9(%rip), %rdi      # 0x8018
movb $0x0, %al
callq 0x10b0
movq -0xa0(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
jmp 0x2282
leaq 0x63c0(%rip), %rdi      # 0x8105
leaq 0x62c5(%rip), %rsi      # 0x8011
callq 0x11f0
movq %rax, -0xb8(%rbp)
cmpq $0x0, %rax
jne 0x1d76
leaq 0x633e(%rip), %rdi      # 0x80a3
callq 0x1200
movl $0x0, -0x4(%rbp)
jmp 0x2282
leaq 0x6394(%rip), %rdi      # 0x8111
leaq 0x628d(%rip), %rsi      # 0x8011
callq 0x11f0
movq %rax, -0xc0(%rbp)
cmpq $0x0, %rax
jne 0x1dae
leaq 0x6306(%rip), %rdi      # 0x80a3
callq 0x1200
movl $0x0, -0x4(%rbp)
jmp 0x2282
jmp 0x1db0
leaq -0x210(%rbp), %rdi
movq -0xa0(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x1100
cmpq $0x0, %rax
je 0x2093
leaq -0x210(%rbp), %rdi
leaq 0x650d(%rip), %rsi      # 0x82ed
callq 0x1210
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rdi
leaq 0x6326(%rip), %rsi      # 0x8120
callq 0x1120
cmpl $0x0, %eax
jne 0x1e06
jmp 0x1db0
movl $0x0, -0x298(%rbp)
cmpq $0x0, -0xd8(%rbp)
je 0x1efa
movl -0x298(%rbp), %eax
incl %eax
movl %eax, -0x298(%rbp)
movl -0x298(%rbp), %eax
movl %eax, -0x2fc(%rbp)
subl $0x1, %eax
je 0x1e5c
jmp 0x1e3f
movl -0x2fc(%rbp), %eax
subl $0x2, %eax
je 0x1e94
jmp 0x1e4c
movl -0x2fc(%rbp), %eax
subl $0x3, %eax
je 0x1ecc
jmp 0x1ede
movq -0xd8(%rbp), %rdi
callq 0x10a0
movq %rax, %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x1190
movq %rax, -0x288(%rbp)
movq -0x288(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x1050
jmp 0x1ede
movq -0xd8(%rbp), %rdi
callq 0x10a0
movq %rax, %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x1190
movq %rax, -0x290(%rbp)
movq -0x290(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x1050
jmp 0x1ede
movq -0xd8(%rbp), %rdi
callq 0x1230
movl %eax, -0x294(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x6404(%rip), %rsi      # 0x82ed
callq 0x1210
movq %rax, -0xd8(%rbp)
jmp 0x1e10
cmpl $0x0, -0x294(%rbp)
je 0x1fc0
movl -0x2b8(%rbp), %eax
cmpl -0x2a4(%rbp), %eax
jge 0x1f46
movq -0x250(%rbp), %rdi
movq -0x288(%rbp), %rsi
movq -0x290(%rbp), %rdx
movl -0x294(%rbp), %ecx
callq 0x5e90
movl -0x2b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2b8(%rbp)
jmp 0x1fbb
movl -0x2c0(%rbp), %eax
cmpl -0x2a8(%rbp), %eax
jge 0x1f8f
movq -0xb8(%rbp), %rdi
movq -0x288(%rbp), %rdx
movq -0x290(%rbp), %rcx
movl -0x294(%rbp), %r8d
leaq 0x61b6(%rip), %rsi      # 0x812d
movb $0x0, %al
callq 0x1140
movl -0x2c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c0(%rbp)
jmp 0x1fb9
movq -0xc0(%rbp), %rdi
movq -0x288(%rbp), %rdx
movq -0x290(%rbp), %rcx
movl -0x294(%rbp), %r8d
leaq 0x617b(%rip), %rsi      # 0x812d
movb $0x0, %al
callq 0x1140
jmp 0x1fbb
jmp 0x2076
movl -0x2b4(%rbp), %eax
cmpl -0x2ac(%rbp), %eax
jge 0x1fff
movq -0x250(%rbp), %rdi
movq -0x288(%rbp), %rsi
movq -0x290(%rbp), %rdx
movl -0x294(%rbp), %ecx
callq 0x5e90
movl -0x2b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2b4(%rbp)
jmp 0x2074
movl -0x2bc(%rbp), %eax
cmpl -0x2b0(%rbp), %eax
jge 0x2048
movq -0xb8(%rbp), %rdi
movq -0x288(%rbp), %rdx
movq -0x290(%rbp), %rcx
movl -0x294(%rbp), %r8d
leaq 0x60fd(%rip), %rsi      # 0x812d
movb $0x0, %al
callq 0x1140
movl -0x2bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2bc(%rbp)
jmp 0x2072
movq -0xc0(%rbp), %rdi
movq -0x288(%rbp), %rdx
movq -0x290(%rbp), %rcx
movl -0x294(%rbp), %r8d
leaq 0x60c2(%rip), %rsi      # 0x812d
movb $0x0, %al
callq 0x1140
jmp 0x2074
jmp 0x2076
movq -0x288(%rbp), %rdi
callq 0x1030
movq -0x290(%rbp), %rdi
callq 0x1030
jmp 0x1db0
movq -0xa0(%rbp), %rdi
callq 0x1080
movq -0xb8(%rbp), %rdi
callq 0x1080
movq -0xc0(%rbp), %rdi
callq 0x1080
leaq 0x6079(%rip), %rdi      # 0x8137
movb $0x0, %al
callq 0x10b0
leaq 0x6096(%rip), %rdi      # 0x8162
leaq 0x6098(%rip), %rsi      # 0x816b
callq 0x11f0
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
leaq 0x6081(%rip), %rsi      # 0x816e
movb $0x0, %al
callq 0x1140
leaq 0x6090(%rip), %rdi      # 0x818b
leaq 0x6069(%rip), %rsi      # 0x816b
callq 0x11f0
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
leaq 0x6052(%rip), %rsi      # 0x816e
movb $0x0, %al
callq 0x1140
movq -0x250(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x60a0
movq -0x250(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x6110
movq -0xa8(%rbp), %rdi
callq 0x1080
movq -0xb0(%rbp), %rdi
callq 0x1080
leaq 0x6030(%rip), %rdi      # 0x8198
movb $0x0, %al
callq 0x10b0
movq -0x250(%rbp), %rdx
leaq 0x5fe5(%rip), %rdi      # 0x8162
leaq 0x6007(%rip), %rsi      # 0x818b
callq 0x27c0
movq %rax, -0x2c8(%rbp)
movq -0x2c8(%rbp), %rdi
movq -0x250(%rbp), %rsi
movq -0x78(%rbp), %rdx
callq 0x3ea0
movq %rax, -0x2d0(%rbp)
leaq 0x6026(%rip), %rdi      # 0x81db
movb $0x0, %al
callq 0x10b0
movq -0x2d0(%rbp), %rsi
movq -0x250(%rbp), %rdx
leaq 0x5f34(%rip), %rdi      # 0x8105
callq 0x30b0
movq -0x2c8(%rbp), %rdi
callq 0x2750
movq -0x78(%rbp), %rdi
callq 0x7980
movq -0x250(%rbp), %rdi
callq 0x5a30
movq -0x268(%rbp), %rdi
callq 0x1030
movq -0x2d0(%rbp), %rdi
callq 0x2300
movq -0xc8(%rbp), %rdi
callq 0x1030
movq -0xd0(%rbp), %rdi
callq 0x1030
movq -0x80(%rbp), %rdi
callq 0x10f0
leaq 0x5ece(%rip), %rdi      # 0x8105
callq 0x1040
leaq 0x5ece(%rip), %rdi      # 0x8111
callq 0x1040
leaq -0x70(%rbp), %rdi
callq 0x11e0
cvtsi2sd %rax, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
subsd -0x18(%rbp), %xmm0
divsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
leaq 0x5f89(%rip), %rdi      # 0x8204
movb $0x1, %al
callq 0x10b0
movl -0x4(%rbp), %eax
addq $0x300, %rsp            # imm = 0x300
popq %rbp
retq
nop