// File: /workspace/github_c_makefile_star2_O2/MartinNovotny25[P]VUT-FIT-IFJ2020/parser.c
// Function: def_func
void def_func() {
    // terminal ID
    if (token.type != t_IDENTIFIER) { error_call(ERR_SYN, &tokens); }
    else { token = get_next_token(stdin); TDLLInsertLast(&tokens, token); }

    // token (
    if (token.type != t_LEFT_BRACKET) { error_call(ERR_SYN, &tokens); }
    else { token = get_next_token(stdin); TDLLInsertLast(&tokens, token); }

    // neterminal <params> -- Vstupne parametre funkcie
    // Zoznam parametrov moze byt prazdny, preto može ist za lavou zatvorkou hned pravá
    if (token.type != t_IDENTIFIER && token.type != t_RIGHT_BRACKET) { error_call(ERR_SYN, &tokens); }
    else {
        //token = get_next_token(stdin);
        //TDLLInsertLast(&tokens, token);
        rule_params();
    }

    // Nasleduje typy návratového listu a za ním telo -- preto RETLIST_BODY
    if (token.type != t_LEFT_BRACKET && token.type != t_BRACES_L) { error_call(ERR_SYN, &tokens); }
    else {
        rule_func_retlist_body();
    }


    // Ak funckia mala mat return, ale v kode sa nenachadza -- ERROR
    if (was_return == false && is_return == true) {error_call(ERR_SEM_RETURN, &tokens);}

    // nastavime flagy na povodnu hodnotu pre dalsie mozne def_func
    was_return = false;
    is_return = false;

    global_brace_count--;

    // Nepovinne EOLy
    if (token.type == t_EOL)
    {
        rule_eol();
    }

    // Ak sa za def func nenachaza ukoncovacia mnozinova zatvorka
    if (token.type != t_BRACES_R) {error_call(ERR_SYN, &tokens);}
    else {token = get_next_token(stdin); TDLLInsertLast(&tokens, token);}

    //Nepovinne eoly medzi blokmi
    if (token.type == t_EOL)
    {
        between_def = true;
        rule_eol();
        between_def = false;
    }

    //Ak dôjde k dalsej definicii, znova def_func
    if (token.type == t_FUNC)
    {
        token = get_next_token(stdin);
        TDLLInsertLast(&tokens, token);
        def_func();
    }


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0xa930(%rip), %r15      # 0xbfd8
leaq 0xad11(%rip), %rbx      # 0xc3c0
pushq $0x6
popq %rbp
xorl %r12d, %r12d
pushq $0x2
popq %r14
cmpl $0x13, 0xad20(%rip)     # 0xc3e0
jne 0x16e4
movq (%r15), %rdi
callq 0x2dbc
movq %rax, 0xad07(%rip)      # 0xc3d8
movl %edx, 0xad09(%rip)      # 0xc3e0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1345
jmp 0x16ef
movl %r14d, %edi
movq %rbx, %rsi
callq 0x3ac4
cmpl $0x6, 0xacea(%rip)      # 0xc3e0
jne 0x171a
movq (%r15), %rdi
callq 0x2dbc
movq %rax, 0xacd1(%rip)      # 0xc3d8
movl %edx, 0xacd3(%rip)      # 0xc3e0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1345
jmp 0x1725
movl %r14d, %edi
movq %rbx, %rsi
callq 0x3ac4
movl 0xacb5(%rip), %eax      # 0xc3e0
cmpl $0x7, %eax
je 0x1735
cmpl $0x13, %eax
jne 0x173c
callq 0x226a
jmp 0x1747
movl %r14d, %edi
movq %rbx, %rsi
callq 0x3ac4
movl 0xac93(%rip), %eax      # 0xc3e0
cmpl $0x6, %eax
je 0x1757
cmpl $0x34, %eax
jne 0x175e
callq 0x1838
jmp 0x1769
movl %r14d, %edi
movq %rbx, %rsi
callq 0x3ac4
cmpb $0x0, 0xac4a(%rip)      # 0xc3ba
jne 0x1785
cmpb $0x1, 0xac40(%rip)      # 0xc3b9
jne 0x1785
movl %ebp, %edi
movq %rbx, %rsi
callq 0x3ac4
decl 0xac31(%rip)            # 0xc3bc
movb %r12b, 0xac28(%rip)     # 0xc3ba
movb %r12b, 0xac20(%rip)     # 0xc3b9
movl 0xac41(%rip), %eax      # 0xc3e0
cmpl $0x2f, %eax
jne 0x17af
callq 0x2b16
movl 0xac31(%rip), %eax      # 0xc3e0
cmpl $0x33, %eax
jne 0x17d6
movq (%r15), %rdi
callq 0x2dbc
movq %rax, 0xac15(%rip)      # 0xc3d8
movl %edx, 0xac17(%rip)      # 0xc3e0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1345
jmp 0x17e1
movl %r14d, %edi
movq %rbx, %rsi
callq 0x3ac4
movl 0xabf9(%rip), %eax      # 0xc3e0
cmpl $0x2f, %eax
jne 0x1805
movb $0x1, 0xabc8(%rip)      # 0xc3bb
callq 0x2b16
movb $0x0, 0xabbc(%rip)      # 0xc3bb
movl 0xabdb(%rip), %eax      # 0xc3e0
cmpl $0x1c, %eax
jne 0x182f
movq (%r15), %rdi
callq 0x2dbc
movq %rax, 0xabbf(%rip)      # 0xc3d8
movl %edx, 0xabc1(%rip)      # 0xc3e0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1345
jmp 0x16b9
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq