// File: /workspace/github_cpp_makefile_star2_O2/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 $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl 0x30(%rdi), %eax
cmpl $0x1, %eax
sete %cl
andb 0x218(%rdx), %cl
cmpb $0x1, %cl
jne 0x19c2d
andl $0x0, 0x30(%r15)
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0x19d3c
movq %r14, %rsi
movq %rbx, %rdx
callq 0x19be0
jmp 0x19d3c
testl %eax, %eax
je 0x19c10
cmpl $0x2, %eax
je 0x19c66
cmpl $0x1, %eax
jne 0x19d3c
andl $0x0, 0x30(%r15)
movb $0x1, %al
movb %al, 0x218(%rbx)
movb %al, 0x13e7c(%rbx)
movq 0x20(%r15), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x19be0
jmp 0x19d37
movq 0x8(%r15), %rdi
testq %rdi, %rdi
je 0x19cc5
movb $0x1, 0x74(%rbx)
movq %r14, %rsi
movq %rbx, %rdx
callq 0xd74c
movb $0x0, 0x74(%rbx)
movq 0x80(%rbx), %rax
cmpq 0x78(%rbx), %rax
je 0x19cc5
movl -0x4(%rax), %eax
movl %eax, 0x13e8c(%rbx)
leaq 0x13f2f(%rip), %rsi     # 0x2dbce
movq %r14, %rdi
callq 0x7310
movl 0x13e8c(%rbx), %esi
movq %rax, %rdi
callq 0x7590
movq %rax, %rdi
callq 0x7190
addq $-0x4, 0x80(%rbx)
movb 0x21b(%rbx), %al
cmpb $0x1, 0x218(%rbx)
jne 0x19cef
testb $0x1, %al
je 0x19cef
movl 0x13e8c(%rbx), %eax
decl %eax
imull 0x258(%rbx), %eax
addl %eax, 0x308(%rbx)
jmp 0x19d1f
testb $0x1, %al
jne 0x19d1f
movl 0x13e8c(%rbx), %eax
decl %eax
imull 0x258(%rbx), %eax
addl 0x30c(%rbx), %eax
movl %eax, 0x30c(%rbx)
movl 0x308(%rbx), %ecx
subl %eax, %ecx
addl $-0x4, %ecx
movl %ecx, 0x2a8(%rbx)
movq 0x20(%r15), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x19be0
cmpb $0x0, 0x21b(%rbx)
jne 0x19d3c
andl $0x0, 0x30(%r15)
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x19d50
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1a220
movq 0x38(%r15), %rsi
testq %rsi, %rsi
je 0x19dae
cmpb $0x1, 0x1d0(%rbx)
jne 0x19d7f
addq $0x1b0, %rbx            # imm = 0x1B0
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x71e0
cmpb $0x0, 0x218(%rbx)
je 0x19d98
testq %rsi, %rsi
je 0x19dae
cmpb $0x1, 0x21b(%rbx)
je 0x19dae
jmp 0x19dbb
cmpb $0x0, 0x21b(%rbx)
jne 0x19dae
cmpb $0x0, 0x21a(%rbx)
je 0x1a07e
cmpb $0x1, 0x4a8(%rbx)
jne 0x19e74
cmpb $0x0, 0x21a(%rbx)
jne 0x19dd1
cmpb $0x0, 0x4a8(%rbx)
je 0x19e56
leaq 0x2d0(%rbx), %rdi
leaq 0x13850(%rip), %rsi     # 0x2d62f
callq 0x820e
testb %al, %al
je 0x19dfd
leaq 0x288(%rbx), %rdi
leaq 0x13872(%rip), %rsi     # 0x2d668
callq 0x7630
jmp 0x19e1d
movq 0x468(%rbx), %rsi
cmpq 0x460(%rbx), %rsi
je 0x19e1d
addq $-0x20, %rsi
leaq 0x288(%rbx), %rdi
callq 0x71e0
leaq 0x258(%rbx), %r12
movq 0x38(%r15), %rsi
leaq 0x260(%rbx), %rdi
callq 0x71e0
cmpb $0x0, 0x217(%rbx)
jne 0x19e45
andq $0x0, 0x280(%rbx)
leaq 0x240(%rbx), %rdi
movq %r12, %rsi
callq 0x1a248
jmp 0x19e74
leaq 0x220(%rbx), %r12
movq %r12, %rdi
callq 0x71e0
leaq 0x460(%rbx), %rdi
movq %r12, %rsi
callq 0xab3c
movq %r14, 0x10(%rsp)
movq 0x248(%rbx), %rax
movl $0x0, 0xc(%rsp)
movl $0x0, 0x4(%rsp)
cmpq 0x240(%rbx), %rax
je 0x19f7f
movq 0x468(%rbx), %r14
movl $0x0, 0x4(%rsp)
subq 0x460(%rbx), %r14
je 0x19f7f
shrq $0x5, %r14
movl $0x0, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
decl %r14d
js 0x19f70
movq 0x248(%rbx), %rax
subq 0x240(%rbx), %rax
cqto
movl $0xb0, %ecx
idivq %rcx
movq %rax, %r12
movslq %r14d, %rbp
decl %r12d
shlq $0x5, %rbp
testl %r12d, %r12d
js 0x19ecd
movl %r12d, %eax
movq 0x240(%rbx), %rcx
imulq $0xb0, %rax, %r13
leaq (%rcx,%r13), %rdi
addq $0x30, %rdi
movq 0x460(%rbx), %rsi
addq %rbp, %rsi
callq 0xcbbb
testb %al, %al
je 0x19f4d
movq 0x38(%r15), %rdi
testq %rdi, %rdi
je 0x19f4d
movq 0x240(%rbx), %rax
leaq (%rax,%r13), %rsi
addq $0x8, %rsi
callq 0xcbbb
testb %al, %al
jne 0x19f52
decl %r12d
jmp 0x19efb
movl %r12d, 0x5b4(%rbx)
pushq $0x1
popq %rax
movl %eax, 0x8(%rsp)
movl %r12d, 0x4(%rsp)
pushq $-0x1
popq %rax
movl %eax, %r12d
movl %eax, %r14d
jmp 0x19ef1
cmpl $0x0, 0x8(%rsp)
je 0x19f7f
pushq $0x1
popq %rax
jmp 0x1a019
movl $0xb0, %r14d
leaq 0x136dc(%rip), %r12     # 0x2d668
xorl %ebp, %ebp
movslq %ebp, %rcx
movq 0x240(%rbx), %rsi
movq 0x248(%rbx), %rax
subq %rsi, %rax
cqto
idivq %r14
cmpq %rcx, %rax
jbe 0x1a015
imulq $0xb0, %rcx, %r13
leaq (%rsi,%r13), %rdi
addq $0x30, %rdi
movq %r12, %rsi
callq 0x820e
testb %al, %al
je 0x1a00e
movq 0x38(%r15), %rdi
testq %rdi, %rdi
je 0x1a00e
movq 0x240(%rbx), %rax
leaq (%rax,%r13), %rsi
addq $0x8, %rsi
callq 0xcbbb
testb %al, %al
je 0x1a00e
movl %ebp, 0x5b4(%rbx)
movq 0x248(%rbx), %rax
subq 0x240(%rbx), %rax
cqto
idivq %r14
pushq $0x2
popq %rcx
movl %ecx, 0xc(%rsp)
movl %ebp, 0x4(%rsp)
movl %eax, %ebp
incl %ebp
jmp 0x19f8e
movl 0xc(%rsp), %eax
cmpb $0x1, 0x1d2(%rbx)
movq 0x10(%rsp), %rsi
jne 0x1a17c
cmpb $0x0, 0x21b(%rbx)
jne 0x1a17c
cmpb $0x1, 0x218(%rbx)
jne 0x1a17c
cmpl $0x2, %eax
je 0x1a0ec
cmpl $0x1, %eax
jne 0x1a106
cmpb $0x1, 0x217(%rbx)
jne 0x1a13c
movq %rbx, %rdi
movl 0x4(%rsp), %edx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16fa4
leaq 0x260(%rbx), %rdi
callq 0x71e0
cmpb $0x0, 0x217(%rbx)
jne 0x1a09b
andq $0x0, 0x280(%rbx)
leaq 0x258(%rbx), %r12
leaq 0x288(%rbx), %rdi
leaq 0x135b8(%rip), %rsi     # 0x2d668
callq 0x7630
leaq 0x240(%rbx), %r13
movq 0x248(%rbx), %rdi
cmpq 0x240(%rbx), %rdi
je 0x1a0e4
addq $-0xa8, %rdi
movq 0x38(%r15), %rsi
callq 0x1a277
testb %al, %al
je 0x19e74
movq %r13, %rdi
jmp 0x19e4c
movq %rbx, %rdi
movl 0x4(%rsp), %edx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17971
cmpq $0x0, 0x38(%r15)
je 0x1a17c
movq %rsi, %rdi
callq 0x7190
leaq 0x13aee(%rip), %rsi     # 0x2dc0a
movq %rax, %rdi
callq 0x7310
movq 0x38(%r15), %rsi
movq %rax, %rdi
callq 0x72d0
leaq 0x13ae0(%rip), %rsi     # 0x2dc17
jmp 0x1a209
movslq 0x4(%rsp), %rax
movq 0x240(%rbx), %rcx
imulq $0xb0, %rax, %r15
movl (%rcx,%r15), %eax
cmpl $0x4, %eax
je 0x1a18b
cmpl $0x2, %eax
je 0x1a173
cmpl $0x1, %eax
jne 0x1a17c
movq %rsi, %rdi
callq 0x7190
leaq 0x13a73(%rip), %rsi     # 0x2dbe4
jmp 0x1a1c0
cmpb $0x0, 0x340(%rbx)
je 0x1a1a8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb 0x340(%rbx), %bpl
movq %rsi, %rdi
callq 0x7190
testb %bpl, %bpl
je 0x1a1b9
leaq 0x13a59(%rip), %rsi     # 0x2dbff
jmp 0x1a1c0
movq %rsi, %rdi
callq 0x7190
leaq 0x13a3f(%rip), %rsi     # 0x2dbf6
jmp 0x1a1c0
leaq 0x13a2d(%rip), %rsi     # 0x2dbed
movq %rax, %rdi
callq 0x7310
movq 0x240(%rbx), %rcx
movl 0x50(%rcx,%r15), %esi
movq %rax, %rdi
callq 0x7590
leaq 0x1382c(%rip), %rsi     # 0x2da0f
movq %rax, %rdi
callq 0x7310
movq 0x240(%rbx), %rcx
leaq (%rcx,%r15), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x72d0
leaq 0x13a1d(%rip), %rsi     # 0x2dc26
movq %rax, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7310
nop