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

	myOctree::create_lists_of_level_nodes();

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

	double global_res = 1.0;

	long int loop = 0;

	//iteration loop
	while(loop <250 ) {
	//while(global_res > pow(10,-7)) {

		global_res = 0.0;
		
		//exchange ghost values
		exchange_ghost_val(level, name);

		//loop over all the nodes
		for (std::list<Octree*>::iterator it = level_nodes[level].begin(), end = level_nodes[level].end(); it != end; ++it) {
	
			for(int l = 0; l<myOctree::scalar_fields.size() ; l++) {
	
				Field *f = (*it)->get_block_data()->scalarfields[l];
							//	std::cerr << f->name << std::endl;
	
				if( f->name == name ) {
					
					global_res = jacobi_for_field(*it, f, global_res);	

				}	
			}
		}

		std::cout << "Residual " << global_res << std::endl;

		loop++;

	}	
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movl %edi, %ebx
callq 0x3018
movl %ebx, -0x2c(%rbp)
movslq %ebx, %rax
leaq (%rax,%rax,2), %rax
leaq 0x7a0c(%rip), %rcx      # 0x15260
leaq (%rcx,%rax,8), %rax
movq %rax, -0x40(%rbp)
cmpq %rax, (%rax)
je 0xd9cb
leaq -0x58(%rbp), %rbx
xorl %r15d, %r15d
leaq 0x7dc5(%rip), %r12      # 0x15638
movq %rbx, -0x68(%rbp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %r13
movq %r13, %rdi
callq 0x39ba
movl -0x2c(%rbp), %edi
movq %r13, %rsi
callq 0x744c
movq %r15, -0x48(%rbp)
movq -0x68(%rbp), %rdi
cmpq %rbx, %rdi
je 0xd8b1
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2210
movq -0x40(%rbp), %rax
movq (%rax), %r15
cmpq %rax, %r15
je 0xd94a
movq (%r12), %rax
movq 0x8(%r12), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
cmpq %rax, %rcx
je 0xd93c
xorl %ebx, %ebx
movq 0x10(%r15), %rdi
callq 0x418c
movq 0x10(%rax), %rax
movq (%rax,%rbx,8), %r13
movq 0x20(%r13), %rdx
cmpq 0x8(%r14), %rdx
jne 0xd91f
testq %rdx, %rdx
je 0xd909
movq (%r14), %rsi
movq 0x18(%r13), %rdi
callq 0x2220
testl %eax, %eax
jne 0xd91f
movq 0x10(%r15), %rdi
movq %r13, %rsi
movsd -0x38(%rbp), %xmm0
callq 0xda1b
movsd %xmm0, -0x38(%rbp)
incq %rbx
movq (%r12), %rax
movq 0x8(%r12), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x5, %rdx
cmpq %rbx, %rdx
ja 0xd8d9
jmp 0xd93f
movq %rax, %rcx
movq (%r15), %r15
cmpq -0x40(%rbp), %r15
jne 0xd8d2
jmp 0xd952
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x9, %edx
movq 0x7672(%rip), %rbx      # 0x14fd0
movq %rbx, %rdi
leaq 0x3c88(%rip), %rsi      # 0x115f0
callq 0x2240
movq %rbx, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x2310
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x21e0
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movq -0x48(%rbp), %r15
incq %r15
cmpq $0xfa, %r15
leaq -0x58(%rbp), %rbx
jne 0xd873
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x761e(%rip), %rdi      # 0x14ff0
leaq 0x3c42(%rip), %rsi      # 0x1161b
callq 0x21f0
movq %rax, %rdi
movl -0x2c(%rbp), %esi
callq 0x2340
movq %rax, %rdi
callq 0x2100
movl $0x1, %edi
callq 0x2260
movq %rax, %r14
movq -0x68(%rbp), %rdi
cmpq %rbx, %rdi
je 0xda13
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2210
movq %r14, %rdi
callq 0x2350