// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x60, %rsp
movq %rdi, %rbx
movslq 0x38(%rdi), %rsi
xorpd %xmm0, %xmm0
leaq 0x30(%rsp), %r14
movupd %xmm0, 0x19(%r14)
movapd %xmm0, 0x10(%r14)
movapd %xmm0, (%r14)
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rcx
movq %r14, %rdx
callq 0xf39e
pushq $0x20
popq %r15
xorl %r12d, %r12d
movslq 0x3c(%rbx), %rax
cmpq %rax, %r12
jge 0xebb5
movq 0x8(%rbx), %rax
movsd -0x8(%rax,%r15), %xmm0
movsd -0x10(%rax,%r15), %xmm1
mulsd %xmm0, %xmm1
movsd -0x20(%rax,%r15), %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
movapd %xmm0, %xmm3
movhpd -0x18(%rax,%r15), %xmm3 # xmm3 = xmm3[0],mem[0]
mulpd %xmm2, %xmm3
movapd %xmm3, 0x30(%rsp)
movsd %xmm1, 0x40(%rsp)
andq $0x0, 0x48(%rsp)
movsd %xmm0, 0x50(%rsp)
movb $0x0, 0x58(%rsp)
movslq (%rax,%r15), %rax
imulq $0x30, %rax, %rdi
addq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0xf3f4
incq %r12
addq $0x28, %r15
jmp 0xeb41
leaq 0x20(%rbx), %r14
xorl %r12d, %r12d
movsd 0x2ff8c(%rip), %xmm3    # 0x3eb50
xorl %r13d, %r13d
movslq 0x38(%rbx), %r15
cmpq %r15, %r13
jge 0xec46
movq 0x10(%rsp), %rcx
leaq (%rcx,%r12), %rdi
movq (%r14), %rax
movsd 0x18(%rax,%r12), %xmm0
movsd %xmm0, 0x18(%rcx,%r12)
movsd 0x20(%rcx,%r12), %xmm0
ucomisd %xmm0, %xmm3
jbe 0xec18
addq %r12, %rax
movupd (%rax), %xmm0
movupd 0x10(%rax), %xmm1
movupd 0x19(%rax), %xmm2
movupd %xmm2, 0x19(%rdi)
movupd %xmm1, 0x10(%rdi)
movupd %xmm0, (%rdi)
jmp 0xec3d
movsd %xmm0, 0x28(%rsp)
callq 0xf436
movsd 0x2ff25(%rip), %xmm3    # 0x3eb50
movq 0x10(%rsp), %rax
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x20(%rax,%r12)
incq %r13
addq $0x30, %r12
jmp 0xebc7
movq (%r14), %rax
movq 0x10(%rsp), %rcx
xorl %edi, %edi
testl %r15d, %r15d
movl $0x0, %edx
cmovgl %r15d, %edx
pushq $0x10
popq %rsi
movapd 0x2ff09(%rip), %xmm0    # 0x3eb70
movq %rdi, %r12
cmpq %rdi, %rdx
je 0xece5
movsd -0x10(%rax,%rsi), %xmm1
subsd -0x10(%rcx,%rsi), %xmm1
andpd %xmm0, %xmm1
ucomisd %xmm3, %xmm1
ja 0xecb8
movsd -0x8(%rax,%rsi), %xmm1
subsd -0x8(%rcx,%rsi), %xmm1
andpd %xmm0, %xmm1
ucomisd %xmm3, %xmm1
ja 0xecb8
movsd (%rax,%rsi), %xmm1
subsd (%rcx,%rsi), %xmm1
andpd %xmm0, %xmm1
leaq 0x1(%r12), %rdi
addq $0x30, %rsi
ucomisd %xmm3, %xmm1
jbe 0xec67
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xf490
movq 0x50(%rbx), %rax
movq 0x58(%rbx), %rcx
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
cmpq %rcx, %rax
je 0xecf2
movq %rdx, (%rax)
addq $0x8, %rax
jmp 0xecd7
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xf490
cmpq %r15, %r12
setge %bl
leaq 0x10(%rsp), %rdi
callq 0x12bda
movl %ebx, %eax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0xed16
jmp 0xed16
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x12bda
movq %rbx, %rdi
callq 0x76c0
nop