// File: /workspace/github_c_makefile_star2_O2/MartinNovotny25[P]VUT-FIT-IFJ2020/semantics.c
// Function: assign_func_params_control
void assign_func_params_control(TDLList *L,tBSTNodePtrLocal *node, char *func_name){
    int type;
    if(!(strcmp(func_name, "inputs"))){
        TDLLSucc(L);
        TDLLSucc(L);
        if(L->Act->tdata.type != t_RIGHT_BRACKET){
            BSTDisposeLocal(node);
            error_call(ERR_SEM_DATATYPE, L);
        } 
    }else if(!(strcmp(func_name, "inputi"))){
        TDLLSucc(L);
        TDLLSucc(L);
        if(L->Act->tdata.type != t_RIGHT_BRACKET){
            BSTDisposeLocal(node);
            error_call(ERR_SEM_DATATYPE, L);
        } 
    }else if(!(strcmp(func_name, "inputf"))){
        TDLLSucc(L);
        TDLLSucc(L);
        if(L->Act->tdata.type != t_RIGHT_BRACKET){
            BSTDisposeLocal(node);
            error_call(ERR_SEM_DATATYPE, L);
        } 
    }else if(!(strcmp(func_name, "int2float"))){
        TDLLSucc(L);
        TDLLSucc(L);
        if(L->Act->tdata.type == t_INT_NON_ZERO || L->Act->tdata.type == t_INT_ZERO || L->Act->tdata.type == t_INT_ID){

        }else if(L->Act->tdata.type == t_IDENTIFIER){
            if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_UNDEF,L);
            }else{
                if(type == t_INT_ID){}
                else{
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_DATATYPE, L);
                }
            }
        }else{
            BSTDisposeLocal(node);
            error_call(ERR_SEM_DATATYPE, L);
        }
    }else if(!(strcmp(func_name, "float2int"))){
        TDLLSucc(L);
        TDLLSucc(L);
        if(L->Act->tdata.type == t_FLOAT64 || L->Act->tdata.type == t_FLOAT){

        }else if(L->Act->tdata.type == t_IDENTIFIER){
            if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_UNDEF, L);
            }else{
                if(type == t_FLOAT64){}
                else{
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_DATATYPE, L);
                }
            }
        }else{
            BSTDisposeLocal(node);
            error_call(ERR_SEM_DATATYPE, L);
        }
    }else if(!(strcmp(func_name, "len"))){
        TDLLSucc(L);
        TDLLSucc(L);
        if(L->Act->tdata.type == t_STRING_ID || L->Act->tdata.type == t_STRING){

        }else if(L->Act->tdata.type == t_IDENTIFIER){
            if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_UNDEF, L);
            }else{
                if(type == t_STRING_ID){}
                else{
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_DATATYPE, L);
                }
            }
        }else{
            BSTDisposeLocal(node);
            error_call(ERR_SEM_DATATYPE, L);
        }
    }else if(!(strcmp(func_name, "substr"))){
        TDLLSucc(L);
        TDLLSucc(L);
        if(L->Act->tdata.type == t_STRING || L->Act->tdata.type == t_STRING_ID){
            TDLLSucc(L);
            if(L->Act->tdata.type != t_COMMA){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_DATATYPE, L);
            }
            TDLLSucc(L);
            if(L->Act->tdata.type == t_INT_ID || L->Act->tdata.type == t_INT_NON_ZERO || L->Act->tdata.type == t_INT_ZERO){
                TDLLSucc(L);
                if(L->Act->tdata.type != t_COMMA){
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_DATATYPE, L);
                }
                TDLLSucc(L);
                if(L->Act->tdata.type == t_INT_ID || L->Act->tdata.type == t_INT_NON_ZERO || L->Act->tdata.type == t_INT_ZERO){
                
                }else if(L->Act->tdata.type == t_IDENTIFIER){
                    if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                        BSTDisposeLocal(node);
                        error_call(ERR_SEM_UNDEF, L);
                    }else{
                        if(type == t_INT_ID){}
                        else{
                            BSTDisposeLocal(node);
                            error_call(ERR_SEM_DATATYPE, L);
                        }
                    }
                }else{
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_DATATYPE, L);
                }
            }else if(L->Act->tdata.type == t_IDENTIFIER){
                if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_UNDEF, L);
                }else{
                    if(type == t_INT_ID){}
                    else{
                        BSTDisposeLocal(node);
                        error_call(ERR_SEM_DATATYPE, L);
                    }
                }
            }else{
                BSTDisposeLocal(node);
                error_call(ERR_SEM_DATATYPE, L);
            }
        }else if(L->Act->tdata.type == t_IDENTIFIER){
            if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_UNDEF, L);
            }else{
                if(type == t_STRING_ID){
                    TDLLSucc(L);
                    if(L->Act->tdata.type != t_COMMA){
                        BSTDisposeLocal(node);
                        error_call(ERR_SEM_DATATYPE, L);
                    }
                    TDLLSucc(L);
                    if(L->Act->tdata.type == t_INT_ID || L->Act->tdata.type == t_INT_NON_ZERO || L->Act->tdata.type == t_INT_ZERO){
                        TDLLSucc(L);
                        if(L->Act->tdata.type != t_COMMA){
                            BSTDisposeLocal(node);
                            error_call(ERR_SEM_DATATYPE, L);
                        }
                        TDLLSucc(L);
                        if(L->Act->tdata.type == t_INT_ID || L->Act->tdata.type == t_INT_NON_ZERO || L->Act->tdata.type == t_INT_ZERO){
                
                        }else if(L->Act->tdata.type == t_IDENTIFIER){
                            if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                                BSTDisposeLocal(node);
                                error_call(ERR_SEM_UNDEF, L);
                            }else{
                                if(type == t_INT_ID){}
                                else{
                                    BSTDisposeLocal(node);
                                    error_call(ERR_SEM_DATATYPE, L);
                                }
                            }
                        }else{
                            BSTDisposeLocal(node);
                            error_call(ERR_SEM_DATATYPE, L);
                        }
                    }else if(L->Act->tdata.type == t_IDENTIFIER){
                        if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                            BSTDisposeLocal(node);
                            error_call(ERR_SEM_UNDEF, L);
                        }else{
                            if(type == t_INT_ID){}
                            else{
                                BSTDisposeLocal(node);
                                error_call(ERR_SEM_DATATYPE, L);
                            }
                        }
                    }else{
                        BSTDisposeLocal(node);
                        error_call(ERR_SEM_DATATYPE, L);
                    }
                }
                else{
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_DATATYPE,L);
                }
            }
        }else{
            BSTDisposeLocal(node);
            error_call(ERR_SEM_DATATYPE, L);
        }
    }else if(!(strcmp(func_name, "ord"))){
        TDLLSucc(L);
        TDLLSucc(L);
        if(L->Act->tdata.type == t_STRING_ID || L->Act->tdata.type == t_STRING){
            TDLLSucc(L);
            if(L->Act->tdata.type != t_COMMA){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_DATATYPE, L);
            }
            TDLLSucc(L);
            if(L->Act->tdata.type == t_INT_ZERO || L->Act->tdata.type == t_INT_NON_ZERO || L->Act->tdata.type == t_INT_ID){

            }else if(L->Act->tdata.type == t_IDENTIFIER){
            if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_UNDEF, L);
            }else{
                if(type == t_INT_ID){}
                else{
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_DATATYPE, L);
                }
            }
        }else{
                BSTDisposeLocal(node);
                error_call(ERR_SEM_DATATYPE, L);
            }
        }else if(L->Act->tdata.type == t_IDENTIFIER){
            if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_UNDEF, L);
            }else{
                if(type == t_STRING_ID){}
                else{
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_DATATYPE, L);
                }
            }
        }else{
            BSTDisposeLocal(node);
            error_call(ERR_SEM_DATATYPE, L);
        }
    }else if(!(strcmp(func_name, "chr"))){
        TDLLSucc(L);
        TDLLSucc(L);
        if(L->Act->tdata.type == t_INT_ID || L->Act->tdata.type == t_INT_ZERO || L->Act->tdata.type == t_INT_NON_ZERO){

        }else if(L->Act->tdata.type == t_IDENTIFIER){
            if(!(MainStackSearch(mainstack, L->Act->tdata.lex, &type))){
                BSTDisposeLocal(node);
                error_call(ERR_SEM_UNDEF, L);
            }else{
                if(type == t_INT_ID){}
                else{
                    BSTDisposeLocal(node);
                    error_call(ERR_SEM_DATATYPE, L);
                }
            }
        }else{
            BSTDisposeLocal(node);
            error_call(ERR_SEM_DATATYPE, L);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1f50, %rsp           # imm = 0x1F50
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x2201(%rip), %rsi      # 0x8533
movq %rdx, %rdi
callq 0x1080
testl %eax, %eax
je 0x645f
leaq 0x21f1(%rip), %rsi      # 0x853a
movq %r15, %rdi
callq 0x1080
testl %eax, %eax
je 0x645f
leaq 0x21e1(%rip), %rsi      # 0x8541
movq %r15, %rdi
callq 0x1080
testl %eax, %eax
je 0x645f
leaq 0x21d1(%rip), %rsi      # 0x8548
movq %r15, %rdi
callq 0x1080
testl %eax, %eax
je 0x63f6
leaq 0x21c8(%rip), %rsi      # 0x8552
movq %r15, %rdi
callq 0x1080
testl %eax, %eax
je 0x648a
leaq 0x21bb(%rip), %rsi      # 0x855c
movq %r15, %rdi
callq 0x1080
testl %eax, %eax
je 0x64f0
leaq 0x21a8(%rip), %rsi      # 0x8560
movq %r15, %rdi
callq 0x1080
testl %eax, %eax
je 0x652a
leaq 0x2198(%rip), %rsi      # 0x8567
movq %r15, %rdi
callq 0x1080
testl %eax, %eax
je 0x65a4
leaq 0x2185(%rip), %rsi      # 0x856b
movq %r15, %rdi
callq 0x1080
testl %eax, %eax
jne 0x647d
movq %rbx, %rdi
callq 0x12c2
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
movl 0x8(%rax), %ecx
leal -0x10(%rcx), %edx
cmpl $0x2, %edx
jb 0x647d
cmpl $0x18, %ecx
je 0x647d
cmpl $0x13, %ecx
jne 0x65fc
movq (%rax), %rax
leaq 0x606b(%rip), %rsi      # 0xc498
movl $0x3e9, %ecx            # imm = 0x3E9
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x1f4c(%rsp), %rsi
movq %rax, %rdi
callq 0x3eb3
testb %al, %al
je 0x673b
cmpl $0x18, 0x1f4c(%rsp)
je 0x647d
jmp 0x672f
movq %rbx, %rdi
callq 0x12c2
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
cmpl $0x7, 0x8(%rax)
jne 0x65fc
addq $0x1f50, %rsp           # imm = 0x1F50
popq %rbx
popq %r14
popq %r15
retq
movq %rbx, %rdi
callq 0x12c2
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
movl 0x8(%rax), %ecx
cmpl $0x29, %ecx
je 0x647d
cmpl $0x17, %ecx
je 0x647d
cmpl $0x13, %ecx
jne 0x65fc
movq (%rax), %rax
leaq 0x5fda(%rip), %rsi      # 0xc498
movl $0x3e9, %ecx            # imm = 0x3E9
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x1f4c(%rsp), %rsi
movq %rax, %rdi
callq 0x3eb3
testb %al, %al
je 0x673b
cmpl $0x17, 0x1f4c(%rsp)
je 0x647d
jmp 0x672f
movq %rbx, %rdi
callq 0x12c2
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
movl 0x8(%rax), %ecx
cmpl $0x2b, %ecx
je 0x647d
cmpl $0x14, %ecx
je 0x647d
cmpl $0x13, %ecx
jne 0x65fc
movq (%rax), %rax
jmp 0x66fb
movq %rbx, %rdi
callq 0x12c2
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rcx
movl 0x8(%rcx), %eax
cmpl $0x13, %eax
je 0x661b
cmpl $0x2b, %eax
je 0x6558
cmpl $0x14, %eax
jne 0x65fc
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
cmpl $0x5, 0x8(%rax)
je 0x657d
movq %r14, %rdi
callq 0x3e46
pushq $0x4
popq %rdi
movq %rbx, %rsi
callq 0x3ac4
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
movl 0x8(%rax), %ecx
leal -0x10(%rcx), %edx
cmpl $0x2, %edx
jb 0x65ce
cmpl $0x13, %ecx
je 0x6423
cmpl $0x18, %ecx
je 0x65ce
jmp 0x65fc
movq %rbx, %rdi
callq 0x12c2
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rcx
movl 0x8(%rcx), %eax
cmpl $0x13, %eax
je 0x66f8
cmpl $0x2b, %eax
je 0x65ce
cmpl $0x14, %eax
jne 0x65fc
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
cmpl $0x5, 0x8(%rax)
je 0x63fe
movq %r14, %rdi
callq 0x3e46
pushq $0x4
popq %rdi
movq %rbx, %rsi
callq 0x3ac4
jmp 0x63fe
movq %r14, %rdi
callq 0x3e46
pushq $0x4
popq %rdi
movq %rbx, %rsi
addq $0x1f50, %rsp           # imm = 0x1F50
popq %rbx
popq %r14
popq %r15
jmp 0x3ac4
movq (%rcx), %rax
leaq 0x5e73(%rip), %rsi      # 0xc498
movl $0x3e9, %ecx            # imm = 0x3E9
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x1f4c(%rsp), %rsi
movq %rax, %rdi
callq 0x3eb3
testb %al, %al
je 0x673b
cmpl $0x14, 0x1f4c(%rsp)
jne 0x672f
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
cmpl $0x5, 0x8(%rax)
je 0x667b
movq %r14, %rdi
callq 0x3e46
pushq $0x4
popq %rdi
movq %rbx, %rsi
callq 0x3ac4
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
movl 0x8(%rax), %ecx
leal -0x10(%rcx), %edx
cmpl $0x2, %edx
jb 0x66a4
cmpl $0x13, %ecx
je 0x6423
cmpl $0x18, %ecx
jne 0x672f
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
cmpl $0x5, 0x8(%rax)
je 0x66c9
movq %r14, %rdi
callq 0x3e46
pushq $0x4
popq %rdi
movq %rbx, %rsi
callq 0x3ac4
movq %rbx, %rdi
callq 0x12c2
movq 0x8(%rbx), %rax
movl 0x8(%rax), %ecx
leal -0x10(%rcx), %edx
cmpl $0x2, %edx
jb 0x647d
cmpl $0x18, %ecx
je 0x647d
cmpl $0x13, %ecx
je 0x6423
jmp 0x672f
movq (%rcx), %rax
leaq 0x5d96(%rip), %rsi      # 0xc498
movl $0x3e9, %ecx            # imm = 0x3E9
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x1f4c(%rsp), %rsi
movq %rax, %rdi
callq 0x3eb3
testb %al, %al
je 0x673b
cmpl $0x14, 0x1f4c(%rsp)
je 0x647d
movq %r14, %rdi
callq 0x3e46
pushq $0x4
jmp 0x6745
movq %r14, %rdi
callq 0x3e46
pushq $0x3
popq %rdi
movq %rbx, %rsi
callq 0x3ac4
jmp 0x647d