// File: myudelson[P]hmm-scalable/trainhmmst.cpp
// Function: cross_validate_nstrat(double*, char const*, char const*, long*, long*, _IO_FILE*)
NUMBER cross_validate_nstrat(NUMBER* metrics, const char *filename, const char *model_file_name, clock_t *tm_fit, clock_t *tm_predict, FILE *fid_console) {//SEQ
//NUMBER cross_validate_nstrat(NUMBER* metrics, const char *filename, const char *model_file_name, double *tm_fit, double *tm_predict, FILE *fid_console) {//PAR
    NPAR f;
    NCAT U; // unstratified
    NDAT t;
    clock_t tm0;//SEQ
//    double _tm0;//PAR
    char *ch;
    FILE *fid = NULL; // file for storing prediction should that be necessary
    FILE *fid_folds = NULL; // file for reading/writing folds
    if(task.predictions>0) {  // if we have to write the predictions file
        fid = fopen(filename,"w");
        if(fid == NULL)
        {
            fprintf(stderr, "Can't write output model file %s\n",filename);
            if(task.duplicate_console==1) fprintf(fid_console, "Can't write output model file %s\n",filename);
            exit(1);
        }
    }
    // produce folds
    NPAR *folds = Calloc(NPAR, (size_t)task.N);
    NDAT *fold_counts = Calloc(NDAT, (size_t)task.cv_folds);
	
    srand ( (unsigned int)time(NULL) ); // randomize
	
    // folds file
    if(task.cv_folds_file[0] > 0) { // file is specified
        if(task.cv_inout_flag=='i') {
            fid_folds = fopen(task.cv_folds_file,"r");
            if(fid_folds == NULL)
            {
                fprintf(stderr, "Can't open folds file for reading %s\n",filename);
                if(task.duplicate_console==1) fprintf(fid_console, "Can't open folds file for reading %s\n",filename);
                exit(1);
            }
            max_line_length = 1024;
            line = (char *)malloc((size_t)max_line_length);// Malloc(char,max_line_length);
        } else if(task.cv_inout_flag=='o') {
            fid_folds = fopen(task.cv_folds_file,"w");
            if(fid_folds == NULL)
            {
                fprintf(stderr, "Can't open folds file for writing %s\n",filename);
                if(task.duplicate_console==1) fprintf(fid_console, "Can't open folds file for writing %s\n",filename);
                exit(1);
            }
        }
    }
    for(U=0; U<task.N; U++) {
        if( task.cv_folds_file[0]==0 || (task.cv_folds_file[0] > 0 && task.cv_inout_flag=='o') ) { // output or default
            folds[U] = (NPAR)(rand() % task.cv_folds); // produce folds
            if(task.cv_folds_file[0] > 0 )
                fprintf(fid_folds,"%i\n",folds[U]); // write out
        } else if( (task.cv_folds_file[0] > 0 && task.cv_inout_flag=='i') ) {
            readline(fid_folds);//
            ch = strtok(line,"\t\n\r");
            if(ch == NULL) {
                fprintf(stderr, "Error reading input folds file (potentialy wrong number of rows)\n");
                if(task.duplicate_console==1) fprintf(fid_console, "Error reading input folds file (potentialy wrong number of rows)\n");
                exit(1);
            }
            folds[U] = (NPAR)(atoi(ch));
        }
    }
    if(task.cv_folds_file[0] > 0) { // file is specified
        fclose(fid_folds);
        if(task.cv_inout_flag=='i')
            free(line);
    }
    
    
    // count number of items in each fold
    for(t=0; t<task.N; t++)  fold_counts[ folds[task.dat_item[t]/*->get(t)*/] ]++;
    // create and fit multiple problems
    HMMProblemSt* hmms[task.cv_folds];
    int q = task.quiet;
//    task.quiet = 1;
    for(f=0; f<task.cv_folds; f++) {
        switch(task.structure)
        {
            case STRUCTURE_SKILL: // Conjugate Gradient Descent
//            case STRUCTURE_GROUP: // Conjugate Gradient Descent
                hmms[f] = new HMMProblemSt(&task);
                break;
            case STRUCTURE_ELO: // Conjugate Gradient Descent
                hmms[f] = new HMMProblemEloSt(&task);
                break;
//            case STRUCTURE_SKABslc: // Conjugate Gradient Descent
//                hmms[f] = new HMMProblemSlicedAB(&param);
//                break;
//            case STRUCTURE_SKAslc: // Conjugate Gradient Descent
//                hmms[f] = new HMMProblemSlicedA(&param);
//                break;
////            case STRUCTURE_PIg: // Gradient Descent: PI by group, A,B by skill
////                hmm = new HMMProblemPiG(&param);
////                break;
//            case STRUCTURE_PIgk: // Gradient Descent, pLo=f(K,G), other by K
//                hmms[f] = new HMMProblemPiGK(&param);
//                break;
//            case STRUCTURE_PIAgk: // Gradient Descent, pLo=f(K,G), pT=f(K,G), other by K
//                hmms[f] = new HMMProblemPiAGK(&param);
//                break;
//            case STRUCTURE_Agk: // Gradient Descent, pT=f(K,G), other by K
//                hmms[f] = new HMMProblemAGK(&param);
//                break;
//            case STRUCTURE_PIABgk: // Gradient Descent, pT=f(K,G), other by K
//                hmms[f] = new HMMProblemPiABGK(&param);
//                break;
//            case BKT_GD_T: // Gradient Descent with Transfer
//                hmm = new HMMProblemKT(&param);
//                break;
            default:
                fprintf(stderr,"Solver specified (%d) is not supported!\n",task.structure);
                exit(1);
                break;
        }
        // block respective data - do not fit the data belonging to the fold
        NPAR *saved_obs = Calloc(NPAR, (size_t)fold_counts[f]);
        NDAT count_saved = 0;
        for(t=0; t<task.N; t++) {
            if( folds[ task.dat_item[t]/*->get(t)*/ ] == f ) {
                saved_obs[count_saved++] = task.dat_obs[t];
                task.dat_obs[t]=-1;//->set(t, -1);
            }
        }
        // now compute
        tm0 = clock(); //SEQ
//        _tm0 = omp_get_wtime(); //PAR
        hmms[f]->fit();
        *(tm_fit) += (clock_t)(clock()- tm0);//SEQ
//        *(tm_fit) += omp_get_wtime()-_tm0;//PAR
        
        // write model
        char fname[1024];
        sprintf(fname,"%s_%i",model_file_name,f);
        hmms[f]->toFile(fname);
        
        // UN-block respective data
        count_saved = 0;
        for(t=0; t<task.N; t++)
            if( folds[ task.dat_item[t]/*->get(t)*/ ] == f )
                task.dat_obs[t]=saved_obs[count_saved++];//->set(t, saved_obs[count_saved++]);
        free(saved_obs);
//        if(q == 0) {
            printf("fold %d is done\n",f+1);
            if(task.duplicate_console==1) fprintf(fid_console, "fold %d is done\n",f+1);
//        }
    }
    free(fold_counts);
    task.quiet = (NPAR)q;
    
    tm0 = clock();//SEQ
//    _tm0 = omp_get_wtime();//PAR
	
	// new prediction
	//		predict
	HMMProblemSt::predict(metrics, filename,
                          //task.N, task.dat_obs, task.dat_group, task.dat_skill, task.dat_skill_stacked, task.dat_skill_rcount, task.dat_skill_rix,
                          &task,
                          hmms, task.cv_folds/*nhmms*/, folds);
	
    printf("Cross-validation is done wrong, if A or B matrices are 'sliced'\n");
    
	*(tm_predict) += (clock_t)(clock()- tm0);//SEQ
//    *(tm_predict) += omp_get_wtime()-_tm0;//PAR
    
    // delete problems
    NCAT n_par = 0;
    for(f=0; f<task.cv_folds; f++) {
        n_par += hmms[f]->getModelParamN();
        delete hmms[f];
    }
    n_par /= task.cv_folds;
    free(folds);
	
	return n_par;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4e0, %rsp            # imm = 0x4E0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
cmpl $0x0, 0x202be(%rip)     # 0x27378
jle 0x7121
movq -0x10(%rbp), %rdi
leaq 0x1707d(%rip), %rsi     # 0x1e144
callq 0x3340
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x711f
movq 0x1fefa(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x18d71(%rip), %rsi     # 0x1fe5d
movb $0x0, %al
callq 0x33f0
movsbl 0x20252(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x7115
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x18d4f(%rip), %rsi     # 0x1fe5d
movb $0x0, %al
callq 0x33f0
movl $0x1, %edi
callq 0x3360
jmp 0x7121
movslq 0x20ad8(%rip), %rdi     # 0x27c00
movl $0x1, %esi
callq 0x3180
movq %rax, -0x68(%rbp)
movsbq 0x20646(%rip), %rdi     # 0x27784
movl $0x4, %esi
callq 0x3180
movq %rax, -0x70(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x3260
movl %eax, %edi
callq 0x3280
movsbl 0x20624(%rip), %eax     # 0x27787
cmpl $0x0, %eax
jle 0x7287
movsbl 0x20a14(%rip), %eax     # 0x27b87
cmpl $0x69, %eax
jne 0x7208
leaq 0x20185(%rip), %rdi     # 0x27308
addq $0x47f, %rdi            # imm = 0x47F
leaq 0x18cee(%rip), %rsi     # 0x1fe7f
callq 0x3340
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x71e9
movq 0x1fe30(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x18ccb(%rip), %rsi     # 0x1fe81
movb $0x0, %al
callq 0x33f0
movsbl 0x20188(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x71df
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x18ca9(%rip), %rsi     # 0x1fe81
movb $0x0, %al
callq 0x33f0
movl $0x1, %edi
callq 0x3360
movl $0x400, 0x20aa5(%rip)   # imm = 0x400
movslq 0x20a9e(%rip), %rdi     # 0x27c98
callq 0x33b0
movq %rax, 0x20a9a(%rip)     # 0x27ca0
jmp 0x7285
movsbl 0x20978(%rip), %eax     # 0x27b87
cmpl $0x6f, %eax
jne 0x7283
leaq 0x200ed(%rip), %rdi     # 0x27308
addq $0x47f, %rdi            # imm = 0x47F
leaq 0x16f1b(%rip), %rsi     # 0x1e144
callq 0x3340
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x7281
movq 0x1fd98(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x18c59(%rip), %rsi     # 0x1fea7
movb $0x0, %al
callq 0x33f0
movsbl 0x200f0(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x7277
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x18c37(%rip), %rsi     # 0x1fea7
movb $0x0, %al
callq 0x33f0
movl $0x1, %edi
callq 0x3360
jmp 0x7283
jmp 0x7285
jmp 0x7287
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl 0x20969(%rip), %eax     # 0x27c00
jge 0x73b5
movsbl 0x204e3(%rip), %eax     # 0x27787
cmpl $0x0, %eax
je 0x72c1
movsbl 0x204d7(%rip), %eax     # 0x27787
cmpl $0x0, %eax
jle 0x730a
movsbl 0x208cb(%rip), %eax     # 0x27b87
cmpl $0x6f, %eax
jne 0x730a
callq 0x30c0
movsbl 0x204b7(%rip), %ecx     # 0x27784
cltd
idivl %ecx
movq -0x68(%rbp), %rax
movslq -0x38(%rbp), %rcx
movb %dl, (%rax,%rcx)
movsbl 0x204a5(%rip), %eax     # 0x27787
cmpl $0x0, %eax
jle 0x7305
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edx
leaq 0x18f3c(%rip), %rsi     # 0x2023a
movb $0x0, %al
callq 0x33f0
jmp 0x73a5
movsbl 0x20476(%rip), %eax     # 0x27787
cmpl $0x0, %eax
jle 0x73a3
movsbl 0x20866(%rip), %eax     # 0x27b87
cmpl $0x69, %eax
jne 0x73a3
movq -0x60(%rbp), %rdi
callq 0x78c0
movq 0x2096a(%rip), %rdi     # 0x27ca0
leaq 0x1811c(%rip), %rsi     # 0x1f459
callq 0x3440
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x738d
movq 0x1fc84(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x18b6f(%rip), %rsi     # 0x1fecd
movb $0x0, %al
callq 0x33f0
movsbl 0x1ffe0(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x7383
movq -0x30(%rbp), %rdi
leaq 0x18b51(%rip), %rsi     # 0x1fecd
movb $0x0, %al
callq 0x33f0
movl $0x1, %edi
callq 0x3360
movq -0x50(%rbp), %rdi
callq 0x3430
movb %al, %dl
movq -0x68(%rbp), %rax
movslq -0x38(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x73a5
jmp 0x73a7
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x728e
movsbl 0x203cb(%rip), %eax     # 0x27787
cmpl $0x0, %eax
jle 0x73e4
movq -0x60(%rbp), %rdi
callq 0x3290
movsbl 0x207b6(%rip), %eax     # 0x27b87
cmpl $0x69, %eax
jne 0x73e2
movq 0x208c3(%rip), %rdi     # 0x27ca0
callq 0x3350
jmp 0x73e4
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl 0x2080c(%rip), %eax     # 0x27c00
jge 0x7426
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movq 0x207bb(%rip), %rdx     # 0x27bc0
movslq -0x3c(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
movsbq (%rcx,%rdx), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x73eb
movzbl 0x20357(%rip), %edx     # 0x27784
movl %edx, %eax
movq %rsp, %rcx
movq %rcx, -0x78(%rbp)
movl %edx, %ecx
leal 0xf(,%rcx,8), %ecx
andl $-0x10, %ecx
movl %ecx, %edx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x4c0(%rbp)
movq %rcx, %rsp
movq %rax, -0x80(%rbp)
movsbl 0x1fef5(%rip), %eax     # 0x27354
movl %eax, -0x84(%rbp)
movb $0x0, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
movsbl 0x20310(%rip), %ecx     # 0x27784
cmpl %ecx, %eax
jge 0x7774
movsbl 0x1fed3(%rip), %eax     # 0x27356
movl %eax, -0x4c4(%rbp)
subl $0x1, %eax
je 0x74a0
jmp 0x7490
movl -0x4c4(%rbp), %eax
subl $0xe, %eax
je 0x7509
jmp 0x756f
movl $0xd0, %edi
callq 0x32a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x4d0(%rbp)
leaq 0x1fe4a(%rip), %rsi     # 0x27308
callq 0x14b20
jmp 0x74c5
movq -0x4c0(%rbp), %rax
movq -0x4d0(%rbp), %rdx
movsbq -0x31(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x7598
movq -0x4d0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0xd0, %esi
callq 0x32b0
jmp 0x7888
movl $0x110, %edi            # imm = 0x110
callq 0x32a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x4d8(%rbp)
leaq 0x1fde1(%rip), %rsi     # 0x27308
callq 0x1d1b0
jmp 0x752e
movq -0x4c0(%rbp), %rax
movq -0x4d8(%rbp), %rdx
movsbq -0x31(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x7598
movq -0x4d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x110, %esi            # imm = 0x110
callq 0x32b0
jmp 0x7888
movq 0x1fa62(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x1fdd6(%rip), %edx     # 0x27356
leaq 0x16c06(%rip), %rsi     # 0x1e18d
movb $0x0, %al
callq 0x33f0
movl $0x1, %edi
callq 0x3360
movq -0x70(%rbp), %rax
movsbq -0x31(%rbp), %rcx
movslq (%rax,%rcx,4), %rdi
movl $0x1, %esi
callq 0x3180
movq %rax, -0xa0(%rbp)
movl $0x0, -0xa4(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl 0x20630(%rip), %eax     # 0x27c00
jge 0x7639
movq -0x68(%rbp), %rax
movq 0x205e3(%rip), %rcx     # 0x27bc0
movslq -0x3c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x31(%rbp), %ecx
cmpl %ecx, %eax
jne 0x762c
movq 0x20590(%rip), %rax     # 0x27b88
movslq -0x3c(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0xa0(%rbp), %rax
movl -0xa4(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0xa4(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq 0x20564(%rip), %rax     # 0x27b88
movslq -0x3c(%rbp), %rcx
movb $-0x1, (%rax,%rcx)
jmp 0x762e
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x75c7
callq 0x3190
movq %rax, %rcx
movq -0x4c0(%rbp), %rax
movq %rcx, -0x48(%rbp)
movsbq -0x31(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
callq 0x3190
movq %rax, %rcx
subq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
leaq -0x4b0(%rbp), %rdi
movq -0x18(%rbp), %rdx
movsbl -0x31(%rbp), %ecx
leaq 0x18888(%rip), %rsi     # 0x1ff0f
movb $0x0, %al
callq 0x30b0
movq -0x4c0(%rbp), %rax
movsbq -0x31(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x4b0(%rbp), %rsi
movq (%rdi), %rax
callq *0x40(%rax)
movl $0x0, -0xa4(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl 0x2053b(%rip), %eax     # 0x27c00
jge 0x771f
movq -0x68(%rbp), %rax
movq 0x204ee(%rip), %rcx     # 0x27bc0
movslq -0x3c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x31(%rbp), %ecx
cmpl %ecx, %eax
jne 0x7712
movq -0xa0(%rbp), %rax
movl -0xa4(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0xa4(%rbp)
movslq %ecx, %rcx
movb (%rax,%rcx), %dl
movq 0x2047d(%rip), %rax     # 0x27b88
movslq -0x3c(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x7714
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x76bc
movq -0xa0(%rbp), %rdi
callq 0x3350
movsbl -0x31(%rbp), %esi
addl $0x1, %esi
leaq 0x187dc(%rip), %rdi     # 0x1ff15
movb $0x0, %al
callq 0x3060
movsbl 0x1fc05(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x7765
movq -0x30(%rbp), %rdi
movsbl -0x31(%rbp), %edx
addl $0x1, %edx
leaq 0x187b7(%rip), %rsi     # 0x1ff15
movb $0x0, %al
callq 0x33f0
jmp 0x7767
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0x7469
movq -0x70(%rbp), %rdi
callq 0x3350
movl -0x84(%rbp), %eax
movb %al, 0x1fbcb(%rip)      # 0x27354
callq 0x3190
movq -0x4c0(%rbp), %rcx
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movb 0x1ffdd(%rip), %al      # 0x27784
movq -0x68(%rbp), %r9
leaq 0x1fb56(%rip), %rdx     # 0x27308
movsbl %al, %r8d
callq 0x18c10
leaq 0x18764(%rip), %rdi     # 0x1ff26
movb $0x0, %al
callq 0x3060
callq 0x3190
movq %rax, %rcx
subq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movl $0x0, -0x4b4(%rbp)
movb $0x0, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
movsbl 0x1ff8c(%rip), %ecx     # 0x27784
cmpl %ecx, %eax
jge 0x7855
movq -0x4c0(%rbp), %rax
movsbq -0x31(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x19440
movl %eax, %ecx
movq -0x4c0(%rbp), %rax
addl -0x4b4(%rbp), %ecx
movl %ecx, -0x4b4(%rbp)
movsbq -0x31(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x4e0(%rbp)
cmpq $0x0, %rax
je 0x7849
movq -0x4e0(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x784b
movb -0x31(%rbp), %al
addb $0x1, %al
movb %al, -0x31(%rbp)
jmp 0x77ed
movsbl 0x1ff28(%rip), %ecx     # 0x27784
movl -0x4b4(%rbp), %eax
cltd
idivl %ecx
movl %eax, -0x4b4(%rbp)
movq -0x68(%rbp), %rdi
callq 0x3350
cvtsi2sdl -0x4b4(%rbp), %xmm0
movq -0x78(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x34c0
nopw %cs:(%rax,%rax)