// File: /workspace/github_c_makefile_star2_O3/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 0xa530(%rip), %r14      # 0xbfd8
leaq 0xa901(%rip), %rbx      # 0xc3b0
xorl %ebp, %ebp
cmpl $0x13, 0xa918(%rip)     # 0xc3d0
jne 0x1adc
movq (%r14), %rdi
callq 0x31f4
movq %rax, 0xa8ff(%rip)      # 0xc3c8
movl %edx, 0xa901(%rip)      # 0xc3d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1722
jmp 0x1ae9
movl $0x2, %edi
movq %rbx, %rsi
callq 0x42d0
cmpl $0x6, 0xa8e0(%rip)      # 0xc3d0
jne 0x1b14
movq (%r14), %rdi
callq 0x31f4
movq %rax, 0xa8c7(%rip)      # 0xc3c8
movl %edx, 0xa8c9(%rip)      # 0xc3d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1722
jmp 0x1b21
movl $0x2, %edi
movq %rbx, %rsi
callq 0x42d0
movl 0xa8a9(%rip), %eax      # 0xc3d0
cmpl $0x7, %eax
je 0x1b31
cmpl $0x13, %eax
jne 0x1b38
callq 0x2685
jmp 0x1b45
movl $0x2, %edi
movq %rbx, %rsi
callq 0x42d0
movl 0xa885(%rip), %eax      # 0xc3d0
cmpl $0x6, %eax
je 0x1b55
cmpl $0x34, %eax
jne 0x1b5c
callq 0x1c39
jmp 0x1b69
movl $0x2, %edi
movq %rbx, %rsi
callq 0x42d0
cmpb $0x0, 0xa83a(%rip)      # 0xc3aa
jne 0x1b88
cmpb $0x1, 0xa830(%rip)      # 0xc3a9
jne 0x1b88
movl $0x6, %edi
movq %rbx, %rsi
callq 0x42d0
decl 0xa81e(%rip)            # 0xc3ac
movb %bpl, 0xa815(%rip)      # 0xc3aa
movb %bpl, 0xa80d(%rip)      # 0xc3a9
movl 0xa82e(%rip), %eax      # 0xc3d0
cmpl $0x2f, %eax
jne 0x1bb2
callq 0x2f48
movl 0xa81e(%rip), %eax      # 0xc3d0
cmpl $0x33, %eax
jne 0x1bd9
movq (%r14), %rdi
callq 0x31f4
movq %rax, 0xa802(%rip)      # 0xc3c8
movl %edx, 0xa804(%rip)      # 0xc3d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1722
jmp 0x1be6
movl $0x2, %edi
movq %rbx, %rsi
callq 0x42d0
movl 0xa7e4(%rip), %eax      # 0xc3d0
cmpl $0x2f, %eax
jne 0x1c0a
movb $0x1, 0xa7b3(%rip)      # 0xc3ab
callq 0x2f48
movb $0x0, 0xa7a7(%rip)      # 0xc3ab
movl 0xa7c6(%rip), %eax      # 0xc3d0
cmpl $0x1c, %eax
jne 0x1c34
movq (%r14), %rdi
callq 0x31f4
movq %rax, 0xa7aa(%rip)      # 0xc3c8
movl %edx, 0xa7ac(%rip)      # 0xc3d0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1722
jmp 0x1ab1
popq %rbx
popq %r14
popq %rbp
retq