// File: /workspace/github_c_makefile_star2_O3/MartinNovotny25[P]VUT-FIT-IFJ2020/parser.c
// Function: rule_func_assign
void rule_func_assign() {
    //V tomto pripade sa pozriem na token dopredu, ak bude lava zatvorka tak funckia, ak nieco ine, vyraz
    //Nesmie byt odriadkovanie
    if (token.type == t_EOL) { error_call(ERR_SYN, &tokens); }

    // Ak príde identifikátor, neviem si to je výraz alebo volanie funckie, volam dalsi token
    if (token.type == t_IDENTIFIER) {
        //PARSER -- tu si ulozim token cisto pre vkladanie do psa_listu
        help = token;

        token = get_next_token(stdin);
        TDLLInsertLast(&tokens, token);

        // Lava zatvorka -- volanie funckie
        if (token.type == t_LEFT_BRACKET) {
            token = get_next_token(stdin);
            TDLLInsertLast(&tokens, token);

            // po vyjdeni budem mat nacitany dalsi token
            rule_func_params();

            rule_eol();

            rule_stat();
        }

            // ciarka - dalsi vyraz
        else if (token.type == t_COMMA) {
            // Ci za jednym vyrazom pokracuje dalsi -- exp_NEXT
            rule_exp_n();

            rule_eol();
            rule_stat();
        }


            // Sem pojde precedencna ak za identifikatorom pojde aritmeticke znamienko
        else if ((token.type == t_PLUS)
                 || (token.type == t_MINUS)
                 || (token.type == t_DIVIDE)
                 || (token.type == t_MULTIPLY)) {
            TDLLInitList(&psa_list);
            // v help mam ulozeny identifikator, kedze je sucastou vyrazu a v token uz je nacitane znamienko
            TDLLInsertLast(&psa_list, help);
            TDLLInsertLast(&psa_list, token);
            token = get_next_token(stdin);
            TDLLInsertLast(&tokens, token);

            //Nacitanie dalsich znakov, koncim ked mi pride ciarka alebo EOL

            while (token.type != t_COMMA && token.type != t_EOL) {
                if ((token.type == t_PLUS)
                    || (token.type == t_MINUS)
                    || (token.type == t_DIVIDE)
                    || (token.type == t_MULTIPLY)
                    || (token.type == t_RIGHT_BRACKET)
                    || (token.type == t_LEFT_BRACKET)
                    || (token.type == t_LESS)
                    || (token.type == t_LESSOREQUAL)
                    || (token.type == t_GREATER)
                    || (token.type == t_GREATEROREQUAL)
                    || (token.type == t_EQUAL)
                    || (token.type == t_NOT_EQUAL)
                    || (token.type == t_IDENTIFIER)
                    || (token.type == t_FLOAT)
                    || (token.type == t_INT_NON_ZERO)
                    || (token.type == t_INT_ZERO)
                    || (token.type == t_STRING)) {

                    TDLLInsertLast(&psa_list, token);
                    token = get_next_token(stdin);
                    TDLLInsertLast(&tokens, token);

                } else { error_call(ERR_SYN, &tokens); }

            }


            //Ak precedencna analyza vrati 1 -- ERROR
            evaluation(&psa_list, &tokens);
            TDLLDisposeList(&psa_list);

            // Pride mi ciarka alebo eol, musim zavolat exp_n ci za tym nieco ide
            rule_exp_n();
            rule_eol();
            rule_stat();

        }
    }

        // ak mi nepride id -- nemusis riesit, ide vyraz
    else if (token.type == t_FLOAT || token.type == t_INT_NON_ZERO || token.type == t_INT_ZERO ||
             token.type == t_STRING || token.type == t_LEFT_BRACKET) {

        TDLLInitList(&psa_list);
        TDLLInsertLast(&psa_list, token);

        token = get_next_token(stdin);
        TDLLInsertLast(&tokens, token);

        //nacitavam, kym nepride ciarka alebo eol -- koneic vyrazu
        while (token.type != t_COMMA && token.type != t_EOL) {
            if ((token.type == t_PLUS)
                || (token.type == t_MINUS)
                || (token.type == t_DIVIDE)
                || (token.type == t_MULTIPLY)
                || (token.type == t_RIGHT_BRACKET)
                || (token.type == t_LEFT_BRACKET)
                || (token.type == t_LESS)
                || (token.type == t_LESSOREQUAL)
                || (token.type == t_GREATER)
                || (token.type == t_GREATEROREQUAL)
                || (token.type == t_EQUAL)
                || (token.type == t_NOT_EQUAL)
                || (token.type == t_IDENTIFIER)
                || (token.type == t_FLOAT)
                || (token.type == t_INT_NON_ZERO)
                || (token.type == t_INT_ZERO)
                || (token.type == t_STRING)) {

                TDLLInsertLast(&psa_list, token);
                token = get_next_token(stdin);
                TDLLInsertLast(&tokens, token);

            } else {
                error_call(ERR_SYN, &tokens);
            }
        }

        evaluation(&psa_list, &tokens);
        TDLLDisposeList(&psa_list);

            // Ci za jednym vyrazom pokracuje dalsi
            rule_exp_n();
            rule_eol();
            rule_stat();
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0x9fde(%rip), %eax      # 0xc3d0
cmpl $0x2f, %eax
jne 0x240e
leaq 0x9fb2(%rip), %rsi      # 0xc3b0
movl $0x2, %edi
callq 0x42d0
movl 0x9fc2(%rip), %eax      # 0xc3d0
cmpl $0x2b, %eax
ja 0x267b
movl %eax, %eax
movabsq $0xa0000030040, %rcx    # imm = 0xA0000030040
btq %rax, %rcx
jae 0x24ef
leaq 0x9fa4(%rip), %rbx      # 0xc3d8
movq %rbx, %rdi
callq 0x16a3
movq 0x9f85(%rip), %rsi      # 0xc3c8
movl 0x9f87(%rip), %edx      # 0xc3d0
movq %rbx, %rdi
callq 0x1722
movq 0x9b80(%rip), %r15      # 0xbfd8
movq (%r15), %rdi
callq 0x31f4
movq %rax, 0x9f61(%rip)      # 0xc3c8
movl %edx, 0x9f63(%rip)      # 0xc3d0
leaq 0x9f3c(%rip), %r14      # 0xc3b0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1722
movabsq $0xa03c00b0fc6, %r12    # imm = 0xA03C00B0FC6
movabsq $0x800000000020, %r13   # imm = 0x800000000020
movl 0x9f37(%rip), %edx      # 0xc3d0
cmpq $0x2f, %rdx
ja 0x24e0
btq %rdx, %r12
jae 0x24d6
movq 0x9f1c(%rip), %rsi      # 0xc3c8
movq %rbx, %rdi
callq 0x1722
movq (%r15), %rdi
callq 0x31f4
movq %rax, 0x9f05(%rip)      # 0xc3c8
movl %edx, 0x9f07(%rip)      # 0xc3d0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1722
jmp 0x2493
btq %rdx, %r13
jb 0x2610
movl $0x2, %edi
movq %r14, %rsi
callq 0x42d0
jmp 0x2493
cmpq $0x13, %rax
jne 0x267b
movups 0x9ec8(%rip), %xmm0     # 0xc3c8
movups %xmm0, 0x9ee9(%rip)     # 0xc3f0
movq 0x9aca(%rip), %r15      # 0xbfd8
movq (%r15), %rdi
callq 0x31f4
movq %rax, 0x9eab(%rip)      # 0xc3c8
movl %edx, 0x9ead(%rip)      # 0xc3d0
leaq 0x9e86(%rip), %rdi      # 0xc3b0
movq %rax, %rsi
callq 0x1722
movl 0x9e98(%rip), %eax      # 0xc3d0
leal -0x8(%rax), %ecx
cmpl $0x4, %ecx
jae 0x2646
leaq 0x9e8d(%rip), %rbx      # 0xc3d8
movq %rbx, %rdi
callq 0x16a3
movq 0x9e96(%rip), %rsi      # 0xc3f0
movl 0x9e98(%rip), %edx      # 0xc3f8
movq %rbx, %rdi
callq 0x1722
movq 0x9e59(%rip), %rsi      # 0xc3c8
movl 0x9e5b(%rip), %edx      # 0xc3d0
movq %rbx, %rdi
callq 0x1722
movq (%r15), %rdi
callq 0x31f4
movq %rax, 0x9e3c(%rip)      # 0xc3c8
movl %edx, 0x9e3e(%rip)      # 0xc3d0
leaq 0x9e17(%rip), %r14      # 0xc3b0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1722
movabsq $0xa03c00b0fc6, %r12    # imm = 0xA03C00B0FC6
movabsq $0x800000000020, %r13   # imm = 0x800000000020
movl 0x9e12(%rip), %edx      # 0xc3d0
cmpq $0x2f, %rdx
ja 0x2601
btq %rdx, %r12
jae 0x25fb
movq 0x9df7(%rip), %rsi      # 0xc3c8
movq %rbx, %rdi
callq 0x1722
movq (%r15), %rdi
callq 0x31f4
movq %rax, 0x9de0(%rip)      # 0xc3c8
movl %edx, 0x9de2(%rip)      # 0xc3d0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1722
jmp 0x25b8
btq %rdx, %r13
jb 0x2610
movl $0x2, %edi
movq %r14, %rsi
callq 0x42d0
jmp 0x25b8
leaq 0x9dc1(%rip), %rbx      # 0xc3d8
leaq 0x9d92(%rip), %rsi      # 0xc3b0
movq %rbx, %rdi
callq 0x7bf8
movq %rbx, %rdi
callq 0x16b2
callq 0x2e31
callq 0x2f48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1e2e
cmpl $0x5, %eax
je 0x262e
cmpl $0x6, %eax
jne 0x267b
movq (%r15), %rdi
callq 0x31f4
movq %rax, 0x9d69(%rip)      # 0xc3c8
movl %edx, 0x9d6b(%rip)      # 0xc3d0
leaq 0x9d44(%rip), %rdi      # 0xc3b0
movq %rax, %rsi
callq 0x1722
callq 0x27cc
jmp 0x2633
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq