// File: /workspace/github_cpp_makefile_star2_O2/openflightmaps[P]ofm2xplane/main.cpp
// Function: print_all_AhpUid(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, rapidxml::xml_node<char>*, std::basic_ofstream<char, std::char_traits<char>>&)
void * print_all_AhpUid(string target, xml_node<> *axim_node, ofstream &outfile)
{
//string target="4693"; // St. Johann in Tirol
	
	//ALLE nodes durchgehen AhpUid 
	xml_node<> * current=axim_node;
	int ebene=0;
	while(true)
	{
	if(current->first_node()!=NULL && current->first_node()->name()[0] != '\0')
		{
			ebene++;
			// cout << "-going deeper. ebene: "<<ebene <<" "<<endl;	
			//printf("first node pointer: %p \n", current->first_node());
			current=current->first_node();
			goto check;
		}
		sibparent:
		if(current->next_sibling()!=NULL)
		{
			// cout << "-going sibling. ebene: "<<ebene <<" "<<endl;
			current=current->next_sibling();
			goto check;
		}
		if(current->parent()!=NULL && ebene > 0)
		{
			ebene--;
			// cout << "-becoming parent. ebene: "<<ebene <<" "<<endl;
			current=current->parent();
			goto sibparent;
		}
		
		// cout << "-no if matched, break."<<endl;
		//printf("my p: %p,  parent p: %p, sibling p: %p, parent->sibling p: %p\n", 
			// current, current->parent(), current->next_sibling(), current->parent()->next_sibling() );
		break;
		
		
		check:
		// cout << "--check: i am '" << current->name() << "'"<<endl;
		//printf(" my p: %p \n", current);
		string s(current->name());
		if(s.compare("AhpUid")==0 && current->first_attribute("mid")->value()[0] != '\0')
		{
			string t(current->first_attribute("mid")->value());
			if(t.compare(target)==0)
			{
				outfile << "--AhpUid: " << current->first_attribute("mid")->value() << " " << ebene << " " << current->parent()->name() << endl;
			}
		}
	}
	//cout << "Rekursive Suche beendet." << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, -0x38(%rbp)
movq %rsi, %r14
movq %rdi, -0x40(%rbp)
xorl %r15d, %r15d
pushq $0x1
popq %r12
leaq 0x6759(%rip), %rbx      # 0xd1f8
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x6ac9
movq (%rax), %rsi
testq %rsi, %rsi
movq %rsi, %rcx
cmoveq %rbx, %rcx
cmpb $0x0, (%rcx)
je 0x6ac9
incl %r15d
movq %rax, %r14
jmp 0x6af2
movq 0x20(%r14), %r14
decl %r15d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %r12d, %ecx
callq 0x6dec
testq %rax, %rax
je 0x6ac2
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl %r12d, %ecx
callq 0x6dec
movq %rax, %r14
movq (%rax), %rsi
testq %rsi, %rsi
cmoveq %rbx, %rsi
leaq -0x80(%rbp), %r13
movq %r13, %rdi
leaq -0x60(%rbp), %rdx
callq 0x6f24
movq %r13, %rdi
leaq 0x2744(%rip), %rsi      # 0x9257
callq 0x2090
testl %eax, %eax
jne 0x6c15
movq %r14, %rdi
leaq 0x2734(%rip), %rsi      # 0x925e
xorl %edx, %edx
movl %r12d, %ecx
callq 0x6e98
movq 0x8(%rax), %rax
testq %rax, %rax
cmoveq %rbx, %rax
cmpb $0x0, (%rax)
je 0x6c15
movq %r14, %rdi
leaq 0x270c(%rip), %rsi      # 0x925e
xorl %edx, %edx
movl %r12d, %ecx
callq 0x6e98
movq 0x8(%rax), %rsi
testq %rsi, %rsi
cmoveq %rbx, %rsi
leaq -0x60(%rbp), %r13
movq %r13, %rdi
leaq -0x29(%rbp), %rdx
callq 0x6f24
movq %r13, %rdi
movq -0x40(%rbp), %rsi
callq 0x2040
testl %eax, %eax
jne 0x6c0c
movq -0x38(%rbp), %rdi
leaq 0x29d5(%rip), %rsi      # 0x956b
callq 0x21b0
movq %rax, %r13
movq %r14, %rdi
leaq 0x26b6(%rip), %rsi      # 0x925e
xorl %edx, %edx
movl %r12d, %ecx
callq 0x6e98
movq 0x8(%rax), %rsi
testq %rsi, %rsi
cmoveq %rbx, %rsi
movq %r13, %rdi
callq 0x21b0
movq %rax, %rdi
leaq 0x267f(%rip), %rsi      # 0x924e
callq 0x21b0
movq %rax, %rdi
movl %r15d, %esi
callq 0x2310
movq %rax, %rdi
leaq 0x2665(%rip), %rsi      # 0x924e
callq 0x21b0
movq 0x20(%r14), %rcx
movq (%rcx), %rsi
testq %rsi, %rsi
cmoveq %rbx, %rsi
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
leaq -0x60(%rbp), %rdi
callq 0x20d0
leaq -0x80(%rbp), %rdi
callq 0x20d0
jmp 0x6a9f
jmp 0x6c27
jmp 0x6c27
movq %rax, %rbx
jmp 0x6c38
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x20d0
leaq -0x80(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x2330
nop