// File: /workspace/github_cpp_makefile_star2_O3/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %r14d
movl %ecx, -0x2c(%rbp)
movl %edx, %r15d
movl %esi, %r12d
movq %rdi, %r13
callq 0x418c
movq 0x10(%rax), %rax
movslq %r12d, %rcx
movq (%rax,%rcx,8), %rbx
movq %r13, %rdi
callq 0x418c
movl (%rbx), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
cmpl %r15d, %ecx
jg 0xfaa9
movl 0x4(%rbx), %eax
movl 0x8(%rbx), %ecx
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
cmpl -0x2c(%rbp), %edx
movl %r14d, -0x30(%rbp)
jle 0xf98b
movq %r13, %rdi
movl $0x1, %esi
xorl %edx, %edx
cmpl %r14d, %eax
jle 0xf9ea
xorl %ecx, %ecx
callq 0x41ee
leaq 0x5d07(%rip), %rcx      # 0x15668
xorl %r10d, %r10d
subl (%rcx), %r10d
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl -0x30(%rbp), %r14d
movl %r14d, %r9d
xorl %eax, %eax
pushq %rax
pushq %rax
jmp 0xfa2d
cmpl %r14d, %eax
movl %r12d, -0x34(%rbp)
jle 0xfa3a
xorl %r14d, %r14d
movq %r13, %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x41ee
leaq 0x5cb2(%rip), %rcx      # 0x15668
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5ca9(%rip), %rcx      # 0x1566c
subl (%rcx), %r14d
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl -0x30(%rbp), %r12d
movl %r12d, %r9d
pushq $0x0
pushq %r14
jmp 0xfa97
movl $0x1, %ecx
callq 0x41ee
leaq 0x5c6d(%rip), %rcx      # 0x15668
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5c68(%rip), %rcx      # 0x15670
xorl %r11d, %r11d
subl (%rcx), %r11d
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl -0x30(%rbp), %r14d
movl %r14d, %r9d
pushq %r11
pushq $0x0
pushq %r10
callq 0xf69b
addq $0x20, %rsp
jmp 0xfaa9
movq %r13, %rdi
movl $0x1, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x41ee
leaq 0x5c10(%rip), %rcx      # 0x15668
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5c07(%rip), %rcx      # 0x1566c
xorl %r11d, %r11d
subl (%rcx), %r11d
xorl %r14d, %r14d
leaq 0x5bfb(%rip), %rcx      # 0x15670
subl (%rcx), %r14d
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl -0x30(%rbp), %r12d
movl %r12d, %r9d
pushq %r14
pushq %r11
pushq %r10
callq 0xf69b
addq $0x20, %rsp
movl %r12d, %r14d
movl -0x34(%rbp), %r12d
movl (%rbx), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
cmpl %r15d, %ecx
jle 0xfb05
movl 0x4(%rbx), %eax
movl 0x8(%rbx), %ecx
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
cmpl -0x2c(%rbp), %edx
jle 0xfb0e
xorl %ebx, %ebx
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
cmpl %r14d, %eax
jle 0xfb4f
xorl %ecx, %ecx
callq 0x41ee
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl %r14d, %r9d
pushq %rbx
jmp 0xfb7f
addq $0x18, %rsp
jmp 0xfbc8
xorl %ebx, %ebx
movq %r13, %rdi
xorl %esi, %esi
movl $0x1, %edx
cmpl %r14d, %eax
jle 0xfb83
xorl %ecx, %ecx
callq 0x41ee
leaq 0x5b3f(%rip), %rcx      # 0x1566c
xorl %r10d, %r10d
subl (%rcx), %r10d
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl %r14d, %r9d
pushq %rbx
pushq %r10
jmp 0xfb80
movl $0x1, %ecx
callq 0x41ee
leaq 0x5b10(%rip), %rcx      # 0x15670
xorl %r10d, %r10d
subl (%rcx), %r10d
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl %r14d, %r9d
pushq %r10
pushq %rbx
pushq %rbx
jmp 0xfbbf
movl $0x1, %ecx
callq 0x41ee
leaq 0x5ad8(%rip), %rcx      # 0x1566c
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5acf(%rip), %rcx      # 0x15670
subl (%rcx), %ebx
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl %r12d, %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl %r14d, %r9d
pushq %rbx
pushq %r10
pushq $0x0
callq 0xf69b
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq