// File: /workspace/github_cpp_makefile_star2_O3/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 $0x98, %rsp
movq %r9, -0x30(%rbp)
movl %r8d, -0x40(%rbp)
movl %ecx, %r12d
movl %edx, %r14d
movl %esi, %r15d
movq %rdi, %r13
callq 0x418c
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq %r13, %rdi
callq 0x423e
movq %rax, %rdi
callq 0x418c
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq %r13, %rdi
callq 0x418c
movq 0x10(%rax), %rax
movslq %r15d, %rbx
movq (%rax,%rbx,8), %rax
movq %rax, -0x50(%rbp)
movq %r13, %rdi
callq 0x423e
movq %rax, %rdi
callq 0x418c
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %rax
movq %rax, -0x60(%rbp)
movq %r13, %rdi
callq 0x418c
movq 0x88(%rax), %rax
movl %r14d, %ebx
movslq %r14d, %rcx
movq %rcx, -0x38(%rbp)
movq (%rax,%rcx,8), %rax
movl %r12d, -0x44(%rbp)
movslq %r12d, %r14
movq (%rax,%r14,8), %rax
movslq -0x40(%rbp), %r15
cmpl $0x1, (%rax,%r15,4)
jne 0xecff
cmpq $0x0, 0x8(%r13)
je 0xeddc
movq %r13, %rdi
callq 0x418c
movq 0x88(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%r14,8), %rax
cmpl $0x2, (%rax,%r15,4)
jne 0xed2c
cmpq $0x0, 0x10(%r13)
je 0xeddc
movq %r13, %rdi
callq 0x418c
movq 0x88(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%r14,8), %rax
cmpl $0x3, (%rax,%r15,4)
jne 0xed59
cmpq $0x0, 0x18(%r13)
je 0xeddc
movq %r13, %rdi
callq 0x418c
movq 0x88(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%r14,8), %rax
cmpl $0x4, (%rax,%r15,4)
jne 0xed82
cmpq $0x0, 0x20(%r13)
je 0xeddc
movq %r13, %rdi
callq 0x418c
movq 0x88(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%r14,8), %rax
cmpl $0x5, (%rax,%r15,4)
jne 0xedab
cmpq $0x0, 0x28(%r13)
je 0xeddc
movq %r13, %rdi
callq 0x418c
movq 0x88(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax,%r14,8), %rax
cmpl $0x6, (%rax,%r15,4)
jne 0xf1d0
cmpq $0x0, 0x30(%r13)
jne 0xf1d0
movq %r14, -0x58(%rbp)
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %edx
leaq 0x63fb(%rip), %rcx      # 0x151e8
movl (%rcx), %ecx
movl %ebx, %edi
subl %ecx, %edi
setne %sil
testb $0x1, %dil
sete %r8b
testb %r8b, %sil
movq -0x50(%rbp), %r10
jne 0xee18
leal (%rcx,%rcx), %esi
notl %esi
movl (%r10), %r8d
addl %esi, %r8d
cmpl %r8d, %edi
jne 0xee8c
movl -0x44(%rbp), %r14d
movl %r14d, %edi
subl %ecx, %edi
setne %sil
testb $0x1, %dil
sete %r8b
testb %r8b, %sil
movl -0x40(%rbp), %r11d
jne 0xee4b
leal (%rcx,%rcx), %esi
notl %esi
movl 0x4(%r10), %r8d
addl %esi, %r8d
cmpl %r8d, %edi
jne 0xef13
movl %r11d, %esi
subl %ecx, %esi
setne %dil
testb $0x1, %sil
sete %r8b
testb %r8b, %dil
jne 0xee72
leal (%rcx,%rcx), %edi
notl %edi
addl 0x8(%r10), %edi
cmpl %edi, %esi
jne 0xef4f
addl %ecx, %ebx
movl %ebx, %esi
shrl $0x1f, %esi
addl %ebx, %esi
sarl %esi
movq -0x30(%rbp), %r8
leal (%rsi,%r8), %edi
decl %edi
addl %r8d, %esi
jmp 0xeef4
movl -0x44(%rbp), %r14d
movl %r14d, %edi
subl %ecx, %edi
setne %r8b
testb $0x1, %dil
sete %r9b
testb %r9b, %r8b
movl -0x40(%rbp), %r11d
jne 0xeeba
movl 0x4(%r10), %r8d
addl %esi, %r8d
cmpl %r8d, %edi
jne 0xef6c
movl %r11d, %edi
subl %ecx, %edi
setne %r8b
testb $0x1, %dil
sete %r9b
testb %r9b, %r8b
jne 0xeedc
addl 0x8(%r10), %esi
cmpl %esi, %edi
jne 0xefda
addl %ecx, %ebx
movl %ebx, %edi
shrl $0x1f, %edi
addl %ebx, %edi
sarl %edi
movq -0x30(%rbp), %r8
leal (%rdi,%r8), %esi
incl %esi
addl %r8d, %edi
addl %ecx, %r14d
movl %r14d, %r8d
shrl $0x1f, %r8d
addl %r14d, %r8d
sarl %r8d
leal (%r8,%rdx), %r9d
decl %r9d
addl %edx, %r8d
jmp 0xefc0
movl %r11d, %edi
subl %ecx, %edi
setne %r8b
testb $0x1, %dil
sete %r9b
testb %r9b, %r8b
jne 0xef35
addl 0x8(%r10), %esi
cmpl %esi, %edi
jne 0xf00e
addl %ecx, %ebx
movl %ebx, %esi
shrl $0x1f, %esi
addl %ebx, %esi
sarl %esi
movq -0x30(%rbp), %r8
leal (%rsi,%r8), %edi
decl %edi
addl %r8d, %esi
jmp 0xefa6
addl %ecx, %ebx
movl %ebx, %esi
shrl $0x1f, %esi
addl %ebx, %esi
sarl %esi
movq -0x30(%rbp), %r8
leal (%rsi,%r8), %edi
decl %edi
addl %r8d, %esi
jmp 0xeff2
movl %r11d, %edi
subl %ecx, %edi
setne %r8b
testb $0x1, %dil
sete %r9b
testb %r9b, %r8b
jne 0xef8e
addl 0x8(%r10), %esi
cmpl %esi, %edi
jne 0xf028
addl %ecx, %ebx
movl %ebx, %edi
shrl $0x1f, %edi
addl %ebx, %edi
sarl %edi
movq -0x30(%rbp), %r8
leal (%rdi,%r8), %esi
incl %esi
addl %r8d, %edi
addl %ecx, %r14d
movl %r14d, %r9d
shrl $0x1f, %r9d
addl %r14d, %r9d
sarl %r9d
leal (%r9,%rdx), %r8d
incl %r8d
addl %edx, %r9d
addl %ecx, %r11d
movl %r11d, %ecx
shrl $0x1f, %ecx
addl %r11d, %ecx
sarl %ecx
leal (%rcx,%rax), %edx
decl %edx
addl %eax, %ecx
jmp 0xf06f
addl %ecx, %ebx
movl %ebx, %edi
shrl $0x1f, %edi
addl %ebx, %edi
sarl %edi
movq -0x30(%rbp), %r8
leal (%rdi,%r8), %esi
incl %esi
addl %r8d, %edi
addl %ecx, %r14d
movl %r14d, %r8d
shrl $0x1f, %r8d
addl %r14d, %r8d
sarl %r8d
leal (%r8,%rdx), %r9d
decl %r9d
addl %edx, %r8d
jmp 0xf05a
addl %ecx, %ebx
movl %ebx, %esi
shrl $0x1f, %esi
addl %ebx, %esi
sarl %esi
movq -0x30(%rbp), %r8
leal (%rsi,%r8), %edi
decl %edi
addl %r8d, %esi
jmp 0xf040
addl %ecx, %ebx
movl %ebx, %edi
shrl $0x1f, %edi
addl %ebx, %edi
sarl %edi
movq -0x30(%rbp), %r8
leal (%rdi,%r8), %esi
incl %esi
addl %r8d, %edi
addl %ecx, %r14d
movl %r14d, %r9d
shrl $0x1f, %r9d
addl %r14d, %r9d
sarl %r9d
leal (%r9,%rdx), %r8d
incl %r8d
addl %edx, %r9d
addl %ecx, %r11d
movl %r11d, %edx
shrl $0x1f, %edx
addl %r11d, %edx
sarl %edx
leal (%rdx,%rax), %ecx
incl %ecx
addl %eax, %edx
movslq %edi, %rax
movslq %esi, %rsi
movslq %r9d, %rdi
movslq %r8d, %r8
movq -0x68(%rbp), %r13
movq 0x20(%r13), %r9
movq -0x38(%rbp), %r12
movq (%r9,%r12,8), %r9
movq -0x58(%rbp), %rbx
movq (%r9,%rbx,8), %r9
movslq %edx, %rdx
movsd (%r9,%rdx,8), %xmm0
movsd %xmm0, -0x40(%rbp)
movslq %ecx, %rcx
movsd (%r9,%rcx,8), %xmm7
movq -0x60(%rbp), %r9
movq 0x10(%r9), %r9
movq (%r9,%rax,8), %r10
movq (%r10,%rdi,8), %r11
movsd (%r11,%rcx,8), %xmm8
movq (%r10,%r8,8), %r10
movsd (%r10,%rcx,8), %xmm9
movq (%r9,%rsi,8), %r9
movq (%r9,%rdi,8), %r14
movsd (%r14,%rcx,8), %xmm10
movq (%r9,%r8,8), %r9
movsd (%r9,%rcx,8), %xmm11
movsd (%r11,%rdx,8), %xmm12
movsd (%r10,%rdx,8), %xmm13
movsd (%r14,%rdx,8), %xmm14
movsd (%r9,%rdx,8), %xmm15
movq 0x10(%r13), %rcx
movq (%rcx,%rax,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r15,8), %xmm6
movq (%rcx,%rsi,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r15,8), %xmm1
movq -0x70(%rbp), %rdx
movq 0x10(%rdx), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r15,8), %xmm2
movq 0x18(%r13), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%rdi,8), %rcx
movsd (%rcx,%r15,8), %xmm3
movq (%rax,%r8,8), %rax
movsd (%rax,%r15,8), %xmm4
movq 0x18(%rdx), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r15,8), %xmm5
movq 0x20(%rdx), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r15,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 -0x40(%rbp), %xmm6
callq 0xeb30
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%rbx,8), %rax
movsd %xmm0, (%rax,%r15,8)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq