// File: /workspace/github_cpp_makefile_star2_O2/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 0x2527
movq 0xaae1(%rip), %rdi      # 0xcfd0
leaq 0x6b7a(%rip), %rsi      # 0x9070
callq 0x21b0
movq (%r12), %rsi
movq %rax, %rdi
callq 0x21b0
leaq 0x6b6a(%rip), %rsi      # 0x9078
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
pushq $0x1
popq %r15
jmp 0x292a
movq 0xaaa2(%rip), %r15      # 0xcfd0
leaq 0x6b4e(%rip), %rsi      # 0x9083
movq %r15, %rdi
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
leaq -0x10690(%rbp), %rax
andq $0x0, -0x40(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rax)
andl $0x0, -0x38(%rax)
andq $0x0, -0x30(%rax)
andq $0x0, -0x20(%rax)
movl $0x10078, %eax          # imm = 0x10078
leaq -0x106f0(%rbp), %rcx
addq %rax, %rcx
leaq -0x10678(%rbp), %rdx
movups %xmm0, 0x10000(%rdx)
movq %rdx, -0x18(%rdx)
leaq -0x20720(%rbp), %r14
andq $0x0, -0x40(%r14)
movaps %xmm0, -0x60(%r14)
andl $0x0, -0x38(%r14)
movq %rdx, -0x10(%rdx)
andq $0x0, -0x30(%r14)
movq %rcx, -0x8(%rdx)
andq $0x0, -0x20(%r14)
leaq -0x20780(%rbp), %rcx
addq %rax, %rcx
leaq -0x20708(%rbp), %rax
movups %xmm0, 0x10000(%rax)
movq %rax, -0x18(%rax)
movq %rax, -0x10(%rax)
movq %rcx, -0x8(%rax)
movq 0x8(%r12), %rsi
leaq -0x668(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2350
leaq -0x5f0(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x2854
movq -0x668(%rbp), %rax
movq -0x18(%rax), %rax
movq -0x580(%rbp,%rax), %rsi
leaq -0x58(%rbp), %rdi
pushq $-0x1
popq %rdx
leaq -0x460(%rbp), %r9
xorl %ecx, %ecx
movl %edx, %r8d
callq 0x6c4a
leaq -0x460(%rbp), %rsi
movb $0x0, (%rsi)
leaq -0x58(%rbp), %rdi
callq 0x70ac
movq -0x58(%rbp), %rsi
leaq -0x106f0(%rbp), %rdi
callq 0x6c7c
leaq 0x6a5e(%rip), %rsi      # 0x90ae
leaq -0x460(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2350
leaq -0x3e8(%rbp), %rdi
callq 0x2060
testb %al, %al
je 0x2878
movq -0x460(%rbp), %rax
movq -0x18(%rax), %rax
movq -0x378(%rbp,%rax), %rsi
leaq -0x40(%rbp), %rdi
pushq $-0x1
popq %rdx
leaq -0x258(%rbp), %r9
xorl %ecx, %ecx
movl %edx, %r8d
callq 0x6c4a
leaq -0x258(%rbp), %rsi
movb $0x0, (%rsi)
leaq -0x40(%rbp), %rdi
callq 0x70ac
movq -0x40(%rbp), %rsi
leaq -0x20780(%rbp), %rdi
callq 0x6c7c
leaq -0x258(%rbp), %rdi
callq 0x22f0
leaq 0x6a0c(%rip), %rsi      # 0x90e0
leaq -0x258(%rbp), %rdi
pushq $0x20
popq %rdx
callq 0x2050
leaq 0x69fe(%rip), %rsi      # 0x90e8
leaq -0x258(%rbp), %rdi
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
leaq 0x69e5(%rip), %rsi      # 0x90ea
leaq -0x258(%rbp), %rdi
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x20e0
movq (%r15), %rax
movq -0x18(%rax), %rax
pushq $0xa
popq %rcx
movq %rcx, 0x8(%r15,%rax)
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rax
movq %rcx, -0x250(%rbp,%rax)
pushq $0x30
popq %rsi
movq %r15, %rdi
callq 0x2290
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
leaq -0x258(%rbp), %rdi
pushq $0x30
popq %rsi
callq 0x2290
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
leaq 0x6a64(%rip), %rsi      # 0x91f0
leaq -0x20780(%rbp), %rdi
pushq $0x1
popq %rcx
xorl %edx, %edx
callq 0x6d52
movq %rax, 0xaa4c(%rip)      # 0xd1f0
movq -0x106c0(%rbp), %rdi
leaq 0x6a4d(%rip), %rsi      # 0x91ff
pushq $0x1
popq %r15
xorl %edx, %edx
movl %r15d, %ecx
callq 0x6d52
movq %rax, %rbx
testq %rax, %rax
je 0x28c5
movq 0xa7fd(%rip), %rdi      # 0xcfd0
leaq 0x6a5f(%rip), %rsi      # 0x9239
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
leaq 0x6a62(%rip), %rsi      # 0x9250
pushq $0x1
popq %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x6d52
movq %rax, %r15
leaq -0x258(%rbp), %rsi
movq %rax, %rdi
callq 0x29bd
leaq 0x6a3c(%rip), %r12      # 0x9250
pushq $0x1
popq %r13
leaq -0x258(%rbp), %rbx
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movl %r13d, %ecx
callq 0x6dec
testq %rax, %rax
je 0x2899
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
movl %r13d, %ecx
callq 0x6dec
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
callq 0x29bd
jmp 0x281f
movq 0xa775(%rip), %rdi      # 0xcfd0
leaq 0x6834(%rip), %rsi      # 0x9096
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
pushq $0x1
popq %r15
jmp 0x290a
movq 0xa751(%rip), %rdi      # 0xcfd0
leaq 0x683a(%rip), %rsi      # 0x90c0
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
pushq $0x1
popq %r15
jmp 0x28f5
leaq 0x69b4(%rip), %rsi      # 0x9254
leaq -0x258(%rbp), %rdi
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
xorl %r15d, %r15d
leaq -0x258(%rbp), %rdi
callq 0x2230
jmp 0x28e0
movq 0xa704(%rip), %rdi      # 0xcfd0
leaq 0x693a(%rip), %rsi      # 0x920d
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
leaq -0x258(%rbp), %rdi
callq 0x2250
leaq -0x40(%rbp), %rdi
callq 0x7082
leaq -0x460(%rbp), %rdi
callq 0x2070
leaq -0x58(%rbp), %rdi
callq 0x7082
leaq -0x668(%rbp), %rdi
callq 0x2070
movq %r14, %rdi
callq 0x6f60
leaq -0x10690(%rbp), %rdi
callq 0x6f60
movl %r15d, %eax
addq $0x20758, %rsp          # imm = 0x20758
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2943
jmp 0x2943
movq %rax, %r15
jmp 0x2977
jmp 0x294a
movq %rax, %r15
jmp 0x2980
jmp 0x2953
jmp 0x2953
movq %rax, %r15
jmp 0x298c
jmp 0x295c
jmp 0x2968
movq %rax, %r15
jmp 0x2995
movq %rax, %r15
jmp 0x29a1
jmp 0x2968
movq %rax, %r15
leaq -0x258(%rbp), %rdi
callq 0x2250
leaq -0x40(%rbp), %rdi
callq 0x7082
leaq -0x460(%rbp), %rdi
callq 0x2070
leaq -0x58(%rbp), %rdi
callq 0x7082
leaq -0x668(%rbp), %rdi
callq 0x2070
movq %r14, %rdi
callq 0x6f60
leaq -0x10690(%rbp), %rdi
callq 0x6f60
movq %r15, %rdi
callq 0x2330