// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
movq 0xa51c(%rip), %r14      # 0xbfd8
leaq 0xa8ed(%rip), %rbx      # 0xc3b0
xorl %ebp, %ebp
cmpl $0x13, 0xa904(%rip)     # 0xc3d0
jne 0x1af0
movq (%r14), %rdi
callq 0x31f0
movq %rax, 0xa8eb(%rip)      # 0xc3c8
movl %edx, 0xa8ed(%rip)      # 0xc3d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1726
jmp 0x1afd
movl $0x2, %edi
movq %rbx, %rsi
callq 0x42c8
cmpl $0x6, 0xa8cc(%rip)      # 0xc3d0
jne 0x1b28
movq (%r14), %rdi
callq 0x31f0
movq %rax, 0xa8b3(%rip)      # 0xc3c8
movl %edx, 0xa8b5(%rip)      # 0xc3d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1726
jmp 0x1b35
movl $0x2, %edi
movq %rbx, %rsi
callq 0x42c8
movl 0xa895(%rip), %eax      # 0xc3d0
cmpl $0x7, %eax
je 0x1b45
cmpl $0x13, %eax
jne 0x1b4c
callq 0x2682
jmp 0x1b59
movl $0x2, %edi
movq %rbx, %rsi
callq 0x42c8
movl 0xa871(%rip), %eax      # 0xc3d0
cmpl $0x6, %eax
je 0x1b69
cmpl $0x34, %eax
jne 0x1b70
callq 0x1c45
jmp 0x1b7d
movl $0x2, %edi
movq %rbx, %rsi
callq 0x42c8
cmpb $0x0, 0xa826(%rip)      # 0xc3aa
jne 0x1b9c
cmpb $0x1, 0xa81c(%rip)      # 0xc3a9
jne 0x1b9c
movl $0x6, %edi
movq %rbx, %rsi
callq 0x42c8
decl 0xa80a(%rip)            # 0xc3ac
movb %bpl, 0xa801(%rip)      # 0xc3aa
movb %bpl, 0xa7f9(%rip)      # 0xc3a9
cmpl $0x2f, 0xa819(%rip)     # 0xc3d0
jne 0x1bbe
callq 0x2f42
cmpl $0x33, 0xa80b(%rip)     # 0xc3d0
jne 0x1be9
movq (%r14), %rdi
callq 0x31f0
movq %rax, 0xa7f2(%rip)      # 0xc3c8
movl %edx, 0xa7f4(%rip)      # 0xc3d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1726
jmp 0x1bf6
movl $0x2, %edi
movq %rbx, %rsi
callq 0x42c8
cmpl $0x2f, 0xa7d3(%rip)     # 0xc3d0
jne 0x1c12
movb $0x1, 0xa7a5(%rip)      # 0xc3ab
callq 0x2f42
movb $0x0, 0xa799(%rip)      # 0xc3ab
cmpl $0x1c, 0xa7b7(%rip)     # 0xc3d0
jne 0x1c40
movq (%r14), %rdi
callq 0x31f0
movq %rax, 0xa79e(%rip)      # 0xc3c8
movl %edx, 0xa7a0(%rip)      # 0xc3d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1726
jmp 0x1ac5
popq %rbx
popq %r14
popq %rbp
retq