// File: /workspace/github_cpp_makefile_star2_O2/openflightmaps[P]ofm2xplane/main.cpp
// Function: dimension(rapidxml::xml_node<char>*, double&, double&, double&)
void dimension(xml_node<> *source, double &HDG, double &len, double &wid)
{
    // Extracting coordinates 
    long double pi=3.14159265358;
    string s(source->value());
//    string s("16.2514907056155,47.8451013849285 16.2514907056155,47.8451013849285 16.2514907056155,47.8451013849285 16.2514907056155,47.8451013849285");
    size_t l=0,r=-1;
    int c=0;
    long double rad=my_stod(string(def->first_node("others")->first_node("earthRadius")->value()));
    
    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];
    long double *x=new long double[c/2];
    long double *y=new long double[c/2];
    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));
    }
    
    // Converting to local x and y
    c=c/2;
    for (int i=0;i<c;i++)
    {
        y[i]=coor[2*i+1]*180/pi*rad;
        x[i]=coor[2*i]*180/pi*rad * cos(coor[2*i+1]*pi/180);
    }
    
    HDG=atan2(x[0]-x[1],y[0]-y[1]) * 180/pi;
    len=sqrt( (x[0]-x[1])*(x[0]-x[1]) + (y[0]-y[1])*(y[0]-y[1]));
    wid=sqrt( (x[2]-x[1])*(x[2]-x[1]) + (y[2]-y[1])*(y[2]-y[1]));
    if(len==0)
        len=my_stod(string(def->first_node("misc")->first_node("heli_len")->value()));
    if(wid==0)
        wid=my_stod(string(def->first_node("misc")->first_node("heli_wid")->value()));
    
    delete [] x;
    delete [] y;
    delete [] coor;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rcx, -0x40(%rbp)
