// File: /workspace/github_cpp_makefile_star2_O3/suhasjains[P]AMR-Solver/src/multigrid.cpp
// Function: amrsolver::restrict(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void restrict(int level, std::string name) {

	myOctree::create_lists_of_level_nodes();
	
	if(myOctree::level_nodes[level].empty()) {
                std::cerr << "Error! No blocks in level " << level << std::endl;
                exit(1);
        }
	

	//loop over nodes
	for (std::list<Octree*>::iterator it = level_nodes[level].begin(), end = level_nodes[level].end(); it != end; ++it) {


		//skip if its a leaf node
		if((*it)->isLeafNode()) {	
			continue;
		}
		
            	//loop over scalar fields
            	for(int l = 0; l<myOctree::scalar_fields.size() ; l++) {

			//field and block
       			Field *f = (*it)->get_block_data()->scalarfields[l];
               		if( f->name == name ) {

  				for(int i=0; i<f->Nx; i++) {
         				for(int j=0; j<f->Ny; j++) {
                         			for(int k=0; k<f->Nz; k++) {
			
					//	std::cout << i << " " << j << " " << k << std::endl;
				
							f->val[i][j][k] = restrict_at((*it),l,i,j,k);

						}
          				}
                 		}
       			}
         	}
        }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, -0x38(%rbp)
movl %edi, %r14d
callq 0x3018
movslq %r14d, %rax
leaq (%rax,%rax,2), %rax
leaq 0x4d94(%rip), %rcx      # 0x15260
leaq (%rcx,%rax,8), %rax
movq (%rax), %rbx
movq %rax, -0x50(%rbp)
cmpq %rax, %rbx
je 0x10610
movq 0x10(%rbx), %rdi
callq 0x4168
testb %al, %al
jne 0x105f4
leaq 0x5140(%rip), %rcx      # 0x15638
movq 0x8(%rcx), %rax
cmpq (%rcx), %rax
je 0x105f4
xorl %r14d, %r14d
movq %rbx, -0x40(%rbp)
movq 0x10(%rbx), %rdi
callq 0x418c
movq 0x10(%rax), %rax
movq %r14, -0x48(%rbp)
movq (%rax,%r14,8), %rsi
movq 0x20(%rsi), %rdx
movq -0x38(%rbp), %rax
cmpq 0x8(%rax), %rdx
jne 0x105ce
testq %rdx, %rdx
movq %rsi, -0x30(%rbp)
je 0x10558
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2220
movq -0x30(%rbp), %rsi
testl %eax, %eax
jne 0x105ce
movl (%rsi), %ecx
testl %ecx, %ecx
jle 0x105ce
movl 0x4(%rsi), %eax
xorl %r15d, %r15d
testl %eax, %eax
jle 0x105c3
movl 0x8(%rsi), %ecx
xorl %r12d, %r12d
testl %ecx, %ecx
jle 0x105b6
xorl %r13d, %r13d
movq -0x40(%rbp), %r14
movq -0x48(%rbp), %rbx
movq 0x10(%r14), %rdi
movl %ebx, %esi
movl %r15d, %edx
movl %r12d, %ecx
movl %r13d, %r8d
callq 0xf8d3
movq -0x30(%rbp), %rsi
movq 0x10(%rsi), %rax
movq (%rax,%r15,8), %rax
movq (%rax,%r12,8), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
movslq 0x8(%rsi), %rcx
cmpq %rcx, %r13
jl 0x1057d
movl 0x4(%rsi), %eax
incq %r12
movslq %eax, %rdx
cmpq %rdx, %r12
jl 0x1056e
movl (%rsi), %ecx
incq %r15
movslq %ecx, %rdx
cmpq %rdx, %r15
jl 0x10564
movq -0x48(%rbp), %r14
incq %r14
leaq 0x505c(%rip), %rcx      # 0x15638
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x5, %rax
cmpq %r14, %rax
movq -0x40(%rbp), %rbx
ja 0x1050c
movq (%rbx), %rbx
cmpq -0x50(%rbp), %rbx
jne 0x104e0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x49d9(%rip), %rdi      # 0x14ff0
leaq 0xff6(%rip), %rsi       # 0x11614
callq 0x21f0
movq %rax, %rdi
movl %r14d, %esi
callq 0x2340
movq %rax, %rdi
callq 0x2100
movl $0x1, %edi
callq 0x2260