// File: /workspace/github_cpp_makefile_star2_O3/openflightmaps[P]ofm2xplane/main.cpp
// Function: main
int main(int argc, char* argv[])
{
    if(argc<=1)
    {
        cout << "Usage: " << argv[0] << " INPUT.xml" << endl;
        return EXIT_FAILURE;
    }
    cout << "Parsing OfmData..." << endl;
	xml_document<> doc, doc_def;
	xml_node<> * aixm_node;
		
	// Read the xml file into a vector
	ifstream theFile (argv[1]);
	if (!theFile.is_open())
	{
        cout << "Cannot open input file!" << endl;
        return EXIT_FAILURE;
    }
	vector<char> buffer((istreambuf_iterator<char>(theFile)), istreambuf_iterator<char>());
	buffer.push_back('\0');
	// Parse the buffer using the xml file parsing library into doc 
	doc.parse<0>(&buffer[0]);
	
	 ifstream convFile("configuration.xml");
	if(!convFile.is_open())
	{
        cout << "Cannot open configuration file!" << endl;
        return EXIT_FAILURE;
    }
    vector<char> buffer2((istreambuf_iterator<char>(convFile)), istreambuf_iterator<char>());
    buffer2.push_back('\0');
    doc_def.parse<0>(&buffer2[0]); 
	//----------------------------------HIER IST ALLES EINGELESEN
	/* erkannte struktur
	1. Ebene. ofm_webServiceResponse
	2. Ebene: "", "AIXM-Snapshot", "", "OFM-AixmPlugin"
	3. Ebene: "Ahp", "Rwy",...
	*/
	
	ofstream out;
	out.open("apt.dat",ios::trunc);
	out << "I" << endl;
    out << "1000 Version - data cycle 2015.07, build 20150729, metadata AptXP1000.  Copyright � 2015, Open flightmaps Association (info@openflightmaps.org).   This data is covered by the open flightmaps general user license, which can be found on the www.openflightmaps.org" << endl << endl << endl;
    
    cout.precision(10);
    out.precision(10);
    cout << std::setfill('0') << std::setw(2);
    out << std::setfill('0') << std::setw(2);
    
	
	//Searching words
	def=doc_def.first_node("default_values");

	aixm_node = doc.first_node()->first_node("AIXM-Snapshot");

	if(aixm_node == NULL)
	{ 
		cout << "ERROR: ROOT Node 'AIXM-Snapshot' not found." << endl;
		return 1;	
	}
	
	
	// Searching all Ahps
	cout << "Searching all Ahps... " << endl;

	xml_node<> * current_Ahp=aixm_node->first_node("Ahp");
    complete_Ahp(current_Ahp,out);
	while(true)
	{
        if(current_Ahp->next_sibling("Ahp")==NULL)
            break;
        
        current_Ahp=current_Ahp->next_sibling("Ahp");
        complete_Ahp(current_Ahp,out);
    }
	out << "99" << endl;
    out.close();
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20758, %rsp          # imm = 0x20758
movq %rsi, %r12
cmpl $0x1, %edi
jg 0x250f
movq 0xcb01(%rip), %rbx      # 0xefd0
leaq 0x8b9a(%rip), %rsi      # 0xb070
movl $0x7, %edx
movq %rbx, %rdi
callq 0x21d0
movq (%r12), %r14
testq %r14, %r14
je 0x29ed
movq %r14, %rdi
callq 0x20e0
movq 0xcad1(%rip), %rdi      # 0xefd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x21d0
jmp 0x2a04
movq 0xcaba(%rip), %r15      # 0xefd0
leaq 0x8b66(%rip), %rsi      # 0xb083
movl $0x12, %edx
movq %r15, %rdi
callq 0x21d0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
xorl %eax, %eax
leaq -0x20720(%rbp), %rbx
movq %rax, -0x40(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbx)
movl %eax, -0x38(%rbx)
movq %rax, -0x30(%rbx)
movq %rax, -0x20(%rbx)
movl $0x10078, %ecx          # imm = 0x10078
leaq -0x20780(%rbp), %rdx
addq %rcx, %rdx
leaq -0x20708(%rbp), %rsi
movups %xmm0, 0x10000(%rsi)
movq %rsi, -0x18(%rsi)
movq %rsi, -0x10(%rsi)
movq %rdx, -0x8(%rsi)
leaq -0x10690(%rbp), %r14
movq %rax, -0x40(%r14)
movaps %xmm0, -0x60(%r14)
movl %eax, -0x38(%r14)
movq %rax, -0x30(%r14)
movq %rax, -0x20(%r14)
leaq -0x106f0(%rbp), %rax
addq %rcx, %rax
leaq -0x10678(%rbp), %rcx
movups %xmm0, 0x10000(%rcx)
movq %rcx, -0x18(%rcx)
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movq 0x8(%r12), %rsi
leaq -0x668(%rbp), %rdi
movl $0x8, %edx
callq 0x2350
leaq -0x5f0(%rbp), %rdi
callq 0x2070
testb %al, %al
je 0x299c
movq -0x668(%rbp), %rax
movq -0x18(%rax), %rax
movq -0x580(%rbp,%rax), %rsi
leaq -0x58(%rbp), %rdi
leaq -0x460(%rbp), %r9
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x860a
leaq -0x460(%rbp), %rsi
movb $0x0, (%rsi)
leaq -0x58(%rbp), %rdi
callq 0x8cea
movq -0x58(%rbp), %rsi
leaq -0x20780(%rbp), %rdi
callq 0x864c
leaq 0x8a51(%rip), %rsi      # 0xb0ae
leaq -0x460(%rbp), %rdi
movl $0x8, %edx
callq 0x2350
leaq -0x3e8(%rbp), %rdi
callq 0x2070
testb %al, %al
je 0x2a4a
movq -0x460(%rbp), %rax
movq -0x18(%rax), %rax
movq -0x378(%rbp,%rax), %rsi
leaq -0x40(%rbp), %rdi
leaq -0x258(%rbp), %r9
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x860a
leaq -0x258(%rbp), %rsi
movb $0x0, (%rsi)
leaq -0x40(%rbp), %rdi
callq 0x8cea
movq -0x40(%rbp), %rsi
leaq -0x106f0(%rbp), %rdi
callq 0x864c
leaq -0x258(%rbp), %rdi
callq 0x22f0
leaq 0x89f8(%rip), %rsi      # 0xb0e0
leaq -0x258(%rbp), %rdi
movl $0x20, %edx
callq 0x2060
leaq 0x89e8(%rip), %rsi      # 0xb0e8
leaq -0x258(%rbp), %r12
movl $0x1, %edx
movq %r12, %rdi
callq 0x21d0
movq -0x258(%rbp), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
leaq -0x258(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq 0x89a0(%rip), %rsi      # 0xb0ea
leaq -0x258(%rbp), %r12
movl $0x105, %edx            # imm = 0x105
movq %r12, %rdi
callq 0x21d0
movq -0x258(%rbp), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
leaq -0x258(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movq (%r15), %rcx
movq -0x18(%rcx), %rax
movl $0xa, %edx
movq %rdx, 0x8(%r15,%rax)
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rsi
movq %rdx, -0x250(%rbp,%rsi)
movq -0x18(%rcx), %rdx
leaq (%r15,%rdx), %r12
cmpb $0x0, 0xe1(%r15,%rdx)
jne 0x2838
movq %r12, %rdi
movl $0x20, %esi
callq 0x2190
movb $0x1, 0xe1(%r12)
movq (%r15), %rcx
movq -0x258(%rbp), %rax
movb $0x30, 0xe0(%r12)
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%r15,%rcx)
movq -0x18(%rax), %rcx
leaq (%rcx,%rbp), %r15
addq $-0x258, %r15           # imm = 0xFDA8
cmpb $0x0, 0xe1(%r15)
jne 0x2883
movq %r15, %rdi
movl $0x20, %esi
callq 0x2190
movb $0x1, 0xe1(%r15)
movq -0x258(%rbp), %rax
movb $0x30, 0xe0(%r15)
movq -0x18(%rax), %rax
movq $0x2, -0x248(%rbp,%rax)
leaq 0x894e(%rip), %rsi      # 0xb1f0
leaq -0x106f0(%rbp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8774
movq %rax, 0xc924(%rip)      # 0xf1e0
movq -0x20750(%rbp), %rdi
leaq 0x8935(%rip), %rsi      # 0xb1ff
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8774
movq %rax, %r15
testq %rax, %rax
je 0x2af6
movq 0xc6e7(%rip), %r12      # 0xefd0
leaq 0x8949(%rip), %rsi      # 0xb239
movl $0x16, %edx
movq %r12, %rdi
callq 0x21d0
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0xc6b4(%rip), %rdi      # 0xefd0
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq 0x8920(%rip), %rsi      # 0xb250
movq %r15, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8774
movq %rax, %r15
leaq -0x258(%rbp), %rsi
movq %rax, %rdi
callq 0x2c82
leaq 0x88f8(%rip), %r12      # 0xb250
leaq -0x258(%rbp), %r13
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x885a
testq %rax, %rax
je 0x2a9b
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x885a
movq %rax, %r15
movq %rax, %rdi
movq %r13, %rsi
callq 0x2c82
jmp 0x295f
movq 0xc62d(%rip), %r15      # 0xefd0
leaq 0x86ec(%rip), %rsi      # 0xb096
movl $0x17, %edx
movq %r15, %rdi
callq 0x21d0
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0xc5fb(%rip), %rdi      # 0xefd0
callq 0x2040
movl $0x1, %r15d
movq %rax, %rdi
callq 0x2140
jmp 0x2bae
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x22e0
leaq 0x866d(%rip), %rsi      # 0xb078
movl $0xa, %edx
movq %rbx, %rdi
callq 0x21d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
movl $0x1, %r15d
jmp 0x2bca
movq 0xc57f(%rip), %r15      # 0xefd0
leaq 0x8668(%rip), %rsi      # 0xb0c0
movl $0x1f, %edx
movq %r15, %rdi
callq 0x21d0
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0xc54d(%rip), %rdi      # 0xefd0
callq 0x2040
movl $0x1, %r15d
movq %rax, %rdi
callq 0x2140
jmp 0x2b8d
leaq 0x87b2(%rip), %rsi      # 0xb254
leaq -0x258(%rbp), %r15
movl $0x2, %edx
movq %r15, %rdi
callq 0x21d0
movq -0x258(%rbp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
leaq -0x258(%rbp), %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2140
xorl %r15d, %r15d
leaq -0x258(%rbp), %rdi
callq 0x2210
jmp 0x2b42
movq 0xc4d3(%rip), %r15      # 0xefd0
leaq 0x8709(%rip), %rsi      # 0xb20d
movl $0x2b, %edx
movq %r15, %rdi
callq 0x21d0
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq 0xc4a1(%rip), %rdi      # 0xefd0
callq 0x2040
movl $0x1, %r15d
movq %rax, %rdi
callq 0x2140
movq 0xc47f(%rip), %rax      # 0xefc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x250(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x258(%rbp,%rcx)
callq 0x2170
leaq -0x160(%rbp), %rdi
callq 0x20c0
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x2b8d
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq -0x460(%rbp), %rdi
callq 0x2080
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x2bae
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq -0x668(%rbp), %rdi
callq 0x2080
movq %r14, %rdi
callq 0x8a40
movq %rbx, %rdi
callq 0x8a40
movl %r15d, %eax
addq $0x20758, %rsp          # imm = 0x20758
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2be3
jmp 0x2be3
movq %rax, %r15
jmp 0x2c1e
jmp 0x2bfc
jmp 0x2bee
jmp 0x2bee
movq %rax, %r15
jmp 0x2c3f
jmp 0x2c08
jmp 0x2c7a
jmp 0x2c7a
movq %rax, %r15
jmp 0x2c33
movq %rax, %r15
jmp 0x2c60
jmp 0x2c0f
movq %rax, %r15
jmp 0x2c54
jmp 0x2c0f
movq %rax, %r15
leaq -0x258(%rbp), %rdi
callq 0x2230
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x2c33
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq -0x460(%rbp), %rdi
callq 0x2080
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x2c54
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq -0x668(%rbp), %rdi
callq 0x2080
movq %r14, %rdi
callq 0x8a40
movq %rbx, %rdi
callq 0x8a40
movq %r15, %rdi
callq 0x2330
jmp 0x2c7a
movq %rax, %rdi
callq 0x8aa1