// File: suhasjains[P]AMR-Solver/src/multigrid.cpp
// Function: amrsolver::restrict_at(myOctree::Octree*, int, int, int, int)
double restrict_at(Octree* node, int l, int i, int j, int k) {
			
	//field and block
       	Field *f = node->get_block_data()->scalarfields[l];
       	Block *b = node->get_block_data();

	double result;

	if(i>=f->Nx/2) {
		if(j>=f->Ny/2) {
			if(k>=f->Nz/2) {
				result = restrict_from_child(node,node->get_child_at(1,1,1),l,i,j,k,-b->iNx,-b->iNy,-b->iNz);
			}
			else if(k<f->Nz/2) {
				result = restrict_from_child(node,node->get_child_at(1,1,0),l,i,j,k,-b->iNx,-b->iNy,0);
			}
		}
		else if(j<f->Ny/2) {
			if(k>=f->Nz/2) {
				result = restrict_from_child(node,node->get_child_at(1,0,1),l,i,j,k,-b->iNx,0,-b->iNz);
			}
			else if(k<f->Nz/2) {
				result = restrict_from_child(node,node->get_child_at(1,0,0),l,i,j,k,-b->iNx,0,0);
			}
		}
	}
	if(i<f->Nx/2) {
		if(j>=f->Ny/2) {
			if(k>=f->Nz/2) {
				result = restrict_from_child(node,node->get_child_at(0,1,1),l,i,j,k,0,-b->iNy,-b->iNz);
			}
			else if(k<f->Nz/2) {
				result = restrict_from_child(node,node->get_child_at(0,1,0),l,i,j,k,0,-b->iNy,0);
			}
		}
		else if(j<f->Ny/2) {
			if(k>=f->Nz/2) {
				result = restrict_from_child(node,node->get_child_at(0,0,1),l,i,j,k,0,0,-b->iNz);
			}
			else if(k<f->Nz/2) {
				result = restrict_from_child(node,node->get_child_at(0,0,0),l,i,j,k,0,0,0);
			}
		}
	}

	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0xd8, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6de0
movq 0x10(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6de0
movq %rax, -0x30(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x3c(%rbp), %eax
cmpl %ecx, %eax
jl 0x1f316
movl -0x1c(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x40(%rbp), %eax
cmpl %ecx, %eax
jl 0x1f1ee
movl -0x20(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x44(%rbp), %eax
cmpl %ecx, %eax
jl 0x1f164
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x6ee0
movq -0x50(%rbp), %rdi
movq %rax, %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
xorl %r11d, %r11d
leaq 0x75bb(%rip), %rax      # 0x266e8
subl (%rax), %r11d
xorl %r10d, %r10d
leaq 0x75b2(%rip), %rax      # 0x266ec
subl (%rax), %r10d
xorl %eax, %eax
leaq 0x75aa(%rip), %rbx      # 0x266f0
subl (%rbx), %eax
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x1ec30
movsd %xmm0, -0x38(%rbp)
jmp 0x1f1e9
movl -0x20(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x54(%rbp), %eax
cmpl %ecx, %eax
jge 0x1f1e7
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %edx
xorl %ecx, %ecx
movl %edx, %esi
callq 0x6ee0
movq -0x60(%rbp), %rdi
movq %rax, %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
xorl %r10d, %r10d
leaq 0x752d(%rip), %rax      # 0x266e8
subl (%rax), %r10d
xorl %eax, %eax
leaq 0x7525(%rip), %r11      # 0x266ec
subl (%r11), %eax
xorl %r11d, %r11d
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x1ec30
movsd %xmm0, -0x38(%rbp)
jmp 0x1f1e9
jmp 0x1f314
movl -0x1c(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x64(%rbp), %eax
cmpl %ecx, %eax
jge 0x1f312
movl -0x20(%rbp), %eax
movl %eax, -0x68(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x68(%rbp), %eax
cmpl %ecx, %eax
jl 0x1f295
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %ecx
xorl %edx, %edx
movl %ecx, %esi
callq 0x6ee0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
xorl %r10d, %r10d
leaq 0x7481(%rip), %rax      # 0x266e8
subl (%rax), %r10d
xorl %eax, %eax
leaq 0x747d(%rip), %r11      # 0x266f0
subl (%r11), %eax
xorl %r11d, %r11d
movl %r10d, (%rsp)
movl $0x0, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x1ec30
movsd %xmm0, -0x38(%rbp)
jmp 0x1f310
movl -0x20(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x74(%rbp), %eax
cmpl %ecx, %eax
jge 0x1f30e
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq 0x6ee0
movq -0x80(%rbp), %rdi
movq %rax, %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
xorl %eax, %eax
leaq 0x73fd(%rip), %r10      # 0x266e8
subl (%r10), %eax
xorl %r10d, %r10d
movl %eax, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x1ec30
movsd %xmm0, -0x38(%rbp)
jmp 0x1f310
jmp 0x1f312
jmp 0x1f314
jmp 0x1f316
movl -0x18(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x84(%rbp), %eax
cmpl %ecx, %eax
jge 0x1f5b5
movl -0x1c(%rbp), %eax
movl %eax, -0x88(%rbp)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x88(%rbp), %eax
cmpl %ecx, %eax
jl 0x1f485
movl -0x20(%rbp), %eax
movl %eax, -0x8c(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x8c(%rbp), %eax
cmpl %ecx, %eax
jl 0x1f3f9
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %ecx
movl %ecx, %edx
callq 0x6ee0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
xorl %r10d, %r10d
leaq 0x7324(%rip), %rax      # 0x266ec
subl (%rax), %r10d
xorl %eax, %eax
leaq 0x731c(%rip), %r11      # 0x266f0
subl (%r11), %eax
xorl %r11d, %r11d
movl $0x0, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x1ec30
movsd %xmm0, -0x38(%rbp)
jmp 0x1f480
movl -0x20(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x9c(%rbp), %eax
cmpl %ecx, %eax
jge 0x1f47e
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
xorl %ecx, %ecx
movl $0x1, %edx
movl %ecx, %esi
callq 0x6ee0
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
xorl %eax, %eax
leaq 0x7291(%rip), %r10      # 0x266ec
subl (%r10), %eax
xorl %r10d, %r10d
movl $0x0, (%rsp)
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x1ec30
movsd %xmm0, -0x38(%rbp)
jmp 0x1f480
jmp 0x1f5b3
movl -0x1c(%rbp), %eax
movl %eax, -0xac(%rbp)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xac(%rbp), %eax
cmpl %ecx, %eax
jge 0x1f5b1
movl -0x20(%rbp), %eax
movl %eax, -0xb0(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xb0(%rbp), %eax
cmpl %ecx, %eax
jl 0x1f534
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
movl %edx, %esi
callq 0x6ee0
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
xorl %eax, %eax
leaq 0x71e1(%rip), %r10      # 0x266f0
subl (%r10), %eax
xorl %r10d, %r10d
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x1ec30
movsd %xmm0, -0x38(%rbp)
jmp 0x1f5af
movl -0x20(%rbp), %eax
movl %eax, -0xbc(%rbp)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xbc(%rbp), %eax
cmpl %ecx, %eax
jge 0x1f5ad
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x6ee0
movq -0xc8(%rbp), %rdi
movq %rax, %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
movl -0x20(%rbp), %r9d
xorl %eax, %eax
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x1ec30
movsd %xmm0, -0x38(%rbp)
jmp 0x1f5af
jmp 0x1f5b1
jmp 0x1f5b3
jmp 0x1f5b5
movsd -0x38(%rbp), %xmm0
addq $0xd8, %rsp
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)