// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rdi, -0x40(%rbp)
xorl %r15d, %r15d
leaq -0x70(%rbp), %r13
leaq 0x6ecb(%rip), %r14      # 0xf1f0
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x834b
movq (%rax), %rcx
testq %rcx, %rcx
cmoveq %r14, %rcx
cmpb $0x0, (%rcx)
je 0x834b
incl %r15d
movq %rax, %rbx
jmp 0x8364
movq %rax, %rbx
decl %r15d
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x8526
movq 0x58(%rbx), %rcx
testq %rcx, %rcx
je 0x8345
movq %rcx, %rbx
movq (%rbx), %rsi
testq %rsi, %rsi
cmoveq %r14, %rsi
leaq -0x80(%rbp), %r12
movq %r12, %rdi
leaq -0x60(%rbp), %rdx
callq 0x8a4c
movq %r12, %rdi
leaq 0x2ecf(%rip), %rsi      # 0xb257
callq 0x20a0
testl %eax, %eax
jne 0x8508
movq %rbx, %rdi
leaq 0x2ebf(%rip), %rsi      # 0xb25e
xorl %edx, %edx
movl $0x1, %ecx
callq 0x894c
movq 0x8(%rax), %rax
testq %rax, %rax
cmoveq %r14, %rax
cmpb $0x0, (%rax)
je 0x8508
movq %rbx, %rdi
leaq 0x2e95(%rip), %rsi      # 0xb25e
xorl %edx, %edx
movl $0x1, %ecx
callq 0x894c
movq 0x8(%rax), %rsi
testq %rsi, %rsi
cmoveq %r14, %rsi
leaq -0x60(%rbp), %r14
movq %r14, %rdi
leaq -0x29(%rbp), %rdx
callq 0x8a4c
movq %r14, %rdi
movq -0x40(%rbp), %rsi
callq 0x2050
testl %eax, %eax
jne 0x84e8
movl $0xa, %edx
movq -0x38(%rbp), %rdi
leaq 0x3157(%rip), %rsi      # 0xb56b
callq 0x21d0
movq %rbx, %rdi
leaq 0x2e3b(%rip), %rsi      # 0xb25e
xorl %edx, %edx
movl $0x1, %ecx
callq 0x894c
movq 0x8(%rax), %r14
testq %r14, %r14
leaq 0x6db3(%rip), %rax      # 0xf1f0
cmoveq %rax, %r14
movq %r14, %rdi
callq 0x20e0
movq -0x38(%rbp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21d0
movl $0x1, %edx
movq -0x38(%rbp), %rdi
leaq 0x2de6(%rip), %rsi      # 0xb24e
callq 0x21d0
movq -0x38(%rbp), %rdi
movl %r15d, %esi
callq 0x2320
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2dc3(%rip), %rsi      # 0xb24e
callq 0x21d0
movq 0x20(%rbx), %rax
movq %r13, %r12
movq (%rax), %r13
testq %r13, %r13
leaq 0x6d4c(%rip), %rax      # 0xf1f0
cmoveq %rax, %r13
movq %r13, %rdi
callq 0x20e0
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %r13
movq %rax, %rdx
callq 0x21d0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x8501
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21b0
leaq 0x6ce8(%rip), %r14      # 0xf1f0
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x8325
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21b0
jmp 0x8325
leaq 0x32b2(%rip), %rdi      # 0xb7df
leaq 0x3096(%rip), %rsi      # 0xb5ca
leaq 0x32b3(%rip), %rcx      # 0xb7ee
movl $0x3ee, %edx            # imm = 0x3EE
callq 0x2130
jmp 0x8549
jmp 0x8549
movq %rax, %rbx
jmp 0x856a
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x856a
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21b0
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x857f
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x2340
nop