// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r13
cmpb $0x1, 0x218(%rdx)
jne 0x20e79
cmpl $0x1, 0x30(%r13)
jne 0x20e79
movl $0x0, 0x30(%r13)
movl 0x30(%r13), %eax
testl %eax, %eax
je 0x20f83
cmpl $0x1, %eax
jne 0x20eb3
xorl %ebx, %ebx
movl %ebx, 0x30(%r13)
movb $0x1, %al
movb %al, 0x218(%r14)
movb %al, 0x13e7c(%r14)
movq 0x20(%r13), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x20e4a
movl %ebx, 0x30(%r13)
cmpl $0x2, 0x30(%r13)
jne 0x20ff6
movq 0x8(%r13), %rax
testq %rax, %rax
je 0x20f55
movb $0x1, 0x74(%r14)
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x20ee4
movq %r15, %rsi
movq %r14, %rdx
callq 0x102a0
movb $0x0, 0x74(%r14)
movq 0x80(%r14), %rax
cmpq 0x78(%r14), %rax
je 0x20f55
movl -0x4(%rax), %eax
movl %eax, 0x13e8c(%r14)
leaq 0x16cbd(%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)
cmpb $0x1, 0x218(%r14)
jne 0x20f99
cmpb $0x1, 0x21b(%r14)
jne 0x20f99
movl 0x13e8c(%r14), %eax
decl %eax
imull 0x258(%r14), %eax
addl %eax, 0x308(%r14)
jmp 0x20fd5
movq 0x20(%r13), %rdi
testq %rdi, %rdi
je 0x20ff6
movq %r15, %rsi
movq %r14, %rdx
callq 0x20e4a
jmp 0x20ff6
cmpb $0x0, 0x21b(%r14)
jne 0x20fd5
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(%r13), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x20e4a
cmpb $0x0, 0x21b(%r14)
jne 0x20ff6
movl $0x0, 0x30(%r13)
movq 0x10(%r13), %rax
testq %rax, %rax
je 0x2102c
movl $0x0, 0x2a8(%r14)
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x2102c
movq %r15, %rsi
movq %r14, %rdx
callq 0x21698
movl 0x2a8(%r14), %eax
movl %eax, 0x418(%r14)
movq 0x38(%r13), %rsi
testq %rsi, %rsi
je 0x2105c
cmpb $0x1, 0x1d0(%r14)
jne 0x2105c
addq $0x1b0, %r14            # imm = 0x1B0
movq %r14, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x71c0
testq %rsi, %rsi
sete %cl
movb 0x218(%r14), %al
orb %al, %cl
movq %r13, 0x18(%rsp)
jne 0x2108a
cmpb $0x0, 0x21b(%r14)
jne 0x2108a
cmpb $0x0, 0x21a(%r14)
je 0x21412
testq %rsi, %rsi
sete %cl
xorb $0x1, %al
orb %cl, %al
movq %r14, %rbx
jne 0x210a2
cmpb $0x1, 0x21b(%rbx)
jne 0x210af
cmpb $0x1, 0x4a8(%rbx)
jne 0x21184
cmpb $0x0, 0x21a(%rbx)
jne 0x210c5
cmpb $0x0, 0x4a8(%rbx)
je 0x21166
leaq 0x2d0(%rbx), %rdi
leaq 0x16552(%rip), %rsi     # 0x37625
callq 0x70c0
testl %eax, %eax
je 0x21103
movq 0x468(%rbx), %rsi
cmpq 0x460(%rbx), %rsi
movq 0x18(%rsp), %r14
je 0x2112a
addq $-0x20, %rsi
leaq 0x288(%rbx), %rdi
callq 0x71c0
jmp 0x2112a
leaq 0x288(%rbx), %rdi
movq 0x290(%rbx), %rdx
leaq 0x16546(%rip), %rcx     # 0x3765e
movl $0x6, %r8d
xorl %esi, %esi
callq 0x7520
movq 0x18(%rsp), %r14
leaq 0x258(%rbx), %r12
movq 0x38(%r14), %rsi
leaq 0x260(%rbx), %rdi
callq 0x71c0
cmpb $0x0, 0x217(%rbx)
jne 0x21155
movq $0x0, 0x280(%rbx)
leaq 0x240(%rbx), %rdi
movq %r12, %rsi
callq 0x21668
jmp 0x21184
leaq 0x220(%rbx), %r12
movq %r12, %rdi
callq 0x71c0
leaq 0x460(%rbx), %rdi
movq %r12, %rsi
callq 0xc5f0
movq %r15, 0x10(%rsp)
movq 0x240(%rbx), %r12
movq 0x248(%rbx), %rcx
movabsq $0x2e8ba2e8ba2e8ba3, %r14 # imm = 0x2E8BA2E8BA2E8BA3
movb $0x1, %al
subq %r12, %rcx
movq %rbx, 0x28(%rsp)
je 0x212b7
movl $0x0, 0xc(%rsp)
movq 0x460(%rbx), %r13
movq 0x468(%rbx), %r15
subq %r13, %r15
je 0x212bf
shrq $0x5, %r15
decl %r15d
js 0x212bf
sarq $0x4, %rcx
imulq %r14, %rcx
decl %ecx
movl $0x0, 0xc(%rsp)
movl $0x0, 0x24(%rsp)
movq %rcx, 0x30(%rsp)
testl %ecx, %ecx
js 0x21295
movq 0x18(%rsp), %rax
movq 0x38(%rax), %rbp
movl %ecx, %ebx
movl %ebx, %eax
imulq $0xb0, %rax, %r14
movslq %r15d, %rax
shlq $0x5, %rax
movq 0x38(%r12,%r14), %rdx
cmpq 0x8(%r13,%rax), %rdx
jne 0x2128d
addq %r12, %r14
testq %rdx, %rdx
je 0x21246
addq %r13, %rax
movq (%rax), %rsi
movq 0x30(%r14), %rdi
callq 0x7350
testl %eax, %eax
jne 0x2128d
testq %rbp, %rbp
je 0x2128d
movq 0x8(%rbp), %rdx
cmpq 0x10(%r14), %rdx
jne 0x2128d
testq %rdx, %rdx
je 0x2126b
movq 0x8(%r14), %rsi
movq (%rbp), %rdi
callq 0x7350
testl %eax, %eax
jne 0x2128d
movq 0x28(%rsp), %rax
movl %ebx, 0x5b4(%rax)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl $0x1, 0x24(%rsp)
movl %ebx, 0xc(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
decl %ebx
jns 0x2120f
decl %r15d
movq 0x30(%rsp), %rcx
jns 0x211fc
cmpl $0x0, 0x24(%rsp)
sete %al
movabsq $0x2e8ba2e8ba2e8ba3, %r14 # imm = 0x2E8BA2E8BA2E8BA3
jmp 0x212bf
movl $0x0, 0xc(%rsp)
movl $0x1, %ebp
testb %al, %al
je 0x213a0
movq 0x28(%rsp), %r13
movq 0x240(%r13), %rax
cmpq %rax, 0x248(%r13)
je 0x213a7
xorl %ecx, %ecx
leaq 0x16370(%rip), %r12     # 0x3765e
xorl %ebx, %ebx
xorl %ebp, %ebp
imulq $0xb0, %rcx, %r15
leaq (%rax,%r15), %rdi
addq $0x30, %rdi
movq %r12, %rsi
callq 0x70c0
testl %eax, %eax
jne 0x21377
movq 0x18(%rsp), %rax
movq 0x38(%rax), %rax
testq %rax, %rax
je 0x21377
movq 0x240(%r13), %r14
movq 0x8(%rax), %rdx
cmpq 0x10(%r14,%r15), %rdx
jne 0x2136d
testq %rdx, %rdx
je 0x21349
leaq (%r14,%r15), %rcx
addq $0x8, %rcx
movq (%rcx), %rsi
movq (%rax), %rdi
callq 0x7350
testl %eax, %eax
jne 0x2136d
movl %ebx, 0x5b4(%r13)
movq 0x248(%r13), %rax
subq %r14, %rax
shrq $0x4, %rax
movl %ebx, 0xc(%rsp)
imull $0xba2e8ba3, %eax, %ebx # imm = 0xBA2E8BA3
movl $0x2, %ebp
movabsq $0x2e8ba2e8ba2e8ba3, %r14 # imm = 0x2E8BA2E8BA2E8BA3
incl %ebx
movslq %ebx, %rcx
movq 0x240(%r13), %rax
movq 0x248(%r13), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
imulq %r14, %rdx
cmpq %rcx, %rdx
ja 0x212f2
jmp 0x213a9
movq 0x28(%rsp), %r13
jmp 0x213a9
xorl %ebp, %ebp
cmpb $0x1, 0x1d2(%r13)
jne 0x21626
cmpb $0x0, 0x21b(%r13)
jne 0x21626
cmpb $0x1, 0x218(%r13)
jne 0x21626
cmpl $0x2, %ebp
je 0x214bb
cmpl $0x1, %ebp
jne 0x214da
cmpb $0x1, 0x217(%r13)
jne 0x21534
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1c95e
leaq 0x260(%r14), %rdi
callq 0x71c0
cmpb $0x0, 0x217(%r14)
jne 0x21433
movq $0x0, 0x280(%r14)
leaq 0x258(%r14), %r12
leaq 0x288(%r14), %rdi
movq 0x290(%r14), %rdx
leaq 0x1620f(%rip), %rcx     # 0x3765e
movl $0x6, %r8d
xorl %esi, %esi
callq 0x7520
leaq 0x240(%r14), %r13
movq 0x240(%r14), %rax
movq %r14, %rbx
movq 0x248(%r14), %rdx
movq %rdx, %rcx
subq %rax, %rcx
je 0x214b3
movq 0x18(%rsp), %rsi
movq 0x38(%rsi), %rsi
movq -0xa0(%rdx), %rdx
cmpq 0x8(%rsi), %rdx
jne 0x214b3
testq %rdx, %rdx
je 0x21184
movq (%rsi), %rsi
movq -0xa8(%rax,%rcx), %rdi
callq 0x7350
testl %eax, %eax
je 0x21184
movq %r13, %rdi
jmp 0x2115c
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movl 0xc(%rsp), %edx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1d938
movq 0x18(%rsp), %rax
cmpq $0x0, 0x38(%rax)
je 0x21626
movq 0x10(%rsp), %rdi
callq 0x7180
movq %rax, %rbx
leaq 0x16702(%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 0x166e3(%rip), %rsi     # 0x37c0d
movl $0x10, %edx
jmp 0x215c5
movslq 0xc(%rsp), %rax
movq 0x240(%r13), %rcx
imulq $0xb0, %rax, %r15
movl (%rcx,%r15), %eax
cmpl $0x1, %eax
jne 0x215db
movq 0x10(%rsp), %rdi
callq 0x7180
movq %rax, %r14
leaq 0x16672(%rip), %rsi     # 0x37bda
movl $0x8, %edx
movq %rax, %rdi
callq 0x73a0
movq 0x240(%r13), %rax
movl 0x50(%rax,%r15), %esi
movq %r14, %rdi
callq 0x75c0
movq %rax, %r14
leaq 0x16472(%rip), %rsi     # 0x37a05
movl $0x7, %edx
movq %rax, %rdi
callq 0x73a0
movq 0x240(%r13), %rax
movq 0x8(%rax,%r15), %rsi
movq 0x10(%rax,%r15), %rdx
movq %r14, %rdi
callq 0x73a0
leaq 0x1665c(%rip), %rsi     # 0x37c1c
movl $0x1, %edx
movq %rax, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x73a0
cmpl $0x4, %eax
jne 0x215ea
cmpb $0x0, 0x340(%r13)
je 0x21635
cmpl $0x2, %eax
jne 0x215f9
cmpb $0x0, 0x340(%r13)
je 0x2164e
cmpl $0x4, %eax
jne 0x21626
cmpb $0x1, 0x340(%r13)
jne 0x21626
movq 0x10(%rsp), %rdi
callq 0x7180
movq %rax, %r14
leaq 0x165d9(%rip), %rsi     # 0x37bf5
movl $0xa, %edx
jmp 0x2156d
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rdi
callq 0x7180
movq %rax, %r14
leaq 0x1659a(%rip), %rsi     # 0x37be3
jmp 0x21568
movq 0x10(%rsp), %rdi
callq 0x7180
movq %rax, %r14
leaq 0x1658a(%rip), %rsi     # 0x37bec
jmp 0x21568
nop