// File: /workspace/github_c_makefile_star2_O3/Gaurang18[P]Compiler-Project-BITS-Pilani/./symboltable.c
// Function: populateSymbolTable
void populateSymbolTable(FILE *fp, parsetree head, char *scope){

    if(head==NULL)
        return;

    if(head->value==4){
         hash_insert_func("driver","", "");
         strcpy(scope, "driver");
         // assert(0);
        }

    populateSymbolTable(fp, head->child, scope);

    

    if(head->value==106){

        if(head->parent->value==5)
        {
            
            if(check_func_present(head->Lex->tk->value))
                fprintf(fp,"ERROR 1: Function %s already Defined, Erroneous declaration, line number %d", head->Lex->tk->value,head->Lex->tk->line);
            else{

                parsetree root = head;
                while(root->value!=1)
                    root = root->parent;


                
                populateFunctionDefinitions(fp, root, head->Lex->tk->value);
                //if(check_func_present(head->Lex->tk->value))
                    //printf("Yay\n");
            }
        }

        if(head->parent->value == 7)
        {
            if(!check_func_present(head->Lex->tk->value))
                populateFunctionDefinitions(fp, head, head->Lex->tk->value);
        }



        //Changes scope
        if(head->parent->value==7)
        {
            strcpy(scope, head->Lex->tk->value);
        }

        //Declare Statements

        if(head->parent->value == 33 && head->parent->parent->value==20)
        {   
            if(checksymbolpresent(head->Lex->tk->value, scope))
                fprintf(fp,"ERROR 9: Redeclaration of variable %s in the same scope, line number %d\n", head->Lex->tk->value, head->Lex->tk->line);
            
            
            switch(head->parent->right->rule)
            {
                case 18: hashinsert(head->Lex->tk->value,"INTEGER",scope,"___");
                    break;
                case 19:hashinsert(head->Lex->tk->value,"REAL",scope,"___");
                    break;
                case 20:hashinsert(head->Lex->tk->value,"BOOLEAN",scope,"___");
                    break;
                case 21: 

                    // int range = atoi(head->parent->right->child->right->child->right->right->Lex->tk->value) - atoi(head->parent->right->child->right->child->Lex->tk->value);
                    // char value[3] = {"0"};
                    // value[0] = range;
                    // value[1] = '\0';
                    {parsetree range = head->parent->right->child->right;
                    int r1 = atoi(range->child->Lex->tk->value);
                    int r2 = atoi(range->child->right->right->Lex->tk->value);
                    int r = r2 -r1 +1;
                    char size[3];
                    ////sprintf(size,"%d",r);

                    // printf("range %d\n", r);
                    char type[100] = {'\0'};



                    switch(range->right->rule){
                        case 22: strcat(type, "ARRAY(INTEGER, ");
                                 strcat(type, size);
                                 strcat(type, ")");
                                 hashinsert(head->Lex->tk->value, type ,scope, "___");
                                break;
                        case 23:strcat(type, "ARRAY(REAL, ");
                                 strcat(type, size);
                                 strcat(type, ")");
                                 hashinsert(head->Lex->tk->value, type ,scope, "___");
                                break;
                        case 24:strcat(type, "ARRAY(BOOLEAN, ");
                                 strcat(type, size);
                                 strcat(type, ")");
                                 hashinsert(head->Lex->tk->value, type ,scope, "___");
                                break;
                    }}
                    break;
            }
        }

        //Declaring more than one identifier

        if(head->parent->value == 34)
        {
                parsetree temphead = head;
                while(temphead->parent->value!=33)
                    temphead = temphead->parent;

            if(temphead->parent->value == 33 && temphead->parent->parent->value==20){
            
            switch(temphead->parent->right->rule)
            {
                case 18: hashinsert(head->Lex->tk->value,"INTEGER",scope,"___");
                    break;
                case 19:hashinsert(head->Lex->tk->value,"REAL",scope,"___");
                    break;
                case 20:hashinsert(head->Lex->tk->value,"BOOLEAN",scope,"___");
                    break;
                case 21: 

                    // int range = atoi(head->parent->right->child->right->child->right->right->Lex->tk->value) - atoi(head->parent->right->child->right->child->Lex->tk->value);
                    // char value[3] = {"0"};
                    // value[0] = range;
                    // value[1] = '\0';
                    {parsetree range = temphead->parent->right->child->right;
                    int r1 = atoi(range->child->Lex->tk->value);
                    int r2 = atoi(range->child->right->right->Lex->tk->value);
                    int r = r2 -r1 +1;
                    char size[3];
                    //sprintf(size,"%d",r);

                    // printf("range %d\n", r);
                    char type[100] = {'\0'};



                    switch(range->right->rule){
                        case 22: strcat(type, "ARRAY(INTEGER, ");
                                 strcat(type, size);
                                 strcat(type, ")");
                                 hashinsert(head->Lex->tk->value, type ,scope, "___");
                                break;
                        case 23:strcat(type, "ARRAY(REAL, ");
                                 strcat(type, size);
                                 strcat(type, ")");
                                 hashinsert(head->Lex->tk->value, type ,scope, "___");
                                break;
                        case 24:strcat(type, "ARRAY(BOOLEAN, ");
                                 strcat(type, size);
                                 strcat(type, ")");
                                 hashinsert(head->Lex->tk->value, type ,scope, "___");
                                break;
                    }}
                    break;
            }
        }}

        //input parameters declaration

        if(head->parent->value == 8 || head->parent->value == 9){

            

            // printf("%s \n", head->Lex->tk->value);

            switch(head->right->rule){
                case 18: hashinsert(head->Lex->tk->value,"INTEGER",scope,"___");
                    break;
                case 19:hashinsert(head->Lex->tk->value,"REAL",scope,"___");
                    break;
                case 20:hashinsert(head->Lex->tk->value,"BOOLEAN",scope,"___");
                    break;
                case 21: 

                    // int range = atoi(head->parent->right->child->right->child->right->right->Lex->tk->value) - atoi(head->parent->right->child->right->child->Lex->tk->value);
                    // char value[3] = {"0"};
                    // value[0] = range;
                    // value[1] = '\0';
                    {parsetree range = head->right->child->right;

                   int r1 = atoi(range->child->Lex->tk->value);
                    int r2 = atoi(range->child->right->right->Lex->tk->value);
                    int r = r2 -r1 + 1;
                    char size[3];
                    //sprintf(size,"%d",r);

                    // printf("range %d\n", r);

                    char type[100] = {'\0'};



                    switch(range->right->rule){
                        case 22: strcat(type, "ARRAY(INTEGER, ");
                                 strcat(type, size);
                                 strcat(type, ")");
                                 hashinsert(head->Lex->tk->value, type ,scope, "___");
                                break;
                        case 23:strcat(type, "ARRAY(REAL, ");
                                 strcat(type, size);
                                 strcat(type, ")");
                                 hashinsert(head->Lex->tk->value, type ,scope, "___");
                                break;
                        case 24:strcat(type, "ARRAY(BOOLEAN, ");
                                 strcat(type, size);
                                 strcat(type, ")");
                                 hashinsert(head->Lex->tk->value, type ,scope, "___");
                                break;
                    }}
                    break;
            }

        }

        //outputparameters declaration

        if(head->parent->value == 11 || head->parent->value == 12){

        

            // printf("%s \n", head->Lex->tk->value);

            switch(head->right->rule){
                        case 22: hashinsert(head->Lex->tk->value,"INTEGER",scope, "___");
                        break;
                        case 23:hashinsert(head->Lex->tk->value,"REAL",scope,"___");
                        break;
                        case 24:hashinsert(head->Lex->tk->value,"BOOLEAN",scope,"___");
                        break;
                    }
        }


        // display(scope);
        // printf("------------------\n");

        if(head->parent->value != 7 && head->parent->value != 5 && head->parent->value != 26 && !checksymbolpresent(head->Lex->tk->value, scope))
            fprintf(fp,"ERROR 2: identifier %s not declared, line number %d\n", head->Lex->tk->value, head->Lex->tk->line);


        //Module Reuse Statement

        if(head->parent->value == 26){
            if(!check_func_present(head->Lex->tk->value))
                fprintf(fp,"ERROR 3: Function definition for %s not found, line number %d\n", head->Lex->tk->value, head->Lex->tk->line);

            else{

                char inputtype[1000] = {'\0'};
                char outputtype[1000] = {'\0'};
                if(head->parent->child->rule == 56){
                    parsetree outlist = head->parent->child->child;
                    strcat(outputtype, gettype(outlist->child->Lex->tk->value, scope));
                    parsetree outlistprime = outlist->child->right;

                    while(outlistprime->rule!= 59){
                        strcat(outputtype, "; ");
                        strcat(outputtype, gettype(outlistprime->child->Lex->tk->value, scope));
                        outlistprime = outlistprime->child->right;
                    }
                }

                parsetree inputlist = head->right;
                strcat(inputtype, gettype(inputlist->child->Lex->tk->value, scope));

                parsetree inputlistprime = inputlist->child->right;

                    while(inputlistprime->rule!= 59){
                        strcat(inputtype, "; ");
                        strcat(inputtype, gettype(inputlistprime->child->Lex->tk->value, scope));
                        inputlistprime = inputlistprime->child->right;
                    }
                 
                if(strcmp(inputtype, get_Function_input_type(head->Lex->tk->value))!=0){
                    fprintf(fp,"\nERROR 4: input types do not match at line number %d \n", head->Lex->tk->line);
                    fprintf(fp,"Entered input parameters - %s\n", inputtype);
                    fprintf(fp,"Expected input parameters - %s\n", get_Function_input_type(head->Lex->tk->value));
                }
                if(strcmp(outputtype, get_Function_output_type(head->Lex->tk->value))!=0){
                    fprintf(fp,"\nERROR 5: output types do not match at line number %d\n", head->Lex->tk->line);
                    fprintf(fp,"Entered output parameters - %s\n", outputtype);
                    fprintf(fp,"Expected output parameters - %s\n", get_Function_output_type(head->Lex->tk->value));
                }





            }
          }

          //Check that array index is always integer
          if(head->parent->value==24){
            //assert(0);
            if(strcmp(gettype(head->Lex->tk->value, scope), "INTEGER")!=0)
                fprintf(fp,"ERROR 6: Array index should be of type integer but here, %s has type %s, line number %d\n", head->Lex->tk->value, gettype(head->Lex->tk->value, scope), head->Lex->tk->line);
            }

          if(head->parent->rule == 41 && head->right->rule==44)
          {
            //char[100] type = {'\0'};
            //type = gettype(head->Lex->tk->value, scope);
            char *token = NULL;
            token = strtok(gettype(head->Lex->tk->value, scope), "(");
            if(token==NULL)
                fprintf(fp,"ERROR 7: Indexing cannot be done on %s which is not an array, but of type %s , line number %d\n", head->Lex->tk->value, gettype(head->Lex->tk->value, scope), head->Lex->tk->line);
            if(strcmp(token,"ARRAY")!=0){
                fprintf(fp,"ERROR 8: Indexing cannot be done on %s which is not an array, but of type %s , line number %d\n", head->Lex->tk->value, gettype(head->Lex->tk->value, scope), head->Lex->tk->line);
            }
          }

          
    }

    //type checking for assignment
    if(head->value==100 && (head->parent->value == 28 || head->parent->value == 29)){
        //printf("Type checking for line number %d\n", head->Lex->tk->line);
        int err = TypeChecker(fp, head, scope);
        //printf("err is %d\n", err);
    }

    if(head->value==21){
        int type2, error = 0;
        int type = TypeChecker(fp, head->child->right, scope);
        parsetree caseStmts = head->child->right->right->right;
        //assert(0);

        if(type==1)
            fprintf(fp,"ERROR 9: The switch statement cannot have identifier of type real, line number %d\n", head->Lex->tk->line);

        else{

            if(type==0 && caseStmts->right->rule != 85)
                fprintf(fp,"ERROR 10: The switch statement has identifier of type integer but no default statement, line number %d\n", head->Lex->tk->line);

            if(type==-1 && caseStmts->right->rule != 84)
                fprintf(fp,"ERROR 11: The switch statement has identifier of type boolean cannot have default statement, line number %d\n", caseStmts->right->Lex->tk->line);



             while(caseStmts->child->value!=109)
            {   
                // printf("%s\n", terms[caseStmts->child->right->child->value]);
                type2 = TypeChecker(fp, caseStmts->child->right->child, scope);

                if(type == type2){
                    caseStmts = caseStmts->child->right->right->right->right;
                    //assert(0);
                }
                else
                {   
                    error = 1;
                    break;
                }

            }

        }
       
        if(error){

            fprintf(fp,"ERROR 12: The type of identifier of switch statement is different from the types of case labels, line number %d\n", caseStmts->child->right->child->Lex->tk->line);
        }
    }

    if(head->value==22 && head->rule==39){
        int type = TypeChecker(fp, head->child->right, scope);
        if(type!=0)
            fprintf(fp,"ERROR 13: The identifier in FOR loop has to be integer, line number %d\n", head->Lex->tk->line);

    }

    if(head->value==22 && head->rule==40){
        int type = TypeChecker(fp, head->child->right, scope);
        if(type!=-1)
            fprintf(fp,"ERROR 14: The expression in WHILE loop has to be of type boolean, line number %d\n", head->Lex->tk->line);



    }




    populateSymbolTable(fp, head->right, scope);
    
}

