// File: /workspace/github_cpp_makefile_star2_O1/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
movl %eax, -0x2c(%rbp)
movl %eax, %eax
leaq (%rax,%rax,2), %rax
leaq 0x11ffc(%rip), %rcx     # 0x15250
leaq (%rcx,%rax,8), %rax
movq (%rax), %r13
movq %rax, -0x38(%rbp)
cmpq %rax, %r13
je 0x340e
movq 0x10(%r13), %rdi
callq 0x4040
testb %al, %al
jne 0x3400
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r15d, %r15d
testl %r15d, %r15d
jne 0x32b9
movq 0x10(%r13), %rax
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x32b9
movl $0x1, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0x40c6
movq %rax, %r12
movq 0x10(%r13), %rdi
xorl %esi, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0x40c6
movq %r12, 0x10(%rax)
testl %r14d, %r14d
jne 0x32f1
movq 0x10(%r13), %rax
movq 0x20(%rax), %rdi
testq %rdi, %rdi
je 0x32f1
movl %r15d, %esi
movl $0x1, %edx
movl %ebx, %ecx
callq 0x40c6
movq %rax, %r12
movq 0x10(%r13), %rdi
movl %r15d, %esi
xorl %edx, %edx
movl %ebx, %ecx
callq 0x40c6
movq %r12, 0x20(%rax)
testl %ebx, %ebx
jne 0x332a
movq 0x10(%r13), %rax
movq 0x30(%rax), %rdi
testq %rdi, %rdi
je 0x332a
movl %r15d, %esi
movl %r14d, %edx
movl $0x1, %ecx
callq 0x40c6
movq %rax, %r12
movq 0x10(%r13), %rdi
movl %r15d, %esi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x40c6
movq %r12, 0x30(%rax)
cmpl $0x1, %r15d
jne 0x3363
movq 0x10(%r13), %rax
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x3363
xorl %esi, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0x40c6
movq %rax, %r12
movq 0x10(%r13), %rdi
movl $0x1, %esi
movl %r14d, %edx
movl %ebx, %ecx
callq 0x40c6
movq %r12, 0x8(%rax)
cmpl $0x1, %r14d
jne 0x339c
movq 0x10(%r13), %rax
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x339c
movl %r15d, %esi
xorl %edx, %edx
movl %ebx, %ecx
callq 0x40c6
movq %rax, %r12
movq 0x10(%r13), %rdi
movl %r15d, %esi
movl $0x1, %edx
movl %ebx, %ecx
callq 0x40c6
movq %r12, 0x18(%rax)
cmpl $0x1, %ebx
jne 0x33d6
movq 0x10(%r13), %rax
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x33d6
movl %r15d, %esi
movl %r14d, %edx
xorl %ecx, %ecx
callq 0x40c6
movq %rax, %r12
movq 0x10(%r13), %rdi
movl %r15d, %esi
movl %r14d, %edx
movl $0x1, %ecx
callq 0x40c6
movq %r12, 0x28(%rax)
incl %r15d
cmpl $0x1, %r15d
je 0x3281
leal 0x1(%r14), %eax
testl %r14d, %r14d
movl %eax, %r14d
je 0x327e
leal 0x1(%rbx), %eax
testl %ebx, %ebx
movl %eax, %ebx
je 0x327b
movq (%r13), %r13
cmpq -0x38(%rbp), %r13
jne 0x3268
movl -0x2c(%rbp), %eax
incl %eax
leaq 0x121fa(%rip), %rcx     # 0x15614
cmpl (%rcx), %eax
jbe 0x3244
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq