// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
movq %rdx, -0x58(%rbp)
movq %rsi, %r14
movq 0x8(%rdi), %rsi
testq %rsi, %rsi
leaq 0x7ba0(%rip), %rbx      # 0xf1f0
cmoveq %rbx, %rsi
leaq -0xb0(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x8a4c
movq 0x7b7d(%rip), %rdi      # 0xf1e8
leaq 0x3e8b(%rip), %rsi      # 0xb4fd
xorl %edx, %edx
movl $0x1, %ecx
callq 0x86f4
leaq 0x3ec8(%rip), %rsi      # 0xb54d
movq %rax, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x86f4
movq 0x8(%rax), %rsi
testq %rsi, %rsi
cmoveq %rbx, %rsi
leaq -0x148(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x8a4c
leaq -0x148(%rbp), %rdi
xorl %esi, %esi
callq 0x5a83
movq %r14, -0x78(%rbp)
movsd %xmm0, -0x90(%rbp)
fldl -0x90(%rbp)
fstpt -0x64(%rbp)
leaq -0x138(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x76f1
movq -0x138(%rbp), %rsi
incq %rsi
callq 0x21b0
movq $-0x1, %r13
movq $-0x10, %rbx
xorl %eax, %eax
leaq 0x3e0d(%rip), %r14      # 0xb515
leaq -0xb0(%rbp), %r15
movl $0xb, %ecx
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2260
movl $0xb, %ecx
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x22e0
incq %r13
addq $0x10, %rbx
cmpq $-0x1, %rax
jne 0x770f
movq %rbx, %rdi
callq 0x2030
movq %rax, %r14
movl %r13d, %ebx
shrl %ebx
shlq $0x4, %rbx
movq %rbx, %rdi
callq 0x2030
movq %rax, %r15
movq %rbx, %rdi
callq 0x2030
movq %rax, -0x38(%rbp)
movq %r14, -0x40(%rbp)
movq %r12, -0x70(%rbp)
testl %r13d, %r13d
je 0x783b
movq $0x0, -0x50(%rbp)
movq %r13, %rbx
movq -0x40(%rbp), %r14
movq %r15, -0x80(%rbp)
movl $0xb, %ecx
leaq -0xb0(%rbp), %r12
movq %r12, %rdi
leaq 0x3d6e(%rip), %rsi      # 0xb515
movq -0x50(%rbp), %rdx
callq 0x2260
movq %rax, %r15
movl $0xc, %ecx
movq %r12, %rdi
leaq 0x3d52(%rip), %rsi      # 0xb514
movq %rax, %rdx
callq 0x22e0
movq %rax, %rcx
movq %rax, -0x50(%rbp)
subq %r15, %rcx
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
leaq -0xb0(%rbp), %rsi
movq %r15, %rdx
callq 0x21c0
movq %r12, %rdi
xorl %esi, %esi
callq 0x5a83
movsd %xmm0, -0x88(%rbp)
fldl -0x88(%rbp)
fstpt (%r14)
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
movq -0x80(%rbp), %r15
je 0x782e
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x21b0
addq $0x10, %r14
decq %rbx
jne 0x7791
cmpl $0x2, %r13d
movq -0x40(%rbp), %r14
movq -0x38(%rbp), %r12
fldt -0x64(%rbp)
jb 0x78c4
shrq %r13
cmpq $0x1, %r13
adcq $0x0, %r13
xorl %ebx, %ebx
flds 0x37f9(%rip)            # 0xb058
fstpt -0xe8(%rbp)
fldl 0x37cd(%rip)            # 0xb038
fstpt -0xdc(%rbp)
fldt 0x10(%r14,%rbx,2)
fldt -0xe8(%rbp)
fld %st(1)
fmul %st(1), %st
fldt -0xdc(%rbp)
fdivr %st, %st(1)
fxch %st(1)
fmul %st(4), %st
fstpt (%r12,%rbx)
fldt (%r14,%rbx,2)
fmul %st(2), %st
fdiv %st(1), %st
fmulp %st, %st(4)
fxch %st(3)
fstpt -0x50(%rbp)
fxch %st(1)
fmulp %st, %st(2)
fdivrp %st, %st(1)
fstpt (%rsp)
callq 0x21e0
fldt -0x64(%rbp)
fldt -0x50(%rbp)
fmulp %st, %st(2)
fxch %st(1)
fstpt (%r15,%rbx)
addq $0x10, %rbx
decq %r13
jne 0x7871
fstp %st(0)
fldt (%r15)
fldt 0x10(%r15)
fsubrp %st, %st(1)
fldt (%r12)
fldt 0x10(%r12)
fsubrp %st, %st(1)
fstpt 0x10(%rsp)
fstpt (%rsp)
callq 0x2290
fmuls 0x376c(%rip)            # 0xb058
fdivl 0x3746(%rip)            # 0xb038
movq -0x78(%rbp), %rax
fstpl (%rax)
fldt (%r15)
fldt 0x10(%r15)
fsubrp %st, %st(1)
fldt (%r12)
fldt 0x10(%r12)
fsubrp %st, %st(1)
fmul %st, %st(0)
fxch %st(1)
fmul %st, %st(0)
faddp %st, %st(1)
fstpt (%rsp)
callq 0x2220
movq -0x58(%rbp), %r14
fstpl (%r14)
fldt 0x20(%r15)
fldt 0x10(%r15)
fsubrp %st, %st(1)
fldt 0x20(%r12)
fldt 0x10(%r12)
fsubrp %st, %st(1)
fmul %st, %st(0)
fxch %st(1)
fmul %st, %st(0)
faddp %st, %st(1)
fstpt (%rsp)
callq 0x2220
movq -0x70(%rbp), %rbx
fstpl (%rbx)
movsd (%r14), %xmm0
movq -0x40(%rbp), %r14
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x79f7
jp 0x79f7
movq 0x7875(%rip), %rdi      # 0xf1e8
leaq 0x3b04(%rip), %rsi      # 0xb47e
xorl %edx, %edx
movl $0x1, %ecx
callq 0x86f4
leaq 0x3bcc(%rip), %rsi      # 0xb559
movq %rax, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x86f4
movq 0x8(%rax), %rsi
testq %rsi, %rsi
leaq 0x7846(%rip), %rax      # 0xf1f0
cmoveq %rax, %rsi
leaq -0x128(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x8a4c
leaq -0x128(%rbp), %rdi
xorl %esi, %esi
callq 0x5a83
movq -0x38(%rbp), %r12
movq -0x58(%rbp), %rax
movsd %xmm0, (%rax)
leaq -0x118(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x79f7
movq -0x118(%rbp), %rsi
incq %rsi
callq 0x21b0
movsd (%rbx), %xmm0
ucomisd 0x363d(%rip), %xmm0     # 0xb040
jne 0x7a96
jp 0x7a96
movq 0x77d2(%rip), %rdi      # 0xf1e8
leaq 0x3a61(%rip), %rsi      # 0xb47e
xorl %edx, %edx
movl $0x1, %ecx
callq 0x86f4
leaq 0x3b32(%rip), %rsi      # 0xb562
movq %rax, %rdi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x86f4
movq 0x8(%rax), %rax
testq %rax, %rax
leaq 0x77a3(%rip), %rsi      # 0xf1f0
cmovneq %rax, %rsi
leaq -0x108(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x8a4c
leaq -0x108(%rbp), %rdi
xorl %esi, %esi
callq 0x5a83
movq -0x38(%rbp), %r12
movsd %xmm0, (%rbx)
leaq -0xf8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7a96
movq -0xf8(%rbp), %rsi
incq %rsi
callq 0x21b0
movq %r15, %rdi
callq 0x2200
movq %r12, %rdi
callq 0x2200
movq %r14, %rdi
callq 0x2200
leaq -0xa0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7acd
movq -0xa0(%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 -0xf8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7b6b
movq -0xf8(%rbp), %rsi
jmp 0x7b63
jmp 0x7b41
movq %rax, %rbx
leaq -0x118(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7b6b
movq -0x118(%rbp), %rsi
jmp 0x7b63
jmp 0x7b41
jmp 0x7b41
jmp 0x7b41
movq %rax, %rbx
leaq -0x138(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7b6b
movq -0x138(%rbp), %rsi
jmp 0x7b63
jmp 0x7b41
jmp 0x7b41
jmp 0x7b41
movq %rax, %rbx
jmp 0x7b6b
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x7b6b
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x21b0
leaq -0xa0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7b8a
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x21b0
movq %rbx, %rdi
callq 0x2340