// File: /workspace/github_cpp_makefile_star2_O3/suhasjains[P]AMR-Solver/src/octreegrid.cpp
// Function: myOctree::reassign_neighbours()
void reassign_neighbours() {

	for (unsigned level=0; level <= max_level; level++) {


		for (std::list<Octree*>::iterator iter = level_nodes[level].begin(), end = level_nodes[level].end(); iter != end; ++iter) { 
			//if it is not leaf node	
			if(!((*iter)->isLeafNode())) {
	
				//setting neighbours to children
			        for(int k=0; k<2; k++) {
			                for(int j=0; j<2; j++) {
			                        for(int i=0; i<2; i++) {
			
			                               // if(i==0) {
			                               //         if((*iter)->west != NULL)  (*iter)->get_child_at(i, j, k)->west = (*iter)->west->get_child_at(i+1, j, k);
			                               // }
			                               // if(j==0) {
			                               //         if((*iter)->south != NULL) (*iter)->get_child_at(i, j, k)->south = (*iter)->south->get_child_at(i, j+1, k);
			                               // }
			                               // if(k==0) {
			                               //         if((*iter)->bottom != NULL)	(*iter)->get_child_at(i, j, k)->bottom = (*iter)->bottom->get_child_at(i, j, k+1);
			                               // }
			                               // if(i==1) {
			                               //         if((*iter)->east != NULL)  (*iter)->get_child_at(i, j, k)->east = (*iter)->east->get_child_at(i-1, j, k);
			                               // }
			                               // if(j==1) {
			                               //         if((*iter)->north != NULL) (*iter)->get_child_at(i, j, k)->north = (*iter)->north->get_child_at(i, j-1, k);
			                               // }
			                               // if(k==1) {
			                               //         if((*iter)->top != NULL)   (*iter)->get_child_at(i, j, k)->top = (*iter)->top->get_child_at(i, j, k-1);
			                               // }
			                                if(i==0) {
			                                        if((*iter)->neighbour[XDIR][LEFT] != NULL)  (*iter)->get_child_at(i, j, k)->neighbour[XDIR][LEFT] = (*iter)->neighbour[XDIR][LEFT]->get_child_at(i+1, j, k);
			                                }
			                                if(j==0) {
			                                        if((*iter)->neighbour[YDIR][LEFT] != NULL) (*iter)->get_child_at(i, j, k)->neighbour[YDIR][LEFT] = (*iter)->neighbour[YDIR][LEFT]->get_child_at(i, j+1, k);
			                                }
			                                if(k==0) {
			                                        if((*iter)->neighbour[ZDIR][LEFT] != NULL)	(*iter)->get_child_at(i, j, k)->neighbour[ZDIR][LEFT] = (*iter)->neighbour[ZDIR][LEFT]->get_child_at(i, j, k+1);
			                                }
			                                if(i==1) {
			                                        if((*iter)->neighbour[XDIR][RIGHT] != NULL)  (*iter)->get_child_at(i, j, k)->neighbour[XDIR][RIGHT] = (*iter)->neighbour[XDIR][RIGHT]->get_child_at(i-1, j, k);
			                                }
			                                if(j==1) {
			                                        if((*iter)->neighbour[YDIR][RIGHT] != NULL) (*iter)->get_child_at(i, j, k)->neighbour[YDIR][RIGHT] = (*iter)->neighbour[YDIR][RIGHT]->get_child_at(i, j-1, k);
			                                }
			                                if(k==1) {
			                                        if((*iter)->neighbour[ZDIR][RIGHT] != NULL)   (*iter)->get_child_at(i, j, k)->neighbour[ZDIR][RIGHT] = (*iter)->neighbour[ZDIR][RIGHT]->get_child_at(i, j, k-1);
			                                }
			                        }
			                }
			        }
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
xorl %eax, %eax
movl %eax, -0x54(%rbp)
movl %eax, %eax
leaq (%rax,%rax,2), %rax
leaq 0x1200c(%rip), %rcx     # 0x15260
leaq (%rcx,%rax,8), %rax
movq (%rax), %r13
movq %rax, -0x60(%rbp)
cmpq %rax, %r13
je 0x34aa
movq 0x10(%r13), %rdi
callq 0x4168
testb %al, %al
jne 0x349c
movl $0x0, -0x44(%rbp)
movb $0x1, %al
movl %eax, -0x34(%rbp)
movl $0x0, -0x2c(%rbp)
movq %r13, -0x50(%rbp)
movb $0x1, %al
movl %eax, -0x38(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x30(%rbp)
xorl %r14d, %r14d
movb $0x1, %bl
xorl %r15d, %r15d
testb $0x1, %bl
je 0x32fa
movq 0x10(%r13), %rax
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x32fa
movl $0x1, %esi
movl -0x30(%rbp), %r12d
movl %r12d, %edx
movl -0x2c(%rbp), %r13d
movl %r13d, %ecx
callq 0x41ee
movq %rax, -0x40(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
xorl %esi, %esi
movl %r12d, %edx
movl %r13d, %ecx
movq -0x50(%rbp), %r13
callq 0x41ee
movq -0x40(%rbp), %rcx
movq %rcx, 0x10(%rax)
testb $0x1, -0x38(%rbp)
je 0x3341
movq 0x10(%r13), %rax
movq 0x20(%rax), %rdi
testq %rdi, %rdi
je 0x3341
movl %r15d, %esi
movl $0x1, %edx
movl -0x2c(%rbp), %r13d
movl %r13d, %ecx
callq 0x41ee
movq %rax, %r12
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdi
movl %r15d, %esi
xorl %edx, %edx
movl %r13d, %ecx
movq -0x50(%rbp), %r13
callq 0x41ee
movq %r12, 0x20(%rax)
testb $0x1, -0x34(%rbp)
je 0x3385
movq 0x10(%r13), %rax
movq 0x30(%rax), %rdi
testq %rdi, %rdi
je 0x3385
movl %r15d, %esi
movl -0x30(%rbp), %r12d
movl %r12d, %edx
movl $0x1, %ecx
callq 0x41ee
movq %rax, -0x40(%rbp)
movq 0x10(%r13), %rdi
movl %r15d, %esi
movl %r12d, %edx
xorl %ecx, %ecx
callq 0x41ee
movq -0x40(%rbp), %rcx
movq %rcx, 0x30(%rax)
testb $0x1, %r14b
je 0x33cd
movq 0x10(%r13), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x33cd
xorl %esi, %esi
movl -0x30(%rbp), %r12d
movl %r12d, %edx
movl -0x2c(%rbp), %r14d
movl %r14d, %ecx
callq 0x41ee
movq %rax, -0x40(%rbp)
movq 0x10(%r13), %rdi
movl $0x1, %esi
movl %r12d, %edx
movl %r14d, %ecx
callq 0x41ee
movq -0x40(%rbp), %rcx
movq %rcx, 0x8(%rax)
testb $0x1, -0x48(%rbp)
je 0x340c
movq 0x10(%r13), %rax
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x340c
movl %r15d, %esi
xorl %edx, %edx
movl -0x2c(%rbp), %r14d
movl %r14d, %ecx
callq 0x41ee
movq %rax, %r12
movq 0x10(%r13), %rdi
movl %r15d, %esi
movl $0x1, %edx
movl %r14d, %ecx
callq 0x41ee
movq %r12, 0x18(%rax)
testb $0x1, -0x44(%rbp)
je 0x344b
movq 0x10(%r13), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x344b
movl %r15d, %esi
movl -0x30(%rbp), %r14d
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x41ee
movq %rax, %r12
movq 0x10(%r13), %rdi
movl %r15d, %esi
movl %r14d, %edx
movl $0x1, %ecx
callq 0x41ee
movq %r12, 0x28(%rax)
movl $0x1, %r15d
movb $0x1, %r14b
testb $0x1, %bl
movl $0x0, %ebx
jne 0x32ab
movl $0x1, -0x30(%rbp)
movb $0x1, %al
movl %eax, -0x48(%rbp)
testb $0x1, -0x38(%rbp)
movl $0x0, -0x38(%rbp)
jne 0x32a3
movl $0x1, -0x2c(%rbp)
movb $0x1, %al
movl %eax, -0x44(%rbp)
testb $0x1, -0x34(%rbp)
movl $0x0, -0x34(%rbp)
jne 0x3290
movq (%r13), %r13
cmpq -0x60(%rbp), %r13
jne 0x3268
movl -0x54(%rbp), %eax
incl %eax
leaq 0x1216e(%rip), %rcx     # 0x15624
cmpl (%rcx), %eax
jbe 0x3244
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq