// File: /workspace/github_cpp_makefile_star2_O2/openflightmaps[P]ofm2xplane/main.cpp
// Function: write_center(rapidxml::xml_node<char>*, std::basic_ofstream<char, std::char_traits<char>>&)
void write_center(xml_node <> *source, ofstream &out)
{
    // Extracting coordinates 
    string s(source->value());
    size_t l=0,r=-1;
    int c=0;
    double x=0.0, y=0.0;
    
    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--;

    double *coor=new double[c];
    l=0;
    r=-1;
    
    // Saving the numbers in double array
    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_stod(s.substr(l,r-l+1));
    }
    
    for(int i=0;i<c;i=i+2)
    {
        x+=coor[i];
        y+=coor[i+1];
    }
    c=c/2;
    x=x/c;
    y=y/c;
    out << fixed << y << " " << x << " ";
    delete [] coor;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, -0x50(%rbp)
movq 0x8(%rdi), %rax
testq %rax, %rax
leaq 0x734a(%rip), %rsi      # 0xd1f8
cmovneq %rax, %rsi
leaq -0x70(%rbp), %r12
leaq -0x29(%rbp), %rdx
movq %r12, %rdi
callq 0x6f24
pushq $-0x1
popq %rbx
pushq $-0x8
popq %r14
xorl %eax, %eax
leaq 0x3643(%rip), %r15      # 0x9515
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2100
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2150
incq %rbx
addq $0x8, %r14
cmpq $-0x1, %rax
jne 0x5ed2
movq %rbx, -0x38(%rbp)
movq %r14, %rdi
callq 0x2030
xorl %edx, %edx
leaq -0x90(%rbp), %r13
movq %rax, -0x48(%rbp)
movq %rax, %r15
movq -0x38(%rbp), %r12
subq $0x1, %r12
jb 0x5f81
leaq -0x70(%rbp), %r14
movq %r14, %rdi
leaq 0x35e6(%rip), %rsi      # 0x9515
callq 0x2100
movq %rax, %rbx
movq %r14, %rdi
leaq 0x35d3(%rip), %rsi      # 0x9514
movq %rax, %rdx
callq 0x2150
movq %rax, %r14
movq %rax, %rcx
subq %rbx, %rcx
movq %r13, %rdi
leaq -0x70(%rbp), %rsi
movq %rbx, %rdx
callq 0x21e0
movq %r13, %rdi
xorl %esi, %esi
callq 0x4bba
movsd %xmm0, (%r15)
movq %r13, %rdi
callq 0x20d0
addq $0x8, %r15
movq %r14, %rdx
jmp 0x5f1b
xorpd %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorl %eax, %eax
movq -0x48(%rbp), %r14
movq -0x38(%rbp), %rcx
cmpq %rcx, %rax
jae 0x5fb6
movsd -0x40(%rbp), %xmm1
addsd (%r14,%rax,8), %xmm1
movsd %xmm1, -0x40(%rbp)
addsd 0x8(%r14,%rax,8), %xmm0
addq $0x2, %rax
jmp 0x5f94
shrl %ecx
cvtsi2sd %ecx, %xmm1
movq -0x50(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movl $0xfffffefb, %ecx       # imm = 0xFFFFFEFB
andl 0x18(%rdi,%rax), %ecx
orl $0x4, %ecx
movl %ecx, 0x18(%rdi,%rax)
movsd %xmm1, -0x38(%rbp)
divsd %xmm1, %xmm0
callq 0x22b0
leaq 0x3262(%rip), %rsi      # 0x924e
movq %rax, %rdi
callq 0x21b0
movsd -0x40(%rbp), %xmm0
divsd -0x38(%rbp), %xmm0
movq %rax, %rdi
callq 0x22b0
leaq 0x3241(%rip), %rsi      # 0x924e
movq %rax, %rdi
callq 0x21b0
movq %r14, %rdi
callq 0x2210
leaq -0x70(%rbp), %rdi
callq 0x20d0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6037
movq %rax, %rbx
jmp 0x604b
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x20d0
leaq -0x70(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x2330