// File: Davidc2525[P]Leaf/parser/Parser.cpp
// Function: Parser::FuncDecl(LEAF::AST::NODEU*&)
void Parser::FuncDecl(ASTU&f_node) {
		int np=0; 
		bool extern_s = false;
		Obj *obj = new Obj();
		MetaData *fd = new MetaData();
		string * FName = new string("anonima_"); 
		FName->append(to_string(++cout_annon_func).c_str()); 
		string * Tipe = new string(""); 
		int anon = 1;
		if (la->kind == 28 /* "extern" */) {
			Get();
			extern_s = true;
		}
		Expect(29 /* "fun" */);
		cout << "; fun "; 
		if (la->kind == _name) {
			Get();
			anon=0; FName = new string(""); LexString(FName);  
		}
		if(anon==1){
		cout<<" anonima retorna "<<*Tipe<<" " ;
		}else{
		cout<<*FName<<" retorna "; 
		} 
		
		obj = symbol_table::insert(4,FName,new Struct()); 
		
		
		symbol_table::pushCurrMethod(obj); 
		symbol_table::openScope(); 
		
		
		if (la->kind == 15 /* "(" */) {
			Get();
			if (StartOf(4)) {
				VarDecl();
				np++;
				while (la->kind == 25 /* "," */) {
					Get();
					VarDecl();
					np++;
				}
			}
			Expect(16 /* ")" */);
		}
		if (StartOf(5)) {
			FuncDcl(fd);
		}
		Expect(24 /* ":" */);
		Expect(_name);
		Tipe = new string(""); LexString(Tipe); *last(fd->type) = *symbol_table::find(Tipe)->type; cout<<";"<< *Tipe << endl; 
		funcion(fd->type); dump(fd->type,1); 
		
		obj->type = fd->type;
		(*obj).nPars = np;
		if(extern_s){
			obj->_extern = true;
			//ss->add(obj->name);
		}
		
		f_node = func_decl(FName);
		set_obj(f_node,obj);
		
		
		
		cout<<";nPars "<<np<<endl;
		
		obj->nPars=np;;
		cout<<";nPars "<<obj->nPars<<endl;
		
		if (!extern_s) {
			StatementBLock(f_node);
		} else if (la->kind == 11 /* ";" */) {
			Get();
		} else SynErr(57);
		symbol_table::currMethod()->locals = symbol_table::curScope->locals;
		symbol_table::currMethod()->type->size = symbol_table::curScope->offset-8;
		
		symbol_table::popCurrMethod(); 
		symbol_table::closeScope(); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
movl $0x0, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
movl $0x48, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x88(%rbp)
callq 0x17930
jmp 0x148b7
movq -0x88(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x20, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x98(%rbp)
callq 0x17720
jmp 0x148e0
movq -0x98(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x20, %edi
callq 0x62e0
movq %rax, -0xa8(%rbp)
movq %rax, -0xb0(%rbp)
movb $0x1, -0x42(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x6500
movq -0xa8(%rbp), %rdi
movq -0xa0(%rbp), %rdx
leaq 0x20145(%rip), %rsi     # 0x34a71
callq 0xada0
jmp 0x14933
movb $0x0, -0x42(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x6340
movq -0xb0(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
movl 0x40(%rax), %esi
incl %esi
movl %esi, 0x40(%rax)
leaq -0x68(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0xae50
movq -0xc0(%rbp), %rdi
callq 0x6120
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x6540
jmp 0x14992
leaq -0x68(%rbp), %rdi
callq 0x6588
movl $0x20, %edi
callq 0x62e0
movq %rax, -0xd0(%rbp)
movq %rax, -0xd8(%rbp)
movb $0x1, -0x72(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x6500
movq -0xd0(%rbp), %rdi
movq -0xc8(%rbp), %rdx
leaq 0x21191(%rip), %rsi     # 0x35b6d
callq 0xada0
jmp 0x149e3
movb $0x0, -0x72(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x6340
movq -0xd8(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, -0x70(%rbp)
movl $0x1, -0x78(%rbp)
movq 0x30(%rax), %rax
cmpl $0x1c, (%rax)
jne 0x14aef
movq -0x90(%rbp), %rdi
callq 0x132b0
movb $0x1, -0x15(%rbp)
jmp 0x14aef
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x48, %esi
callq 0x62f0
jmp 0x1501c
movq -0x98(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x20, %esi
callq 0x62f0
jmp 0x1501c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x6340
testb $0x1, -0x42(%rbp)
jne 0x14a8c
jmp 0x14a9d
movq -0xb0(%rbp), %rdi
movl $0x20, %esi
callq 0x62f0
jmp 0x1501c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x6588
jmp 0x1501c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x6340
testb $0x1, -0x72(%rbp)
jne 0x14ad9
jmp 0x14aea
movq -0xd8(%rbp), %rdi
movl $0x20, %esi
callq 0x62f0
jmp 0x1501c
movq -0x90(%rbp), %rdi
movl $0x1d, %esi
callq 0x133a0
movq 0x354c9(%rip), %rdi     # 0x49fd0
leaq 0x1ff6c(%rip), %rsi     # 0x34a7a
callq 0x62c0
movq -0x90(%rbp), %rax
movq 0x30(%rax), %rax
cmpl $0x4, (%rax)
jne 0x14bdf
movq -0x90(%rbp), %rdi
callq 0x132b0
movl $0x0, -0x78(%rbp)
movl $0x20, %edi
callq 0x62e0
movq %rax, -0xe8(%rbp)
movq %rax, -0xf0(%rbp)
movb $0x1, -0x7a(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x6500
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x20ff2(%rip), %rsi     # 0x35b6d
callq 0xada0
jmp 0x14b82
movq -0xf0(%rbp), %rax
movb $0x0, -0x7a(%rbp)
movq %rax, -0x40(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x6340
movq -0x90(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x17810
jmp 0x14bdf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x6340
testb $0x1, -0x7a(%rbp)
jne 0x14bc9
jmp 0x14bda
movq -0xf0(%rbp), %rdi
movl $0x20, %esi
callq 0x62f0
jmp 0x1501c
cmpl $0x1, -0x78(%rbp)
jne 0x14c15
movq 0x353e4(%rip), %rdi     # 0x49fd0
leaq 0x1fe8e(%rip), %rsi     # 0x34a81
callq 0x62c0
movq %rax, %rdi
movq -0x70(%rbp), %rsi
callq 0x6280
movq %rax, %rdi
leaq 0x1fdeb(%rip), %rsi     # 0x349f9
callq 0x62c0
jmp 0x14c34
movq -0x40(%rbp), %rsi
movq 0x353b0(%rip), %rdi     # 0x49fd0
callq 0x6280
movq %rax, %rdi
leaq 0x1fe5a(%rip), %rsi     # 0x34a89
callq 0x62c0
movq -0x40(%rbp), %rax
movq %rax, -0x100(%rbp)
movl $0x30, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xf8(%rbp)
callq 0xcab0
jmp 0x14c5d
movq -0xf8(%rbp), %rdx
movq -0x100(%rbp), %rsi
movl $0x4, %edi
callq 0x1fed0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x20a30
callq 0x201a0
movq -0x90(%rbp), %rax
movq 0x30(%rax), %rax
cmpl $0xf, (%rax)
jne 0x14d3b
movq -0x90(%rbp), %rdi
callq 0x132b0
movq -0x90(%rbp), %rdi
movl $0x4, %esi
callq 0x13450
testb $0x1, %al
jne 0x14cbe
jmp 0x14d2a
movq -0x90(%rbp), %rdi
callq 0x15bd0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x90(%rbp), %rax
movq 0x30(%rax), %rax
cmpl $0x19, (%rax)
jne 0x14d28
movq -0x90(%rbp), %rdi
callq 0x132b0
movq -0x90(%rbp), %rdi
callq 0x15bd0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x14cd3
movq -0xf8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x30, %esi
callq 0x62f0
jmp 0x1501c
jmp 0x14d2a
movq -0x90(%rbp), %rdi
movl $0x10, %esi
callq 0x133a0
movq -0x90(%rbp), %rdi
movl $0x5, %esi
callq 0x13450
testb $0x1, %al
jne 0x14d52
jmp 0x14d62
movq -0x90(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x15c00
movq -0x90(%rbp), %rdi
movl $0x18, %esi
callq 0x133a0
movq -0x90(%rbp), %rdi
movl $0x4, %esi
callq 0x133a0
movl $0x20, %edi
callq 0x62e0
movq %rax, -0x110(%rbp)
movq %rax, -0x118(%rbp)
movb $0x1, -0x7c(%rbp)
leaq -0x7b(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x6500
movq -0x110(%rbp), %rdi
movq -0x108(%rbp), %rdx
leaq 0x20da8(%rip), %rsi     # 0x35b6d
callq 0xada0
jmp 0x14dcc
movq -0x118(%rbp), %rax
movb $0x0, -0x7c(%rbp)
movq %rax, -0x70(%rbp)
leaq -0x7b(%rbp), %rdi
callq 0x6340
movq -0x90(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x17810
movq -0x70(%rbp), %rdi
callq 0x20020
movq -0x90(%rbp), %rdi
movq 0x18(%rax), %rax
movq %rax, -0x120(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x178e0
movq -0x120(%rbp), %rsi
movq %rax, %rdi
movl $0x30, %edx
callq 0x6230
movq 0x35199(%rip), %rdi     # 0x49fd0
leaq 0x1fc55(%rip), %rsi     # 0x34a93
callq 0x62c0
movq %rax, %rdi
movq -0x70(%rbp), %rsi
callq 0x6280
movq %rax, %rdi
movq 0x35157(%rip), %rsi     # 0x49fb0
callq 0x6320
movq -0x90(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x17b50
movq -0x90(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
movl $0x1, %edx
callq 0x17670
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x38(%rax)
testb $0x1, -0x15(%rbp)
je 0x14ee8
movq -0x20(%rbp), %rax
movb $0x1, 0x28(%rax)
jmp 0x14ee8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x7b(%rbp), %rdi
callq 0x6340
testb $0x1, -0x7c(%rbp)
jne 0x14ed2
jmp 0x14ee3
movq -0x118(%rbp), %rdi
movl $0x20, %esi
callq 0x62f0
jmp 0x1501c
movq -0x40(%rbp), %rdi
callq 0xe230
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0xe300
movq 0x350be(%rip), %rdi     # 0x49fd0
leaq 0x1fb7c(%rip), %rsi     # 0x34a95
callq 0x62c0
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x64e0
movq %rax, %rdi
movq 0x3507d(%rip), %rsi     # 0x49fb0
callq 0x6320
movl -0x14(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x38(%rax)
movq 0x35087(%rip), %rdi     # 0x49fd0
leaq 0x1fb45(%rip), %rsi     # 0x34a95
callq 0x62c0
movq %rax, %rdi
movq -0x20(%rbp), %rax
movl 0x38(%rax), %esi
callq 0x64e0
movq %rax, %rdi
movq 0x35042(%rip), %rsi     # 0x49fb0
callq 0x6320
testb $0x1, -0x15(%rbp)
jne 0x14f8b
movq -0x90(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x15030
jmp 0x14fbc
movq -0x90(%rbp), %rax
movq 0x30(%rax), %rax
cmpl $0xb, (%rax)
jne 0x14fa9
movq -0x90(%rbp), %rdi
callq 0x132b0
jmp 0x14fba
movq -0x90(%rbp), %rdi
movl $0x39, %esi
callq 0x12be0
jmp 0x14fbc
leaq 0x3606d(%rip), %rax     # 0x4b030
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x130(%rbp)
callq 0x20a10
movq -0x130(%rbp), %rcx
movq %rcx, 0x40(%rax)
leaq 0x36048(%rip), %rax     # 0x4b030
movq (%rax), %rax
movl 0x10(%rax), %eax
subl $0x8, %eax
movl %eax, -0x124(%rbp)
callq 0x20a10
movl -0x124(%rbp), %ecx
movq 0x18(%rax), %rax
movl %ecx, 0xc(%rax)
callq 0x20a60
callq 0x20220
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x64f0
nopw %cs:(%rax,%rax)