// File: /workspace/github_cpp_makefile_star2_O2/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, %r12d
movl %ecx, -0x2c(%rbp)
movl %edx, %r15d
movl %esi, %ebx
movq %rdi, %r13
callq 0x3db0
movq 0x10(%rax), %rax
movl %ebx, -0x30(%rbp)
movslq %ebx, %rcx
movq (%rax,%rcx,8), %r14
movq %r13, %rdi
callq 0x3db0
movl (%r14), %eax
pushq $0x2
popq %rbx
cltd
idivl %ebx
cmpl %r15d, %eax
jg 0xd7f3
movl 0x4(%r14), %eax
movl 0x8(%r14), %ecx
cltd
idivl %ebx
movl %eax, %esi
movl %ecx, %eax
cltd
idivl %ebx
cmpl -0x2c(%rbp), %esi
movl %r12d, -0x34(%rbp)
jle 0xd6ea
cmpl %r12d, %eax
jle 0xd73d
pushq $0x1
popq %rsi
xorl %r12d, %r12d
movq %r13, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3e12
leaq 0x5f84(%rip), %rcx      # 0x13648
subl (%rcx), %r12d
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl -0x30(%rbp), %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl -0x34(%rbp), %r9d
pushq $0x0
pushq $0x0
pushq %r12
jmp 0xd7e6
cmpl %r12d, %eax
jle 0xd792
pushq $0x1
popq %rdx
movq %r13, %rdi
movl %edx, %esi
xorl %ecx, %ecx
callq 0x3e12
leaq 0x5f3f(%rip), %rcx      # 0x13648
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5f36(%rip), %rcx      # 0x1364c
xorl %r11d, %r11d
subl (%rcx), %r11d
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl -0x30(%rbp), %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl -0x34(%rbp), %r12d
movl %r12d, %r9d
pushq $0x0
pushq %r11
jmp 0xd785
pushq $0x1
popq %rcx
movq %r13, %rdi
movl %ecx, %esi
xorl %edx, %edx
callq 0x3e12
leaq 0x5ef5(%rip), %rcx      # 0x13648
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5ef0(%rip), %rcx      # 0x13650
xorl %r11d, %r11d
subl (%rcx), %r11d
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl -0x30(%rbp), %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl -0x34(%rbp), %r12d
movl %r12d, %r9d
pushq %r11
pushq $0x0
pushq %r10
callq 0xd435
addq $0x20, %rsp
jmp 0xd7f3
pushq $0x1
popq %rcx
movq %r13, %rdi
movl %ecx, %esi
movl %ecx, %edx
callq 0x3e12
leaq 0x5ea0(%rip), %rcx      # 0x13648
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5e97(%rip), %rcx      # 0x1364c
xorl %r11d, %r11d
subl (%rcx), %r11d
xorl %r12d, %r12d
leaq 0x5e8b(%rip), %rcx      # 0x13650
subl (%rcx), %r12d
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl -0x30(%rbp), %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl -0x34(%rbp), %r9d
pushq %r12
pushq %r11
pushq %r10
callq 0xd435
addq $0x20, %rsp
movl -0x34(%rbp), %r12d
movl (%r14), %eax
cltd
idivl %ebx
cmpl %r15d, %eax
jle 0xd843
movl 0x4(%r14), %eax
movl 0x8(%r14), %ecx
cltd
idivl %ebx
movl %eax, %esi
movl %ecx, %eax
cltd
idivl %ebx
cmpl -0x2c(%rbp), %esi
jle 0xd84c
cmpl %r12d, %eax
jle 0xd887
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3e12
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl -0x30(%rbp), %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl %r12d, %r9d
pushq $0x0
jmp 0xd8b9
addq $0x18, %rsp
jmp 0xd909
cmpl %r12d, %eax
jle 0xd8bd
pushq $0x1
popq %rdx
xorl %ebx, %ebx
movq %r13, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x3e12
leaq 0x5de3(%rip), %rcx      # 0x1364c
subl (%rcx), %ebx
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl -0x30(%rbp), %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl %r12d, %r9d
pushq $0x0
pushq %rbx
jmp 0xd8fe
xorl %ebx, %ebx
pushq $0x1
popq %rcx
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3e12
leaq 0x5db1(%rip), %rcx      # 0x13650
subl (%rcx), %ebx
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl -0x30(%rbp), %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl %r12d, %r9d
pushq %rbx
pushq $0x0
jmp 0xd8fe
xorl %ebx, %ebx
pushq $0x1
popq %rcx
movq %r13, %rdi
xorl %esi, %esi
movl %ecx, %edx
callq 0x3e12
leaq 0x5d77(%rip), %rcx      # 0x1364c
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5d6e(%rip), %rcx      # 0x13650
subl (%rcx), %ebx
subq $0x8, %rsp
movq %r13, %rdi
movq %rax, %rsi
movl -0x30(%rbp), %edx
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
movl %r12d, %r9d
pushq %rbx
pushq %r10
pushq $0x0
callq 0xd435
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq