// File: /workspace/github_c_makefile_star2_O1/MartinNovotny25[P]VUT-FIT-IFJ2020/semantics.c
// Function: assign_vals_control
void assign_vals_control(TDLList *L, tBSTNodePtrLocal *node, functionData params){

    if(L->Act->rptr->tdata.type == t_EOL){
        error_call(ERR_SEM_OTHER, L);
    }
  
    char *id[MAXPARAMS];
    // na ukladanie typov
    int type[MAXPARAMS];
    int types_of_defined_vars[MAXPARAMS];
    // zbytocna premenna
    char *data = "null";
    // pocet stringov
    int string_count = 0;
    // pocet cisel
    int int_count = 0;
    // pocet floatov
    int float_count = 0;
    // pocet identifikatorov
    int identifier = 0;
    // id na ukladanie premennych v spravnom poradi
    int id_insert = 0;
    int is_function = 0;
    int underscore_found = 0;

    // Pocet premennych nalavo od =
    // po ukonceni cyklu bude L->act ukazovat na =
   
    while(L->Act->tdata.type != t_ASSIGN){
        if(L->Act->tdata.type == t_IDENTIFIER){

            id[identifier] = L->Act->tdata.lex;
            if(MainStackSearch(mainstack, id[identifier], &types_of_defined_vars[identifier])){
                    // premenna bola najdena v ramci a while bol hned zastaveny
                    // stack sa prehladava zhora dole
                if(!(strcmp(id[identifier], "_"))){
                    types_of_defined_vars[identifier] = 404;
                    underscore_found = 1;
                }
                //identifier++;
                //break;
            }else{
                BSTDisposeLocal(node);
                error_call(ERR_SEM_UNDEF, L);
            }
            identifier++;
        }
        TDLLSucc(L);
    }
    // pocet identifikatorov napravo od =
    //int identif_count = 0;
    // pocet ciarok napravo od =
    int comma_count = 0;
    // prechadzaj pokym neprejdeme na koniec riadku
    while(L->Act->tdata.type!= t_EOL){
            if(L->Act->tdata.type == t_GREATER){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_EXCOMPAT, L);
            }else if(L->Act->tdata.type == t_GREATEROREQUAL){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_EXCOMPAT, L);
            }else if(L->Act->tdata.type == t_LESS){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_EXCOMPAT, L);
            }else if(L->Act->tdata.type == t_LESSOREQUAL){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_EXCOMPAT, L);
            }else if(L->Act->tdata.type == t_EQUAL){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_EXCOMPAT, L);
            }else if(L->Act->tdata.type == t_NOT_EQUAL){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_EXCOMPAT, L);
            }

            if(!(strcmp(L->Act->tdata.lex, "/"))){
                if(L->Act->rptr->tdata.type == t_INT_ZERO){
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_ZERODIV, L);
                }
            }

            if(!(strcmp(L->Act->tdata.lex, "_"))){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_UNDEF, L);
            }
           

            if(L->Act->tdata.type == t_INT_NON_ZERO || L->Act->tdata.type == t_INT_ZERO){
                type[id_insert] = t_INT_ID;
                int_count++;
                id_insert++;
            // ak ide o float
            }else if(L->Act->tdata.type == t_FLOAT64 || L->Act->tdata.type == t_FLOAT){
                if(!(strcmp(L->Act->tdata.lex, "0.0"))){
                    if(!(strcmp(L->Act->lptr->tdata.lex, "/"))){
                        BSTDisposeLocal(node);
                        error_call(ERR_SEM_ZERODIV, L);
                    }
                }
                type[id_insert] = t_FLOAT64;
                float_count++;
                id_insert++;
            // ak ide o string
            }else if(L->Act->tdata.type == t_STRING){
                if(L->Act->rptr->tdata.type == t_MINUS || L->Act->rptr->tdata.type == t_DIVIDE || L->Act->rptr->tdata.type == t_MULTIPLY){
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_EXCOMPAT, L);
                }
                
                type[id_insert] = t_STRING_ID;
                string_count++;
                id_insert++;
            // ak ide o premennu
            }else if(L->Act->tdata.type == t_IDENTIFIER){
                int datovytyp;
                char *name = L->Act->tdata.lex;
                functionData returned_data;
                if(!(strcmp(L->Act->tdata.lex, "_"))){
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_UNDEF, L);
                }
           
                if(!(strcmp(L->Act->tdata.lex, "inputs"))){
                    assign_func_params_control(L, node, "inputs");
                    if(identifier != 2) error_call(ERR_SEM_RETURN, L);
                   if(types_of_defined_vars[0] == t_STRING_ID && (types_of_defined_vars[1] == t_INT_ID || types_of_defined_vars[1] == 404)){
                       is_function++;
                   }else{
                       BSTDisposeLocal(node);
                       error_call(ERR_SEM_EXCOMPAT, L);
                   }
                }else if(!(strcmp(L->Act->tdata.lex, "inputi"))){
                    assign_func_params_control(L, node, "inputi");
                    if(identifier != 2) error_call(ERR_SEM_RETURN, L);
                    if(types_of_defined_vars[0] == t_INT_ID && (types_of_defined_vars[1] == t_INT_ID || types_of_defined_vars[1] == 404)){
                       is_function++;
                    }else{
                       BSTDisposeLocal(node);
                       error_call(ERR_SEM_EXCOMPAT, L);
                    }
                }else if(!(strcmp(L->Act->tdata.lex, "inputf"))){
                    assign_func_params_control(L, node, "inputf");
                    if(identifier != 2) error_call(ERR_SEM_RETURN, L);
                    if(types_of_defined_vars[0] == t_FLOAT64 && (types_of_defined_vars[1] == t_INT_ID || types_of_defined_vars[1] == 404)){
                        is_function++;
                    }else{
                       BSTDisposeLocal(node);
                       error_call(ERR_SEM_EXCOMPAT, L);
                    }
                }else if(!(strcmp(L->Act->tdata.lex, "int2float"))){
                    assign_func_params_control(L, node, "int2float");
                    if(identifier != 1) error_call(ERR_SEM_RETURN, L);
                    if(types_of_defined_vars[0] != t_FLOAT64){
                        if(types_of_defined_vars[1] != 404){
                            BSTDisposeLocal(node);
                            error_call(ERR_SEM_EXCOMPAT, L);
                        }
                    }
                    is_function++;
                }else if(!(strcmp(L->Act->tdata.lex, "float2int"))){
                    assign_func_params_control(L, node, "float2int");
                    if(identifier != 1) error_call(ERR_SEM_RETURN, L);
                    if(types_of_defined_vars[0] != t_INT_ID ){
                        if(types_of_defined_vars[1] != 404){
                            BSTDisposeLocal(node);
                            error_call(ERR_SEM_EXCOMPAT, L);
                        }
                    }
                    is_function++;
                }else if(!(strcmp(L->Act->tdata.lex, "len"))){
                    assign_func_params_control(L, node, "len");
                    if(identifier != 1) error_call(ERR_SEM_RETURN, L);
                    if(types_of_defined_vars[0] != t_INT_ID ){
                        if( types_of_defined_vars[1] != 404){
                            BSTDisposeLocal(node);
                            error_call(ERR_SEM_EXCOMPAT, L);
                        }
                    }
                    is_function++;
                }else if(!(strcmp(L->Act->tdata.lex, "substr"))){
                    assign_func_params_control(L, node, "substr");
                    if(identifier != 2) error_call(ERR_SEM_RETURN, L);
                    if(types_of_defined_vars[0] == t_STRING_ID && (types_of_defined_vars[1] == t_INT_ID || types_of_defined_vars[1] == 404)){
                         is_function++;
                    }else{
                       BSTDisposeLocal(node);
                       error_call(ERR_SEM_EXCOMPAT, L);
                    }
                }else if(!(strcmp(L->Act->tdata.lex, "ord"))){
                    assign_func_params_control(L, node, "ord");
                    if(identifier != 2) error_call(ERR_SEM_RETURN, L);
                    if(types_of_defined_vars[0] == t_INT_ID && (types_of_defined_vars[1] == t_INT_ID || types_of_defined_vars[1] == 404)){
                        is_function++;
                    }else{
                       BSTDisposeLocal(node);
                       error_call(ERR_SEM_EXCOMPAT, L);
                    }
                }else if(!(strcmp(L->Act->tdata.lex, "chr"))){
                    assign_func_params_control(L, node, "chr");
                    if(identifier != 2) error_call(ERR_SEM_RETURN, L);
                    if(types_of_defined_vars[0] == t_STRING_ID && (types_of_defined_vars[1] == t_INT_ID || types_of_defined_vars[1] == 404)){
                        is_function++;
                    }else{
                       BSTDisposeLocal(node);
                       error_call(ERR_SEM_EXCOMPAT, L);
                    }
                }else if(!(strcmp(L->Act->tdata.lex, "print"))){
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_EXCOMPAT, L);

                }else if(BSTSearchGlobal(functions, L->Act->tdata.lex, &returned_data)){
                    if(L->Act->rptr->tdata.type == t_LEFT_BRACKET){
                    checkCallFunction(L, L->Act->tdata.lex, node);
                    if(identifier != returned_data.numOfReturns) error_call(ERR_SEM_RETURN, L);
                    else{
                        int i = 0;
                        while(returned_data.numOfReturns != i){
                            type[i] = returned_data.returns[i];
                            i++;
                        }

                        for(int i = 0; i < identifier; i++){
                            if(types_of_defined_vars[i] != type[i]){
                                if(!(strcmp(id[i], "_"))){

                                }else{
                                    BSTDisposeLocal(node);
                                     error_call(ERR_SEM_EXCOMPAT, L);
                                }
                            }else{
                                is_function++;
                                break;
                            }
                        }
                    }
                    }
                }else if(MainStackSearch(mainstack, name, &datovytyp)) {
                     type[id_insert] = datovytyp;
                            if(datovytyp == t_INT_ID){
                                int_count++;
                                id_insert++;
                            }else if(datovytyp == t_FLOAT64){
                                float_count++;
                                id_insert++;
                            }else if(datovytyp == t_STRING_ID){
                                if(L->Act->rptr->tdata.type == t_MINUS || L->Act->rptr->tdata.type == t_DIVIDE || L->Act->rptr->tdata.type == t_MULTIPLY){
                                    BSTDisposeLocal(node);
                                    error_call(ERR_SEM_EXCOMPAT, L);
                                }
                                string_count++;
                                id_insert++;
                            }
                        }else{
                            error_call(ERR_SEM_UNDEF, L);
                            BSTDisposeLocal(node);
                        }
                // ak premenna napravo od =
                // nebola najdena v glob.strome ani v lok.ramci najnizsej urovni
                // potom musime prehladat vyssie ramce
                }else{
                      
                }
            // ak nejde o cislo, string, float alebo premennu
            
            

            if(L->Act->tdata.type == T_SEMICOLON) break;
            // Ak najdes ciarku tzv, chce sa deklarovat viac premennych naraz chyba
              
            // ak sme prisli na ciarku alebo koniec riadku
            if(L->Act->tdata.type == t_COMMA || L->Act->rptr->tdata.type == t_EOL || L->Act->tdata.type == t_BRACES_L){
                // ak vo vyraze boli len stringy
                if(string_count != 0 && int_count == 0 && float_count == 0){
                    
                    // je premenna do ktorej chceme ulozit hodnotu deklarovana?
                    if(types_of_defined_vars[comma_count] == t_STRING_ID || types_of_defined_vars[comma_count] == 404){
                        BSTInsertLocal(node, id[comma_count], type, data);
                        id_insert++;
                        string_count = 0;
                        int_count = 0;
                        float_count = 0;
                    }else{
                        if(types_of_defined_vars[comma_count] != t_INT_ID ){
                            if(types_of_defined_vars[comma_count] != t_STRING_ID){
                                if(types_of_defined_vars[comma_count] != t_FLOAT64){
                                    error_call(ERR_SEM_OTHER, L);
                                }else{
                                    error_call(ERR_SEM_EXCOMPAT, L);
                                }
                            }else{
                                error_call(ERR_SEM_EXCOMPAT, L);
                            }
                        }else{
                            error_call(ERR_SEM_EXCOMPAT, L);
                        }
                    }
                
                    // ak vo vyraze boli len cisla
                }else if(string_count == 0 && int_count != 0 && float_count == 0){
                    
                    // je premenna do ktorej chceme ulozit hodnotu deklarovana?
                    
                    if(types_of_defined_vars[comma_count] == t_INT_ID || types_of_defined_vars[comma_count] == 404){
                        //BSTInsertLocal(node, id[comma_count], types_of_defined_vars[comma_count], data);
                        id_insert++;
                        string_count = 0;
                        int_count = 0;
                        float_count = 0;
                    }else{
                        if(types_of_defined_vars[comma_count] != t_INT_ID ){
                            if(types_of_defined_vars[comma_count] != t_STRING_ID){
                                if(types_of_defined_vars[comma_count] != t_FLOAT64){
                                    error_call(ERR_SEM_OTHER, L);
                                }else{
                                    error_call(ERR_SEM_EXCOMPAT, L);
                                }
                            }else{
                                error_call(ERR_SEM_EXCOMPAT, L);
                            }
                        }else{
                            error_call(ERR_SEM_EXCOMPAT, L);
                        }
                        
                    }

                // ak vo vyraze boli len floaty
                }else if(string_count == 0 && int_count == 0 && float_count != 0){
                    
                    // je premenna do ktorej chceme ulozit hodnotu deklarovana?
                    
                    if(types_of_defined_vars[comma_count] == t_FLOAT64 || types_of_defined_vars[comma_count] == 404){
                        BSTInsertLocal(node, id[comma_count], type, data);
                        id_insert++;
                        string_count = 0;
                        int_count = 0;
                        float_count = 0;
                    }else{
                        if(types_of_defined_vars[comma_count] != t_INT_ID ){
                            if(types_of_defined_vars[comma_count] != t_STRING_ID){
                                if(types_of_defined_vars[comma_count] != t_FLOAT64){
                                    error_call(ERR_SEM_OTHER, L);
                                }else{
                                    error_call(ERR_SEM_EXCOMPAT, L);
                                }
                            }else{
                                error_call(ERR_SEM_EXCOMPAT, L);
                            }
                        }else{
                            error_call(ERR_SEM_EXCOMPAT, L);
                        }
                    }
                }else if(underscore_found == 1){
                    id_insert++;
                    string_count = 0;
                    int_count = 0;
                    float_count = 0;
                }else if(string_count == 0 && int_count == 0 && float_count == 0){
                    
                }else{
                    error_call(ERR_SEM_EXCOMPAT, L);
                }
                comma_count++;
            }
        TDLLSucc(L);
    }
    // Ak je pocet premennych do ktorych sa ma priradovat ako hodnot rozdielny
    if(is_function == 0){
        if(identifier != comma_count){
            error_call(ERR_SEM_OTHER, L);
            BSTDisposeLocal(node);
        }
    }
    //TDLLPred(L);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3f88, %rsp           # imm = 0x3F88
