// File: /workspace/github_c_makefile_star2_O2/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 $0x3f98, %rsp           # imm = 0x3F98
movq %rsi, %r13
movq %rdi, %r14
movq 0x8(%rdi), %rax
movq 0x18(%rax), %rax
cmpl $0x2f, 0x8(%rax)
jne 0x4dc7
pushq $0x7
popq %rdi
movq %r14, %rsi
callq 0x3ac4
xorl %ebp, %ebp
leaq 0x76c8(%rip), %r15      # 0xc498
pushq $0x1
popq %rbx
movl $0x0, 0x1f78(%rsp)
movq %r13, 0x1f60(%rsp)
movq 0x8(%r14), %rax
movl 0x8(%rax), %ecx
cmpl $0x13, %ecx
je 0x4e00
cmpl $0x3, %ecx
jne 0x4e84
jmp 0x4e91
movq (%rax), %r13
movslq %ebp, %rax
movq %r13, 0x2790(%rsp,%rax,8)
leaq (%rsp,%rax,4), %r12
addq $0x1f90, %r12           # imm = 0x1F90
movl $0x3e9, %ecx            # imm = 0x3E9
movq %rsp, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rdi
movq %r12, %rsi
callq 0x3eb3
testb %al, %al
je 0x4e5d
cmpb $0x5f, (%r13)
jne 0x4e7a
cmpb $0x0, 0x1(%r13)
movq 0x1f60(%rsp), %r13
jne 0x4e82
movl $0x194, (%r12)          # imm = 0x194
movl %ebx, 0x1f78(%rsp)
jmp 0x4e82
movq 0x1f60(%rsp), %r13
movq %r13, %rdi
callq 0x3e46
pushq $0x3
popq %rdi
movq %r14, %rsi
callq 0x3ac4
jmp 0x4e82
movq 0x1f60(%rsp), %r13
incl %ebp
movq %r14, %rdi
callq 0x12c2
jmp 0x4de6
xorl %r12d, %r12d
testl %ebp, %ebp
movl $0x0, %eax
cmovgl %ebp, %eax
movq %rax, 0x1f80(%rsp)
movl %ebp, %eax
movq %rax, 0x1f88(%rsp)
pushq $0x3
popq %rax
xorl %r15d, %r15d
movl $0x0, 0x1f5c(%rsp)
movl $0x0, 0x1f54(%rsp)
xorl %ebx, %ebx
movl $0x0, 0x1f74(%rsp)
cmpl $0x2f, %eax
ja 0x4f07
movl %eax, %eax
movabsq $0x3c0000006, %rcx      # imm = 0x3C0000006
btq %rax, %rcx
jae 0x526b
movq %r13, %rdi
callq 0x3e46
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x3ac4
movq %r12, 0x1f68(%rsp)
movq 0x8(%r14), %r12
movq (%r12), %rax
movb (%rax), %cl
cmpb $0x2f, %cl
jne 0x4f4c
cmpb $0x0, 0x1(%rax)
jne 0x4f6e
movq 0x18(%r12), %rax
cmpl $0x10, 0x8(%rax)
jne 0x4f6e
movq %r13, %rdi
callq 0x3e46
pushq $0x9
popq %rdi
movq %r14, %rsi
callq 0x3ac4
movq 0x8(%r14), %r12
movq (%r12), %rax
movb (%rax), %cl
cmpb $0x5f, %cl
jne 0x4f6e
cmpb $0x0, 0x1(%rax)
jne 0x4f6e
movq %r13, %rdi
callq 0x3e46
pushq $0x3
popq %rdi
movq %r14, %rsi
callq 0x3ac4
movq 0x8(%r14), %r12
movl %r15d, 0x1f50(%rsp)
movl %ebp, %r15d
movl 0x8(%r12), %eax
leal -0x10(%rax), %ecx
movslq 0x1f5c(%rsp), %rbp
cmpl $0x2, %ecx
jb 0x5005
cmpl $0x13, %eax
leaq 0x359b(%rip), %rsi      # 0x8533
je 0x509a
cmpl $0x17, %eax
je 0x5032
cmpl $0x29, %eax
je 0x5032
cmpl $0x2b, %eax
jne 0x4ff8
movq 0x18(%r12), %rax
movl 0x8(%rax), %eax
cmpl $0xb, %eax
ja 0x4fdf
movl $0xb00, %ecx            # imm = 0xB00
btl %eax, %ecx
jae 0x4fdf
movq %r13, %rdi
callq 0x3e46
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x3ac4
movl $0x14, 0x2390(%rsp,%rbp,4)
incl 0x1f74(%rsp)
incl 0x1f5c(%rsp)
movl %r15d, %ebp
movq 0x1f68(%rsp), %r12
jmp 0x5025
movl $0x18, 0x2390(%rsp,%rbp,4)
movq 0x1f68(%rsp), %r12
incl %r12d
incl 0x1f5c(%rsp)
movl %r15d, %ebp
movl 0x1f50(%rsp), %r15d
jmp 0x5406
movq (%r12), %rdi
leaq 0x34f2(%rip), %rsi      # 0x852f
callq 0x1080
testl %eax, %eax
jne 0x506c
movq 0x10(%r12), %rax
movq (%rax), %rax
cmpb $0x2f, (%rax)
jne 0x506c
cmpb $0x0, 0x1(%rax)
jne 0x506c
movq %r13, %rdi
callq 0x3e46
pushq $0x9
popq %rdi
movq %r14, %rsi
callq 0x3ac4
movl $0x17, 0x2390(%rsp,%rbp,4)
movl 0x1f50(%rsp), %eax
incl %eax
incl 0x1f5c(%rsp)
movl %r15d, %ebp
movl %eax, %r15d
movq 0x1f68(%rsp), %r12
jmp 0x5406
movl %ebx, 0x1f58(%rsp)
movq (%r12), %r13
cmpb $0x5f, (%r13)
movq %r13, %r12
jne 0x50df
cmpb $0x0, 0x1(%r13)
movq %r13, %r12
jne 0x50df
movq 0x1f60(%rsp), %rdi
callq 0x3e46
pushq $0x3
popq %rdi
movq %r14, %rsi
callq 0x3ac4
leaq 0x345b(%rip), %rsi      # 0x8533
movq 0x8(%r14), %rax
movq (%rax), %r12
movq %r12, %rdi
movq %rsi, %rbx
callq 0x1080
testl %eax, %eax
je 0x527a
movq %r12, %rdi
leaq 0x343e(%rip), %rbx      # 0x853a
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x52ae
movq %r12, %rdi
leaq 0x342b(%rip), %rbx      # 0x8541
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x52e2
movq %r12, %rdi
leaq 0x3418(%rip), %rbx      # 0x8548
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5394
movq %r12, %rdi
leaq 0x3408(%rip), %rbx      # 0x8552
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5360
movq %r12, %rdi
leaq 0x33f8(%rip), %rbx      # 0x855c
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x5360
movq %r12, %rdi
leaq 0x33e2(%rip), %rbx      # 0x8560
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x527a
movq %r12, %rdi
leaq 0x33cf(%rip), %rbx      # 0x8567
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x52ae
movq %r12, %rdi
leaq 0x33b9(%rip), %rbx      # 0x856b
movq %rbx, %rsi
callq 0x1080
testl %eax, %eax
je 0x527a
movq %r12, %rdi
leaq 0x3353(%rip), %rsi      # 0x851f
callq 0x1080
testl %eax, %eax
je 0x55ae
movq 0x9200(%rip), %rdi      # 0xe3e0
movq %r12, %rsi
leaq 0x2f90(%rsp), %rdx
callq 0x3b85
testb %al, %al
movl 0x1f58(%rsp), %ebx
je 0x55d8
movq 0x8(%r14), %rax
movq 0x18(%rax), %rcx
cmpl $0x6, 0x8(%rcx)
movq 0x1f68(%rsp), %r12
jne 0x5642
movq (%rax), %rsi
movq %r14, %rdi
movq 0x1f60(%rsp), %r13
movq %r13, %rdx
callq 0x45c5
movl %r15d, %ebp
cmpl 0x2f94(%rsp), %r15d
jne 0x566f
xorl %eax, %eax
movl 0x1f50(%rsp), %r15d
cmpq %rax, 0x1f88(%rsp)
je 0x567f
movl 0x3b98(%rsp,%rax,4), %ecx
movl %ecx, 0x2390(%rsp,%rax,4)
incq %rax
jmp 0x524a
cmpq $0x2f, %rax
jne 0x4f07
jmp 0x5737
movq %r14, %rdi
movq 0x1f60(%rsp), %r13
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6316
movl %r15d, %ebp
cmpl $0x2, %r15d
je 0x52a4
pushq $0x6
popq %rdi
movq %r14, %rsi
callq 0x3ac4
cmpl $0x14, 0x1f90(%rsp)
jmp 0x5314
movq %r14, %rdi
movq 0x1f60(%rsp), %r13
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6316
movl %r15d, %ebp
cmpl $0x2, %r15d
je 0x52d8
pushq $0x6
popq %rdi
movq %r14, %rsi
callq 0x3ac4
cmpl $0x18, 0x1f90(%rsp)
jmp 0x5314
movq %r14, %rdi
movq 0x1f60(%rsp), %r13
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6316
movl %r15d, %ebp
cmpl $0x2, %r15d
je 0x530c
pushq $0x6
popq %rdi
movq %r14, %rsi
callq 0x3ac4
cmpl $0x17, 0x1f90(%rsp)
movl 0x1f58(%rsp), %ebx
movq 0x1f68(%rsp), %r12
movl 0x1f50(%rsp), %r15d
jne 0x5348
movl 0x1f94(%rsp), %eax
cmpl $0x194, %eax            # imm = 0x194
je 0x53ff
cmpl $0x18, %eax
je 0x53ff
movq %r13, %rdi
callq 0x3e46
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x3ac4
jmp 0x5406
movq %r14, %rdi
movq 0x1f60(%rsp), %r13
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6316
movl %r15d, %ebp
cmpl $0x1, %r15d
je 0x538a
pushq $0x6
popq %rdi
movq %r14, %rsi
callq 0x3ac4
cmpl $0x18, 0x1f90(%rsp)
jmp 0x53c6
movq %r14, %rdi
movq 0x1f60(%rsp), %r13
movq %r13, %rsi
movq %rbx, %rdx
callq 0x6316
movl %r15d, %ebp
cmpl $0x1, %r15d
je 0x53be
pushq $0x6
popq %rdi
movq %r14, %rsi
callq 0x3ac4
cmpl $0x17, 0x1f90(%rsp)
movl 0x1f58(%rsp), %ebx
movq 0x1f68(%rsp), %r12
movl 0x1f50(%rsp), %r15d
je 0x53ff
cmpl $0x194, 0x1f94(%rsp) # imm = 0x194
je 0x53ff
movq %r13, %rdi
callq 0x3e46
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x3ac4
incl 0x1f54(%rsp)
movq 0x8(%r14), %rax
movl 0x8(%rax), %ecx
cmpl $0x5, %ecx
je 0x542e
cmpl $0x38, %ecx
je 0x5737
cmpl $0x34, %ecx
je 0x542e
movq 0x18(%rax), %rax
cmpl $0x2f, 0x8(%rax)
jne 0x558a
movl 0x1f74(%rsp), %esi
testl %esi, %esi
setne %al
movl %r12d, %ecx
orl %r15d, %ecx
sete %cl
andb %al, %cl
movslq %ebx, %rax
cmpb $0x1, %cl
jne 0x54a5
movl 0x1f90(%rsp,%rax,4), %ecx
cmpl $0x194, %ecx            # imm = 0x194
je 0x5477
cmpl $0x17, %ecx
je 0x552a
cmpl $0x18, %ecx
je 0x552a
cmpl $0x14, %ecx
jne 0x5569
movq 0x2790(%rsp,%rax,8), %rsi
movq %r13, %rdi
leaq 0x2390(%rsp), %rdx
leaq 0x3099(%rip), %rcx      # 0x852a
callq 0x3d28
incl 0x1f5c(%rsp)
xorl %r12d, %r12d
jmp 0x5562
testl %r12d, %r12d
setne %cl
movl %esi, %edx
orl %r15d, %edx
sete %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x54e3
movl 0x1f90(%rsp,%rax,4), %eax
cmpl $0x14, %eax
je 0x5557
cmpl $0x17, %eax
je 0x5557
cmpl $0x194, %eax            # imm = 0x194
je 0x5496
cmpl $0x18, %eax
je 0x5496
pushq $0x7
jmp 0x5559
movl %esi, %ecx
orl %r12d, %ecx
sete %cl
testl %r15d, %r15d
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x552e
movl 0x1f90(%rsp,%rax,4), %ecx
cmpl $0x14, %ecx
je 0x559e
cmpl $0x194, %ecx            # imm = 0x194
je 0x5477
cmpl $0x18, %ecx
je 0x559e
cmpl $0x17, %ecx
je 0x5477
pushq $0x7
jmp 0x55a0
pushq $0x5
jmp 0x556b
cmpl $0x1, 0x1f78(%rsp)
je 0x5496
testl %r15d, %r15d
sete %al
testb %al, %cl
jne 0x549d
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x3ac4
jmp 0x557a
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x3ac4
xorl %r15d, %r15d
xorl %eax, %eax
jmp 0x5581
pushq $0x7
popq %rdi
movq %r14, %rsi
callq 0x3ac4
xorl %r12d, %r12d
xorl %r15d, %r15d
movl 0x1f74(%rsp), %eax
movl %eax, 0x1f74(%rsp)
incl %ebx
movq %r14, %rdi
callq 0x12c2
movq 0x8(%r14), %rax
movl 0x8(%rax), %eax
jmp 0x4ed9
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x3ac4
xorl %r12d, %r12d
jmp 0x5565
movq 0x1f60(%rsp), %r13
movq %r13, %rdi
callq 0x3e46
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x3ac4
movl %r15d, %ebp
movl 0x1f58(%rsp), %ebx
jmp 0x4ffb
movl $0x3e9, %ecx            # imm = 0x3E9
movq %rsp, %rdi
leaq 0x6eb1(%rip), %rsi      # 0xc498
rep  movsq (%rsi), %es:(%rdi)
movq %r13, %rdi
leaq 0x1f7c(%rsp), %rsi
callq 0x3eb3
testb %al, %al
movq 0x1f68(%rsp), %r12
je 0x564f
movl 0x1f7c(%rsp), %eax
movl %eax, 0x2390(%rsp,%rbp,4)
cmpl $0x14, %eax
movq 0x1f60(%rsp), %r13
je 0x56e8
cmpl $0x17, %eax
movl %r15d, %ebp
je 0x56d1
cmpl $0x18, %eax
jne 0x5025
incl %r12d
jmp 0x571f
movq 0x1f60(%rsp), %r13
jmp 0x5022
pushq $0x3
popq %rdi
movq %r14, %rsi
callq 0x3ac4
movq 0x1f60(%rsp), %r13
movq %r13, %rdi
callq 0x3e46
jmp 0x5022
pushq $0x6
popq %rdi
movq %r14, %rsi
callq 0x3ac4
jmp 0x5025
xorl %r12d, %r12d
cmpq %r12, 0x1f80(%rsp)
je 0x508d
movl 0x1f90(%rsp,%r12,4), %eax
cmpl 0x2390(%rsp,%r12,4), %eax
je 0x572b
movq 0x2790(%rsp,%r12,8), %rax
cmpb $0x5f, (%rax)
jne 0x56b9
cmpb $0x0, 0x1(%rax)
je 0x56cc
movq %r13, %rdi
callq 0x3e46
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x3ac4
incq %r12
jmp 0x5682
movl 0x1f50(%rsp), %r15d
incl %r15d
incl 0x1f5c(%rsp)
jmp 0x5406
movq 0x8(%r14), %rax
movq 0x18(%rax), %rax
movl 0x8(%rax), %eax
cmpl $0xb, %eax
movl %r15d, %ebp
ja 0x5718
movl $0xb00, %ecx            # imm = 0xB00
btl %eax, %ecx
jae 0x5718
movq %r13, %rdi
callq 0x3e46
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x3ac4
incl 0x1f74(%rsp)
incl 0x1f5c(%rsp)
jmp 0x5025
incl 0x1f54(%rsp)
jmp 0x508d
cmpl $0x0, 0x1f54(%rsp)
setne %al
cmpl %ebx, %ebp
sete %cl
orb %al, %cl
jne 0x575e
pushq $0x7
popq %rdi
movq %r14, %rsi
callq 0x3ac4
movq %r13, %rdi
callq 0x3e46
addq $0x3f98, %rsp           # imm = 0x3F98
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq