// File: /workspace/github_cpp_makefile_star2_O2/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 $0x18, %rsp
xorl %eax, %eax
leaq 0x1057e(%rip), %rcx     # 0x13604
cmpl (%rcx), %eax
ja 0x3267
movl %eax, -0x2c(%rbp)
movl %eax, %eax
imulq $0x18, %rax, %r14
leaq 0x101a2(%rip), %rax     # 0x13240
addq %rax, %r14
movq %r14, %rbx
movq %r14, -0x38(%rbp)
movq (%rbx), %rbx
cmpq %r14, %rbx
je 0x325d
movq 0x10(%rbx), %rdi
callq 0x3d8c
testb %al, %al
jne 0x30a8
xorl %r14d, %r14d
cmpl $0x2, %r14d
je 0x3254
xorl %r15d, %r15d
cmpl $0x2, %r15d
je 0x324c
xorl %r12d, %r12d
testl %r12d, %r12d
je 0x30ee
cmpl $0x2, %r12d
jne 0x3121
jmp 0x3244
movq 0x10(%rbx), %rax
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x3121
pushq $0x1
popq %rsi
movl %r15d, %edx
movl %r14d, %ecx
callq 0x3e12
movq %rax, %r13
movq 0x10(%rbx), %rdi
xorl %esi, %esi
movl %r15d, %edx
movl %r14d, %ecx
callq 0x3e12
movq %r13, 0x10(%rax)
testl %r15d, %r15d
jne 0x3159
movq 0x10(%rbx), %rax
movq 0x20(%rax), %rdi
testq %rdi, %rdi
je 0x3159
movl %r12d, %esi
pushq $0x1
popq %rdx
movl %r14d, %ecx
callq 0x3e12
movq %rax, %r13
movq 0x10(%rbx), %rdi
movl %r12d, %esi
xorl %edx, %edx
movl %r14d, %ecx
callq 0x3e12
movq %r13, 0x20(%rax)
testl %r14d, %r14d
jne 0x3191
movq 0x10(%rbx), %rax
movq 0x30(%rax), %rdi
testq %rdi, %rdi
je 0x3191
movl %r12d, %esi
movl %r15d, %edx
pushq $0x1
popq %rcx
callq 0x3e12
movq %rax, %r13
movq 0x10(%rbx), %rdi
movl %r12d, %esi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x3e12
movq %r13, 0x30(%rax)
cmpl $0x1, %r12d
jne 0x31ca
movq 0x10(%rbx), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x31ca
xorl %esi, %esi
movl %r15d, %edx
movl %r14d, %ecx
callq 0x3e12
movq %rax, %r13
movq 0x10(%rbx), %rdi
pushq $0x1
popq %rsi
movl %r15d, %edx
movl %r14d, %ecx
callq 0x3e12
movq %r13, 0x8(%rax)
cmpl $0x1, %r15d
jne 0x3203
movq 0x10(%rbx), %rax
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x3203
movl %r12d, %esi
xorl %edx, %edx
movl %r14d, %ecx
callq 0x3e12
movq %rax, %r13
movq 0x10(%rbx), %rdi
movl %r12d, %esi
pushq $0x1
popq %rdx
movl %r14d, %ecx
callq 0x3e12
movq %r13, 0x18(%rax)
cmpl $0x1, %r14d
jne 0x323c
movq 0x10(%rbx), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x323c
movl %r12d, %esi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x3e12
movq %rax, %r13
movq 0x10(%rbx), %rdi
movl %r12d, %esi
movl %r15d, %edx
pushq $0x1
popq %rcx
callq 0x3e12
movq %r13, 0x28(%rax)
incl %r12d
jmp 0x30de
incl %r15d
jmp 0x30d1
incl %r14d
jmp 0x30c4
movq -0x38(%rbp), %r14
jmp 0x30a8
movl -0x2c(%rbp), %eax
incl %eax
jmp 0x307f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq