// File: /workspace/github_cpp_makefile_star2_O3/gioannides[P]Language_Processors/src/../include/ast/ast_node.hpp
// Function: DirectDeclarator::render_asm(std::basic_ofstream<char, std::char_traits<char>>&, Context&)
inline void DirectDeclarator::render_asm(std::ofstream& file,Context& contxt) {

			if(contxt.function  && round1_square2_closed3==1)
			{
				round1_square2_closed3=0;
			}
			if(round1_square2_closed3) 
			{
				

				if(round1_square2_closed3==1) //this is a  function declaration
				{
					round1_square2_closed3=0;
					contxt.function=true;	//we are in a function
					contxt.function_dec=true;	//we are declaring a function
					//contxt.funct_id=*(DirectDeclaratorPtr->IDENTIFIER);	
					DirectDeclaratorPtr->render_asm(file,contxt); //this will: contxt.funct_id=*IDENTIFIER
					round1_square2_closed3=0;
				}
				if(round1_square2_closed3==2)
				{
					if(ConstantExpRession!=NULL) //TODO: FINISH IT
					{
						contxt.LocalArray=true;
						ConstantExpRession->render_asm(file,contxt);
						contxt.LocalArray=false;
						if(contxt.ArraySize.size()){
							contxt.no_array_elements=contxt.ArraySize[contxt.ArraySize.size()-1];
							file << "\n#no_array_elements: " << contxt.no_array_elements << std::endl;
							contxt.ArraySize.pop_back();
							
						
						}
					}
					if(contxt.function && contxt.reading){
						contxt.totalStackArea+=(contxt.no_array_elements-1)*contxt.variable.word_size;
					}
					else{
						if(!contxt.reading){
						contxt.StackOffset += (contxt.no_array_elements-1)*contxt.variable.word_size;
						contxt.variable.offset = contxt.StackOffset-4;//contxt.variable.word_size;
						contxt.variable.offset = contxt.totalStackArea - contxt.variable.offset - 8; 
					}
				}
					DirectDeclaratorPtr->render_asm(file, contxt);
					
					if(!contxt.reading){
						round1_square2_closed3=0;				
					}
					//contxt.count_array_initializers=0;
					
				}
			}else if( DirectDeclaratorPtr != NULL) {
				//std::cout << "print this once" << std::endl; 
				DirectDeclaratorPtr->render_asm(file,contxt);
			}
			if( ParameterTypeLiSt != NULL) 
				{
					//std::cout << "go to parameter type list" << std::endl;
					ParameterTypeLiSt->render_asm(file,contxt);
				}
	
			if( IDENTIFIER != NULL && contxt.typedefs_){
				contxt.TypeDef.DummyName = *IDENTIFIER;
				return;

			}		
			
			
			if((!contxt.function && IDENTIFIER != NULL && !contxt.reading && !contxt.protect)) 			//if we are not in a function then this must be a global declaration
			{
				//std::cout << "it shouldn't be global!" << std::endl;
				contxt.variable.id = *IDENTIFIER;
				if( !contxt.initialized ) {				//if it is not initialized then set it to 0
					contxt.variable.value = 0;
				}
				contxt.variable.scope = "global";			//set the variable's scope as global to be saved in the bindings struct
				if(contxt.Variables.size()==0){
					contxt.Variables.push_back(contxt.variable);

				}
				else if(contxt.Variables.size()>0 && contxt.Variables[contxt.Variables.size()-1].id!=*IDENTIFIER)
				{	
					contxt.Variables.push_back(contxt.variable);
				}  
				//print_variables(contxt,file);
			}
			else if((contxt.function && IDENTIFIER != NULL && !contxt.reading)||contxt.parameter) //for parameters and local functions
			{		//if we are in a function and the identifier is not null and protect flag is off
				
				if( !contxt.protect && !contxt.parameter)// we only push the id of the functions that are defined 
				{				//then this is a function name we are reading					
					contxt.funct_id = *IDENTIFIER;		//obtain the scope we are currently in	
					contxt.Scopes.push_back(contxt.funct_id);
				}
				else
				{
					if(contxt.variable.StorageClass == "extern"){
						contxt.variable.scope = "global";
					}
					else{
						if(contxt.Scopes.size()>0){
							contxt.variable.scope = contxt.Scopes[contxt.Scopes.size()-1]; //assign the variable the scope it is in
						}
						
					}
					contxt.variable.id = *IDENTIFIER;	//if the portect flag is on then we are already inside the function , not reading the function name
					if( !contxt.initialized ) 
					{			//if the local declaration is not initialized, set it to 0
						contxt.variable.value = 0;
					}
					contxt.Variables.push_back(contxt.variable);
				}
			}
				int found_local = 0;	
				int good_index = 0;		//this will determine whether the variable wanted is a global or a local
				int i, j;				//must initialize the index i outside so it is accessible throughout here
				if(contxt.Variables.size()>0&&contxt.Scopes.size()>0)
				{
					for (j=contxt.Scopes.size()-1; j>=0; j--)
					{
						for(i=contxt.Variables.size()-1; i>=0; i--) {
							if(contxt.Variables[i].scope == contxt.Scopes[j] && IDENTIFIER!=NULL && *IDENTIFIER == contxt.Variables[i].id) 
							{
								good_index = i;
								contxt.good_i = good_index;
								found_local = 1;		//means that we found a local variable in the function of that name												good_index=i;
								i = -1;
								j = -1;						
							}
						}
					}
				}
				if(!found_local) 
				{
					for(i=0; i<contxt.Variables.size(); i++) 
					{
						if(contxt.Variables[i].scope == "global" && IDENTIFIER!=NULL && *IDENTIFIER == contxt.Variables[i].id) 
						{
							found_local=2;
							good_index = i;
							contxt.good_i = good_index;
							i = contxt.Variables.size();
						}
					}
				}   	
				if(contxt.lhs_of_assignment  && !contxt.reading && contxt.function){
					if(found_local==1) 
					{ //local
						if(contxt.initialized)
						{
							store_locals(contxt, file, good_index);
						}
						else 
						{
							if(contxt.Variables[good_index].word_size==1)
							{
								file << std::endl << "\tsb\t$0, " << contxt.Variables[good_index].offset << "($sp) #" << contxt.Variables[good_index].id << "\n";
							}
							else if( contxt.Variables[good_index].word_size==4 && !contxt.float_)
							{
								file << std::endl << "\tsw\t$0, " << contxt.Variables[good_index].offset << "($sp) #" << contxt.Variables[good_index].id << "\n"; 
							}
							else if( contxt.Variables[good_index].word_size==2 && !contxt.float_)
							{
								file << std::endl << "\tsh\t$0, " << contxt.Variables[good_index].offset << "($sp) #" << contxt.Variables[good_index].id << "\n"; 
							}
							else if( contxt.Variables[good_index].word_size==4 && contxt.float_)
							{
								file << std::endl << "\tswc1\t$0, " << contxt.Variables[good_index].offset << "($sp) #" << contxt.Variables[good_index].id << "\n"; 
							}
							
						}
					}
					else if(found_local==2) 
					{ //global
						store_globals(contxt, file, good_index);
					}	
								
					else
					{
						if(IDENTIFIER!=NULL){
							file << std::endl << "#VARIABLE : " << *IDENTIFIER << "NOT DECLARED!!!\n";
						}
					}
				}		
				

					

				
				
					
					/*else if( IDentifierList != NULL) {
						IDentifierList->render_asm(file);
					}*/

			

	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbp
movl 0x30(%rdi), %eax
cmpl $0x1, %eax
sete %cl
andb 0x218(%rdx), %cl
cmpb $0x1, %cl
jne 0x20743
movl $0x0, 0x30(%rbp)
movq 0x20(%rbp), %rdi
testq %rdi, %rdi
je 0x2089d
movq %r15, %rsi
movq %r14, %rdx
callq 0x206f4
jmp 0x2089d
testl %eax, %eax
je 0x20726
cmpl $0x2, %eax
je 0x20781
cmpl $0x1, %eax
jne 0x2089d
xorl %ebx, %ebx
movl %ebx, 0x30(%rbp)
movb $0x1, %al
movb %al, 0x218(%r14)
movb %al, 0x13e7c(%r14)
movq 0x20(%rbp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x206f4
movl %ebx, 0x30(%rbp)
jmp 0x2089d
movq 0x8(%rbp), %rax
testq %rax, %rax
je 0x20818
movb $0x1, 0x74(%r14)
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x207a7
movq %r15, %rsi
movq %r14, %rdx
callq 0xf9a2
movb $0x0, 0x74(%r14)
movq 0x80(%r14), %rax
cmpq 0x78(%r14), %rax
je 0x20818
movl -0x4(%rax), %eax
movl %eax, 0x13e8c(%r14)
leaq 0x173fa(%rip), %rsi     # 0x37bc4
movl $0x15, %edx
movq %r15, %rdi
callq 0x73a0
movl 0x13e8c(%r14), %esi
movq %r15, %rdi
callq 0x75c0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x7300
movsbl %al, %esi
movq %r12, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x7220
addq $-0x4, 0x80(%r14)
movb 0x21b(%r14), %al
cmpb $0x1, 0x218(%r14)
jne 0x20847
testb $0x1, %al
je 0x20847
movl 0x13e8c(%r14), %eax
decl %eax
imull 0x258(%r14), %eax
addl %eax, 0x308(%r14)
jmp 0x2087d
testb $0x1, %al
jne 0x2087d
movl 0x13e8c(%r14), %eax
decl %eax
imull 0x258(%r14), %eax
addl 0x30c(%r14), %eax
movl %eax, 0x30c(%r14)
movl 0x308(%r14), %ecx
subl %eax, %ecx
addl $-0x4, %ecx
movl %ecx, 0x2a8(%r14)
movq 0x20(%rbp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x206f4
cmpb $0x0, 0x21b(%r14)
jne 0x2089d
movl $0x0, 0x30(%rbp)
movq 0x10(%rbp), %rax
testq %rax, %rax
je 0x208d3
movl $0x0, 0x2a8(%r14)
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x208d3
movq %r15, %rsi
movq %r14, %rdx
callq 0x20f4a
movl 0x2a8(%r14), %eax
movl %eax, 0x418(%r14)
movq 0x38(%rbp), %rsi
testq %rsi, %rsi
je 0x20936
cmpb $0x1, 0x1d0(%r14)
jne 0x20903
addq $0x1b0, %r14            # imm = 0x1B0
movq %r14, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x71c0
cmpb $0x0, 0x218(%r14)
je 0x2091e
testq %rsi, %rsi
je 0x20936
cmpb $0x1, 0x21b(%r14)
je 0x20936
jmp 0x20944
cmpb $0x0, 0x21b(%r14)
jne 0x20936
cmpb $0x0, 0x21a(%r14)
je 0x20cb5
cmpb $0x1, 0x4a8(%r14)
jne 0x20a12
cmpb $0x0, 0x21a(%r14)
jne 0x2095c
cmpb $0x0, 0x4a8(%r14)
je 0x209f4
leaq 0x2d0(%r14), %rdi
leaq 0x16cbb(%rip), %rsi     # 0x37625
callq 0x70c0
testl %eax, %eax
je 0x20995
movq 0x468(%r14), %rsi
cmpq 0x460(%r14), %rsi
je 0x209b7
addq $-0x20, %rsi
leaq 0x288(%r14), %rdi
callq 0x71c0
jmp 0x209b7
leaq 0x288(%r14), %rdi
movq 0x290(%r14), %rdx
leaq 0x16cb4(%rip), %rcx     # 0x3765e
movl $0x6, %r8d
xorl %esi, %esi
callq 0x7520
leaq 0x258(%r14), %r12
movq 0x38(%rbp), %rsi
leaq 0x260(%r14), %rdi
callq 0x71c0
cmpb $0x0, 0x217(%r14)
jne 0x209e3
movq $0x0, 0x280(%r14)
leaq 0x240(%r14), %rdi
movq %r12, %rsi
callq 0x20f1a
jmp 0x20a12
leaq 0x220(%r14), %r12
movq %r12, %rdi
callq 0x71c0
leaq 0x460(%r14), %rdi
movq %r12, %rsi
callq 0xbcf4
movq %r15, 0x10(%rsp)
movq 0x240(%r14), %r13
movq 0x248(%r14), %rax
movq %rax, %rcx
subq %r13, %rcx
movq %rbp, 0x18(%rsp)
je 0x20c28
movq 0x460(%r14), %rdx
movq 0x468(%r14), %rsi
movq %rdx, 0x48(%rsp)
subq %rdx, %rsi
je 0x20b5c
shrq $0x5, %rsi
decl %esi
js 0x20b5c
movq %rax, 0x30(%rsp)
movq %r14, 0x20(%rsp)
sarq $0x4, %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rax # imm = 0x2E8BA2E8BA2E8BA3
imulq %rax, %rcx
movq %rcx, 0x40(%rsp)
leal -0x1(%rcx), %eax
movq 0x38(%rbp), %r14
movq %rax, 0x50(%rsp)
imulq $0xb0, %rax, %rax
addq %r13, %rax
addq $0x38, %rax
movq %rax, 0x38(%rsp)
movq %rsi, 0x28(%rsp)
cmpl $0x0, 0x50(%rsp)
js 0x20b3f
movl 0x28(%rsp), %eax
shlq $0x5, %rax
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax), %rdx
movq %rdx, 0x8(%rsp)
movq 0x8(%rcx,%rax), %rbx
movq 0x38(%rsp), %r15
movq 0x40(%rsp), %rax
movl %eax, %ebp
movq (%r15), %rdx
cmpq %rbx, %rdx
jne 0x20b32
testq %rdx, %rdx
je 0x20b06
testq %r14, %r14
sete %r12b
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq -0x8(%r15), %rdi
callq 0x7350
testl %eax, %eax
setne %al
orb %r12b, %al
je 0x20b0b
jmp 0x20b32
testq %r14, %r14
je 0x20b32
movq 0x8(%r14), %rdx
cmpq -0x28(%r15), %rdx
jne 0x20b32
testq %rdx, %rdx
je 0x20c34
movq -0x30(%r15), %rsi
movq (%r14), %rdi
callq 0x7350
testl %eax, %eax
je 0x20c34
decl %ebp
addq $-0xb0, %r15
testl %ebp, %ebp
jg 0x20ad5
movq 0x28(%rsp), %rsi
decl %esi
jns 0x20a9e
cmpq %r13, 0x30(%rsp)
movq 0x20(%rsp), %r14
je 0x20c28
xorl %eax, %eax
leaq 0x16af9(%rip), %r12     # 0x3765e
xorl %r15d, %r15d
xorl %ebp, %ebp
movl $0x0, 0x8(%rsp)
imulq $0xb0, %rax, %rbx
leaq (%rbx,%r13), %rdi
addq $0x30, %rdi
movq %r12, %rsi
callq 0x70c0
testl %eax, %eax
je 0x20bc0
movq 0x240(%r14), %r13
incl %r15d
movslq %r15d, %rax
movq 0x248(%r14), %rcx
subq %r13, %rcx
sarq $0x4, %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %rdx # imm = 0x2E8BA2E8BA2E8BA3
imulq %rdx, %rcx
cmpq %rax, %rcx
ja 0x20b72
jmp 0x20c4a
movq 0x18(%rsp), %rax
movq 0x38(%rax), %rax
movq 0x240(%r14), %r13
testq %rax, %rax
je 0x20b94
movq 0x8(%rax), %rdx
cmpq 0x10(%r13,%rbx), %rdx
jne 0x20b94
testq %rdx, %rdx
je 0x20bfc
leaq (%rbx,%r13), %rcx
addq $0x8, %rcx
movq (%rcx), %rsi
movq (%rax), %rdi
callq 0x7350
testl %eax, %eax
jne 0x20b94
movl %r15d, 0x5b4(%r14)
movq 0x248(%r14), %rax
subq %r13, %rax
shrq $0x4, %rax
movl %r15d, %ebp
imull $0xba2e8ba3, %eax, %r15d # imm = 0xBA2E8BA3
movl $0x2, 0x8(%rsp)
jmp 0x20b94
movl $0x0, 0x8(%rsp)
xorl %ebp, %ebp
jmp 0x20c4a
decl %ebp
movq 0x20(%rsp), %r14
movl %ebp, 0x5b4(%r14)
movl $0x1, 0x8(%rsp)
cmpb $0x1, 0x1d2(%r14)
jne 0x20e0e
cmpb $0x0, 0x21b(%r14)
jne 0x20e0e
cmpb $0x1, 0x218(%r14)
jne 0x20e0e
movl 0x8(%rsp), %eax
cmpl $0x2, %eax
je 0x20d56
cmpl $0x1, %eax
jne 0x20d73
cmpb $0x1, 0x217(%r14)
jne 0x20dcd
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl %ebp, %edx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1c13a
leaq 0x260(%r14), %rdi
callq 0x71c0
cmpb $0x0, 0x217(%r14)
jne 0x20cd6
movq $0x0, 0x280(%r14)
leaq 0x258(%r14), %r12
leaq 0x288(%r14), %rdi
movq 0x290(%r14), %rdx
leaq 0x1696c(%rip), %rcx     # 0x3765e
movl $0x6, %r8d
xorl %esi, %esi
callq 0x7520
leaq 0x240(%r14), %r13
movq 0x240(%r14), %rax
movq 0x248(%r14), %rdx
movq %rdx, %rcx
subq %rax, %rcx
je 0x20d4e
movq 0x38(%rbp), %rsi
movq -0xa0(%rdx), %rdx
cmpq 0x8(%rsi), %rdx
jne 0x20d4e
testq %rdx, %rdx
je 0x20a12
movq (%rsi), %rsi
movq -0xa8(%rax,%rcx), %rdi
callq 0x7350
testl %eax, %eax
je 0x20a12
movq %r13, %rdi
jmp 0x209ea
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl %ebp, %edx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1d118
movq 0x18(%rsp), %rax
cmpq $0x0, 0x38(%rax)
je 0x20e0e
movq 0x10(%rsp), %rdi
callq 0x7180
movq %rax, %rbx
leaq 0x16e69(%rip), %rsi     # 0x37c00
movl $0xc, %edx
movq %rax, %rdi
callq 0x73a0
movq 0x18(%rsp), %rax
movq 0x38(%rax), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0x73a0
leaq 0x16e4a(%rip), %rsi     # 0x37c0d
movl $0x10, %edx
jmp 0x20f04
movslq %ebp, %rax
imulq $0xb0, %rax, %r15
movl (%r13,%r15), %eax
cmpl $0x4, %eax
je 0x20e1d
cmpl $0x2, %eax
je 0x20e04
cmpl $0x1, %eax
jne 0x20e0e
movq 0x10(%rsp), %rdi
callq 0x7180
movq %r14, %rbx
movq %rax, %r14
leaq 0x16dd8(%rip), %rsi     # 0x37bda
jmp 0x20e5d
cmpb $0x0, 0x340(%r14)
je 0x20e46
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb 0x340(%r14), %bl
movq 0x10(%rsp), %rdi
callq 0x7180
movq %r14, %r12
movq %rax, %r14
testb %bl, %bl
je 0x20e9e
leaq 0x16db6(%rip), %rsi     # 0x37bf5
movl $0xa, %edx
jmp 0x20eaa
movq 0x10(%rsp), %rdi
callq 0x7180
movq %r14, %rbx
movq %rax, %r14
leaq 0x16d8f(%rip), %rsi     # 0x37bec
movl $0x8, %edx
movq %rax, %rdi
callq 0x73a0
movq 0x240(%rbx), %rax
movl 0x50(%rax,%r15), %esi
movq %r14, %rdi
callq 0x75c0
movq %rax, %r14
leaq 0x16b7d(%rip), %rsi     # 0x37a05
movl $0x7, %edx
movq %rax, %rdi
callq 0x73a0
movq 0x240(%rbx), %rax
jmp 0x20ee6
leaq 0x16d3e(%rip), %rsi     # 0x37be3
movl $0x8, %edx
movq %r14, %rdi
callq 0x73a0
movq 0x240(%r12), %rax
movl 0x50(%rax,%r15), %esi
movq %r14, %rdi
callq 0x75c0
movq %rax, %r14
leaq 0x16b34(%rip), %rsi     # 0x37a05
movl $0x7, %edx
movq %rax, %rdi
callq 0x73a0
movq 0x240(%r12), %rax
movq 0x8(%rax,%r15), %rsi
movq 0x10(%rax,%r15), %rdx
movq %r14, %rdi
callq 0x73a0
leaq 0x16d1d(%rip), %rsi     # 0x37c1c
movl $0x1, %edx
movq %rax, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x73a0