// File: /workspace/github_cpp_makefile_star2_O1/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 0x4064
movq 0x10(%rax), %rax
movslq %r12d, %rcx
movq (%rax,%rcx,8), %rbx
movq %r13, %rdi
callq 0x4064
movl (%rbx), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
cmpl %r15d, %ecx
jg 0xfc2e
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 0xfb10
movq %r13, %rdi
movl $0x1, %esi
xorl %edx, %edx
cmpl %r14d, %eax
jle 0xfb6f
xorl %ecx, %ecx
callq 0x40c6
leaq 0x5b72(%rip), %rcx      # 0x15658
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 0xfbb2
cmpl %r14d, %eax
movl %r12d, -0x34(%rbp)
jle 0xfbbf
xorl %r14d, %r14d
movq %r13, %rdi
movl $0x1, %esi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x40c6
leaq 0x5b1d(%rip), %rcx      # 0x15658
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5b14(%rip), %rcx      # 0x1565c
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 0xfc1c
movl $0x1, %ecx
callq 0x40c6
leaq 0x5ad8(%rip), %rcx      # 0x15658
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5ad3(%rip), %rcx      # 0x15660
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 0xf820
addq $0x20, %rsp
jmp 0xfc2e
movq %r13, %rdi
movl $0x1, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x40c6
leaq 0x5a7b(%rip), %rcx      # 0x15658
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x5a72(%rip), %rcx      # 0x1565c
xorl %r11d, %r11d
subl (%rcx), %r11d
xorl %r14d, %r14d
leaq 0x5a66(%rip), %rcx      # 0x15660
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 0xf820
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 0xfc8a
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 0xfc93
xorl %ebx, %ebx
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
cmpl %r14d, %eax
jle 0xfcd4
xorl %ecx, %ecx
callq 0x40c6
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 0xfd04
addq $0x18, %rsp
jmp 0xfd4d
xorl %ebx, %ebx
movq %r13, %rdi
xorl %esi, %esi
movl $0x1, %edx
cmpl %r14d, %eax
jle 0xfd08
xorl %ecx, %ecx
callq 0x40c6
leaq 0x59aa(%rip), %rcx      # 0x1565c
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 0xfd05
movl $0x1, %ecx
callq 0x40c6
leaq 0x597b(%rip), %rcx      # 0x15660
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 0xfd44
movl $0x1, %ecx
callq 0x40c6
leaq 0x5943(%rip), %rcx      # 0x1565c
xorl %r10d, %r10d
subl (%rcx), %r10d
leaq 0x593a(%rip), %rcx      # 0x15660
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 0xf820
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq