// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0xa411(%rip), %eax      # 0xc3e0
cmpl $0x2f, %eax
jne 0x1fe9
leaq 0xa3e5(%rip), %rsi      # 0xc3c0
pushq $0x2
popq %rdi
callq 0x3ac4
movl 0xa3f7(%rip), %eax      # 0xc3e0
cmpl $0x2b, %eax
ja 0x225b
movl %eax, %eax
movabsq $0xa0000030040, %rcx    # imm = 0xA0000030040
btq %rax, %rcx
jae 0x20ca
leaq 0xa3d9(%rip), %rbx      # 0xc3e8
movq %rbx, %rdi
callq 0x12d4
movq 0xa3ba(%rip), %rsi      # 0xc3d8
movl 0xa3bc(%rip), %edx      # 0xc3e0
movq %rbx, %rdi
callq 0x1345
movq 0x9fa5(%rip), %r15      # 0xbfd8
movq (%r15), %rdi
callq 0x2dbc
movq %rax, 0xa396(%rip)      # 0xc3d8
movl %edx, 0xa398(%rip)      # 0xc3e0
leaq 0xa371(%rip), %r14      # 0xc3c0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1345
pushq $0x2
popq %rbp
movabsq $0xa03c00b0fc6, %r12    # imm = 0xA03C00B0FC6
movabsq $0x800000000020, %r13   # imm = 0x800000000020
movl 0xa369(%rip), %edx      # 0xc3e0
cmpq $0x2f, %rdx
ja 0x20be
btq %rdx, %r12
jae 0x20b4
movq 0xa34e(%rip), %rsi      # 0xc3d8
movq %rbx, %rdi
callq 0x1345
movq (%r15), %rdi
callq 0x2dbc
movq %rax, 0xa337(%rip)      # 0xc3d8
movl %edx, 0xa339(%rip)      # 0xc3e0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1345
jmp 0x2071
btq %rdx, %r13
jb 0x21eb
movl %ebp, %edi
movq %r14, %rsi
callq 0x3ac4
jmp 0x2071
cmpq $0x13, %rax
jne 0x225b
movups 0xa2fd(%rip), %xmm0     # 0xc3d8
movups %xmm0, 0xa31e(%rip)     # 0xc400
movq 0x9eef(%rip), %r15      # 0xbfd8
movq (%r15), %rdi
callq 0x2dbc
movq %rax, 0xa2e0(%rip)      # 0xc3d8
movl %edx, 0xa2e2(%rip)      # 0xc3e0
leaq 0xa2bb(%rip), %rdi      # 0xc3c0
movq %rax, %rsi
callq 0x1345
movl 0xa2cd(%rip), %eax      # 0xc3e0
leal -0x8(%rax), %ecx
cmpl $0x4, %ecx
jae 0x2226
leaq 0xa2c2(%rip), %rbx      # 0xc3e8
movq %rbx, %rdi
callq 0x12d4
movq 0xa2cb(%rip), %rsi      # 0xc400
movl 0xa2cd(%rip), %edx      # 0xc408
movq %rbx, %rdi
callq 0x1345
movq 0xa28e(%rip), %rsi      # 0xc3d8
movl 0xa290(%rip), %edx      # 0xc3e0
movq %rbx, %rdi
callq 0x1345
movq (%r15), %rdi
callq 0x2dbc
movq %rax, 0xa271(%rip)      # 0xc3d8
movl %edx, 0xa273(%rip)      # 0xc3e0
leaq 0xa24c(%rip), %r14      # 0xc3c0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1345
pushq $0x2
popq %rbp
movabsq $0xa03c00b0fc6, %r12    # imm = 0xA03C00B0FC6
movabsq $0x800000000020, %r13   # imm = 0x800000000020
movl 0xa244(%rip), %edx      # 0xc3e0
cmpq $0x2f, %rdx
ja 0x21df
btq %rdx, %r12
jae 0x21d9
movq 0xa229(%rip), %rsi      # 0xc3d8
movq %rbx, %rdi
callq 0x1345
movq (%r15), %rdi
callq 0x2dbc
movq %rax, 0xa212(%rip)      # 0xc3d8
movl %edx, 0xa214(%rip)      # 0xc3e0
movq %r14, %rdi
movq %rax, %rsi
callq 0x1345
jmp 0x2196
btq %rdx, %r13
jb 0x21eb
movl %ebp, %edi
movq %r14, %rsi
callq 0x3ac4
jmp 0x2196
leaq 0xa1f6(%rip), %rbx      # 0xc3e8
leaq 0xa1c7(%rip), %rsi      # 0xc3c0
movq %rbx, %rdi
callq 0x7282
movq %rbx, %rdi
callq 0x12e0
callq 0x29f5
callq 0x2b16
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a25
cmpl $0x5, %eax
je 0x2209
cmpl $0x6, %eax
jne 0x225b
movq (%r15), %rdi
callq 0x2dbc
movq %rax, 0xa199(%rip)      # 0xc3d8
movl %edx, 0xa19b(%rip)      # 0xc3e0
leaq 0xa174(%rip), %rdi      # 0xc3c0
movq %rax, %rsi
callq 0x1345
callq 0x23a9
jmp 0x220e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq