// File: /workspace/github_cpp_makefile_star2_O1/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 0x251f
movq 0xcaf1(%rip), %rbx      # 0xefd0
leaq 0x8b8a(%rip), %rsi      # 0xb070
movl $0x7, %edx
movq %rbx, %rdi
callq 0x21d0
movq (%r12), %r14
testq %r14, %r14
je 0x2a0c
movq %r14, %rdi
callq 0x20e0
movq 0xcac1(%rip), %rdi      # 0xefd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x21d0
jmp 0x2a23
movq 0xcaaa(%rip), %r15      # 0xefd0
leaq 0x8b56(%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 0x2360
leaq -0x5f0(%rbp), %rdi
callq 0x2070
testb %al, %al
je 0x29bb
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 0x8588
leaq -0x460(%rbp), %rsi
movb $0x0, (%rsi)
leaq -0x58(%rbp), %rdi
callq 0x8d16
movq -0x58(%rbp), %rsi
leaq -0x20780(%rbp), %rdi
callq 0x85ca
leaq 0x8a41(%rip), %rsi      # 0xb0ae
leaq -0x460(%rbp), %rdi
movl $0x8, %edx
callq 0x2360
leaq -0x3e8(%rbp), %rdi
callq 0x2070
testb %al, %al
je 0x2a69
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 0x8588
leaq -0x258(%rbp), %rsi
movb $0x0, (%rsi)
leaq -0x40(%rbp), %rdi
callq 0x8d16
movq -0x40(%rbp), %rsi
leaq -0x106f0(%rbp), %rdi
callq 0x85ca
leaq -0x258(%rbp), %rdi
callq 0x2300
leaq 0x89e8(%rip), %rsi      # 0xb0e0
leaq -0x258(%rbp), %rdi
movl $0x20, %edx
callq 0x2060
leaq 0x89d8(%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 0x8990(%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), %rax
movq -0x18(%rax), %rcx
movl $0xa, %edx
movq %rdx, 0x8(%r15,%rcx)
movq -0x258(%rbp), %rcx
movq -0x18(%rcx), %rcx
movq %rdx, -0x250(%rbp,%rcx)
movq -0x18(%rax), %rax
leaq (%r15,%rax), %r12
cmpb $0x0, 0xe1(%r15,%rax)
jne 0x2846
movq %r12, %rdi
movl $0x20, %esi
callq 0x2190
movb %al, 0xe0(%r12)
movb $0x1, 0xe1(%r12)
movb $0x30, 0xe0(%r12)
movq (%r15), %rax
movq -0x18(%rax), %rax
movq $0x2, 0x10(%r15,%rax)
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %r15
addq $-0x258, %r15           # imm = 0xFDA8
cmpb $0x0, 0xe1(%r15)
jne 0x289b
movq %r15, %rdi
movl $0x20, %esi
callq 0x2190
movb %al, 0xe0(%r15)
movb $0x1, 0xe1(%r15)
movb $0x30, 0xe0(%r15)
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rax
movq $0x2, -0x248(%rbp,%rax)
leaq 0x892f(%rip), %rsi      # 0xb1f0
leaq -0x106f0(%rbp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x86f4
movq %rax, 0xc90d(%rip)      # 0xf1e8
movq -0x20750(%rbp), %rdi
leaq 0x8916(%rip), %rsi      # 0xb1ff
xorl %edx, %edx
movl $0x1, %ecx
callq 0x86f4
movq %rax, %r15
testq %rax, %rax
je 0x2b15
movq 0xc6c8(%rip), %r12      # 0xefd0
leaq 0x892a(%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 0xc695(%rip), %rdi      # 0xefd0
callq 0x2040
movq %rax, %rdi
callq 0x2140
leaq 0x8901(%rip), %rsi      # 0xb250
movq %r15, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x86f4
movq %rax, %r15
leaq -0x258(%rbp), %rsi
movq %rax, %rdi
callq 0x2ca1
leaq 0x88d9(%rip), %r12      # 0xb250
leaq -0x258(%rbp), %r13
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8822
testq %rax, %rax
je 0x2aba
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8822
movq %rax, %r15
movq %rax, %rdi
movq %r13, %rsi
callq 0x2ca1
jmp 0x297e
movq 0xc60e(%rip), %r15      # 0xefd0
leaq 0x86cd(%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 0xc5dc(%rip), %rdi      # 0xefd0
callq 0x2040
movl $0x1, %r15d
movq %rax, %rdi
callq 0x2140
jmp 0x2bcd
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x22f0
leaq 0x864e(%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 0x2be9
movq 0xc560(%rip), %r15      # 0xefd0
leaq 0x8649(%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 0xc52e(%rip), %rdi      # 0xefd0
callq 0x2040
movl $0x1, %r15d
movq %rax, %rdi
callq 0x2140
jmp 0x2bac
leaq 0x8793(%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 0x2b61
movq 0xc4b4(%rip), %r15      # 0xefd0
leaq 0x86ea(%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 0xc482(%rip), %rdi      # 0xefd0
callq 0x2040
movl $0x1, %r15d
movq %rax, %rdi
callq 0x2140
movq 0xc460(%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 0x2bac
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq -0x460(%rbp), %rdi
callq 0x2080
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x2bcd
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq -0x668(%rbp), %rdi
callq 0x2080
movq %r14, %rdi
callq 0x8a8a
movq %rbx, %rdi
callq 0x8a8a
movl %r15d, %eax
addq $0x20758, %rsp          # imm = 0x20758
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c02
jmp 0x2c02
movq %rax, %r15
jmp 0x2c3d
jmp 0x2c1b
jmp 0x2c0d
jmp 0x2c0d
movq %rax, %r15
jmp 0x2c5e
jmp 0x2c27
jmp 0x2c99
jmp 0x2c99
movq %rax, %r15
jmp 0x2c52
movq %rax, %r15
jmp 0x2c7f
jmp 0x2c2e
movq %rax, %r15
jmp 0x2c73
jmp 0x2c2e
movq %rax, %r15
leaq -0x258(%rbp), %rdi
callq 0x2240
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x2c52
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq -0x460(%rbp), %rdi
callq 0x2080
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x2c73
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x21b0
leaq -0x668(%rbp), %rdi
callq 0x2080
movq %r14, %rdi
callq 0x8a8a
movq %rbx, %rdi
callq 0x8a8a
movq %r15, %rdi
callq 0x2340
jmp 0x2c99
movq %rax, %rdi
callq 0x8aed