movq %rsi, 0x1f50(%rsp)
movq %rdi, %r14
movq 0x8(%rdi), %rax
movq 0x18(%rax), %rax
cmpl $0x2f, 0x8(%rax)
jne 0x56c0
movl $0x7, %edi
movq %r14, %rsi
callq 0x42c8
xorl %ebx, %ebx
leaq 0x6dbf(%rip), %r15      # 0xc488
leaq 0x2e48(%rip), %r12      # 0x8518
movl $0x0, 0x1f68(%rsp)
movq 0x8(%r14), %rax
movl 0x8(%rax), %ecx
cmpl $0x13, %ecx
je 0x56f1
cmpl $0x3, %ecx
jne 0x5767
jmp 0x5774
movq (%rax), %rbp
movslq %ebx, %rax
movq %rbp, 0x2780(%rsp,%rax,8)
leaq (%rsp,%rax,4), %r13
addq $0x1f80, %r13           # imm = 0x1F80
movl $0x3e9, %ecx            # imm = 0x3E9
movq %rsp, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x471e
testb %al, %al
je 0x574b
movq %rbp, %rdi
movq %r12, %rsi
callq 0x1080
testl %eax, %eax
jne 0x5765
movl $0x194, (%r13)          # imm = 0x194
movl $0x1, 0x1f68(%rsp)
jmp 0x5765
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x3, %edi
movq %r14, %rsi
callq 0x42c8
incl %ebx
movq %r14, %rdi
callq 0x1695
jmp 0x56db
movl %ebx, 0x1f60(%rsp)
movl %ebx, %eax
movq %rax, 0x1f70(%rsp)
xorl %r12d, %r12d
leaq 0x2dac(%rip), %rbx      # 0x853b
movl $0x0, 0x1f48(%rsp)
xorl %r15d, %r15d
movl $0x0, 0x1f64(%rsp)
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x8(%r14), %rax
movl 0x8(%rax), %eax
cmpq $0x2f, %rax
ja 0x57e8
movabsq $0x3c0000006, %rcx      # imm = 0x3C0000006
btq %rax, %rcx
jae 0x5bcd
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x5, %edi
movq %r14, %rsi
callq 0x42c8
movl %ebp, 0x1f4c(%rsp)
movq %r12, 0x1f58(%rsp)
movl %r15d, %r12d
movq %rbx, %rbp
movq 0x8(%r14), %r15
movq (%r15), %rdi
leaq 0x2d2a(%rip), %rsi      # 0x8535
callq 0x1080
testl %eax, %eax
jne 0x5838
movq 0x18(%r15), %rax
cmpl $0x10, 0x8(%rax)
jne 0x5838
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x9, %edi
movq %r14, %rsi
callq 0x42c8
movq 0x8(%r14), %rax
movq (%rax), %rdi
leaq 0x2cd2(%rip), %rsi      # 0x8518
callq 0x1080
testl %eax, %eax
jne 0x5869
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x3, %edi
movq %r14, %rsi
callq 0x42c8
movq 0x8(%r14), %r15
movl 0x8(%r15), %eax
cmpl $0x16, %eax
jg 0x58a9
leal -0x10(%rax), %ecx
cmpl $0x2, %ecx
jae 0x5993
movl %r12d, %r15d
movslq %r12d, %rax
movl $0x18, 0x2380(%rsp,%rax,4)
movq 0x1f58(%rsp), %r12
incl %r12d
incl %r15d
movq %rbp, %rbx
jmp 0x5dfd
cmpl $0x17, %eax
je 0x5922
cmpl $0x29, %eax
je 0x5922
cmpl $0x2b, %eax
jne 0x5def
movq 0x18(%r15), %rax
movl 0x8(%rax), %eax
cmpl $0xb, %eax
ja 0x58ec
movl $0xb00, %ecx            # imm = 0xB00
btl %eax, %ecx
jae 0x58ec
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x5, %edi
movq %r14, %rsi
callq 0x42c8
movl %r12d, %r15d
movslq %r12d, %rax
movl $0x14, 0x2380(%rsp,%rax,4)
movl 0x1f4c(%rsp), %eax
incl %eax
incl %r15d
movq %rbp, %rbx
movl %eax, %ebp
movq 0x1f58(%rsp), %r12
movl 0x1f48(%rsp), %edx
jmp 0x5e0b
movq (%r15), %rdi
leaq 0x2c0b(%rip), %rsi      # 0x8537
callq 0x1080
testl %eax, %eax
jne 0x5966
movq 0x10(%r15), %rax
movq (%rax), %rdi
leaq 0x2bf2(%rip), %rsi      # 0x8535
callq 0x1080
testl %eax, %eax
jne 0x5966
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x9, %edi
movq %r14, %rsi
callq 0x42c8
movl %r12d, %r15d
movslq %r12d, %rax
movl $0x17, 0x2380(%rsp,%rax,4)
movl 0x1f48(%rsp), %edx
incl %edx
incl %r15d
movq %rbp, %rbx
movq 0x1f58(%rsp), %r12
jmp 0x5e04
cmpl $0x13, %eax
jne 0x5def
movq (%r15), %rax
movq %rax, 0x1f78(%rsp)
movq (%r15), %rdi
leaq 0x2b67(%rip), %rsi      # 0x8518
callq 0x1080
testl %eax, %eax
jne 0x59d4
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x3, %edi
movq %r14, %rsi
callq 0x42c8
movq 0x8(%r14), %rax
movq (%rax), %r15
movq %r15, %rdi
movq %rbp, %rbx
movq %rbp, %rsi
callq 0x1080
testl %eax, %eax
je 0x5bdc
movq %r15, %rdi
leaq 0x2b47(%rip), %rbx      # 0x8542
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5c58
movq %r15, %rdi
leaq 0x2b34(%rip), %rbx      # 0x8549
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5c8c
movq %r15, %rdi
leaq 0x2b21(%rip), %rbx      # 0x8550
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5d34
movq %r15, %rdi
leaq 0x2b11(%rip), %rbx      # 0x855a
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5d00
movq %r15, %rdi
leaq 0x2b01(%rip), %rbx      # 0x8564
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5d00
movq %r15, %rdi
leaq 0x2aeb(%rip), %rbx      # 0x8568
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5d9e
movq %r15, %rdi
leaq 0x2ad8(%rip), %rbx      # 0x856f
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5c58
movq %r15, %rdi
leaq 0x2ac2(%rip), %rbx      # 0x8573
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5d9e
movq %r15, %rdi
leaq 0x2a56(%rip), %rsi      # 0x8521
callq 0x1080
testl %eax, %eax
je 0x5dd5
movq 0x88f1(%rip), %rdi      # 0xe3d0
movq %r15, %rsi
leaq 0x2f80(%rsp), %rdx
callq 0x43a8
testb %al, %al
je 0x5fdb
movq 0x8(%r14), %rax
movq 0x18(%rax), %rcx
cmpl $0x6, 0x8(%rcx)
movq %rbp, %rbx
movl %r12d, %r15d
jne 0x5df5
movq (%rax), %rsi
movq %r14, %rdi
movq 0x1f50(%rsp), %rdx
callq 0x4e67
movl 0x2f84(%rsp), %edx
cmpl %edx, 0x1f60(%rsp)
jne 0x606a
testq %rdx, %rdx
je 0x5b54
shlq $0x2, %rdx
leaq 0x2380(%rsp), %rdi
leaq 0x3b88(%rsp), %rsi
callq 0x1090
cmpl $0x0, 0x1f60(%rsp)
jle 0x5def
xorl %r15d, %r15d
movl 0x1f48(%rsp), %edx
movl 0x1f80(%rsp,%r15,4), %eax
cmpl 0x2380(%rsp,%r15,4), %eax
je 0x60c3
movq 0x2780(%rsp,%r15,8), %rdi
leaq 0x2987(%rip), %rsi      # 0x8518
callq 0x1080
testl %eax, %eax
je 0x5bb4
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x5, %edi
movq %r14, %rsi
callq 0x42c8
incq %r15
cmpq %r15, 0x1f70(%rsp)
movl 0x1f48(%rsp), %edx
jne 0x5b6c
jmp 0x60ca
cmpq $0x2f, %rax
jne 0x57e8
jmp 0x60d5
movq %r14, %rdi
movq 0x1f50(%rsp), %rsi
movq %rbx, %rdx
callq 0x6c38
cmpl $0x2, 0x1f60(%rsp)
je 0x5c06
movl $0x6, %edi
movq %r14, %rsi
callq 0x42c8
cmpl $0x14, 0x1f80(%rsp)
movl %r12d, %r15d
movl 0x1f4c(%rsp), %ebp
jne 0x5c39
movl 0x1f84(%rsp), %eax
cmpl $0x194, %eax            # imm = 0x194
je 0x5c2d
cmpl $0x18, %eax
jne 0x5c39
incl 0x1f64(%rsp)
jmp 0x590e
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x5, %edi
movq %r14, %rsi
callq 0x42c8
jmp 0x590e
movq %r14, %rdi
movq 0x1f50(%rsp), %rsi
movq %rbx, %rdx
callq 0x6c38
cmpl $0x2, 0x1f60(%rsp)
je 0x5c82
movl $0x6, %edi
movq %r14, %rsi
callq 0x42c8
cmpl $0x18, 0x1f80(%rsp)
jmp 0x5cbe
movq %r14, %rdi
movq 0x1f50(%rsp), %rsi
movq %rbx, %rdx
callq 0x6c38
cmpl $0x2, 0x1f60(%rsp)
je 0x5cb6
movl $0x6, %edi
movq %r14, %rsi
callq 0x42c8
cmpl $0x17, 0x1f80(%rsp)
movq %rbp, %rbx
movl %r12d, %r15d
jne 0x5ce1
movl 0x1f84(%rsp), %eax
cmpl $0x194, %eax            # imm = 0x194
je 0x5d95
cmpl $0x18, %eax
je 0x5d95
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x5, %edi
movq %r14, %rsi
callq 0x42c8
jmp 0x5df5
movq %r14, %rdi
movq 0x1f50(%rsp), %rsi
movq %rbx, %rdx
callq 0x6c38
cmpl $0x1, 0x1f60(%rsp)
je 0x5d2a
movl $0x6, %edi
movq %r14, %rsi
callq 0x42c8
cmpl $0x18, 0x1f80(%rsp)
jmp 0x5d66
movq %r14, %rdi
movq 0x1f50(%rsp), %rsi
movq %rbx, %rdx
callq 0x6c38
cmpl $0x1, 0x1f60(%rsp)
je 0x5d5e
movl $0x6, %edi
movq %r14, %rsi
callq 0x42c8
cmpl $0x17, 0x1f80(%rsp)
movq %rbp, %rbx
movl %r12d, %r15d
je 0x5d95
cmpl $0x194, 0x1f84(%rsp) # imm = 0x194
je 0x5d95
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x5, %edi
movq %r14, %rsi
callq 0x42c8
incl 0x1f64(%rsp)
jmp 0x5df5
movq %r14, %rdi
movq 0x1f50(%rsp), %rsi
movq %rbx, %rdx
callq 0x6c38
cmpl $0x2, 0x1f60(%rsp)
je 0x5dc8
movl $0x6, %edi
movq %r14, %rsi
callq 0x42c8
cmpl $0x14, 0x1f80(%rsp)
jmp 0x5cbe
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x5, %edi
movq %r14, %rsi
callq 0x42c8
movq %rbp, %rbx
movl %r12d, %r15d
movq 0x1f58(%rsp), %r12
movl 0x1f48(%rsp), %edx
movl 0x1f4c(%rsp), %ebp
movq 0x8(%r14), %rax
movl 0x8(%rax), %ecx
cmpl $0x5, %ecx
je 0x5e3b
cmpl $0x38, %ecx
je 0x60d5
cmpl $0x34, %ecx
je 0x5e3b
movq 0x18(%rax), %rax
cmpl $0x2f, 0x8(%rax)
je 0x5e3b
movl %edx, 0x1f48(%rsp)
jmp 0x5f9d
testl %ebp, %ebp
setne %al
movl %r12d, %ecx
orl %edx, %ecx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x5e71
movslq %r13d, %rax
movl 0x1f80(%rsp,%rax,4), %ecx
cmpl $0x17, %ecx
jg 0x5eb0
cmpl $0x14, %ecx
je 0x5ec1
cmpl $0x17, %ecx
je 0x5f27
jmp 0x5f81
testl %r12d, %r12d
setne %al
movl %ebp, %ecx
orl %edx, %ecx
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x5eed
movslq %r13d, %rax
movl 0x1f80(%rsp,%rax,4), %eax
cmpl $0x17, %eax
jg 0x5f2e
cmpl $0x14, %eax
je 0x5ea6
cmpl $0x17, %eax
jne 0x5f3a
movl $0x5, %edi
jmp 0x5f3f
cmpl $0x18, %ecx
je 0x5f27
cmpl $0x194, %ecx            # imm = 0x194
jne 0x5f81
movq 0x2780(%rsp,%rax,8), %rsi
movq 0x1f50(%rsp), %rdi
leaq 0x2380(%rsp), %rdx
leaq 0x2650(%rip), %rcx      # 0x8530
callq 0x4576
incl %r15d
xorl %r12d, %r12d
jmp 0x5f47
movl %ebp, %eax
orl %r12d, %eax
sete %al
testl %edx, %edx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x5f4d
movslq %r13d, %rax
movl 0x1f80(%rsp,%rax,4), %ecx
cmpl $0x17, %ecx
jg 0x5faa
cmpl $0x14, %ecx
je 0x5fc2
cmpl $0x17, %ecx
je 0x5ec1
jmp 0x5fbb
movl $0x5, %edi
jmp 0x5f86
cmpl $0x194, %eax            # imm = 0x194
je 0x5ee5
cmpl $0x18, %eax
je 0x5ee5
movl $0x7, %edi
movq %r14, %rsi
callq 0x42c8
xorl %eax, %eax
xorl %ebp, %ebp
jmp 0x5f93
cmpl $0x1, 0x1f68(%rsp)
je 0x5ee5
testl %edx, %edx
sete %cl
testb %cl, %al
jne 0x5ee8
movl $0x5, %edi
movq %r14, %rsi
movl %ebp, 0x1f4c(%rsp)
movl %edx, %ebp
callq 0x42c8
movl %ebp, %eax
movl 0x1f4c(%rsp), %ebp
jmp 0x5f93
movl $0x7, %edi
movq %r14, %rsi
callq 0x42c8
xorl %r12d, %r12d
xorl %eax, %eax
movl %eax, 0x1f48(%rsp)
incl %r13d
movq %r14, %rdi
callq 0x1695
jmp 0x57ad
cmpl $0x18, %ecx
je 0x5fc2
cmpl $0x194, %ecx            # imm = 0x194
je 0x5ec1
movl $0x7, %edi
jmp 0x5fc7
movl $0x5, %edi
movq %r14, %rsi
movl %edx, %ebp
callq 0x42c8
movl %ebp, %eax
xorl %r12d, %r12d
jmp 0x5f49
movl $0x3e9, %ecx            # imm = 0x3E9
movq %rsp, %rdi
leaq 0x649e(%rip), %rsi      # 0xc488
rep  movsq (%rsi), %es:(%rdi)
movq 0x1f78(%rsp), %rdi
leaq 0x1f6c(%rsp), %rsi
callq 0x471e
testb %al, %al
movq %rbp, %rbx
movl %r12d, %r15d
je 0x604b
movl 0x1f6c(%rsp), %eax
movslq %r15d, %rcx
movl %eax, 0x2380(%rsp,%rcx,4)
cmpl $0x14, %eax
movq 0x1f58(%rsp), %r12
movl 0x1f4c(%rsp), %ebp
je 0x6085
cmpl $0x17, %eax
je 0x6074
cmpl $0x18, %eax
movl 0x1f48(%rsp), %edx
jne 0x5e0b
incl %r12d
jmp 0x607d
movl $0x3, %edi
movq %r14, %rsi
callq 0x42c8
movq 0x1f50(%rsp), %rdi
callq 0x46ab
jmp 0x5df5
movl $0x6, %edi
jmp 0x5cf3
movl 0x1f48(%rsp), %edx
incl %edx
incl %r15d
jmp 0x5e0b
movq 0x8(%r14), %rax
movq 0x18(%rax), %rax
movl 0x8(%rax), %eax
cmpl $0xb, %eax
ja 0x60b9
movl $0xb00, %ecx            # imm = 0xB00
btl %eax, %ecx
jae 0x60b9
movq 0x1f50(%rsp), %rdi
callq 0x46ab
movl $0x5, %edi
movq %r14, %rsi
callq 0x42c8
incl %ebp
incl %r15d
jmp 0x5916
incl 0x1f64(%rsp)
movq %rbp, %rbx
movl %r12d, %r15d
jmp 0x5986
cmpl $0x0, 0x1f64(%rsp)
setne %al
cmpl %r13d, 0x1f60(%rsp)
sete %cl
orb %al, %cl
jne 0x6109
movl $0x7, %edi
movq %r14, %rsi
callq 0x42c8
movq 0x1f50(%rsp), %rdi
callq 0x46ab
addq $0x3f88, %rsp           # imm = 0x3F88
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq