// File: 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
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x90(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
movq %rdx, %rsi
callq 0xca70
cmpq $0x0, %rax
je 0xc401
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
movq %rdx, %rsi
callq 0xca70
movq %rax, %rdi
callq 0xce80
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xc401
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
movq %rdx, %rsi
callq 0xca70
movq %rax, -0x20(%rbp)
jmp 0xc46b
jmp 0xc403
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
movq %rdx, %rsi
callq 0xcb50
cmpq $0x0, %rax
je 0xc439
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
movq %rdx, %rsi
callq 0xcb50
movq %rax, -0x20(%rbp)
jmp 0xc46b
movq -0x20(%rbp), %rdi
callq 0xcec0
cmpq $0x0, %rax
je 0xc466
cmpl $0x0, -0x24(%rbp)
jle 0xc466
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
callq 0xcec0
movq %rax, -0x20(%rbp)
jmp 0xc403
jmp 0xc734
movq -0x20(%rbp), %rdi
callq 0xce80
movq %rax, -0xa0(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x3450
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq -0x48(%rbp), %rdi
callq 0xcdd0
jmp 0xc4a4
leaq -0x49(%rbp), %rdi
callq 0x3260
leaq -0x48(%rbp), %rdi
leaq 0x4d83(%rip), %rsi      # 0x1123b
callq 0x30a0
cmpl $0x0, %eax
jne 0xc71b
movq -0x20(%rbp), %rdi
leaq 0x4d71(%rip), %rsi      # 0x11242
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0xccc0
movq %rax, -0xa8(%rbp)
jmp 0xc4e8
movq -0xa8(%rbp), %rdi
callq 0xcd90
movq %rax, -0xb0(%rbp)
jmp 0xc4fd
movq -0xb0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xc71b
movq -0x20(%rbp), %rdi
leaq 0x4d27(%rip), %rsi      # 0x11242
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0xccc0
movq %rax, -0xb8(%rbp)
jmp 0xc532
movq -0xb8(%rbp), %rdi
callq 0xcd90
movq %rax, -0xc0(%rbp)
jmp 0xc547
leaq -0x81(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x3450
movq -0xc0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0xcdd0
jmp 0xc573
leaq -0x81(%rbp), %rdi
callq 0x3260
movq -0x90(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x3040
movl %eax, -0xcc(%rbp)
jmp 0xc597
movl -0xcc(%rbp), %eax
cmpl $0x0, %eax
jne 0xc712
movq -0x18(%rbp), %rdi
leaq 0x4fc0(%rip), %rsi      # 0x11571
callq 0x3200
movq %rax, -0xd8(%rbp)
jmp 0xc5bf
movq -0x20(%rbp), %rdi
leaq 0x4c78(%rip), %rsi      # 0x11242
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0xccc0
movq %rax, -0xe0(%rbp)
jmp 0xc5e1
movq -0xe0(%rbp), %rdi
callq 0xcd90
movq %rax, -0xe8(%rbp)
jmp 0xc5f6
movq -0xe8(%rbp), %rsi
movq -0xd8(%rbp), %rdi
callq 0x3200
movq %rax, -0xf0(%rbp)
jmp 0xc612
movq -0xf0(%rbp), %rdi
leaq 0x4c12(%rip), %rsi      # 0x11232
callq 0x3200
movq %rax, -0xf8(%rbp)
jmp 0xc62e
movq -0xf8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x3420
movq %rax, -0x100(%rbp)
jmp 0xc646
movq -0x100(%rbp), %rdi
leaq 0x4bde(%rip), %rsi      # 0x11232
callq 0x3200
movq %rax, -0x108(%rbp)
jmp 0xc662
movq -0x20(%rbp), %rdi
callq 0xcec0
movq %rax, -0x110(%rbp)
jmp 0xc674
movq -0x110(%rbp), %rdi
callq 0xce80
movq %rax, -0x118(%rbp)
jmp 0xc689
movq -0x118(%rbp), %rsi
movq -0x108(%rbp), %rdi
callq 0x3200
movq %rax, -0x120(%rbp)
jmp 0xc6a5
movq -0x120(%rbp), %rdi
movq 0x990d(%rip), %rsi      # 0x15fc0
callq 0x3240
jmp 0xc6ba
jmp 0xc712
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x49(%rbp), %rdi
callq 0x3260
jmp 0xc736
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0xc729
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x81(%rbp), %rdi
callq 0x3260
jmp 0xc729
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3160
jmp 0xc729
leaq -0x80(%rbp), %rdi
callq 0x3160
leaq -0x48(%rbp), %rdi
callq 0x3160
jmp 0xc39d
leaq -0x48(%rbp), %rdi
callq 0x3160
jmp 0xc736
ud2
movq -0x58(%rbp), %rdi
callq 0x3440
nop