// File: /workspace/github_c_makefile_star2_O1/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
cmpl $0x2f, 0x9fdd(%rip)     # 0xc3d0
jne 0x2406
leaq 0x9fb4(%rip), %rsi      # 0xc3b0
movl $0x2, %edi
callq 0x42c8
movl 0x9fc4(%rip), %eax      # 0xc3d0
cmpq $0x2b, %rax
ja 0x2678
movabsq $0xa0000030040, %rcx    # imm = 0xA0000030040
btq %rax, %rcx
jae 0x24ec
leaq 0x9fa7(%rip), %rbx      # 0xc3d8
movq %rbx, %rdi
callq 0x16a7
movq 0x9f88(%rip), %rsi      # 0xc3c8
movl 0x9f8a(%rip), %edx      # 0xc3d0
movq %rbx, %rdi
callq 0x1726
movq 0x9b83(%rip), %r15      # 0xbfd8
movq (%r15), %rdi
callq 0x31f0
movq %rax, 0x9f64(%rip)      # 0xc3c8
movl %edx, 0x9f66(%rip)      # 0xc3d0
leaq 0x9f3f(%rip), %r14      # 0xc3b0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1726
movabsq $0xa03c00b0fc6, %r12    # imm = 0xA03C00B0FC6
movabsq $0x800000000020, %r13   # imm = 0x800000000020
movl 0x9f3a(%rip), %edx      # 0xc3d0
cmpq $0x2f, %rdx
ja 0x24dd
btq %rdx, %r12
jae 0x24d3
movq 0x9f1f(%rip), %rsi      # 0xc3c8
movq %rbx, %rdi
callq 0x1726
movq (%r15), %rdi
callq 0x31f0
movq %rax, 0x9f08(%rip)      # 0xc3c8
movl %edx, 0x9f0a(%rip)      # 0xc3d0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1726
jmp 0x2490
btq %rdx, %r13
jb 0x260d
movl $0x2, %edi
movq %r14, %rsi
callq 0x42c8
jmp 0x2490
cmpq $0x13, %rax
jne 0x2678
movups 0x9ecb(%rip), %xmm0     # 0xc3c8
movups %xmm0, 0x9eec(%rip)     # 0xc3f0
movq 0x9acd(%rip), %r15      # 0xbfd8
movq (%r15), %rdi
callq 0x31f0
movq %rax, 0x9eae(%rip)      # 0xc3c8
movl %edx, 0x9eb0(%rip)      # 0xc3d0
leaq 0x9e89(%rip), %rdi      # 0xc3b0
movq %rax, %rsi
callq 0x1726
movl 0x9e9b(%rip), %eax      # 0xc3d0
leal -0x8(%rax), %ecx
cmpl $0x4, %ecx
jae 0x2643
leaq 0x9e90(%rip), %rbx      # 0xc3d8
movq %rbx, %rdi
callq 0x16a7
movq 0x9e99(%rip), %rsi      # 0xc3f0
movl 0x9e9b(%rip), %edx      # 0xc3f8
movq %rbx, %rdi
callq 0x1726
movq 0x9e5c(%rip), %rsi      # 0xc3c8
movl 0x9e5e(%rip), %edx      # 0xc3d0
movq %rbx, %rdi
callq 0x1726
movq (%r15), %rdi
callq 0x31f0
movq %rax, 0x9e3f(%rip)      # 0xc3c8
movl %edx, 0x9e41(%rip)      # 0xc3d0
leaq 0x9e1a(%rip), %r14      # 0xc3b0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1726
movabsq $0xa03c00b0fc6, %r12    # imm = 0xA03C00B0FC6
movabsq $0x800000000020, %r13   # imm = 0x800000000020
movl 0x9e15(%rip), %edx      # 0xc3d0
cmpq $0x2f, %rdx
ja 0x25fe
btq %rdx, %r12
jae 0x25f8
movq 0x9dfa(%rip), %rsi      # 0xc3c8
movq %rbx, %rdi
callq 0x1726
movq (%r15), %rdi
callq 0x31f0
movq %rax, 0x9de3(%rip)      # 0xc3c8
movl %edx, 0x9de5(%rip)      # 0xc3d0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1726
jmp 0x25b5
btq %rdx, %r13
jb 0x260d
movl $0x2, %edi
movq %r14, %rsi
callq 0x42c8
jmp 0x25b5
leaq 0x9dc4(%rip), %rbx      # 0xc3d8
leaq 0x9d95(%rip), %rsi      # 0xc3b0
movq %rbx, %rdi
callq 0x7d13
movq %rbx, %rdi
callq 0x16b6
callq 0x2e2e
callq 0x2f42
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1e3a
cmpl $0x5, %eax
je 0x262b
cmpl $0x6, %eax
jne 0x2678
movq (%r15), %rdi
callq 0x31f0
movq %rax, 0x9d6c(%rip)      # 0xc3c8
movl %edx, 0x9d6e(%rip)      # 0xc3d0
leaq 0x9d47(%rip), %rdi      # 0xc3b0
movq %rax, %rsi
callq 0x1726
callq 0x27c9
jmp 0x2630
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq