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

	//relative locations wrt siblings
	int *loc_x, *loc_y, *loc_z;
	loc_x = new int;
	loc_y = new int;
	loc_z = new int;

	myOctree::create_lists_of_level_nodes();
	
	if(myOctree::level_nodes[level].empty()) {
                std::cerr << "Error! No blocks in level " << level << std::endl;
                exit(1);
        }
	
	if(level==0) {
                std::cerr << "Error! Level cannot be zero" << 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) {

        	//get location relative to siblings
            	(*it)->get_relative_location(loc_x,loc_y,loc_z);

            	//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];
       			Block *b = (*it)->get_block_data();

               		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++) {
								

							if(*loc_x==1) {
								if(*loc_y==1) {
									if(*loc_z==1) {
										prolongate_ghost_for_child((*it),l,i,j,k,b->iNx/2,b->iNy/2,b->iNz/2);
									}
									else if(*loc_z==0) {
										prolongate_ghost_for_child((*it),l,i,j,k,b->iNx/2,b->iNy/2,0);
									}
								}
								else if(*loc_y==0) {
									if(*loc_z==1) {
										prolongate_ghost_for_child((*it),l,i,j,k,b->iNx/2,0,b->iNz/2);
									}
									else if(*loc_z==0) {
										prolongate_ghost_for_child((*it),l,i,j,k,b->iNx/2,0,0);
									}
								}
							}
							if(*loc_x==0) {
								if(*loc_y==1) {
									if(*loc_z==1) {
										prolongate_ghost_for_child((*it),l,i,j,k,0,b->iNy/2,b->iNz/2);
									}
									else if(*loc_z==0) {
										prolongate_ghost_for_child((*it),l,i,j,k,0,b->iNy/2,0);
									}
								}
								else if(*loc_y==0) {
									if(*loc_z==1) {
										prolongate_ghost_for_child((*it),l,i,j,k,0,0,b->iNz/2);
									}
									else if(*loc_z==0) {
										prolongate_ghost_for_child((*it),l,i,j,k,0,0,0);
									}
								}
							}
						}
          				}
                 		}
       			}
         	}
        }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, -0x58(%rbp)
