// File: AndrewAlbert[P]Compiler-Theory/SourceCode/codeGenerator.cpp
// Function: codeGenerator::header()
void codeGenerator::header(){
	//Attach necessary header files for c program
	fprintf( oFile, "#include <stdio.h>\n" );
	fprintf( oFile, "#include <stdlib.h>\n" );
	fprintf( oFile, "#include <string.h>\n\n" );

	//Define the memory space attributes
	fprintf( oFile, "#define MM_SIZE %d\n", MM_SIZE );
	fprintf( oFile, "#define REG_SIZE %d\n", REG_SIZE );
	
	comment("Include runtime functions\n");
	
	fprintf( oFile, "extern void handleBoolOp( int val1, int val2 );\n" );
	fprintf( oFile, "extern int getBool();\n" );
	fprintf( oFile, "extern int getInteger();\n" );
	fprintf( oFile, "extern float getFloat();\n" );
	fprintf( oFile, "extern int getString();\n" );
	fprintf( oFile, "extern char getChar();\n\n" );
	fprintf( oFile, "extern void putBool( int val );\n" );
	fprintf( oFile, "extern void putInteger( int val );\n" );
	fprintf( oFile, "extern void putFloat( float val );\n" );
	fprintf( oFile, "extern void putString( char* str_ptr );\n" );
	fprintf( oFile, "extern void putChar( char val );\n\n" );

	//Create registers and stack
	fprintf( oFile, "int MM[MM_SIZE];\n" );
	fprintf( oFile, "int iReg[REG_SIZE];\n" );
	fprintf( oFile, "float fReg[REG_SIZE];\n" );
	fprintf( oFile, "int FP_reg;\n" );
	fprintf( oFile, "int SP_reg;\n" );
	fprintf( oFile, "int TP_reg;\n" );
	fprintf( oFile, "int HP_reg;\n" );
	fprintf( oFile, "char buffer[256];\n\n" );

	comment( "Begin program execution" );
	//Call to main for function
	fprintf( oFile, "int main( void ){\n" );
	
	//Declare registers
	comment("Allocated registers for stack operations");
	fprintf( oFile, "   FP_reg = 0;\n" );
	fprintf( oFile, "   SP_reg = 0;\n" );
	fprintf( oFile, "   TP_reg = 0;\n" );
	fprintf( oFile, "   HP_reg = MM_SIZE - 1;\n" );
	fprintf( oFile, "   goto BUILD_HEAP;\n\n" );
	
	// Add the runtime function inline code
	WriteRuntime();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0x308(%rax), %rdi
leaq 0xd6a6(%rip), %rsi      # 0x26d2e
xorl %eax, %eax
movb %al, -0x99(%rbp)
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0x99(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd692(%rip), %rsi      # 0x26d42
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0x99(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd687(%rip), %rsi      # 0x26d57
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0x99(%rbp), %al
movq 0x308(%rcx), %rdi
movl (%rcx), %edx
leaq 0xd67b(%rip), %rsi      # 0x26d6d
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0x99(%rbp), %al
movq 0x308(%rcx), %rdi
movl 0x4(%rcx), %edx
leaq 0xd66c(%rip), %rsi      # 0x26d81
callq 0x3380
leaq -0x29(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x3430
movq -0x98(%rbp), %rdx
leaq 0xd65e(%rip), %rsi      # 0x26d96
leaq -0x28(%rbp), %rdi
callq 0x62d0
jmp 0x19743
movq -0xa8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
movq %rsi, -0xc0(%rbp)
xorl %edx, %edx
movl %edx, -0xb8(%rbp)
callq 0x19bb0
movq -0xc0(%rbp), %rdi
callq 0x31a0
leaq -0x29(%rbp), %rdi
callq 0x32e0
movl -0xb8(%rbp), %eax
movq -0xa8(%rbp), %rcx
movq 0x308(%rcx), %rdi
leaq 0xd61f(%rip), %rsi      # 0x26db1
movb %al, -0xb1(%rbp)
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd62a(%rip), %rsi      # 0x26de2
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd621(%rip), %rsi      # 0x26df9
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd61b(%rip), %rsi      # 0x26e13
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd615(%rip), %rsi      # 0x26e2d
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd60e(%rip), %rsi      # 0x26e46
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd607(%rip), %rsi      # 0x26e5f
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd608(%rip), %rsi      # 0x26e80
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd60c(%rip), %rsi      # 0x26ea4
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd610(%rip), %rsi      # 0x26ec8
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd619(%rip), %rsi      # 0x26ef1
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd61c(%rip), %rsi      # 0x26f14
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd60e(%rip), %rsi      # 0x26f26
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd603(%rip), %rsi      # 0x26f3b
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd5fa(%rip), %rsi      # 0x26f52
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd5e7(%rip), %rsi      # 0x26f5f
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd5d4(%rip), %rsi      # 0x26f6c
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd5c1(%rip), %rsi      # 0x26f79
callq 0x3380
movq -0xa8(%rbp), %rcx
movb -0xb1(%rbp), %al
movq 0x308(%rcx), %rdi
leaq 0xd5ae(%rip), %rsi      # 0x26f86
callq 0x3380
leaq -0x61(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x3430
movq -0xb0(%rbp), %rdx
leaq 0xd59f(%rip), %rsi      # 0x26f9a
leaq -0x60(%rbp), %rdi
callq 0x62d0
jmp 0x19a06
movq -0xa8(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movq %rsi, -0xd8(%rbp)
xorl %edx, %edx
movl %edx, -0xcc(%rbp)
callq 0x19bb0
movq -0xd8(%rbp), %rdi
callq 0x31a0
leaq -0x61(%rbp), %rdi
callq 0x32e0
movq -0xa8(%rbp), %rcx
movl -0xcc(%rbp), %eax
movq 0x308(%rcx), %rdi
leaq 0xd55d(%rip), %rsi      # 0x26fb2
callq 0x3380
leaq -0x89(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x3430
movq -0xc8(%rbp), %rdx
leaq 0xd54a(%rip), %rsi      # 0x26fc5
leaq -0x88(%rbp), %rdi
callq 0x62d0
jmp 0x19a89
movq -0xa8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
xorl %edx, %edx
callq 0x19bb0
leaq -0x88(%rbp), %rdi
callq 0x31a0
leaq -0x89(%rbp), %rdi
callq 0x32e0
movq -0xa8(%rbp), %rax
movq 0x308(%rax), %rdi
leaq 0xd523(%rip), %rsi      # 0x26fee
movb $0x0, %al
callq 0x3380
movq -0xa8(%rbp), %rax
movq 0x308(%rax), %rdi
leaq 0xd517(%rip), %rsi      # 0x26ffe
movb $0x0, %al
callq 0x3380
movq -0xa8(%rbp), %rax
movq 0x308(%rax), %rdi
leaq 0xd50b(%rip), %rsi      # 0x2700e
movb $0x0, %al
callq 0x3380
movq -0xa8(%rbp), %rax
movq 0x308(%rax), %rdi
leaq 0xd4ff(%rip), %rsi      # 0x2701e
movb $0x0, %al
callq 0x3380
movq -0xa8(%rbp), %rax
movq 0x308(%rax), %rdi
leaq 0xd4fd(%rip), %rsi      # 0x27038
movb $0x0, %al
callq 0x3380
movq -0xa8(%rbp), %rdi
callq 0x19c70
addq $0xe0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x32e0
jmp 0x19b9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x32e0
jmp 0x19b9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x89(%rbp), %rdi
callq 0x32e0
movq -0x38(%rbp), %rdi
callq 0x3420
nopw %cs:(%rax,%rax)