movq %rdx, -0x78(%rbp)
movq %rsi, %rbx
movq 0x8(%rdi), %rsi
testq %rsi, %rsi
leaq 0x716f(%rip), %rax      # 0xd1f8
cmoveq %rax, %rsi
leaq -0xc8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x6f24
movq 0x714c(%rip), %rdi      # 0xd1f0
leaq 0x3452(%rip), %rsi      # 0x94fd
pushq $0x1
popq %rcx
xorl %edx, %edx
callq 0x6d52
leaq 0x3491(%rip), %rsi      # 0x954d
pushq $0x1
popq %rcx
movq %rax, %rdi
xorl %edx, %edx
callq 0x6d52
movq 0x8(%rax), %rsi
testq %rsi, %rsi
leaq 0x7121(%rip), %rax      # 0xd1f8
cmoveq %rax, %rsi
leaq -0x128(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x6f24
movq %rbx, -0x90(%rbp)
leaq -0x128(%rbp), %rdi
xorl %esi, %esi
callq 0x4bba
movsd %xmm0, -0x38(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x20d0
pushq $-0x1
popq %r14
pushq $-0x10
popq %rbx
xorl %eax, %eax
leaq 0x33f4(%rip), %r12      # 0x9515
leaq -0xc8(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2100
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2150
incq %r14
addq $0x10, %rbx
cmpq $-0x1, %rax
jne 0x6128
movsd -0x38(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
fldl -0xa8(%rbp)
fstpt -0x6c(%rbp)
movq %rbx, %rdi
callq 0x2030
movq %rax, %r12
movl %r14d, %ebx
shrl %ebx
shlq $0x4, %rbx
movq %rbx, %rdi
callq 0x2030
movq %rax, %r15
movq %r14, -0x38(%rbp)
movq %rbx, %rdi
callq 0x2030
movq %rax, -0x48(%rbp)
movq %r15, -0x80(%rbp)
xorl %edx, %edx
leaq -0x148(%rbp), %r14
movq %r12, -0x88(%rbp)
movq %r12, %r15
movq -0x38(%rbp), %r12
subq $0x1, %r12
jb 0x6229
leaq -0xc8(%rbp), %rbx
movq %rbx, %rdi
leaq 0x334d(%rip), %rsi      # 0x9515
callq 0x2100
movq %rax, %r13
movq %rbx, %rdi
leaq 0x333a(%rip), %rsi      # 0x9514
movq %rax, %rdx
callq 0x2150
movq %rax, %rbx
movq %rax, %rcx
subq %r13, %rcx
movq %r14, %rdi
leaq -0xc8(%rbp), %rsi
movq %r13, %rdx
callq 0x21e0
movq %r14, %rdi
xorl %esi, %esi
callq 0x4bba
movsd %xmm0, -0xa0(%rbp)
fldl -0xa0(%rbp)
fstpt (%r15)
movq %r14, %rdi
callq 0x20d0
addq $0x10, %r15
movq %rbx, %rdx
jmp 0x61b1
movq -0x38(%rbp), %r14
shrq %r14
xorl %ebx, %ebx
flds 0x2e18(%rip)            # 0x9050
fstpt -0x60(%rbp)
fldl 0x2df7(%rip)            # 0x9038
fstpt -0x54(%rbp)
movq -0x88(%rbp), %r15
movq -0x80(%rbp), %r12
subq $0x1, %r14
jb 0x629e
fldt 0x10(%r15,%rbx,2)
fldt -0x60(%rbp)
fld %st(1)
fmul %st(1), %st
fldt -0x54(%rbp)
fdivr %st, %st(1)
fldt -0x6c(%rbp)
fmul %st, %st(2)
movq -0x48(%rbp), %rax
fxch %st(2)
fstpt (%rax,%rbx)
fldt (%r15,%rbx,2)
fmul %st(3), %st
fdiv %st(1), %st
fmulp %st, %st(2)
fxch %st(1)
fstpt -0x38(%rbp)
fmulp %st, %st(2)
fdivrp %st, %st(1)
fstpt (%rsp)
callq 0x21f0
fldt -0x38(%rbp)
fmulp %st, %st(1)
fstpt (%r12,%rbx)
addq $0x10, %rbx
jmp 0x624f
fldt (%r12)
fldt 0x10(%r12)
fld %st(0)
fstpt -0x38(%rbp)
fsubrp %st, %st(1)
fld %st(0)
fstpt -0x60(%rbp)
movq -0x48(%rbp), %rbx
fldt (%rbx)
fldt 0x10(%rbx)
fld %st(0)
fstpt -0x6c(%rbp)
fsubrp %st, %st(1)
fld %st(0)
fstpt -0x54(%rbp)
fstpt 0x10(%rsp)
fstpt (%rsp)
callq 0x22a0
fmuls 0x2d76(%rip)            # 0x9050
fdivl 0x2d58(%rip)            # 0x9038
movq -0x90(%rbp), %rax
fstpl (%rax)
fldt -0x54(%rbp)
fmul %st, %st(0)
fldt -0x60(%rbp)
fmul %st, %st(0)
faddp %st, %st(1)
fsqrt
movq -0x78(%rbp), %rcx
fstpl (%rcx)
fldt 0x20(%r12)
fldt -0x38(%rbp)
fsubrp %st, %st(1)
fldt 0x20(%rbx)
fldt -0x6c(%rbp)
fsubrp %st, %st(1)
fmul %st, %st(0)
fxch %st(1)
fmul %st, %st(0)
faddp %st, %st(1)
fsqrt
fstpl -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
movq -0x40(%rbp), %rax
movsd %xmm0, (%rax)
movsd (%rcx), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jne 0x63bb
jp 0x63bb
movq 0x6eaa(%rip), %rdi      # 0xd1f0
leaq 0x3131(%rip), %rsi      # 0x947e
pushq $0x1
popq %rcx
xorl %edx, %edx
callq 0x6d52
leaq 0x31fb(%rip), %rsi      # 0x9559
pushq $0x1
popq %rcx
movq %rax, %rdi
xorl %edx, %edx
callq 0x6d52
movq 0x8(%rax), %rsi
testq %rsi, %rsi
leaq 0x6e7f(%rip), %rax      # 0xd1f8
cmoveq %rax, %rsi
leaq -0x108(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x6f24
leaq -0x108(%rbp), %rdi
xorl %esi, %esi
callq 0x4bba
movq -0x78(%rbp), %rax
movsd %xmm0, (%rax)
leaq -0x108(%rbp), %rdi
callq 0x20d0
movq -0x40(%rbp), %rax
movsd (%rax), %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jne 0x6433
jp 0x6433
movq 0x6e26(%rip), %rdi      # 0xd1f0
leaq 0x30ad(%rip), %rsi      # 0x947e
pushq $0x1
popq %rcx
xorl %edx, %edx
callq 0x6d52
leaq 0x3180(%rip), %rsi      # 0x9562
pushq $0x1
popq %rcx
movq %rax, %rdi
xorl %edx, %edx
callq 0x6d52
movq 0x8(%rax), %rax
testq %rax, %rax
leaq 0x6dfb(%rip), %rsi      # 0xd1f8
cmovneq %rax, %rsi
leaq -0xe8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x6f24
leaq -0xe8(%rbp), %rdi
xorl %esi, %esi
callq 0x4bba
movq -0x40(%rbp), %rax
movsd %xmm0, (%rax)
leaq -0xe8(%rbp), %rdi
callq 0x20d0
movq %r12, %rdi
callq 0x2210
movq -0x48(%rbp), %rdi
callq 0x2210
movq %r15, %rdi
callq 0x2210
leaq -0xc8(%rbp), %rdi
callq 0x20d0
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
jmp 0x64ab
jmp 0x649c
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0x64ab
jmp 0x649c
jmp 0x649c
jmp 0x649c
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
jmp 0x64ab
jmp 0x649c
jmp 0x649c
jmp 0x649c
movq %rax, %rbx
jmp 0x64b0
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x20d0
leaq -0xc8(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x2330