// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movslq 0x38(%rdi), %rsi
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %rdx
movupd %xmm0, 0x19(%rdx)
movapd %xmm0, 0x10(%rdx)
movapd %xmm0, (%rdx)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
callq 0x13ba8
movslq 0x3c(%rbx), %rdx
testq %rdx, %rdx
jle 0x12f9a
movq 0x8(%rbx), %rax
movq 0x10(%rsp), %rcx
shlq $0x3, %rdx
leaq (%rdx,%rdx,4), %rdx
xorl %esi, %esi
xorpd %xmm0, %xmm0
movsd 0x18(%rax,%rsi), %xmm1
movsd (%rax,%rsi), %xmm2
movsd 0x8(%rax,%rsi), %xmm3
movsd 0x10(%rax,%rsi), %xmm4
movslq 0x20(%rax,%rsi), %rdi
leaq (%rdi,%rdi,2), %rdi
shlq $0x4, %rdi
mulsd %xmm1, %xmm2
addsd (%rcx,%rdi), %xmm2
movsd %xmm2, (%rcx,%rdi)
mulsd %xmm1, %xmm3
addsd 0x8(%rcx,%rdi), %xmm3
movsd %xmm3, 0x8(%rcx,%rdi)
mulsd %xmm1, %xmm4
addsd 0x10(%rcx,%rdi), %xmm4
movsd %xmm4, 0x10(%rcx,%rdi)
movsd 0x18(%rcx,%rdi), %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, 0x18(%rcx,%rdi)
addsd 0x20(%rcx,%rdi), %xmm1
movsd %xmm1, 0x20(%rcx,%rdi)
addq $0x28, %rsi
cmpq %rsi, %rdx
jne 0x12f23
movl 0x38(%rbx), %edx
testl %edx, %edx
jle 0x13031
xorl %r14d, %r14d
movsd 0x37ba0(%rip), %xmm3    # 0x4ab50
xorl %r15d, %r15d
movq 0x10(%rsp), %rcx
leaq (%rcx,%r14), %rdi
movq 0x20(%rbx), %rax
movsd 0x18(%rax,%r14), %xmm0
movsd %xmm0, 0x18(%rcx,%r14)
movsd 0x20(%rcx,%r14), %xmm0
ucomisd %xmm0, %xmm3
jbe 0x12ffc
addq %r14, %rax
movupd (%rax), %xmm0
movupd 0x10(%rax), %xmm1
movupd 0x19(%rax), %xmm2
movupd %xmm2, 0x19(%rdi)
movupd %xmm1, 0x10(%rdi)
movupd %xmm0, (%rdi)
jmp 0x13021
movsd %xmm0, 0x28(%rsp)
callq 0x13c3c
movsd 0x37b41(%rip), %xmm3    # 0x4ab50
movq 0x10(%rsp), %rax
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x20(%rax,%r14)
incq %r15
movslq 0x38(%rbx), %rdx
addq $0x30, %r14
cmpq %rdx, %r15
jl 0x12fb3
testl %edx, %edx
setle %bpl
jle 0x1310b
movq 0x20(%rbx), %rax
movq 0x10(%rsp), %rcx
movsd (%rax), %xmm0
subsd (%rcx), %xmm0
andpd 0x37b1a(%rip), %xmm0    # 0x4ab70
ucomisd 0x37af2(%rip), %xmm0    # 0x4ab50
jbe 0x1309a
leaq 0x20(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x13c9e
movq 0x50(%rbx), %rax
movq 0x58(%rbx), %rcx
cmpq %rcx, %rax
je 0x1311c
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
movq %rdx, (%rax)
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x13089
jmp 0x1311c
movl %edx, %edx
movl $0x8, %esi
movl $0x1, %edi
movapd 0x37ac2(%rip), %xmm0    # 0x4ab70
movsd 0x37a9a(%rip), %xmm1    # 0x4ab50
movsd (%rax,%rsi), %xmm2
subsd (%rcx,%rsi), %xmm2
andpd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
ja 0x13060
movsd 0x8(%rax,%rsi), %xmm2
subsd 0x8(%rcx,%rsi), %xmm2
andpd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
ja 0x13060
cmpq %rdx, %rdi
setae %bpl
je 0x1310b
movsd 0x28(%rax,%rsi), %xmm2
subsd 0x28(%rcx,%rsi), %xmm2
andpd %xmm0, %xmm2
addq $0x30, %rsi
incq %rdi
ucomisd %xmm1, %xmm2
jbe 0x130b6
jmp 0x13060
addq $0x20, %rbx
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x13c9e
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x13133
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x7380
andb $0x1, %bpl
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x13146
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x13160
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x7380
movq %rbx, %rdi
callq 0x76c0