// Assembly:
testq %rsi, %rsi
je 0x68d5
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7e8, %rsp            # imm = 0x7E8
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r13
cmpl $0x4, 0x8(%rsi)
jne 0x5ea8
leaq 0x33fd(%rip), %rdi      # 0x9287
leaq 0x3dbd(%rip), %rdx      # 0x9c4e
movq %rdx, %rsi
callq 0x4703
movl $0x76697264, (%r14)     # imm = 0x76697264
movl $0x726576, 0x3(%r14)    # imm = 0x726576
movq 0x18(%r15), %rsi
movq %r13, %rdi
movq %r14, %rdx
callq 0x5e57
movl 0x8(%r15), %eax
cmpl $0x6a, %eax
jne 0x66e5
movq 0x30(%r15), %rax
cmpl $0x5, 0x8(%rax)
jne 0x5f15
movq (%r15), %rax
movq (%rax), %rbx
leaq 0x1e(%rbx), %r12
movq %r12, %rdi
callq 0x4b53
testl %eax, %eax
je 0x5efd
movl 0x3c(%rbx), %ecx
leaq 0x3c1a(%rip), %rsi      # 0x9b08
movq %r13, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2130
jmp 0x5f15
movq %r15, %rsi
movq 0x30(%rsi), %rsi
cmpl $0x1, 0x8(%rsi)
jne 0x5f00
movq %r13, %rdi
movq %r12, %rdx
callq 0x59d7
movq %r13, -0x30(%rbp)
movq 0x30(%r15), %r13
movl 0x8(%r13), %eax
cmpl $0x7, %eax
jne 0x5f72
movq (%r15), %rax
movq (%rax), %r12
addq $0x1e, %r12
movq %r12, %rdi
callq 0x4b53
testl %eax, %eax
jne 0x5f58
movq -0x30(%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x59d7
movq 0x30(%r15), %r13
movl 0x8(%r13), %eax
cmpl $0x7, %eax
jne 0x5f72
movq (%r15), %rax
movq (%rax), %rsi
addq $0x1e, %rsi
movq %r14, %rdi
callq 0x2060
movq 0x30(%r15), %r13
movl 0x8(%r13), %eax
cmpl $0x21, %eax
jne 0x60a2
movq 0x30(%r13), %rax
cmpl $0x14, 0x8(%rax)
jne 0x60a2
movq (%r15), %rax
movq (%rax), %rbx
leaq 0x1e(%rbx), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4fae
testl %eax, %eax
je 0x5fbe
movl 0x3c(%rbx), %ecx
leaq 0x3ba8(%rip), %rsi      # 0x9b54
movq -0x30(%rbp), %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2130
movq 0x30(%r15), %r13
movq 0x28(%r13), %rax
movl 0xc(%rax), %ecx
addl $-0x12, %ecx
cmpl $0x3, %ecx
ja 0x60a2
leaq 0x3198(%rip), %rdx      # 0x9170
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x3aca(%rip), %rsi      # 0x9abc
jmp 0x6093
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x3ac5(%rip), %rsi      # 0x9acd
jmp 0x6093
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0x3d0(%rbp)
movaps %xmm0, -0x3e0(%rbp)
movaps %xmm0, -0x3f0(%rbp)
movaps %xmm0, -0x400(%rbp)
movaps %xmm0, -0x410(%rbp)
movaps %xmm0, -0x420(%rbp)
movl $0x0, -0x3c0(%rbp)
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x69c8
cmpl $0x17, %eax
je 0x6964
cmpl $0x16, %eax
jne 0x60a2
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x3a5a(%rip), %xmm0     # 0x9ad7
jmp 0x69db
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x3a33(%rip), %rsi      # 0x9ac6
leaq 0x3b03(%rip), %rcx      # 0x9b9d
movq %r14, %rdx
callq 0x4c0f
movq 0x30(%r15), %rax
cmpl $0x22, 0x8(%rax)
jne 0x61af
movq %r15, %rax
movq 0x30(%rax), %rax
cmpl $0x21, 0x8(%rax)
jne 0x60b3
movq 0x30(%rax), %rcx
cmpl $0x14, 0x8(%rcx)
jne 0x61af
movq 0x28(%rax), %rax
movl 0xc(%rax), %ecx
addl $-0x12, %ecx
cmpl $0x3, %ecx
ja 0x61af
leaq 0x309b(%rip), %rdx      # 0x9180
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x39bd(%rip), %rsi      # 0x9abc
jmp 0x61a0
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x39b8(%rip), %rsi      # 0x9acd
jmp 0x61a0
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0x3d0(%rbp)
movaps %xmm0, -0x3e0(%rbp)
movaps %xmm0, -0x3f0(%rbp)
movaps %xmm0, -0x400(%rbp)
movaps %xmm0, -0x410(%rbp)
movaps %xmm0, -0x420(%rbp)
movl $0x0, -0x3c0(%rbp)
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x6a24
cmpl $0x17, %eax
je 0x6996
cmpl $0x16, %eax
jne 0x61af
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x394d(%rip), %xmm0     # 0x9ad7
jmp 0x6a37
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x3926(%rip), %rsi      # 0x9ac6
leaq 0x39f6(%rip), %rcx      # 0x9b9d
movq %r14, %rdx
callq 0x4c0f
movq 0x30(%r15), %rax
movl 0x8(%rax), %eax
andl $-0x2, %eax
cmpl $0x8, %eax
jne 0x62a6
movq 0x28(%r15), %rax
movl 0xc(%rax), %ecx
addl $-0x12, %ecx
cmpl $0x3, %ecx
ja 0x62a6
leaq 0x2fb4(%rip), %rdx      # 0x9190
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x38c6(%rip), %rsi      # 0x9abc
jmp 0x6297
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x38c1(%rip), %rsi      # 0x9acd
jmp 0x6297
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0x3d0(%rbp)
movaps %xmm0, -0x3e0(%rbp)
movaps %xmm0, -0x3f0(%rbp)
movaps %xmm0, -0x400(%rbp)
movaps %xmm0, -0x410(%rbp)
movaps %xmm0, -0x420(%rbp)
movl $0x0, -0x3c0(%rbp)
movq 0x28(%rax), %rax
movl 0xc(%rax), %eax
cmpl $0x18, %eax
je 0x6908
cmpl $0x17, %eax
je 0x68d6
cmpl $0x16, %eax
jne 0x62a6
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x3856(%rip), %xmm0     # 0x9ad7
jmp 0x691b
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x382f(%rip), %rsi      # 0x9ac6
leaq 0x38ff(%rip), %rcx      # 0x9b9d
movq %r14, %rdx
callq 0x4c0f
movq 0x30(%r15), %rax
movl 0x8(%rax), %eax
addl $-0xb, %eax
cmpl $0x1, %eax
ja 0x62ed
movq 0x28(%r15), %rax
movl 0xc(%rax), %eax
addl $-0x16, %eax
cmpl $0x2, %eax
ja 0x62ed
movl %eax, %eax
leaq 0x2f5f(%rip), %rcx      # 0x922c
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x38b8(%rip), %rcx      # 0x9b9d
movq %r14, %rdx
callq 0x4c0f
movq 0x30(%r15), %r13
movl 0x8(%r13), %eax
cmpl $0x1a, %eax
ja 0x6572
movl $0x40000a0, %ecx        # imm = 0x40000A0
btl %eax, %ecx
jae 0x6572
cmpl $0x1a, %eax
jne 0x65c8
movq (%r15), %rax
movq %rax, -0x38(%rbp)
movq (%rax), %rbx
leaq 0x1e(%rbx), %r12
movq %r12, %rdi
callq 0x4b53
testl %eax, %eax
je 0x65b0
leaq -0x420(%rbp), %rdi
movl $0x3e8, %edx            # imm = 0x3E8
xorl %esi, %esi
callq 0x20f0
leaq -0x810(%rbp), %rdi
movl $0x3e8, %edx            # imm = 0x3E8
xorl %esi, %esi
callq 0x20f0
movq 0x18(%r13), %rax
cmpl $0x38, 0xc(%rax)
jne 0x63f0
movq 0x18(%rax), %rbx
movq 0x18(%rbx), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
movq %r14, %rsi
callq 0x5119
leaq -0x810(%rbp), %rdi
movq %rax, %rsi
callq 0x21b0
movq 0x18(%rbx), %rax
movq 0x28(%rax), %r13
cmpl $0x3b, 0xc(%r13)
je 0x63f0
leaq -0x810(%rbp), %r12
movq %r12, %rdi
callq 0x20a0
movw $0x203b, -0x810(%rbp,%rax) # imm = 0x203B
movb $0x0, -0x80e(%rbp,%rax)
movq 0x18(%r13), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
movq %r14, %rsi
callq 0x5119
movq %r12, %rdi
movq %rax, %rsi
callq 0x21b0
movq 0x18(%r13), %rax
movq 0x28(%rax), %r13
cmpl $0x3b, 0xc(%r13)
jne 0x63a6
movq 0x28(%r15), %rbx
movq 0x18(%rbx), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
movq %r14, %rsi
callq 0x5119
leaq -0x420(%rbp), %rdi
movq %rax, %rsi
callq 0x21b0
movq 0x18(%rbx), %rax
movq 0x28(%rax), %r13
cmpl $0x3b, 0xc(%r13)
je 0x6479
leaq -0x420(%rbp), %r12
movq %r12, %rdi
callq 0x20a0
movw $0x203b, -0x420(%rbp,%rax) # imm = 0x203B
movb $0x0, -0x41e(%rbp,%rax)
movq 0x18(%r13), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
movq %r14, %rsi
callq 0x5119
movq %r12, %rdi
movq %rax, %rsi
callq 0x21b0
movq 0x18(%r13), %rax
movq 0x28(%rax), %r13
cmpl $0x3b, 0xc(%r13)
jne 0x642f
movq -0x38(%rbp), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
callq 0x4a22
leaq -0x420(%rbp), %rdi
movq %rax, %rsi
callq 0x2120
testl %eax, %eax
movq -0x30(%rbp), %rbx
je 0x64f5
movq (%r15), %rax
movq (%rax), %rax
movl 0x3c(%rax), %edx
leaq 0x3768(%rip), %rsi      # 0x9c18
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2130
leaq 0x378e(%rip), %rsi      # 0x9c4f
leaq -0x420(%rbp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2130
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
callq 0x4a22
leaq 0x3786(%rip), %rsi      # 0x9c6e
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2130
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
callq 0x4ab9
leaq -0x810(%rbp), %rdi
movq %rax, %rsi
callq 0x2120
testl %eax, %eax
je 0x65c8
movq (%r15), %rax
movq (%rax), %rax
movl 0x3c(%rax), %edx
leaq 0x3763(%rip), %rsi      # 0x9c8e
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2130
leaq 0x3789(%rip), %rsi      # 0x9cc5
leaq -0x810(%rbp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x2130
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
callq 0x4ab9
leaq 0x3782(%rip), %rsi      # 0x9ce5
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x2130
jmp 0x65c8
movq (%r15), %rax
movq (%rax), %rbx
leaq 0x1e(%rbx), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4fae
testl %eax, %eax
jne 0x65c8
movl 0x3c(%rbx), %ecx
leaq 0x360c(%rip), %rsi      # 0x9ba1
movq -0x30(%rbp), %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2130
movq 0x30(%r15), %r13
movl 0x8(%r13), %eax
jmp 0x630c
movl 0x3c(%rbx), %ecx
leaq 0x361c(%rip), %rsi      # 0x9bd6
movq -0x30(%rbp), %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x2130
movq %r14, %r12
movq 0x30(%r15), %r14
cmpl $0x18, 0x8(%r14)
jne 0x6623
movq (%r15), %rax
movq (%rax), %rbx
leaq 0x1e(%rbx), %rdi
movq %rdi, -0x38(%rbp)
movq %r12, %rsi
callq 0x5119
movq %rax, %r13
leaq 0x34c6(%rip), %rsi      # 0x9abc
movq %rax, %rdi
callq 0x2120
testl %eax, %eax
je 0x6623
movl 0x3c(%rbx), %r8d
leaq 0x36f9(%rip), %rsi      # 0x9d06
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x2130
movq 0x30(%r15), %r14
cmpl $0x29, 0xc(%r14)
movq %r12, %r14
jne 0x66dd
movq 0x28(%r15), %rax
cmpl $0x2c, 0xc(%rax)
jne 0x66dd
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
movq %r14, %rsi
callq 0x5119
leaq 0x2d75(%rip), %rsi      # 0x93cd
movq %rax, %rdi
callq 0x2180
movq %rax, %r12
testq %rax, %rax
jne 0x6699
movq (%r15), %rax
movq (%rax), %rbx
leaq 0x1e(%rbx), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x5119
movl 0x3c(%rbx), %r8d
leaq 0x36d7(%rip), %rsi      # 0x9d5f
movq -0x30(%rbp), %rdi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2130
leaq 0x2c67(%rip), %rsi      # 0x9307
movq %r12, %rdi
callq 0x2120
testl %eax, %eax
je 0x66dd
movq (%r15), %rax
movq (%rax), %rbx
leaq 0x1e(%rbx), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x5119
movl 0x3c(%rbx), %r8d
leaq 0x36f2(%rip), %rsi      # 0x9dbe
movq -0x30(%rbp), %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x2130
movl 0x8(%r15), %eax
movq -0x30(%rbp), %r13
cmpl $0x64, %eax
jne 0x670f
movq 0x30(%r15), %rax
movl 0x8(%rax), %eax
andl $-0x2, %eax
cmpl $0x1c, %eax
jne 0x6875
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x5333
movl 0x8(%r15), %eax
cmpl $0x15, %eax
jne 0x6838
movq 0x18(%r15), %rax
movq 0x28(%rax), %rsi
movq %r14, %rdx
movq %r13, %r14
movq %r13, %rdi
movq %rdx, -0x30(%rbp)
callq 0x5333
movl %eax, %r12d
movq 0x18(%r15), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %r13
cmpl $-0x1, %r12d
je 0x677b
cmpl $0x1, %r12d
je 0x676c
testl %r12d, %r12d
jne 0x679f
movq 0x28(%r13), %rax
cmpl $0x55, 0xc(%rax)
je 0x679f
leaq 0x3709(%rip), %rsi      # 0x9e70
movq %r15, %rax
jmp 0x678c
leaq 0x36aa(%rip), %rsi      # 0x9e1d
movq %r15, %rax
jmp 0x681a
movq 0x28(%r13), %rax
cmpl $0x54, 0xc(%rax)
je 0x679f
leaq 0x374c(%rip), %rsi      # 0x9ed8
movq (%rax), %rax
movq (%rax), %rax
movl 0x3c(%rax), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2130
movq 0x18(%r13), %rax
cmpl $0x6d, 0x8(%rax)
je 0x682d
movq 0x28(%rax), %rax
movq 0x18(%rax), %rsi
movq %r14, %rdi
movq -0x30(%rbp), %rdx
callq 0x5333
cmpl %eax, %r12d
jne 0x6807
addq $0x18, %r13
movq %r13, %rbx
movq (%rbx), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %r13
movq 0x18(%r13), %rax
cmpl $0x6d, 0x8(%rax)
je 0x682d
leaq 0x18(%r13), %rbx
movq 0x28(%rax), %rax
movq 0x18(%rax), %rsi
movq %r14, %rdi
movq -0x30(%rbp), %rdx
callq 0x5333
cmpl %eax, %r12d
je 0x67cd
movq 0x18(%r13), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rax
leaq 0x372b(%rip), %rsi      # 0x9f45
movq (%rax), %rax
movq (%rax), %rax
movl 0x3c(%rax), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2130
movl 0x8(%r15), %eax
movq %r14, %r13
movq -0x30(%rbp), %r14
cmpl $0x16, %eax
jne 0x6875
cmpl $0x27, 0xc(%r15)
jne 0x6875
movq 0x18(%r15), %rax
movq 0x28(%rax), %rsi
movq %r13, %rdi
movq %r14, %rdx
callq 0x5333
testl %eax, %eax
je 0x6875
movq (%r15), %rax
movq (%rax), %rax
movl 0x3c(%rax), %edx
leaq 0x374b(%rip), %rsi      # 0x9fb6
movq %r13, %rdi
xorl %eax, %eax
callq 0x2130
cmpl $0x16, 0x8(%r15)
jne 0x68b5
cmpl $0x28, 0xc(%r15)
jne 0x68b5
movq 0x18(%r15), %rax
movq 0x28(%rax), %rsi
movq %r13, %rdi
movq %r14, %rdx
callq 0x5333
cmpl $-0x1, %eax
je 0x68b5
movq (%r15), %rax
movq (%rax), %rax
movl 0x3c(%rax), %edx
leaq 0x3753(%rip), %rsi      # 0x9ffe
movq %r13, %rdi
xorl %eax, %eax
callq 0x2130
movq 0x28(%r15), %rsi
movq %r13, %rdi
movq %r14, %rdx
callq 0x5e57
addq $0x7e8, %rsp            # imm = 0x7E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x420(%rbp), %rdi
callq 0x20a0
movabsq $0x4552285941525241, %rcx # imm = 0x4552285941525241
movq %rcx, -0x420(%rbp,%rax)
movabsq $0x202c4c41455228, %rcx # imm = 0x202C4C41455228
movq %rcx, -0x41b(%rbp,%rax)
jmp 0x6923
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x31dd(%rip), %xmm0     # 0x9af8
movups %xmm0, -0x420(%rbp,%rax)
leaq -0x420(%rbp), %r12
leaq -0x810(%rbp), %rsi
movq %r12, %rdi
callq 0x21b0
movq %r12, %rdi
callq 0x20a0
movw $0x29, -0x420(%rbp,%rax)
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x3241(%rip), %rcx      # 0x9b9d
movq %r12, %rsi
jmp 0x629e
leaq -0x420(%rbp), %rdi
callq 0x20a0
movabsq $0x4552285941525241, %rcx # imm = 0x4552285941525241
movq %rcx, -0x420(%rbp,%rax)
movabsq $0x202c4c41455228, %rcx # imm = 0x202C4C41455228
movq %rcx, -0x41b(%rbp,%rax)
jmp 0x69e3
leaq -0x420(%rbp), %rdi
callq 0x20a0
movabsq $0x4552285941525241, %rcx # imm = 0x4552285941525241
movq %rcx, -0x420(%rbp,%rax)
movabsq $0x202c4c41455228, %rcx # imm = 0x202C4C41455228
movq %rcx, -0x41b(%rbp,%rax)
jmp 0x6a3f
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x311d(%rip), %xmm0     # 0x9af8
movups %xmm0, -0x420(%rbp,%rax)
leaq -0x420(%rbp), %r12
leaq -0x810(%rbp), %rsi
movq %r12, %rdi
callq 0x21b0
movq %r12, %rdi
callq 0x20a0
movw $0x29, -0x420(%rbp,%rax)
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x3181(%rip), %rcx      # 0x9b9d
movq %r12, %rsi
jmp 0x609a
leaq -0x420(%rbp), %rdi
callq 0x20a0
movups 0x30c1(%rip), %xmm0     # 0x9af8
movups %xmm0, -0x420(%rbp,%rax)
leaq -0x420(%rbp), %r12
leaq -0x810(%rbp), %rsi
movq %r12, %rdi
callq 0x21b0
movq %r12, %rdi
callq 0x20a0
movw $0x29, -0x420(%rbp,%rax)
movq (%r15), %rax
movq (%rax), %rdi
addq $0x1e, %rdi
leaq 0x3125(%rip), %rcx      # 0x9b9d
movq %r12, %rsi
jmp 0x61a7