// File: /workspace/github_cpp_makefile_star2_O3/AndrewAlbert[P]Compiler-Theory/SourceCode/parser.cpp
// Function: Parser::ProcedureHeader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, scopeValue&, bool)
bool Parser::ProcedureHeader(string &id, scopeValue &procDeclaration, bool global){
	if( CheckToken(T_PROCEDURE) ){
		//Create new scope in nested symbol tables for the procedure
		Scopes->newScope();
		
		//Set the symbol table entry's type and size to the correct values for a procedure
		procDeclaration.type = TYPE_PROCEDURE;
		procDeclaration.size = 0;
		
		//get procedure identifier and set value to be added to the symbol table
		if( Identifier(id) ){
			Scopes->ChangeScopeName(id);
			
			// Get unique label from code generator and place at the start of the procedure
			procDeclaration.CallLabel = generator->newLabel( "Procedure_" + id );
			generator->placeLabel( procDeclaration.CallLabel );
		
			//get parameter list for the procedure, if it has parameters
			if( CheckToken(T_LPAREN) ){
				ParameterList(procDeclaration);
				if( !CheckToken(T_RPAREN) ) ReportLineError("Bad Line. Expected ')' after parameter list in procedure header");
				Scopes->addSymbol(id, procDeclaration, global);
				return true;
				
			}
			else{
				ReportFatalError("Expected '(' in procedure header before parameter list.");
				return true;
			}
		}
		else{
			ReportFatalError("Expected procedure identifier in procedure header.");
			return true;
		}
	}
	else return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
movl $0x106, %esi            # imm = 0x106
callq 0x5c08
movl %eax, %ebx
testb %al, %al
je 0x757b
movl %ebp, 0xc(%rsp)
movb %bl, 0xb(%rsp)
movq 0x90(%r15), %rdi
callq 0xfa5e
movq $0x11e, (%r14)          # imm = 0x11E
movq %r15, %rdi
movq %r12, %rsi
callq 0x6a76
testb %al, %al
je 0x758f
movq 0x90(%r15), %r13
leaq 0x80(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rbp
movq %rbp, %rdi
callq 0x3bac
movq %r13, %rdi
movq %rbp, %rsi
callq 0x101c4
movq 0x70(%rsp), %rdi
cmpq %rbx, %rdi
je 0x7363
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x98(%r15), %r13
leaq 0x123d3(%rip), %rsi     # 0x19744
leaq 0x90(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rdx
callq 0xdcc7
leaq 0xf0(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x15d26
leaq 0x20(%r14), %rdi
leaq 0xf0(%rsp), %r13
movq %r13, %rsi
callq 0x2270
movq (%r13), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x73cc
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x2200
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x73ed
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x98(%r15), %r13
leaq 0x60(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
callq 0x3bac
movq %r13, %rdi
movq %rbp, %rsi
callq 0x15fc6
movq 0x50(%rsp), %rdi
cmpq %rbx, %rdi
je 0x7437
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2200
movq %r15, %rdi
movl $0x12d, %esi            # imm = 0x12D
callq 0x5c08
testb %al, %al
je 0x75c5
movq %r15, %rdi
movq %r14, %rsi
callq 0x7cae
movq %r15, %rdi
movl $0x12e, %esi            # imm = 0x12E
callq 0x5c08
testb %al, %al
jne 0x74b3
leaq 0x40(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x122d7(%rip), %rsi     # 0x1974f
leaq 0x1230f(%rip), %rdx     # 0x1978e
leaq 0x30(%rsp), %r13
movq %r13, %rdi
callq 0x3c42
movq %r15, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x4e96
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x74b3
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2200
movq 0x90(%r15), %r13
leaq 0x20(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0x3bac
movq (%r14), %rax
leaq 0x118(%rsp), %r15
movq %rax, -0x8(%r15)
leaq 0x8(%r14), %rsi
movq %r15, %rdi
callq 0xdfee
leaq 0x130(%rsp), %rdi
leaq 0x140(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
callq 0x3bac
movq 0x40(%r14), %rax
leaq 0x110(%rsp), %rdx
movq %rax, 0x40(%rdx)
movzbl 0xc(%rsp), %ecx
leaq 0x10(%rsp), %rsi
movq %r13, %rdi
callq 0xfb86
movq 0x130(%rsp), %rdi
cmpq %r12, %rdi
je 0x7558
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x2200
movq %r15, %rdi
callq 0xdda4
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
movb 0xb(%rsp), %bl
je 0x757b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2200
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc0(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x12224(%rip), %rsi     # 0x197c7
leaq 0x1224f(%rip), %rdx     # 0x197f9
leaq 0xb0(%rsp), %rbx
movq %rbx, %rdi
callq 0x3c42
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4a02
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x121b6(%rip), %rsi     # 0x1978f
leaq 0x121e6(%rip), %rdx     # 0x197c6
leaq 0xd0(%rsp), %rbx
movq %rbx, %rdi
callq 0x3c42
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4a02
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x76d0
movq 0x40(%rsp), %rsi
jmp 0x76c8
movq %rax, %r14
leaq 0x110(%rsp), %rdi
callq 0xdd7a
jmp 0x7638
movq %rax, %r14
movq %r15, %rdi
callq 0xdda4
jmp 0x7638
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x76d0
movq 0x20(%rsp), %rsi
jmp 0x76c8
movq %rax, %r14
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x76d0
movq 0xe0(%rsp), %rsi
jmp 0x76c8
movq %rax, %r14
movq 0x50(%rsp), %rdi
cmpq %rbx, %rdi
je 0x76d0
movq 0x60(%rsp), %rsi
jmp 0x76c8
movq %rax, %r14
leaq 0xa0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x76d0
movq 0xa0(%rsp), %rsi
jmp 0x76c8
movq %rax, %r14
movq 0x70(%rsp), %rdi
cmpq %rbx, %rdi
je 0x76d0
movq 0x80(%rsp), %rsi
jmp 0x76c8
movq %rax, %r14
movq 0xb0(%rsp), %rdi
cmpq %r12, %rdi
je 0x76d0
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2200
movq %r14, %rdi
callq 0x2330