// File: /workspace/github_cpp_makefile_star2_O3/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, -0x50(%rbp)
movl %edi, %ebx
movl $0x4, %edi
callq 0x2200
movq %rax, %r14
movl $0x4, %edi
callq 0x2200
movq %rax, %r15
movl $0x4, %edi
callq 0x2200
movq %rax, -0x48(%rbp)
callq 0x3018
movslq %ebx, %rax
leaq (%rax,%rax,2), %rax
leaq 0x563b(%rip), %rcx      # 0x15260
leaq (%rcx,%rax,8), %rax
movq (%rax), %r12
movq %rax, -0x58(%rbp)
cmpq %rax, %r12
je 0xfff6
testl %ebx, %ebx
je 0x10015
movq 0x10(%r12), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq -0x48(%rbp), %rcx
callq 0x424c
leaq 0x59dc(%rip), %rcx      # 0x15638
movq 0x8(%rcx), %rax
cmpq (%rcx), %rax
je 0xffd9
xorl %edx, %edx
movq %r12, -0x38(%rbp)
movq 0x10(%r12), %rdi
movq %rdx, %rbx
callq 0x418c
movq 0x10(%rax), %rax
movq %r12, %rcx
movq %rbx, -0x40(%rbp)
movq (%rax,%rbx,8), %r12
movq 0x10(%rcx), %rdi
callq 0x418c
movq 0x20(%r12), %rdx
movq -0x50(%rbp), %rax
cmpq 0x8(%rax), %rdx
jne 0xffb3
testq %rdx, %rdx
je 0xfcc5
movq -0x50(%rbp), %rax
movq (%rax), %rsi
movq 0x18(%r12), %rdi
callq 0x2220
testl %eax, %eax
jne 0xffb3
movl (%r12), %ecx
testl %ecx, %ecx
jle 0xffb3
movl 0x4(%r12), %eax
movl $0x0, -0x2c(%rbp)
testl %eax, %eax
jle 0xffa3
movl 0x8(%r12), %ecx
xorl %r13d, %r13d
testl %ecx, %ecx
jle 0xff93
xorl %ebx, %ebx
movl (%r14), %eax
cmpl $0x1, %eax
jne 0xfe68
movl (%r15), %eax
testl %eax, %eax
je 0xfd88
cmpl $0x1, %eax
jne 0xff7f
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0xfde6
cmpl $0x1, %eax
jne 0xfe65
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x592f(%rip), %rax      # 0x15668
movl (%rax), %eax
movl %eax, %r9d
shrl $0x1f, %r9d
addl %eax, %r9d
sarl %r9d
leaq 0x591d(%rip), %rax      # 0x1566c
movl (%rax), %eax
movl %eax, %r10d
shrl $0x1f, %r10d
addl %eax, %r10d
sarl %r10d
leaq 0x590b(%rip), %rax      # 0x15670
movl (%rax), %eax
movl %eax, %r11d
shrl $0x1f, %r11d
addl %eax, %r11d
sarl %r11d
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl %r13d, %ecx
movl %ebx, %r8d
pushq %r11
jmp 0xfe29
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0xfe2d
cmpl $0x1, %eax
jne 0xfe65
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x58ba(%rip), %rax      # 0x15668
movl (%rax), %eax
movl %eax, %r9d
shrl $0x1f, %r9d
addl %eax, %r9d
sarl %r9d
leaq 0x58ac(%rip), %rax      # 0x15670
movl (%rax), %eax
movl %eax, %r10d
shrl $0x1f, %r10d
addl %eax, %r10d
sarl %r10d
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl %r13d, %ecx
movl %ebx, %r8d
pushq %r10
pushq $0x0
jmp 0xfe5c
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5873(%rip), %rax      # 0x15668
movl (%rax), %eax
movl %eax, %r9d
shrl $0x1f, %r9d
addl %eax, %r9d
sarl %r9d
leaq 0x5861(%rip), %rax      # 0x1566c
movl (%rax), %eax
movl %eax, %r10d
shrl $0x1f, %r10d
addl %eax, %r10d
sarl %r10d
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl %r13d, %ecx
movl %ebx, %r8d
pushq $0x0
pushq %r10
jmp 0xfe5c
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x582c(%rip), %rax      # 0x15668
movl (%rax), %eax
movl %eax, %r9d
shrl $0x1f, %r9d
addl %eax, %r9d
sarl %r9d
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl %r13d, %ecx
movl %ebx, %r8d
xorl %eax, %eax
pushq %rax
pushq %rax
callq 0xec43
addq $0x10, %rsp
movl (%r14), %eax
testl %eax, %eax
jne 0xff7f
movl (%r15), %eax
testl %eax, %eax
je 0xfedf
cmpl $0x1, %eax
jne 0xff7f
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0xff26
cmpl $0x1, %eax
jne 0xff7f
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x57c6(%rip), %rax      # 0x1566c
movl (%rax), %eax
movl %eax, %r10d
shrl $0x1f, %r10d
addl %eax, %r10d
sarl %r10d
leaq 0x57b4(%rip), %rax      # 0x15670
movl (%rax), %eax
movl %eax, %r11d
shrl $0x1f, %r11d
addl %eax, %r11d
sarl %r11d
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl %r13d, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
pushq %r11
jmp 0xff56
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0xff5a
cmpl $0x1, %eax
jne 0xff7f
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x576f(%rip), %rax      # 0x15670
movl (%rax), %eax
movl %eax, %r10d
shrl $0x1f, %r10d
addl %eax, %r10d
sarl %r10d
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl %r13d, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
pushq %r10
pushq $0x0
jmp 0xff76
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5737(%rip), %rax      # 0x1566c
movl (%rax), %eax
movl %eax, %r10d
shrl $0x1f, %r10d
addl %eax, %r10d
sarl %r10d
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl %r13d, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq %r10
jmp 0xff76
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x40(%rbp), %rsi
movl -0x2c(%rbp), %edx
movl %r13d, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
xorl %eax, %eax
pushq %rax
pushq %rax
callq 0xec43
addq $0x10, %rsp
incl %ebx
movl 0x8(%r12), %ecx
cmpl %ecx, %ebx
jl 0xfcf7
movl 0x4(%r12), %eax
incl %r13d
cmpl %eax, %r13d
jl 0xfced
movl (%r12), %ecx
movl -0x2c(%rbp), %edx
incl %edx
movl %edx, -0x2c(%rbp)
cmpl %ecx, %edx
jl 0xfcdd
movq -0x40(%rbp), %rdx
incq %rdx
leaq 0x5677(%rip), %rcx      # 0x15638
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x5, %rax
cmpq %rdx, %rax
movq -0x38(%rbp), %r12
ja 0xfc6f
movq (%r12), %r12
cmpq -0x58(%rbp), %r12
jne 0xfc41
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4ff3(%rip), %rdi      # 0x14ff0
leaq 0x1610(%rip), %rsi      # 0x11614
callq 0x21f0
movq %rax, %rdi
movl %ebx, %esi
callq 0x2340
jmp 0x10028
movq 0x4fd4(%rip), %rdi      # 0x14ff0
leaq 0x160c(%rip), %rsi      # 0x1162f
callq 0x21f0
movq %rax, %rdi
callq 0x2100
movl $0x1, %edi
callq 0x2260