// File: icemiliang[P]vot/src/vot/diagram.cc
// Function: vot::Diagram::update_dirac()
bool Diagram::update_dirac() {
        std::vector<Dirac> newDiracs(mNumDiracs, Dirac(0, 0, 0, 0, 0, false));
        // Sum up all empirical measures
        for (int iterE = 0; iterE < mNumEmpiricals; iterE++) {
            newDiracs[mEmpiricals[iterE].cellIndex()] += 
                                    Dirac(mEmpiricals[iterE].x() * mEmpiricals[iterE].mass(),
                                          mEmpiricals[iterE].y() * mEmpiricals[iterE].mass(),
                                          mEmpiricals[iterE].z() * mEmpiricals[iterE].mass(),
                                          0,
                                          mEmpiricals[iterE].mass(),
                                          false);
        }

        // Compute new Dirac measures
        for (int iterD = 0; iterD < mNumDiracs; iterD++) {
            // Use old dirac measure
            newDiracs[iterD].reset_dirac(mDiracs[iterD].dirac());

            // Divide x,y,z by mass
            double mass = newDiracs[iterD].mass();
            // If cell is empty, do not update the dirac
            if (mass < vot::otTOLERANCE) {
                newDiracs[iterD] = mDiracs[iterD];
                continue;
            } 
            newDiracs[iterD] /= mass;
            newDiracs[iterD].set_mass(mass);
        }

        // Check if old and new Dirac measures have similar locations
        for (int iterD = 0; iterD < mNumDiracs; iterD++) {
            if (fabs(mDiracs[iterD].x() - newDiracs[iterD].x()) > otTOLERANCE ||
                fabs(mDiracs[iterD].y() - newDiracs[iterD].y()) > otTOLERANCE ||
                fabs(mDiracs[iterD].z() - newDiracs[iterD].z()) > otTOLERANCE) {
                // Update Dirac measures
                mDiracs = newDiracs;
                
                // Reset h to 1
                std::fill(mHs.begin(), mHs.end(), 1.0);
                return false;
            }
        }

        // Update Dirac measures
        mDiracs = newDiracs;
        return true;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xf8(%rbp)
movslq 0x38(%rax), %rax
movq %rax, -0xf0(%rbp)
leaq -0x58(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
xorps %xmm4, %xmm4
xorl %esi, %esi
movaps %xmm4, %xmm0
movaps %xmm4, %xmm1
movaps %xmm4, %xmm2
movaps %xmm4, %xmm3
callq 0x21690
leaq -0x59(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x224c0
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
movq -0xe0(%rbp), %rcx
leaq -0x28(%rbp), %rdi
callq 0x224e0
jmp 0x20c36
leaq -0x59(%rbp), %rdi
callq 0x22560
leaq -0x58(%rbp), %rdi
callq 0x21710
movl $0x0, -0x70(%rbp)
movq -0xf8(%rbp), %rcx
movl -0x70(%rbp), %eax
cmpl 0x3c(%rcx), %eax
jge 0x20ea5
movq -0xf8(%rbp), %rdi
addq $0x8, %rdi
movslq -0x70(%rbp), %rsi
callq 0x21ab0
movq %rax, %rdi
callq 0x218d0
movsd %xmm0, -0x100(%rbp)
jmp 0x20c88
movq -0xf8(%rbp), %rdi
addq $0x8, %rdi
movslq -0x70(%rbp), %rsi
callq 0x21ab0
movq %rax, %rdi
callq 0x21ad0
movsd %xmm0, -0x108(%rbp)
jmp 0x20cae
movq -0xf8(%rbp), %rdi
movsd -0x108(%rbp), %xmm1
movsd -0x100(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x118(%rbp)
addq $0x8, %rdi
movslq -0x70(%rbp), %rsi
callq 0x21ab0
movq %rax, %rdi
callq 0x218f0
movsd %xmm0, -0x110(%rbp)
jmp 0x20cf0
movq -0xf8(%rbp), %rdi
addq $0x8, %rdi
movslq -0x70(%rbp), %rsi
callq 0x21ab0
movq %rax, %rdi
callq 0x21ad0
movsd %xmm0, -0x120(%rbp)
jmp 0x20d16
movq -0xf8(%rbp), %rdi
movsd -0x120(%rbp), %xmm1
movsd -0x110(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x130(%rbp)
addq $0x8, %rdi
movslq -0x70(%rbp), %rsi
callq 0x21ab0
movq %rax, %rdi
callq 0x21910
movsd %xmm0, -0x128(%rbp)
jmp 0x20d58
movq -0xf8(%rbp), %rdi
addq $0x8, %rdi
movslq -0x70(%rbp), %rsi
callq 0x21ab0
movq %rax, %rdi
callq 0x21ad0
movsd %xmm0, -0x138(%rbp)
jmp 0x20d7e
movq -0xf8(%rbp), %rdi
movsd -0x138(%rbp), %xmm1
movsd -0x128(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x148(%rbp)
addq $0x8, %rdi
movslq -0x70(%rbp), %rsi
callq 0x21ab0
movq %rax, %rdi
callq 0x21ad0
movsd %xmm0, -0x140(%rbp)
jmp 0x20dc0
movsd -0x140(%rbp), %xmm4
movsd -0x148(%rbp), %xmm2
movsd -0x130(%rbp), %xmm1
movsd -0x118(%rbp), %xmm0
leaq -0xa0(%rbp), %rdi
xorps %xmm3, %xmm3
xorl %esi, %esi
callq 0x21690
jmp 0x20df3
movq -0xf8(%rbp), %rdi
addq $0x8, %rdi
movslq -0x70(%rbp), %rsi
callq 0x21ab0
movq %rax, %rdi
callq 0x22580
movl %eax, -0x14c(%rbp)
jmp 0x20e17
movl -0x14c(%rbp), %eax
movslq %eax, %rsi
leaq -0x28(%rbp), %rdi
callq 0x218b0
movq %rax, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x225a0
jmp 0x20e3a
leaq -0xa0(%rbp), %rdi
callq 0x21710
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x20c4f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x22560
leaq -0x58(%rbp), %rdi
callq 0x21710
jmp 0x2127b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x21272
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x21710
jmp 0x21272
movl $0x0, -0xa4(%rbp)
movq -0xf8(%rbp), %rcx
movl -0xa4(%rbp), %eax
cmpl 0x38(%rcx), %eax
jge 0x2100d
movslq -0xa4(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x218b0
movq -0xf8(%rbp), %rdi
movq %rax, -0x160(%rbp)
addq $0x20, %rdi
movslq -0xa4(%rbp), %rsi
callq 0x218b0
movq %rax, %rdi
callq 0x21970
movsd %xmm0, -0x158(%rbp)
jmp 0x20f05
movsd -0x158(%rbp), %xmm0
movq -0x160(%rbp), %rdi
callq 0x22640
jmp 0x20f1b
movslq -0xa4(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x218b0
movq %rax, %rdi
callq 0x21930
movsd %xmm0, -0x168(%rbp)
jmp 0x20f3d
movsd -0x168(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd 0x6ce5b(%rip), %xmm0    # 0x8ddb0
ucomisd -0xb0(%rbp), %xmm0
jbe 0x20fa3
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
movslq -0xa4(%rbp), %rsi
callq 0x218b0
movq %rax, -0x170(%rbp)
movslq -0xa4(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x218b0
movq -0x170(%rbp), %rsi
movq %rax, %rdi
movl $0x29, %edx
callq 0xa410
jmp 0x20ff9
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0x178(%rbp)
movslq -0xa4(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x218b0
movsd -0x178(%rbp), %xmm0
movq %rax, %rdi
callq 0x22660
jmp 0x20fd5
movslq -0xa4(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x218b0
movq %rax, %rdi
movsd -0xb0(%rbp), %xmm0
callq 0x22700
jmp 0x20ff7
jmp 0x20ff9
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x20eaf
movl $0x0, -0xb4(%rbp)
movq -0xf8(%rbp), %rcx
movl -0xb4(%rbp), %eax
cmpl 0x38(%rcx), %eax
jge 0x21237
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
movslq -0xb4(%rbp), %rsi
callq 0x218b0
movq %rax, %rdi
callq 0x218d0
movsd %xmm0, -0x180(%rbp)
jmp 0x21056
movslq -0xb4(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x218b0
movq %rax, %rdi
callq 0x218d0
movsd %xmm0, -0x188(%rbp)
jmp 0x21078
movsd -0x188(%rbp), %xmm1
movsd -0x180(%rbp), %xmm0
subsd %xmm1, %xmm0
movaps 0x6cd0d(%rip), %xmm1    # 0x8dda0
pand %xmm1, %xmm0
movsd 0x6cd11(%rip), %xmm1    # 0x8ddb0
ucomisd %xmm1, %xmm0
ja 0x2119d
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
movslq -0xb4(%rbp), %rsi
callq 0x218b0
movq %rax, %rdi
callq 0x218f0
movsd %xmm0, -0x190(%rbp)
jmp 0x210d2
movslq -0xb4(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x218b0
movq %rax, %rdi
callq 0x218f0
movsd %xmm0, -0x198(%rbp)
jmp 0x210f4
movsd -0x198(%rbp), %xmm1
movsd -0x190(%rbp), %xmm0
subsd %xmm1, %xmm0
movaps 0x6cc91(%rip), %xmm1    # 0x8dda0
pand %xmm1, %xmm0
movsd 0x6cc95(%rip), %xmm1    # 0x8ddb0
ucomisd %xmm1, %xmm0
ja 0x2119d
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
movslq -0xb4(%rbp), %rsi
callq 0x218b0
movq %rax, %rdi
callq 0x21910
movsd %xmm0, -0x1a0(%rbp)
jmp 0x2114a
movslq -0xb4(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x218b0
movq %rax, %rdi
callq 0x21910
movsd %xmm0, -0x1a8(%rbp)
jmp 0x2116c
movsd -0x1a8(%rbp), %xmm1
movsd -0x1a0(%rbp), %xmm0
subsd %xmm1, %xmm0
movaps 0x6cc19(%rip), %xmm1    # 0x8dda0
pand %xmm1, %xmm0
movsd 0x6cc1d(%rip), %xmm1    # 0x8ddb0
ucomisd %xmm1, %xmm0
jbe 0x21221
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
leaq -0x28(%rbp), %rsi
callq 0x22720
jmp 0x211b3
movq -0xf8(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x229b0
movq -0x1b0(%rbp), %rdi
movq %rax, -0xc0(%rbp)
callq 0x229e0
movq %rax, -0xc8(%rbp)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, -0xd0(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x22970
jmp 0x21211
movb $0x0, -0x1(%rbp)
movl $0x1, -0xd4(%rbp)
jmp 0x2125b
jmp 0x21223
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x21017
movq -0xf8(%rbp), %rdi
addq $0x20, %rdi
leaq -0x28(%rbp), %rsi
callq 0x22720
jmp 0x2124d
movb $0x1, -0x1(%rbp)
movl $0x1, -0xd4(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x215a0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x215a0
movq -0x68(%rbp), %rdi
callq 0xa950
nopw %cs:(%rax,%rax)