// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
movq %rdx, -0x88(%rbp)
movq %rsi, %rbx
movq 0x8(%rdi), %rsi
testq %rsi, %rsi
leaq 0x7b83(%rip), %rax      # 0xf1e8
cmoveq %rax, %rsi
leaq -0xa8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x8a02
movq 0x7b60(%rip), %rdi      # 0xf1e0
leaq 0x3e76(%rip), %rsi      # 0xb4fd
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8774
leaq 0x3eb3(%rip), %rsi      # 0xb54d
movq %rax, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8774
movq 0x8(%rax), %rsi
testq %rsi, %rsi
leaq 0x7b31(%rip), %rax      # 0xf1e8
cmoveq %rax, %rsi
leaq -0x150(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x8a02
leaq -0x150(%rbp), %rdi
xorl %esi, %esi
callq 0x5a62
movq %rbx, -0xb8(%rbp)
movsd %xmm0, -0xd0(%rbp)
fldl -0xd0(%rbp)
fstpt -0x44(%rbp)
leaq -0x140(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7710
movq -0x140(%rbp), %rsi
incq %rsi
callq 0x21b0
movq $-0x1, %r14
movq $-0x10, %rbx
xorl %eax, %eax
leaq 0x3dee(%rip), %r12      # 0xb515
leaq -0xa8(%rbp), %r15
movl $0xb, %ecx
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x2250
movl $0xb, %ecx
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x22d0
incq %r14
addq $0x10, %rbx
cmpq $-0x1, %rax
jne 0x772e
movq %rbx, %rdi
callq 0x2030
movq %rax, %r15
movl %r14d, %ebx
shrl %ebx
shlq $0x4, %rbx
movq %rbx, %rdi
callq 0x2030
movq %rax, %r12
movq %rbx, %rdi
callq 0x2030
movq %rax, %rbx
fldz
testl %r14d, %r14d
je 0x793f
fstp %st(0)
movq %rbx, -0xb0(%rbp)
movq %r12, -0x50(%rbp)
movq %r13, -0x80(%rbp)
xorl %r12d, %r12d
movq %r14, %r13
leaq -0xf0(%rbp), %r14
movq %r13, -0x38(%rbp)
movq %r15, -0x60(%rbp)
movq %r15, %rbx
movl $0xb, %ecx
leaq -0xa8(%rbp), %rdi
leaq 0x3d43(%rip), %rsi      # 0xb515
movq %r12, %rdx
callq 0x2250
movq %rax, %r15
movl $0xc, %ecx
leaq -0xa8(%rbp), %rdi
leaq 0x3d24(%rip), %rsi      # 0xb514
movq %rax, %rdx
callq 0x22d0
movq %rax, %r12
movq %rax, %rcx
subq %r15, %rcx
movq %r14, %rdi
leaq -0xa8(%rbp), %rsi
movq %r15, %rdx
callq 0x21c0
movq %r14, %rdi
xorl %esi, %esi
callq 0x5a62
movsd %xmm0, -0xc8(%rbp)
fldl -0xc8(%rbp)
fstpt (%rbx)
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x784f
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x21b0
addq $0x10, %rbx
decq %r13
jne 0x77bf
fldz
fld %st(0)
fld %st(1)
fld %st(2)
fld %st(3)
fld %st(4)
movq -0x38(%rbp), %r14
cmpl $0x1, %r14d
movq -0x80(%rbp), %r13
movq -0x60(%rbp), %r15
movq -0x50(%rbp), %r12
movq -0xb0(%rbp), %rbx
fxch %st(1)
fxch %st(5)
fxch %st(1)
je 0x7949
fstp %st(5)
fstp %st(4)
fstp %st(1)
fstp %st(1)
fstp %st(1)
fstp %st(0)
shrq %r14
cmpq $0x1, %r14
adcq $0x0, %r14
movq %rbx, %r13
xorl %ebx, %ebx
flds 0x37a7(%rip)            # 0xb058
fstpt -0x78(%rbp)
fldl 0x3786(%rip)            # 0xb040
fstpt -0x6c(%rbp)
fldt -0x44(%rbp)
fstp %st(0)
fldt 0x10(%r15,%rbx,2)
fldt -0x78(%rbp)
fld %st(1)
fmul %st(1), %st
fldt -0x6c(%rbp)
fdivr %st, %st(1)
fldt -0x44(%rbp)
fmul %st, %st(2)
fxch %st(2)
fstpt (%r13,%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 0x21e0
fldt -0x38(%rbp)
fmulp %st, %st(1)
fstpt (%r12,%rbx)
addq $0x10, %rbx
decq %r14
jne 0x78c2
fldt (%r12)
fldt 0x10(%r12)
fldt (%r13)
fldt 0x10(%r13)
fldt 0x20(%r12)
fldt 0x20(%r13)
movq %r13, %rbx
movq -0x80(%rbp), %r13
fxch %st(3)
fxch %st(5)
fxch %st(3)
fxch %st(4)
fxch %st(3)
fxch %st(1)
fxch %st(2)
fxch %st(1)
jmp 0x7949
fld %st(0)
fld %st(1)
fld %st(2)
fld %st(3)
fld %st(4)
fxch %st(2)
fstpt -0x6c(%rbp)
fld %st(2)
fstpt -0x78(%rbp)
fld %st(0)
fstpt -0x44(%rbp)
fxch %st(3)
fstpt -0x38(%rbp)
fsubp %st, %st(1)
fld %st(0)
fstpt -0x60(%rbp)
fxch %st(2)
fsubp %st, %st(1)
fld %st(0)
fstpt -0x50(%rbp)
fstpt 0x10(%rsp)
fstpt (%rsp)
callq 0x2280
fmuls 0x36d9(%rip)            # 0xb058
fdivl 0x36bb(%rip)            # 0xb040
movq -0xb8(%rbp), %rax
fstpl (%rax)
fldt -0x50(%rbp)
fmul %st, %st(0)
fldt -0x60(%rbp)
fmul %st, %st(0)
faddp %st, %st(1)
fsqrt
movq -0x88(%rbp), %rax
fstpl (%rax)
fldt -0x78(%rbp)
fldt -0x6c(%rbp)
fsubp %st, %st(1)
fldt -0x38(%rbp)
fldt -0x44(%rbp)
fsubrp %st, %st(1)
fmul %st, %st(0)
fxch %st(1)
fmul %st, %st(0)
faddp %st, %st(1)
fsqrt
fstpl -0xc0(%rbp)
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, (%r13)
movsd (%rax), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jne 0x7a7b
jp 0x7a7b
movq 0x77ee(%rip), %rdi      # 0xf1e0
leaq 0x3a85(%rip), %rsi      # 0xb47e
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8774
leaq 0x3b4d(%rip), %rsi      # 0xb559
movq %rax, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8774
movq 0x8(%rax), %rsi
testq %rsi, %rsi
leaq 0x77bf(%rip), %rax      # 0xf1e8
cmoveq %rax, %rsi
leaq -0x130(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x8a02
leaq -0x130(%rbp), %rdi
xorl %esi, %esi
callq 0x5a62
movq -0x88(%rbp), %rax
movsd %xmm0, (%rax)
leaq -0x120(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7a75
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x21b0
movsd (%r13), %xmm0
ucomisd 0x35b5(%rip), %xmm0     # 0xb038
jne 0x7b14
jp 0x7b14
movq 0x774a(%rip), %rdi      # 0xf1e0
leaq 0x39e1(%rip), %rsi      # 0xb47e
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8774
leaq 0x3ab2(%rip), %rsi      # 0xb562
movq %rax, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8774
movq 0x8(%rax), %rax
testq %rax, %rax
leaq 0x771b(%rip), %rsi      # 0xf1e8
cmovneq %rax, %rsi
leaq -0x110(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x8a02
leaq -0x110(%rbp), %rdi
xorl %esi, %esi
callq 0x5a62
movsd %xmm0, (%r13)
leaq -0x100(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7b14
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x21b0
movq %r12, %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x2200
movq %r15, %rdi
callq 0x2200
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7b4b
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x21b0
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x100(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7be9
movq -0x100(%rbp), %rsi
jmp 0x7be1
jmp 0x7bbf
movq %rax, %rbx
leaq -0x120(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7be9
movq -0x120(%rbp), %rsi
jmp 0x7be1
jmp 0x7bbf
jmp 0x7bbf
jmp 0x7bbf
movq %rax, %rbx
leaq -0x140(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7be9
movq -0x140(%rbp), %rsi
jmp 0x7be1
jmp 0x7bbf
jmp 0x7bbf
jmp 0x7bbf
movq %rax, %rbx
jmp 0x7be9
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x7be9
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x21b0
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7c08
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x2330