// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0x4, %edi
callq 0x21f0
movq %rax, %r14
movl $0x4, %edi
callq 0x21f0
movq %rax, %r15
movl $0x4, %edi
callq 0x21f0
movq %rax, -0x48(%rbp)
callq 0x3010
movslq %ebx, %rax
leaq (%rax,%rax,2), %rax
leaq 0x54a6(%rip), %rcx      # 0x15250
leaq (%rcx,%rax,8), %rax
movq (%rax), %r13
movq %rax, -0x50(%rbp)
cmpq %rax, %r13
je 0x1016b
testl %ebx, %ebx
je 0x1018a
cmpq -0x50(%rbp), %r13
je 0x1015c
movq 0x10(%r13), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq -0x48(%rbp), %rcx
callq 0x4124
leaq 0x583e(%rip), %rcx      # 0x15628
movq 0x8(%rcx), %rax
cmpq (%rcx), %rax
je 0x10153
xorl %ebx, %ebx
movq %r13, -0x38(%rbp)
movq 0x10(%r13), %rdi
callq 0x4064
movq 0x10(%rax), %rax
movq %rbx, -0x40(%rbp)
movq (%rax,%rbx,8), %r12
movq 0x10(%r13), %rdi
callq 0x4064
movq 0x20(%r12), %rdx
movq -0x58(%rbp), %rax
cmpq 0x8(%rax), %rdx
jne 0x1012d
testq %rdx, %rdx
je 0xfe4c
movq -0x58(%rbp), %rax
movq (%rax), %rsi
movq 0x18(%r12), %rdi
callq 0x2210
testl %eax, %eax
jne 0x1012d
cmpl $0x0, (%r12)
jle 0x1012d
movl $0x0, -0x2c(%rbp)
cmpl $0x0, 0x4(%r12)
jle 0x1011b
xorl %r13d, %r13d
cmpl $0x0, 0x8(%r12)
jle 0x1010d
xorl %ebx, %ebx
cmpl $0x1, (%r14)
jne 0xffe7
movl (%r15), %eax
testl %eax, %eax
je 0xff0a
cmpl $0x1, %eax
jne 0xffe7
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0xff68
cmpl $0x1, %eax
jne 0xffe7
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x579d(%rip), %rax      # 0x15658
movl (%rax), %eax
movl %eax, %r9d
shrl $0x1f, %r9d
addl %eax, %r9d
sarl %r9d
leaq 0x578b(%rip), %rax      # 0x1565c
movl (%rax), %eax
movl %eax, %r10d
shrl $0x1f, %r10d
addl %eax, %r10d
sarl %r10d
leaq 0x5779(%rip), %rax      # 0x15660
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 0xffab
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0xffaf
cmpl $0x1, %eax
jne 0xffe7
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5728(%rip), %rax      # 0x15658
movl (%rax), %eax
movl %eax, %r9d
shrl $0x1f, %r9d
addl %eax, %r9d
sarl %r9d
leaq 0x571a(%rip), %rax      # 0x15660
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 0xffde
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x56e1(%rip), %rax      # 0x15658
movl (%rax), %eax
movl %eax, %r9d
shrl $0x1f, %r9d
addl %eax, %r9d
sarl %r9d
leaq 0x56cf(%rip), %rax      # 0x1565c
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 0xffde
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x569a(%rip), %rax      # 0x15658
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 0xec37
addq $0x10, %rsp
cmpl $0x0, (%r14)
jne 0x10100
movl (%r15), %eax
testl %eax, %eax
je 0x10060
cmpl $0x1, %eax
jne 0x10100
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0x100a7
cmpl $0x1, %eax
jne 0x10100
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x5635(%rip), %rax      # 0x1565c
movl (%rax), %eax
movl %eax, %r10d
shrl $0x1f, %r10d
addl %eax, %r10d
sarl %r10d
leaq 0x5623(%rip), %rax      # 0x15660
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 0x100d7
movq -0x48(%rbp), %rax
movl (%rax), %eax
testl %eax, %eax
je 0x100db
cmpl $0x1, %eax
jne 0x10100
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x55de(%rip), %rax      # 0x15660
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 0x100f7
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x55a6(%rip), %rax      # 0x1565c
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 0x100f7
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 0xec37
addq $0x10, %rsp
incl %ebx
cmpl 0x8(%r12), %ebx
jl 0xfe7b
incl %r13d
cmpl 0x4(%r12), %r13d
jl 0xfe6d
movl -0x2c(%rbp), %eax
incl %eax
movl %eax, -0x2c(%rbp)
cmpl (%r12), %eax
jl 0xfe5e
movq -0x40(%rbp), %rbx
incq %rbx
leaq 0x54ed(%rip), %rcx      # 0x15628
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x5, %rax
cmpq %rbx, %rax
movq -0x38(%rbp), %r13
ja 0xfdfd
movq (%r13), %r13
jmp 0xfdc6
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4e7e(%rip), %rdi      # 0x14ff0
leaq 0x146b(%rip), %rsi      # 0x115e4
callq 0x21e0
movq %rax, %rdi
movl %ebx, %esi
callq 0x2330
jmp 0x1019d
movq 0x4e5f(%rip), %rdi      # 0x14ff0
leaq 0x1467(%rip), %rsi      # 0x115ff
callq 0x21e0
movq %rax, %rdi
callq 0x2100
movl $0x1, %edi
callq 0x2250