// File: 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
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0xcd90
movq %rax, -0xb8(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x3450
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0xcdd0
jmp 0xadcc
leaq -0x31(%rbp), %rdi
callq 0x3260
movq $0x0, -0x50(%rbp)
movq $-0x1, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
jmp 0xadfe
movq -0x58(%rbp), %rdx
addq $0x1, %rdx
leaq -0x30(%rbp), %rdi
leaq 0x670a(%rip), %rsi      # 0x1151b
callq 0x3120
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdx
leaq -0x30(%rbp), %rdi
leaq 0x66f2(%rip), %rsi      # 0x1151b
callq 0x3150
subq $0x1, %rax
movq %rax, -0x58(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
cmpq $-0x2, -0x58(%rbp)
jne 0xae62
jmp 0xae64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x3260
jmp 0xb0e4
jmp 0xadfc
movl -0x5c(%rbp), %eax
decl %eax
movl %eax, -0x5c(%rbp)
movslq -0x5c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xc0(%rbp)
jmp 0xae94
movq -0xc0(%rbp), %rax
movq %rax, -0x78(%rbp)
movq $0x0, -0x50(%rbp)
movq $-0x1, -0x58(%rbp)
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0xaf9a
movq -0x58(%rbp), %rdx
incq %rdx
leaq 0x664b(%rip), %rsi      # 0x1151b
leaq -0x30(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x3120
movq -0xc8(%rbp), %rdi
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdx
leaq 0x6624(%rip), %rsi      # 0x1151a
callq 0x3150
movq -0xc8(%rbp), %rsi
decq %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdx
movq -0x58(%rbp), %rcx
subq %rdx, %rcx
incq %rcx
leaq -0xa0(%rbp), %rdi
callq 0x3230
jmp 0xaf25
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
callq 0x8d50
movsd %xmm0, -0xd0(%rbp)
jmp 0xaf3d
movsd -0xd0(%rbp), %xmm0
movq -0x78(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
leaq -0xa0(%rbp), %rdi
callq 0x3160
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0xaeb6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xb0db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x3160
jmp 0xb0db
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jge 0xaff9
movq -0x78(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x78(%rbp), %rax
movl -0xa4(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movl -0xa4(%rbp), %eax
addl $0x2, %eax
movl %eax, -0xa4(%rbp)
jmp 0xafa4
movl -0x5c(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
sarl %eax
movl %eax, -0x5c(%rbp)
movsd -0x68(%rbp), %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x70(%rbp), %xmm0
cvtsi2sdl -0x5c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x1f07(%rip), %rsi      # 0xcf40
callq 0x30b0
movq %rax, -0xd8(%rbp)
jmp 0xb047
movq -0xd8(%rbp), %rdi
movsd -0x70(%rbp), %xmm0
callq 0x3490
movq %rax, -0xe0(%rbp)
jmp 0xb061
movq -0xe0(%rbp), %rdi
leaq 0x61c3(%rip), %rsi      # 0x11232
callq 0x3200
movq %rax, -0xe8(%rbp)
jmp 0xb07d
movq -0xe8(%rbp), %rdi
movsd -0x68(%rbp), %xmm0
callq 0x3490
movq %rax, -0xf0(%rbp)
jmp 0xb097
movq -0xf0(%rbp), %rdi
leaq 0x618d(%rip), %rsi      # 0x11232
callq 0x3200
jmp 0xb0ac
movq -0x78(%rbp), %rax
movq %rax, -0xf8(%rbp)
cmpq $0x0, %rax
je 0xb0c9
movq -0xf8(%rbp), %rdi
callq 0x32e0
leaq -0x30(%rbp), %rdi
callq 0x3160
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x3160
movq -0x40(%rbp), %rdi
callq 0x3440
nopl (%rax)