// File: /workspace/github_cpp_makefile_star2_O2/openflightmaps[P]ofm2xplane/main.cpp
// Function: write_coordinates(rapidxml::xml_node<char>*, std::basic_ofstream<char, std::char_traits<char>>&, int, int)
void write_coordinates(xml_node<> *source, ofstream &out, int line, int light)
{
    // Extracting coordinates 
    string s(source->value());
    size_t l=0,r=-1, ll, rr;
    int c=0;
    string x,y,bx,by;
    
    while(true)
    {
        l=s.find_first_of("1234567890.",r+1);
        r=s.find_first_not_of("1234567890.",l)-1;
        c++;
        if(r==s.npos-1)
            break;
    }
    c--;

    long double *coor=new long double[c];
    l=0;
    r=-1;
    
    for(int i=0;i<c;i++)
    {
        l=s.find_first_of("1234567890.",r+1);
        r=s.find_first_not_of("11234567890.",l)-1;
        coor[i]=my_stold(s.substr(l,r-l+1));
    }
    delete [] coor;
    c=c/2;
        
    r=-1;
    l=0;
    for(int i=0;i<c-1;i=i+3)
    {
        l=s.find_first_of("1234567890.",r+1);
        r=s.find_first_not_of("1234567890.",l)-1;
        x=s.substr(l,r-l+1);
        l=s.find_first_of("1234567890.",r+1);
        r=s.find_first_not_of("1234567890.",l)-1;
        y=s.substr(l,r-l+1);     
        
        l=s.find_first_of("1234567890.",r+1);
        r=s.find_first_not_of("1234567890.",l)-1;
        bx=s.substr(l,r-l+1);
        l=s.find_first_of("1234567890.",r+1);
        r=s.find_first_not_of("1234567890.",l)-1;
        by=s.substr(l,r-l+1);    
        
        //out << "112 " << y << " " << x << " " << by << " " << bx << " ";
        out << "112 " << y << " " << x << " ";
        out << by << " " << bx << " ";
        //out << 2*my_stold(y)-my_stold(by) << " " << 2*my_stold(x)-my_stold(bx) << " ";
        if(line!=0)
            out << line << " ";
        if(light!=0)
            out << light << " ";
        out << endl;
        
        l=s.find_first_of("1234567890.",r+1);
        r=s.find_first_not_of("1234567890.",l)-1;
        bx=s.substr(l,r-l+1);
        l=s.find_first_of("1234567890.",r+1);
        r=s.find_first_not_of("1234567890.",l)-1;
        by=s.substr(l,r-l+1);
        
        ll=l;
        rr=r;     
        
        l=s.find_first_of("1234567890.",r+1);
        r=s.find_first_not_of("1234567890.",l)-1;
        x=s.substr(l,r-l+1);
        l=s.find_first_of("1234567890.",r+1);
        r=s.find_first_not_of("1234567890.",l)-1;
        y=s.substr(l,r-l+1);  
        
        out << "116 " << y << " " << x << " ";
        //out << by << " " << bx << " ";
        out << 2*my_stold(y)-my_stold(by) << " " << 2*my_stold(x)-my_stold(bx) << " ";
        
        if(line!=0)
            out << line << " "; // line
        if(light!=0)
            out << light << " "; // light
        out << endl;
        r=rr;
        l=ll;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %ecx, -0x34(%rbp)
movl %edx, -0x38(%rbp)
movq %rsi, -0x30(%rbp)
movq 0x8(%rdi), %rax
testq %rax, %rax
leaq 0x7aa9(%rip), %rsi      # 0xd1f8
cmovneq %rax, %rsi
leaq -0x118(%rbp), %rbx
leaq -0x70(%rbp), %rdx
movq %rbx, %rdi
callq 0x6f24
leaq -0x60(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %eax, %eax
leaq -0x88(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %al, (%rcx)
movb %al, (%rdx)
leaq -0xa8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
leaq -0xc8(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %al, (%rcx)
movb %al, (%rdx)
pushq $-0x1
popq %r12
leaq 0x3d5d(%rip), %r14      # 0x9515
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2100
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2150
incl %r12d
cmpq $-0x1, %rax
jne 0x57b8
xorl %ebx, %ebx
leaq -0x118(%rbp), %r14
leaq -0x1b8(%rbp), %r13
movl %r12d, -0x3c(%rbp)
subl $0x1, %r12d
jb 0x584b
movq %r14, %rdi
leaq 0x3d14(%rip), %rsi      # 0x9515
movq %rbx, %rdx
callq 0x2100
movq %rax, %r15
movq %r14, %rdi
leaq 0x3cfe(%rip), %rsi      # 0x9514
movq %rax, %rdx
callq 0x2150
movq %rax, %rbx
movq %rax, %rcx
subq %r15, %rcx
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x21e0
movq %r13, %rdi
xorl %esi, %esi
callq 0x64c4
fstp %st(0)
movq %r13, %rdi
callq 0x20d0
jmp 0x57f1
movl -0x3c(%rbp), %eax
shrl %eax
decl %eax
movl %eax, -0x3c(%rbp)
xorl %r14d, %r14d
leaq 0x3cb6(%rip), %r12      # 0x9515
leaq -0x118(%rbp), %r13
leaq -0xf8(%rbp), %rbx
xorl %eax, %eax
movl %eax, -0x40(%rbp)
cmpl -0x3c(%rbp), %eax
jge 0x5d96
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2100
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2150
movq %rax, %r14
movq %rax, %rcx
subq %r15, %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x21e0
leaq -0x70(%rbp), %rdi
movq %rbx, %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x20d0
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2100
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2150
movq %rax, %r14
movq %rax, %rcx
subq %r15, %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x21e0
leaq -0x98(%rbp), %rdi
movq %rbx, %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x20d0
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2100
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2150
movq %rax, %r14
movq %rax, %rcx
subq %r15, %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x21e0
leaq -0xb8(%rbp), %rdi
movq %rbx, %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x20d0
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2100
movq %rax, %r15
movq %r13, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2150
movq %rax, %r14
movq %rax, %rcx
subq %r15, %rcx
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x21e0
leaq -0xd8(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x20d0
movq -0x30(%rbp), %rdi
leaq 0x3b67(%rip), %rsi      # 0x9521
callq 0x21b0
movq %rax, %rdi
leaq -0x98(%rbp), %rsi
callq 0x21a0
movq %rax, %rdi
leaq 0x3876(%rip), %rsi      # 0x924e
callq 0x21b0
movq %rax, %rdi
leaq -0x70(%rbp), %rsi
callq 0x21a0
movq %rax, %rdi
leaq 0x385b(%rip), %rsi      # 0x924e
callq 0x21b0
movq -0x30(%rbp), %rdi
movq %r12, %rsi
callq 0x21a0
movq %rax, %rdi
leaq 0x3840(%rip), %rsi      # 0x924e
callq 0x21b0
movq %rax, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x21a0
movq %rax, %rdi
leaq 0x3822(%rip), %rsi      # 0x924e
callq 0x21b0
cmpl $0x0, -0x38(%rbp)
je 0x5a52
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x2310
movq %rax, %rdi
leaq 0x3801(%rip), %rsi      # 0x924e
callq 0x21b0
cmpl $0x0, -0x34(%rbp)
je 0x5a73
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x2310
movq %rax, %rdi
leaq 0x37e0(%rip), %rsi      # 0x924e
callq 0x21b0
movq -0x30(%rbp), %rdi
callq 0x20e0
movq %r13, %rdi
movq %rbx, %r12
movq %r13, %rbx
leaq 0x3a89(%rip), %r13      # 0x9515
movq %r13, %rsi
movq %r14, %rdx
callq 0x2100
movq %rax, %r15
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x2150
movq %rax, %r14
movq %rax, %rcx
subq %r15, %rcx
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x21e0
leaq -0xb8(%rbp), %rdi
leaq -0xf8(%rbp), %r12
movq %r12, %rsi
callq 0x2200
movq %r12, %rdi
callq 0x20d0
movq %rbx, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2100
movq %rax, %r15
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x2150
movq %rax, %r13
movq %rax, %rcx
subq %r15, %rcx
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x21e0
leaq -0xd8(%rbp), %rdi
leaq -0xf8(%rbp), %r14
movq %r14, %rsi
callq 0x2200
movq %r14, %rdi
callq 0x20d0
movq %rbx, %rdi
leaq 0x39da(%rip), %rsi      # 0x9515
movq %r13, -0x78(%rbp)
movq %r13, %rdx
movq %rsi, %r13
callq 0x2100
movq %rax, %r12
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x2150
movq %rax, %r15
movq %rax, %rcx
subq %r12, %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x21e0
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
callq 0x2200
movq %r14, %rdi
callq 0x20d0
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x2100
movq %rax, %r15
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x2150
subq %r15, %rax
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x21e0
movq %rbx, %r13
leaq -0x98(%rbp), %rdi
leaq -0xf8(%rbp), %rbx
movq %rbx, %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x20d0
movq -0x30(%rbp), %rdi
leaq 0x3941(%rip), %rsi      # 0x9526
callq 0x21b0
leaq -0xd8(%rbp), %r15
movq -0x78(%rbp), %r14
movq %rax, %rdi
leaq -0x98(%rbp), %rsi
callq 0x21a0
movq %rax, %rdi
leaq 0x3640(%rip), %rsi      # 0x924e
callq 0x21b0
movq %rax, %rdi
leaq -0x70(%rbp), %rsi
callq 0x21a0
movq %rax, %rdi
leaq 0x3625(%rip), %rsi      # 0x924e
callq 0x21b0
leaq -0x158(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x2220
leaq -0x158(%rbp), %rdi
xorl %esi, %esi
callq 0x64c4
fstpt -0x4c(%rbp)
leaq -0x198(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2220
movq %r12, %rdi
xorl %esi, %esi
callq 0x64c4
fldt -0x4c(%rbp)
fadd %st, %st(0)
fsubp %st, %st(1)
fstpt (%rsp)
movq -0x30(%rbp), %rdi
callq 0x2110
fldz
fstp %st(0)
movq %rax, %rdi
leaq 0x35bf(%rip), %rsi      # 0x924e
callq 0x21b0
fldz
movq %rax, %r15
fstp %st(0)
leaq -0x138(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x2220
fldz
fstp %st(0)
leaq -0x138(%rbp), %rdi
xorl %esi, %esi
callq 0x64c4
fstpt -0x4c(%rbp)
leaq -0x178(%rbp), %r12
movq %r12, %rdi
leaq -0xb8(%rbp), %rsi
callq 0x2220
movq %r12, %rdi
xorl %esi, %esi
callq 0x64c4
fldt -0x4c(%rbp)
fadd %st, %st(0)
fsubp %st, %st(1)
fstpt (%rsp)
movq %r15, %rdi
callq 0x2110
fldz
fstp %st(0)
movq %rax, %rdi
leaq 0x354e(%rip), %rsi      # 0x924e
callq 0x21b0
fldz
fstp %st(0)
leaq -0x178(%rbp), %rdi
callq 0x20d0
leaq -0x138(%rbp), %rdi
callq 0x20d0
leaq -0x198(%rbp), %rdi
callq 0x20d0
leaq -0x158(%rbp), %rdi
callq 0x20d0
cmpl $0x0, -0x38(%rbp)
je 0x5d5a
movq -0x30(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0x2310
movq %rax, %rdi
leaq 0x34f9(%rip), %rsi      # 0x924e
callq 0x21b0
cmpl $0x0, -0x34(%rbp)
je 0x5d7b
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x2310
movq %rax, %rdi
leaq 0x34d8(%rip), %rsi      # 0x924e
callq 0x21b0
movq -0x30(%rbp), %rdi
callq 0x20e0
movl -0x40(%rbp), %eax
addl $0x3, %eax
leaq 0x3784(%rip), %r12      # 0x9515
jmp 0x586f
leaq -0xd8(%rbp), %rdi
callq 0x20d0
leaq -0xb8(%rbp), %rdi
callq 0x20d0
leaq -0x98(%rbp), %rdi
callq 0x20d0
leaq -0x70(%rbp), %rdi
callq 0x20d0
leaq -0x118(%rbp), %rdi
callq 0x20d0
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5e47
jmp 0x5e47
jmp 0x5e47
jmp 0x5e47
jmp 0x5e47
jmp 0x5e47
jmp 0x5e47
jmp 0x5e47
jmp 0x5e47
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
jmp 0x5e40
movq %rax, %rbx
jmp 0x5e1a
movq %rax, %rbx
jmp 0x5e39
fstp %st(0)
movq %rax, %rbx
leaq -0x178(%rbp), %rdi
callq 0x20d0
leaq -0x138(%rbp), %rdi
callq 0x20d0
jmp 0x5e2d
fstp %st(0)
movq %rax, %rbx
leaq -0x198(%rbp), %rdi
callq 0x20d0
leaq -0x158(%rbp), %rdi
callq 0x20d0
jmp 0x5e4a
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x20d0
leaq -0xb8(%rbp), %rdi
callq 0x20d0
leaq -0x98(%rbp), %rdi
callq 0x20d0
leaq -0x70(%rbp), %rdi
callq 0x20d0
leaq -0x118(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x2330