movl %edi, %ebx
pushq $0x4
popq %r12
movq %r12, %rdi
callq 0x21e0
movq %rax, %r14
movq %r12, %rdi
callq 0x21e0
movq %rax, %r15
movq %r12, %rdi
callq 0x21e0
movq %rax, -0x48(%rbp)
callq 0x2e8e
movslq %ebx, %rax
imulq $0x18, %rax, %rax
leaq 0x58dc(%rip), %rcx      # 0x13240
leaq (%rcx,%rax), %rdx
movq (%rcx,%rax), %r12
movq %rdx, -0x50(%rbp)
cmpq %rdx, %r12
je 0xdc9a
testl %ebx, %ebx
je 0xdcb9
cmpq -0x50(%rbp), %r12
je 0xdc8b
movq 0x10(%r12), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq -0x48(%rbp), %rcx
callq 0x3e6c
xorl %edx, %edx
movq %r12, -0x38(%rbp)
leaq 0x5c6c(%rip), %rcx      # 0x13618
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x5, %rax
cmpq %rdx, %rax
jbe 0xdc82
movq 0x10(%r12), %rdi
movq %rdx, %rbx
callq 0x3db0
movq 0x10(%rax), %rax
movq %r12, %rcx
movq %rbx, -0x40(%rbp)
movq (%rax,%rbx,8), %r12
movq 0x10(%rcx), %rdi
callq 0x3db0
leaq 0x18(%r12), %rdi
movq -0x58(%rbp), %rsi
callq 0x6c56
testb %al, %al
je 0xdc72
xorl %r8d, %r8d
cmpl (%r12), %r8d
jge 0xdc72
xorl %r13d, %r13d
movl %r8d, -0x2c(%rbp)
cmpl 0x4(%r12), %r13d
jge 0xdc6a
xorl %ebx, %ebx
cmpl 0x8(%r12), %ebx
jge 0xdc62
movl (%r14), %eax
cmpl $0x1, %eax
jne 0xdb60
movl (%r15), %eax
testl %eax, %eax
je 0xdaa4
cmpl $0x1, %eax
jne 0xdc5b
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0xdaed
cmpl $0x1, %eax
jne 0xdb5d
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5bdf(%rip), %rax      # 0x13648
movl (%rax), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %r9d
leaq 0x5bd1(%rip), %rax      # 0x1364c
movl (%rax), %eax
cltd
idivl %ecx
movl %eax, %r10d
leaq 0x5bc6(%rip), %rax      # 0x13650
movl (%rax), %eax
cltd
idivl %ecx
movq -0x40(%rbp), %rsi
movl %r8d, %edx
movl %r13d, %ecx
movl %ebx, %r8d
pushq %rax
pushq %r10
jmp 0xdb50
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0xdb25
cmpl $0x1, %eax
jne 0xdb5d
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5b82(%rip), %rax      # 0x13648
movl (%rax), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %r9d
leaq 0x5b78(%rip), %rax      # 0x13650
movl (%rax), %eax
cltd
idivl %ecx
movq -0x40(%rbp), %rsi
movl %r8d, %edx
movl %r13d, %ecx
movl %ebx, %r8d
pushq %rax
jmp 0xdb4e
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5b4c(%rip), %rax      # 0x13648
movl (%rax), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %r9d
leaq 0x5b3e(%rip), %rax      # 0x1364c
movl (%rax), %eax
cltd
idivl %ecx
movq -0x40(%rbp), %rsi
movl %r8d, %edx
movl %r13d, %ecx
movl %ebx, %r8d
pushq $0x0
pushq %rax
jmp 0xdb50
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5b14(%rip), %rax      # 0x13648
movl (%rax), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq -0x40(%rbp), %rsi
movl %r8d, %edx
movl %r13d, %ecx
movl %ebx, %r8d
movl %eax, %r9d
pushq $0x0
pushq $0x0
callq 0xc9cb
movl -0x2c(%rbp), %r8d
addq $0x10, %rsp
movl (%r14), %eax
testl %eax, %eax
jne 0xdc5b
movl (%r15), %eax
testl %eax, %eax
je 0xdbcd
cmpl $0x1, %eax
jne 0xdc5b
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0xdc06
cmpl $0x1, %eax
jne 0xdc5b
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5aae(%rip), %rax      # 0x1364c
movl (%rax), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %r10d
leaq 0x5aa0(%rip), %rax      # 0x13650
movl (%rax), %eax
cltd
idivl %ecx
movq -0x40(%rbp), %rsi
movl %r8d, %edx
movl %r13d, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
pushq %rax
pushq %r10
jmp 0xdc4e
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0xdc32
cmpl $0x1, %eax
jne 0xdc5b
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5a65(%rip), %rax      # 0x13650
movl (%rax), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq -0x40(%rbp), %rsi
movl %r8d, %edx
movl %r13d, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
pushq %rax
jmp 0xdc4c
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5a37(%rip), %rax      # 0x1364c
movl (%rax), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movq -0x40(%rbp), %rsi
movl %r8d, %edx
movl %r13d, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq %rax
jmp 0xdc4e
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x40(%rbp), %rsi
movl %r8d, %edx
movl %r13d, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $0x0
callq 0xc9cb
movl -0x2c(%rbp), %r8d
addq $0x10, %rsp
incl %ebx
jmp 0xda1c
incl %r13d
jmp 0xda0f
incl %r8d
jmp 0xd9fe
movq -0x40(%rbp), %rdx
incq %rdx
movq -0x38(%rbp), %r12
jmp 0xd9a5
movq (%r12), %r12
jmp 0xd981
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x534f(%rip), %rdi      # 0x12ff0
leaq 0x194c(%rip), %rsi      # 0xf5f4
callq 0x21d0
movq %rax, %rdi
movl %ebx, %esi
callq 0x2310
jmp 0xdccc
movq 0x5330(%rip), %rdi      # 0x12ff0
leaq 0x1948(%rip), %rsi      # 0xf60f
callq 0x21d0
movq %rax, %rdi
callq 0x2110
pushq $0x1
popq %rdi
callq 0x2220