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

	//grid and child's grid
	VecField* mesh = node->get_block_data()->mesh;
	VecField* meshc = child->get_block_data()->mesh; 

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

	//domain
	if(node->get_block_data()->flag[i][j][k]==DOMAIN) {
		std::cout << node->get_block_data()->flag[i][j][k] << std::endl;
		i0=addx+2*i-pad;
		i1=addx+2*i-pad+1;
		j0=addy+2*j-pad; 
		j1=addy+2*j-pad+1;
		k0=addz+2*k-pad;
		k1=addz+2*k-pad+1;
		result = Trilinear_interpolate(meshc->x[i0][j][k],meshc->x[i1][j][k],mesh->x[i][j][k], \
							meshc->y[i][j0][k],meshc->y[i][j1][k],mesh->y[i][j][k], \
							meshc->z[i][j][k0],meshc->z[i][j][k1],mesh->z[i][j][k], \
							fc->val[i0][j0][k1],fc->val[i0][j1][k1], \
							fc->val[i1][j0][k1],fc->val[i1][j1][k1], \
							fc->val[i0][j0][k0],fc->val[i0][j1][k0], \
							fc->val[i1][j0][k0],fc->val[i1][j1][k0]);
	}

	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %r9d, -0x30(%rbp)
movl %r8d, %r14d
movl %ecx, %r12d
movl %edx, %r13d
movq %rsi, %rbx
movq %rdi, %r15
callq 0x4064
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq %rbx, %rdi
callq 0x4064
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq %r15, %rdi
callq 0x4064
movslq %r13d, %r13
movq %rbx, %rdi
callq 0x4064
movq 0x10(%rax), %rax
movq (%rax,%r13,8), %rax
movq %rax, -0x48(%rbp)
movq %r15, %rdi
callq 0x4064
movslq %r12d, %r12
movslq %r14d, %r14
movslq -0x30(%rbp), %r13
movq %r15, %rdi
callq 0x4064
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%r14,8), %rax
movl (%rax,%r13,4), %esi
movq 0x571e(%rip), %rdi      # 0x14fd0
callq 0x2330
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2150
leal (%r12,%r12), %eax
addl 0x10(%rbp), %eax
leaq 0x58f1(%rip), %rcx      # 0x151e0
movl (%rcx), %edx
subl %edx, %eax
leal (%r14,%r14), %esi
addl 0x18(%rbp), %esi
subl %edx, %esi
leal (,%r13,2), %ecx
addl 0x20(%rbp), %ecx
subl %edx, %ecx
cltq
movq -0x38(%rbp), %r8
movq 0x10(%r8), %rdx
movq 0x18(%r8), %rdi
movq %r8, %r10
movq (%rdx,%rax,8), %r8
movq 0x8(%rdx,%rax,8), %rdx
movq (%r8,%r14,8), %r8
movsd (%r8,%r13,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq (%rdx,%r14,8), %rdx
movsd (%rdx,%r13,8), %xmm1
movq -0x40(%rbp), %r9
movq 0x10(%r9), %rdx
movq 0x18(%r9), %r8
movq (%rdx,%r12,8), %rdx
movq (%rdx,%r14,8), %rdx
movsd (%rdx,%r13,8), %xmm2
movq (%rdi,%r12,8), %rdx
movslq %esi, %rsi
movq (%rdx,%rsi,8), %rdi
movq 0x8(%rdx,%rsi,8), %rdx
movsd (%rdi,%r13,8), %xmm3
movsd (%rdx,%r13,8), %xmm4
movq (%r8,%r12,8), %rdx
movq (%rdx,%r14,8), %rdx
movsd (%rdx,%r13,8), %xmm5
movq 0x20(%r10), %rdx
movq (%rdx,%r12,8), %rdx
movq (%rdx,%r14,8), %rdx
movslq %ecx, %rcx
movsd (%rdx,%rcx,8), %xmm6
movsd 0x8(%rdx,%rcx,8), %xmm7
movq 0x20(%r9), %rdx
movq (%rdx,%r12,8), %rdx
movq (%rdx,%r14,8), %rdx
movsd (%rdx,%r13,8), %xmm8
movq -0x48(%rbp), %rdx
movq 0x10(%rdx), %rdx
movq (%rdx,%rax,8), %rdi
movq 0x8(%rdx,%rax,8), %rax
movq (%rdi,%rsi,8), %rdx
movq 0x8(%rdi,%rsi,8), %rdi
movsd (%rdx,%rcx,8), %xmm9
movsd 0x8(%rdx,%rcx,8), %xmm10
movsd (%rdi,%rcx,8), %xmm11
movsd 0x8(%rdi,%rcx,8), %xmm12
movq (%rax,%rsi,8), %rdx
movq 0x8(%rax,%rsi,8), %rax
movsd (%rdx,%rcx,8), %xmm13
movsd 0x8(%rdx,%rcx,8), %xmm14
movsd (%rax,%rcx,8), %xmm15
movsd 0x8(%rax,%rcx,8), %xmm0
movsd %xmm15, 0x40(%rsp)
movsd %xmm13, 0x38(%rsp)
movsd %xmm11, 0x30(%rsp)
movsd %xmm9, 0x28(%rsp)
movsd %xmm0, 0x20(%rsp)
movsd %xmm14, 0x18(%rsp)
movsd %xmm12, 0x10(%rsp)
movsd %xmm10, 0x8(%rsp)
movsd %xmm8, (%rsp)
movsd -0x30(%rbp), %xmm0
callq 0xeb24
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq