// File: 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
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
fldl 0x5f27(%rip)            # 0x11038
fstpt -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0xcd90
movq %rax, -0x178(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x3450
movq -0x178(%rbp), %rsi
movq -0x170(%rbp), %rdx
leaq -0x50(%rbp), %rdi
callq 0xcdd0
jmp 0xb14d
leaq -0x51(%rbp), %rdi
callq 0x3260
movq $0x0, -0x70(%rbp)
movq $-0x1, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movq 0xb12c(%rip), %rdi      # 0x162a0
leaq 0x6388(%rip), %rsi      # 0x11503
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0xca70
movq %rax, -0x180(%rbp)
jmp 0xb192
movq -0x180(%rbp), %rdi
leaq 0x63b3(%rip), %rsi      # 0x11553
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0xca70
movq %rax, -0x188(%rbp)
jmp 0xb1b7
movq -0x188(%rbp), %rdi
callq 0xcd90
movq %rax, -0x190(%rbp)
jmp 0xb1cc
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x3450
movq -0x190(%rbp), %rsi
movq -0x198(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0xcdd0
jmp 0xb1fb
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
callq 0x8d50
movsd %xmm0, -0x1a0(%rbp)
jmp 0xb213
movsd -0x1a0(%rbp), %xmm0
movsd %xmm0, -0x158(%rbp)
fldl -0x158(%rbp)
fstpt -0x1ac(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3160
leaq -0xb1(%rbp), %rdi
callq 0x3260
fldt -0x1ac(%rbp)
fstpt -0x90(%rbp)
jmp 0xb255
movq -0x78(%rbp), %rdx
addq $0x1, %rdx
leaq -0x50(%rbp), %rdi
leaq 0x62b3(%rip), %rsi      # 0x1151b
callq 0x3120
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdx
leaq -0x50(%rbp), %rdi
leaq 0x629b(%rip), %rsi      # 0x1151b
callq 0x3150
subq $0x1, %rax
movq %rax, -0x78(%rbp)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
cmpq $-0x2, -0x78(%rbp)
jne 0xb301
jmp 0xb306
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x51(%rbp), %rdi
callq 0x3260
jmp 0xb956
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xb94d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xb2f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3160
leaq -0xb1(%rbp), %rdi
callq 0x3260
jmp 0xb94d
jmp 0xb253
movl -0x7c(%rbp), %eax
decl %eax
movl %eax, -0x7c(%rbp)
movslq -0x7c(%rbp), %rax
movl $0x10, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0x1b8(%rbp)
jmp 0xb336
movq -0x1b8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
sarl %eax
cltq
movl $0x10, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0x1c0(%rbp)
jmp 0xb376
movq -0x1c0(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %ecx, %eax
sarl %eax
cltq
movl $0x10, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0x1c8(%rbp)
jmp 0xb3b6
movq -0x1c8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq $0x0, -0x70(%rbp)
movq $-0x1, -0x78(%rbp)
movl $0x0, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
cmpl -0x7c(%rbp), %eax
jge 0xb4d0
movq -0x78(%rbp), %rdx
incq %rdx
leaq 0x6120(%rip), %rsi      # 0x1151b
leaq -0x50(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x3120
movq -0x1d0(%rbp), %rdi
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdx
leaq 0x60f9(%rip), %rsi      # 0x1151a
callq 0x3150
movq -0x1d0(%rbp), %rsi
decq %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdx
movq -0x78(%rbp), %rcx
subq %rdx, %rcx
incq %rcx
leaq -0xf8(%rbp), %rdi
callq 0x3230
jmp 0xb450
leaq -0xf8(%rbp), %rdi
xorl %esi, %esi
callq 0x8d50
movsd %xmm0, -0x1d8(%rbp)
jmp 0xb468
movsd -0x1d8(%rbp), %xmm0
movsd %xmm0, -0x168(%rbp)
fldl -0x168(%rbp)
movq -0xc0(%rbp), %rax
movslq -0xd4(%rbp), %rcx
shlq $0x4, %rcx
fstpt (%rax,%rcx)
leaq -0xf8(%rbp), %rdi
callq 0x3160
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0xb3de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x3160
jmp 0xb94d
movl -0x7c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x7c(%rbp)
movl $0x0, -0xfc(%rbp)
movl -0xfc(%rbp), %eax
cmpl -0x7c(%rbp), %eax
jge 0xb5ba
movq -0xc0(%rbp), %rax
movslq -0xfc(%rbp), %rcx
movl %ecx, %edx
addl %edx, %edx
movslq %edx, %rdx
shlq $0x4, %rdx
fldt 0x10(%rax,%rdx)
flds 0x5b36(%rip)            # 0x11050
fmul %st, %st(1)
fldt -0x30(%rbp)
fdivrp %st, %st(2)
fldt -0x90(%rbp)
fmulp %st, %st(2)
movq -0xd0(%rbp), %rax
shlq $0x4, %rcx
fxch %st(1)
fstpt (%rax,%rcx)
movq -0xc0(%rbp), %rax
movl -0xfc(%rbp), %ecx
addl %ecx, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
fldt (%rax,%rcx)
fmul %st(1), %st
fldt -0x30(%rbp)
fdivr %st, %st(1)
fldt -0x90(%rbp)
fmulp %st, %st(2)
fxch %st(1)
fstpt -0x1f0(%rbp)
fldt 0x10(%rax,%rcx)
fmulp %st, %st(1)
fdivp %st, %st(1)
movq %rsp, %rax
fstpt (%rax)
callq 0xcf70
fstpt -0x1e4(%rbp)
jmp 0xb583
fldt -0x1f0(%rbp)
fldt -0x1e4(%rbp)
fmulp %st, %st(1)
movq -0xc8(%rbp), %rax
movslq -0xfc(%rbp), %rcx
shlq $0x4, %rcx
fstpt (%rax,%rcx)
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0xb4e8
movq -0xc8(%rbp), %rax
fldt (%rax)
fldt 0x10(%rax)
fsubrp %st, %st(1)
movq -0xd0(%rbp), %rax
fldt (%rax)
fldt 0x10(%rax)
fsubrp %st, %st(1)
movq %rsp, %rax
fstpt 0x10(%rax)
fstpt (%rax)
callq 0xcfa0
fstpt -0x1fc(%rbp)
jmp 0xb5eb
fldt -0x1fc(%rbp)
flds 0x5a59(%rip)            # 0x11050
fmulp %st, %st(1)
fldt -0x30(%rbp)
fdivrp %st, %st(1)
movq -0x10(%rbp), %rax
fstpl (%rax)
movq -0xc8(%rbp), %rax
fldt (%rax)
fldt 0x10(%rax)
fsubrp %st, %st(1)
movq -0xd0(%rbp), %rax
fldt (%rax)
fldt 0x10(%rax)
fsubrp %st, %st(1)
fmul %st, %st(0)
fxch %st(1)
fmul %st, %st(0)
faddp %st, %st(1)
movq %rsp, %rax
fstpt (%rax)
callq 0xcfe0
fstpt -0x208(%rbp)
jmp 0xb63a
fldt -0x208(%rbp)
movq -0x18(%rbp), %rax
fstpl (%rax)
movq -0xc8(%rbp), %rax
fldt 0x20(%rax)
fldt 0x10(%rax)
fsubrp %st, %st(1)
movq -0xd0(%rbp), %rax
fldt 0x20(%rax)
fldt 0x10(%rax)
fsubrp %st, %st(1)
fmul %st, %st(0)
fxch %st(1)
fmul %st, %st(0)
faddp %st, %st(1)
movq %rsp, %rax
fstpt (%rax)
callq 0xcfe0
fstpt -0x214(%rbp)
jmp 0xb67e
fldt -0x214(%rbp)
fstpl -0x160(%rbp)
movsd -0x160(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xb7bc
jp 0xb7bc
movq 0xabe4(%rip), %rdi      # 0x162a0
leaq 0x5d9f(%rip), %rsi      # 0x11462
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0xca70
movq %rax, -0x220(%rbp)
jmp 0xb6da
movq -0x220(%rbp), %rdi
leaq 0x5e77(%rip), %rsi      # 0x1155f
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0xca70
movq %rax, -0x228(%rbp)
jmp 0xb6ff
movq -0x228(%rbp), %rdi
callq 0xcd90
movq %rax, -0x230(%rbp)
jmp 0xb714
leaq -0x121(%rbp), %rdi
movq %rdi, -0x238(%rbp)
callq 0x3450
movq -0x230(%rbp), %rsi
movq -0x238(%rbp), %rdx
leaq -0x120(%rbp), %rdi
callq 0xcdd0
jmp 0xb743
leaq -0x120(%rbp), %rdi
xorl %esi, %esi
callq 0x8d50
movsd %xmm0, -0x240(%rbp)
jmp 0xb75b
movsd -0x240(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
leaq -0x120(%rbp), %rdi
callq 0x3160
leaq -0x121(%rbp), %rdi
callq 0x3260
jmp 0xb7bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xb7ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x3160
leaq -0x121(%rbp), %rdi
callq 0x3260
jmp 0xb94d
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xb8db
jp 0xb8db
movq 0xaac2(%rip), %rdi      # 0x162a0
leaq 0x5c7d(%rip), %rsi      # 0x11462
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0xca70
movq %rax, -0x248(%rbp)
jmp 0xb7fc
movq -0x248(%rbp), %rdi
leaq 0x5d5e(%rip), %rsi      # 0x11568
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0xca70
movq %rax, -0x250(%rbp)
jmp 0xb821
movq -0x250(%rbp), %rdi
callq 0xcd90
movq %rax, -0x258(%rbp)
jmp 0xb836
leaq -0x149(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x3450
movq -0x258(%rbp), %rsi
movq -0x260(%rbp), %rdx
leaq -0x148(%rbp), %rdi
callq 0xcdd0
jmp 0xb865
leaq -0x148(%rbp), %rdi
xorl %esi, %esi
callq 0x8d50
movsd %xmm0, -0x268(%rbp)
jmp 0xb87d
movsd -0x268(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
leaq -0x148(%rbp), %rdi
callq 0x3160
leaq -0x149(%rbp), %rdi
callq 0x3260
jmp 0xb8db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0xb8cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x3160
leaq -0x149(%rbp), %rdi
callq 0x3260
jmp 0xb94d
movq -0xc8(%rbp), %rax
movq %rax, -0x270(%rbp)
cmpq $0x0, %rax
je 0xb8fb
movq -0x270(%rbp), %rdi
callq 0x32e0
movq -0xd0(%rbp), %rax
movq %rax, -0x278(%rbp)
cmpq $0x0, %rax
je 0xb91b
movq -0x278(%rbp), %rdi
callq 0x32e0
movq -0xc0(%rbp), %rax
movq %rax, -0x280(%rbp)
cmpq $0x0, %rax
je 0xb93b
movq -0x280(%rbp), %rdi
callq 0x32e0
leaq -0x50(%rbp), %rdi
callq 0x3160
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x3160
movq -0x60(%rbp), %rdi
callq 0x3440
nop