// File: /workspace/github_cpp_makefile_star2_O3/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 0x6e44(%rip), %r14      # 0xf1e8
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x83cd
movq (%rax), %rsi
testq %rsi, %rsi
movq %rsi, %rcx
cmoveq %r14, %rcx
cmpb $0x0, (%rcx)
je 0x83cd
incl %r15d
movq %rax, %rbx
jmp 0x83e9
movq %rax, %rbx
decl %r15d
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x85a8
movq 0x58(%rbx), %rcx
testq %rcx, %rcx
je 0x83c7
movq (%rcx), %rsi
movq %rcx, %rbx
testq %rsi, %rsi
cmoveq %r14, %rsi
leaq -0x80(%rbp), %r12
movq %r12, %rdi
leaq -0x60(%rbp), %rdx
callq 0x8a02
movq %r12, %rdi
leaq 0x2e4d(%rip), %rsi      # 0xb257
callq 0x20a0
testl %eax, %eax
jne 0x858a
movq %rbx, %rdi
leaq 0x2e3d(%rip), %rsi      # 0xb25e
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8940
movq 0x8(%rax), %rax
testq %rax, %rax
cmoveq %r14, %rax
cmpb $0x0, (%rax)
je 0x858a
movq %rbx, %rdi
leaq 0x2e13(%rip), %rsi      # 0xb25e
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8940
movq 0x8(%rax), %rsi
testq %rsi, %rsi
cmoveq %r14, %rsi
leaq -0x60(%rbp), %r14
movq %r14, %rdi
leaq -0x29(%rbp), %rdx
callq 0x8a02
movq %r14, %rdi
movq -0x40(%rbp), %rsi
callq 0x2050
testl %eax, %eax
jne 0x856a
movl $0xa, %edx
movq -0x38(%rbp), %rdi
leaq 0x30d5(%rip), %rsi      # 0xb56b
callq 0x21d0
movq %rbx, %rdi
leaq 0x2db9(%rip), %rsi      # 0xb25e
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8940
movq 0x8(%rax), %r14
testq %r14, %r14
leaq 0x6d29(%rip), %rax      # 0xf1e8
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 0x2d64(%rip), %rsi      # 0xb24e
callq 0x21d0
movq -0x38(%rbp), %rdi
movl %r15d, %esi
callq 0x2310
movq %rax, %r14
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2d41(%rip), %rsi      # 0xb24e
callq 0x21d0
movq 0x20(%rbx), %rax
movq %r13, %r12
movq (%rax), %r13
testq %r13, %r13
leaq 0x6cc2(%rip), %rax      # 0xf1e8
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 0x8583
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21b0
leaq 0x6c5e(%rip), %r14      # 0xf1e8
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x83a4
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21b0
jmp 0x83a4
leaq 0x3230(%rip), %rdi      # 0xb7df
leaq 0x3014(%rip), %rsi      # 0xb5ca
leaq 0x3231(%rip), %rcx      # 0xb7ee
movl $0x3ee, %edx            # imm = 0x3EE
callq 0x2130
jmp 0x85cb
jmp 0x85cb
movq %rax, %rbx
jmp 0x85ec
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x85ec
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x21b0
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x8601
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x2330
nop