// File: /workspace/github_cpp_makefile_star2_O2/suhasjains[P]AMR-Solver/src/multigrid.cpp
// Function: amrsolver::prolongate_ghost_for_child(myOctree::Octree*, int, int, int, int, int, int, int)
void prolongate_ghost_for_child(Octree* node, int l, int i, int j, int k, int addx, int addy, int addz) {
	//indices
	int i0, i1, j0, j1, k0, k1;	
	

	//grid and parent's grid
	VecField* mesh = node->get_block_data()->mesh;
	VecField* meshp = node->get_parent()->get_block_data()->mesh; 

	//field and parent's field
       	Field *f = node->get_block_data()->scalarfields[l];
       	Field *fp = node->get_parent()->get_block_data()->scalarfields[l];


	if((node->get_block_data()->flag[i][j][k]==EAST_GHOST && node->neighbour[XDIR][RIGHT]==NULL)||
	   (node->get_block_data()->flag[i][j][k]==WEST_GHOST && node->neighbour[XDIR][LEFT]==NULL)||
	   (node->get_block_data()->flag[i][j][k]==NORTH_GHOST && node->neighbour[YDIR][RIGHT]==NULL)||
	   (node->get_block_data()->flag[i][j][k]==SOUTH_GHOST && node->neighbour[YDIR][LEFT]==NULL)||
	   (node->get_block_data()->flag[i][j][k]==TOP_GHOST && node->neighbour[ZDIR][RIGHT]==NULL)||
	   (node->get_block_data()->flag[i][j][k]==BOTTOM_GHOST && node->neighbour[ZDIR][LEFT]==NULL)) {
		if((((i-pad)%2==0)&&((i-pad)!=0))||((i-pad)==(f->Nx-1-2*pad))) {
			if((((j-pad)%2==0)&&((j-pad)!=0))||((j-pad)==(f->Ny-1-2*pad))) {
				if((((k-pad)%2==0)&&((k-pad)!=0))||((k-pad)==(f->Nz-1-2*pad))) {
					i0=addx+(i+pad)/2 - 1;
					i1=addx+(i+pad)/2;
					j0=addy+(j+pad)/2 - 1;
					j1=addy+(j+pad)/2;
					k0=addz+(k+pad)/2 - 1;
					k1=addz+(k+pad)/2;
					f->val[i][j][k] = Trilinear_interpolate(meshp->x[i0][j][k],meshp->x[i1][j][k],mesh->x[i][j][k], \
										meshp->y[i][j0][k],meshp->y[i][j1][k],mesh->y[i][j][k], \
										meshp->z[i][j][k0],meshp->z[i][j][k1],mesh->z[i][j][k], \
										fp->val[i0][j0][k1],fp->val[i0][j1][k1], \
										fp->val[i1][j0][k1],fp->val[i1][j1][k1], \
										fp->val[i0][j0][k0],fp->val[i0][j1][k0], \
										fp->val[i1][j0][k0],fp->val[i1][j1][k0]);
				}
				else if((((k-pad)%2!=0)&&((k-pad)!=(f->Nz-1-2*pad)))||((k-pad)==0)) {
					i0=addx+(i+pad)/2 - 1;
					i1=addx+(i+pad)/2;
					j0=addy+(j+pad)/2 - 1;
					j1=addy+(j+pad)/2;
					k0=addz+(k+pad)/2 ;
					k1=addz+(k+pad)/2 + 1;
					f->val[i][j][k] = Trilinear_interpolate(meshp->x[i0][j][k],meshp->x[i1][j][k],mesh->x[i][j][k], \
										meshp->y[i][j0][k],meshp->y[i][j1][k],mesh->y[i][j][k], \
										meshp->z[i][j][k0],meshp->z[i][j][k1],mesh->z[i][j][k], \
										fp->val[i0][j0][k1],fp->val[i0][j1][k1], \
										fp->val[i1][j0][k1],fp->val[i1][j1][k1], \
										fp->val[i0][j0][k0],fp->val[i0][j1][k0], \
										fp->val[i1][j0][k0],fp->val[i1][j1][k0]);
				}
			}
			else if((((j-pad)%2!=0)&&((j-pad)!=(f->Ny-1-2*pad)))||((j-pad)==0)) {
				if((((k-pad)%2==0)&&((k-pad)!=0))||((k-pad)==(f->Nz-1-2*pad))) {
					i0=addx+(i+pad)/2 - 1;
					i1=addx+(i+pad)/2;
					j0=addy+(j+pad)/2;
					j1=addy+(j+pad)/2 + 1;
					k0=addz+(k+pad)/2 - 1;
					k1=addz+(k+pad)/2;
					f->val[i][j][k] = Trilinear_interpolate(meshp->x[i0][j][k],meshp->x[i1][j][k],mesh->x[i][j][k], \
										meshp->y[i][j0][k],meshp->y[i][j1][k],mesh->y[i][j][k], \
										meshp->z[i][j][k0],meshp->z[i][j][k1],mesh->z[i][j][k], \
										fp->val[i0][j0][k1],fp->val[i0][j1][k1], \
										fp->val[i1][j0][k1],fp->val[i1][j1][k1], \
										fp->val[i0][j0][k0],fp->val[i0][j1][k0], \
										fp->val[i1][j0][k0],fp->val[i1][j1][k0]);
				}
				else if((((k-pad)%2!=0)&&((k-pad)!=(f->Nz-1-2*pad)))||((k-pad)==0)) {
					i0=addx+(i+pad)/2 - 1;
					i1=addx+(i+pad)/2;
					j0=addy+(j+pad)/2;
					j1=addy+(j+pad)/2 + 1;
					k0=addz+(k+pad)/2; 
					k1=addz+(k+pad)/2 + 1;
					f->val[i][j][k] = Trilinear_interpolate(meshp->x[i0][j][k],meshp->x[i1][j][k],mesh->x[i][j][k], \
										meshp->y[i][j0][k],meshp->y[i][j1][k],mesh->y[i][j][k], \
										meshp->z[i][j][k0],meshp->z[i][j][k1],mesh->z[i][j][k], \
										fp->val[i0][j0][k1],fp->val[i0][j1][k1], \
										fp->val[i1][j0][k1],fp->val[i1][j1][k1], \
										fp->val[i0][j0][k0],fp->val[i0][j1][k0], \
										fp->val[i1][j0][k0],fp->val[i1][j1][k0]);
				}
			}
		}
		else if((((i-pad)%2!=0)&&((i-pad)!=(f->Nx-1-2*pad)))||((i-pad)==0)) {
			if((((j-pad)%2==0)&&((j-pad)!=0))||((j-pad)==(f->Ny-1-2*pad))) {
				if((((k-pad)%2==0)&&((k-pad)!=0))||((k-pad)==(f->Nz-1-2*pad))) {
					i0=addx+(i+pad)/2; 
					i1=addx+(i+pad)/2 + 1;
					j0=addy+(j+pad)/2 - 1;
					j1=addy+(j+pad)/2;
					k0=addz+(k+pad)/2 - 1;
					k1=addz+(k+pad)/2;
					f->val[i][j][k] = Trilinear_interpolate(meshp->x[i0][j][k],meshp->x[i1][j][k],mesh->x[i][j][k], \
										meshp->y[i][j0][k],meshp->y[i][j1][k],mesh->y[i][j][k], \
										meshp->z[i][j][k0],meshp->z[i][j][k1],mesh->z[i][j][k], \
										fp->val[i0][j0][k1],fp->val[i0][j1][k1], \
										fp->val[i1][j0][k1],fp->val[i1][j1][k1], \
										fp->val[i0][j0][k0],fp->val[i0][j1][k0], \
										fp->val[i1][j0][k0],fp->val[i1][j1][k0]);
				}
				else if((((k-pad)%2!=0)&&((k-pad)!=(f->Nz-1-2*pad)))||((k-pad)==0)) {
					i0=addx+(i+pad)/2; 
					i1=addx+(i+pad)/2 + 1;
					j0=addy+(j+pad)/2 - 1;
					j1=addy+(j+pad)/2;
					k0=addz+(k+pad)/2; 
					k1=addz+(k+pad)/2 + 1;
					f->val[i][j][k] = Trilinear_interpolate(meshp->x[i0][j][k],meshp->x[i1][j][k],mesh->x[i][j][k], \
										meshp->y[i][j0][k],meshp->y[i][j1][k],mesh->y[i][j][k], \
										meshp->z[i][j][k0],meshp->z[i][j][k1],mesh->z[i][j][k], \
										fp->val[i0][j0][k1],fp->val[i0][j1][k1], \
										fp->val[i1][j0][k1],fp->val[i1][j1][k1], \
										fp->val[i0][j0][k0],fp->val[i0][j1][k0], \
										fp->val[i1][j0][k0],fp->val[i1][j1][k0]);
				}
			}
			else if((((j-pad)%2!=0)&&((j-pad)!=(f->Ny-1-2*pad)))||((j-pad)==0)) {
				if((((k-pad)%2==0)&&((k-pad)!=0))||((k-pad)==(f->Nz-1-2*pad))) {
					i0=addx+(i+pad)/2; 
					i1=addx+(i+pad)/2 + 1;
					j0=addy+(j+pad)/2; 
					j1=addy+(j+pad)/2 + 1;
					k0=addz+(k+pad)/2 - 1;
					k1=addz+(k+pad)/2;
					f->val[i][j][k] = Trilinear_interpolate(meshp->x[i0][j][k],meshp->x[i1][j][k],mesh->x[i][j][k], \
										meshp->y[i][j0][k],meshp->y[i][j1][k],mesh->y[i][j][k], \
										meshp->z[i][j][k0],meshp->z[i][j][k1],mesh->z[i][j][k], \
										fp->val[i0][j0][k1],fp->val[i0][j1][k1], \
										fp->val[i1][j0][k1],fp->val[i1][j1][k1], \
										fp->val[i0][j0][k0],fp->val[i0][j1][k0], \
										fp->val[i1][j0][k0],fp->val[i1][j1][k0]);
				}
				else if((((k-pad)%2!=0)&&((k-pad)!=(f->Nz-1-2*pad)))||((k-pad)==0)) {
					i0=addx+(i+pad)/2; 
					i1=addx+(i+pad)/2 + 1;
					j0=addy+(j+pad)/2; 
					j1=addy+(j+pad)/2 + 1;
					k0=addz+(k+pad)/2; 
					k1=addz+(k+pad)/2 + 1;
					f->val[i][j][k] = Trilinear_interpolate(meshp->x[i0][j][k],meshp->x[i1][j][k],mesh->x[i][j][k], \
										meshp->y[i][j0][k],meshp->y[i][j1][k],mesh->y[i][j][k], \
										meshp->z[i][j][k0],meshp->z[i][j][k1],mesh->z[i][j][k], \
										fp->val[i0][j0][k1],fp->val[i0][j1][k1], \
										fp->val[i1][j0][k1],fp->val[i1][j1][k1], \
										fp->val[i0][j0][k0],fp->val[i0][j1][k0], \
										fp->val[i1][j0][k0],fp->val[i1][j1][k0]);
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, -0x40(%rbp)
movl %r8d, -0x38(%rbp)
movl %ecx, %r12d
movl %edx, %r14d
movl %esi, %r15d
movq %rdi, %r13
callq 0x3db0
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq %r13, %rdi
callq 0x3e5e
movq %rax, %rdi
callq 0x3db0
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq %r13, %rdi
callq 0x3db0
movq 0x10(%rax), %rax
movslq %r15d, %rbx
movq (%rax,%rbx,8), %rax
movq %rax, -0x48(%rbp)
movq %r13, %rdi
callq 0x3e5e
movq %rax, %rdi
callq 0x3db0
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %rax
movq %rax, -0x50(%rbp)
movq %r13, %rdi
callq 0x3db0
movq 0x88(%rax), %rax
movl %r14d, %r15d
movslq %r14d, %rcx
movq (%rax,%rcx,8), %rax
movl %r12d, -0x2c(%rbp)
movslq %r12d, %rbx
movq %rcx, %r12
movq (%rax,%rbx,8), %rax
movslq -0x38(%rbp), %r14
cmpl $0x1, (%rax,%r14,4)
jne 0xca86
cmpq $0x0, 0x8(%r13)
je 0xcb4b
movq %r13, %rdi
callq 0x3db0
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x2, (%rax,%r14,4)
jne 0xcaaf
cmpq $0x0, 0x10(%r13)
je 0xcb4b
movq %r13, %rdi
callq 0x3db0
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x3, (%rax,%r14,4)
jne 0xcad4
cmpq $0x0, 0x18(%r13)
je 0xcb4b
movq %r13, %rdi
callq 0x3db0
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x4, (%rax,%r14,4)
jne 0xcaf9
cmpq $0x0, 0x20(%r13)
je 0xcb4b
movq %r13, %rdi
callq 0x3db0
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x5, (%rax,%r14,4)
jne 0xcb1e
cmpq $0x0, 0x28(%r13)
je 0xcb4b
movq %r13, %rdi
callq 0x3db0
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%rbx,8), %rax
cmpl $0x6, (%rax,%r14,4)
jne 0xcf4a
cmpq $0x0, 0x30(%r13)
jne 0xcf4a
movl 0x18(%rbp), %ecx
movl 0x10(%rbp), %edi
leaq 0x6678(%rip), %rax      # 0x131d0
movl (%rax), %esi
movl %r15d, %edx
subl %esi, %edx
setne %r9b
testb $0x1, %dl
sete %r8b
testb %r8b, %r9b
jne 0xcb85
leal (%rsi,%rsi), %r10d
notl %r10d
movq -0x48(%rbp), %r8
movl (%r8), %r8d
addl %r10d, %r8d
cmpl %r8d, %edx
jne 0xcc01
movl -0x2c(%rbp), %edx
subl %esi, %edx
setne %r9b
testb $0x1, %dl
sete %r8b
testb %r8b, %r9b
jne 0xcbb5
leal (%rsi,%rsi), %r10d
notl %r10d
movq -0x48(%rbp), %r8
movl 0x4(%r8), %r8d
addl %r10d, %r8d
cmpl %r8d, %edx
jne 0xcc86
movl -0x38(%rbp), %r9d
subl %esi, %r9d
setne %dl
testb $0x1, %r9b
sete %r8b
testb %r8b, %dl
jne 0xcbe2
leal (%rsi,%rsi), %edx
notl %edx
movq -0x48(%rbp), %r8
addl 0x8(%r8), %edx
cmpl %edx, %r9d
jne 0xcccb
addl %esi, %r15d
pushq $0x2
popq %r13
movl %r15d, %eax
cltd
idivl %r13d
movq -0x40(%rbp), %rdx
leal (%rax,%rdx), %r8d
leal (%rax,%rdx), %r9d
decl %r9d
jmp 0xcc6d
movl -0x2c(%rbp), %edx
subl %esi, %edx
setne %r8b
testb $0x1, %dl
sete %r9b
testb %r9b, %r8b
jne 0xcc2a
movq -0x48(%rbp), %r8
movl 0x4(%r8), %r8d
addl %r10d, %r8d
cmpl %r8d, %edx
jne 0xcced
movl -0x38(%rbp), %edx
subl %esi, %edx
setne %r8b
testb $0x1, %dl
sete %r9b
testb %r9b, %r8b
jne 0xcc50
movq -0x48(%rbp), %r8
addl 0x8(%r8), %r10d
cmpl %r10d, %edx
jne 0xcd5a
addl %esi, %r15d
pushq $0x2
popq %r13
movl %r15d, %eax
cltd
idivl %r13d
movq -0x40(%rbp), %rdx
leal (%rax,%rdx), %r9d
leal (%rax,%rdx), %r8d
incl %r8d
movl -0x2c(%rbp), %eax
addl %esi, %eax
cltd
idivl %r13d
leal (%rax,%rdi), %r10d
leal (%rax,%rdi), %r11d
decl %r11d
jmp 0xcd44
movl -0x38(%rbp), %edx
subl %esi, %edx
setne %r8b
testb $0x1, %dl
sete %r9b
testb %r9b, %r8b
jne 0xccac
movq -0x48(%rbp), %r8
addl 0x8(%r8), %r10d
cmpl %r10d, %edx
jne 0xcd8d
addl %esi, %r15d
pushq $0x2
popq %r13
movl %r15d, %eax
cltd
idivl %r13d
movq -0x40(%rbp), %rdx
leal (%rax,%rdx), %r8d
leal (%rax,%rdx), %r9d
decl %r9d
jmp 0xcd30
addl %esi, %r15d
pushq $0x2
popq %r13
movl %r15d, %eax
cltd
idivl %r13d
movq -0x40(%rbp), %rdx
leal (%rax,%rdx), %r8d
leal (%rax,%rdx), %r9d
decl %r9d
jmp 0xcd77
movl -0x38(%rbp), %edx
subl %esi, %edx
setne %r8b
testb $0x1, %dl
sete %r9b
testb %r9b, %r8b
jne 0xcd13
movq -0x48(%rbp), %r8
addl 0x8(%r8), %r10d
cmpl %r10d, %edx
jne 0xcdac
addl %esi, %r15d
pushq $0x2
popq %r13
movl %r15d, %eax
cltd
idivl %r13d
movq -0x40(%rbp), %rdx
leal (%rax,%rdx), %r9d
leal (%rax,%rdx), %r8d
incl %r8d
movl -0x2c(%rbp), %eax
addl %esi, %eax
cltd
idivl %r13d
leal (%rax,%rdi), %r11d
leal (%rax,%rdi), %r10d
incl %r10d
movl -0x38(%rbp), %eax
addl %esi, %eax
cltd
idivl %r13d
leal (%rax,%rcx), %edx
leal (%rax,%rcx), %esi
decl %esi
jmp 0xcdee
addl %esi, %r15d
pushq $0x2
popq %r13
movl %r15d, %eax
cltd
idivl %r13d
movq -0x40(%rbp), %rdx
leal (%rax,%rdx), %r9d
leal (%rax,%rdx), %r8d
incl %r8d
movl -0x2c(%rbp), %eax
addl %esi, %eax
cltd
idivl %r13d
leal (%rax,%rdi), %r10d
leal (%rax,%rdi), %r11d
decl %r11d
jmp 0xcddd
addl %esi, %r15d
pushq $0x2
popq %r13
movl %r15d, %eax
cltd
idivl %r13d
movq -0x40(%rbp), %rdx
leal (%rax,%rdx), %r8d
leal (%rax,%rdx), %r9d
decl %r9d
jmp 0xcdc9
addl %esi, %r15d
pushq $0x2
popq %r13
movl %r15d, %eax
cltd
idivl %r13d
movq -0x40(%rbp), %rdx
leal (%rax,%rdx), %r9d
leal (%rax,%rdx), %r8d
incl %r8d
movl -0x2c(%rbp), %eax
addl %esi, %eax
cltd
idivl %r13d
leal (%rax,%rdi), %r11d
leal (%rax,%rdi), %r10d
incl %r10d
movl -0x38(%rbp), %eax
addl %esi, %eax
cltd
idivl %r13d
leal (%rax,%rcx), %esi
leal (%rax,%rcx), %edx
incl %edx
movslq %r9d, %rax
movslq %r8d, %rcx
movslq %r11d, %rdi
movslq %r10d, %r8
movq -0x58(%rbp), %r13
movq 0x20(%r13), %r9
movq (%r9,%r12,8), %r9
movq (%r9,%rbx,8), %r9
movslq %esi, %rsi
movsd (%r9,%rsi,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movslq %edx, %rdx
movsd (%r9,%rdx,8), %xmm7
movq -0x50(%rbp), %r9
movq 0x10(%r9), %r9
movq (%r9,%rax,8), %r10
movq (%r10,%rdi,8), %r11
movsd (%r11,%rdx,8), %xmm8
movq (%r10,%r8,8), %r10
movsd (%r10,%rdx,8), %xmm9
movq (%r9,%rcx,8), %r9
movq %r12, %r15
movq (%r9,%rdi,8), %r12
movsd (%r12,%rdx,8), %xmm10
movq (%r9,%r8,8), %r9
movsd (%r9,%rdx,8), %xmm11
movsd (%r11,%rsi,8), %xmm12
movsd (%r10,%rsi,8), %xmm13
movsd (%r12,%rsi,8), %xmm14
movsd (%r9,%rsi,8), %xmm15
movq 0x10(%r13), %rdx
movq (%rdx,%rax,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r14,8), %xmm6
movq (%rdx,%rcx,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r14,8), %xmm1
movq -0x60(%rbp), %rdx
movq 0x10(%rdx), %rax
movq (%rax,%r15,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r14,8), %xmm2
movq 0x18(%r13), %rax
movq (%rax,%r15,8), %rax
movq (%rax,%rdi,8), %rcx
movsd (%rcx,%r14,8), %xmm3
movq (%rax,%r8,8), %rax
movsd (%rax,%r14,8), %xmm4
movq 0x18(%rdx), %rax
movq (%rax,%r15,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r14,8), %xmm5
movq 0x20(%rdx), %rax
movq (%rax,%r15,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r14,8), %xmm0
movsd %xmm15, 0x40(%rsp)
movsd %xmm14, 0x38(%rsp)
movsd %xmm13, 0x30(%rsp)
movsd %xmm12, 0x28(%rsp)
movsd %xmm11, 0x20(%rsp)
movsd %xmm10, 0x18(%rsp)
movsd %xmm9, 0x10(%rsp)
movsd %xmm8, 0x8(%rsp)
movsd %xmm0, (%rsp)
movaps %xmm6, %xmm0
movsd -0x38(%rbp), %xmm6
callq 0xc8b8
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax,%r15,8), %rax
movq (%rax,%rbx,8), %rax
movsd %xmm0, (%rax,%r14,8)
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq