// File: /workspace/github_cpp_makefile_star2_O3/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 0x13b20
movslq 0x3c(%rbx), %rdx
testq %rdx, %rdx
jle 0x12ee4
movq 0x8(%rbx), %rax
movq 0x10(%rsp), %rcx
shlq $0x3, %rdx
leaq (%rdx,%rdx,4), %rdx
xorl %esi, %esi
movsd 0x18(%rax,%rsi), %xmm0
movsd 0x10(%rax,%rsi), %xmm1
mulsd %xmm0, %xmm1
movslq 0x20(%rax,%rsi), %rdi
leaq (%rdi,%rdi,2), %rdi
shlq $0x4, %rdi
movsd (%rax,%rsi), %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
movapd %xmm0, %xmm3
movhpd 0x8(%rax,%rsi), %xmm3   # xmm3 = xmm3[0],mem[0]
mulpd %xmm2, %xmm3
movupd (%rcx,%rdi), %xmm2
addpd %xmm3, %xmm2
movupd 0x10(%rcx,%rdi), %xmm3
movupd %xmm2, (%rcx,%rdi)
movq %xmm1, %xmm1            # xmm1 = xmm1[0],zero
addpd %xmm3, %xmm1
movupd %xmm1, 0x10(%rcx,%rdi)
addsd 0x20(%rcx,%rdi), %xmm0
movsd %xmm0, 0x20(%rcx,%rdi)
addq $0x28, %rsi
cmpq %rsi, %rdx
jne 0x12e79
cmpl $0x0, 0x38(%rbx)
jle 0x130e3
movq 0x10(%rsp), %rcx
xorl %r14d, %r14d
movsd 0x37c62(%rip), %xmm3    # 0x4ab60
xorl %r15d, %r15d
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 0x12f45
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 0x12f6a
movsd %xmm0, 0x28(%rsp)
callq 0x13bc0
movsd 0x37c08(%rip), %xmm3    # 0x4ab60
movq 0x10(%rsp), %rcx
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x20(%rcx,%r14)
incq %r15
movslq 0x38(%rbx), %rax
addq $0x30, %r14
cmpq %rax, %r15
jl 0x12f01
testl %eax, %eax
jle 0x130e3
movq 0x20(%rbx), %rcx
movq 0x10(%rsp), %rdx
movsd (%rcx), %xmm0
subsd (%rdx), %xmm0
andpd 0x37c15(%rip), %xmm0    # 0x4abb0
ucomisd 0x37bbd(%rip), %xmm0    # 0x4ab60
jbe 0x13072
xorl %ebp, %ebp
leaq 0x20(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0x13c1c
movq 0x50(%rbx), %rax
movq 0x58(%rbx), %rcx
cmpq %rcx, %rax
je 0x130f7
subq %rax, %rcx
addq $-0x8, %rcx
movq %rcx, %xmm0
shrq $0x3, %rcx
addq $0x2, %rcx
andq $-0x2, %rcx
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
psrlq $0x3, %xmm0
xorl %edx, %edx
movdqa 0x37b8a(%rip), %xmm1    # 0x4ab80
movdqa 0x37b92(%rip), %xmm2    # 0x4ab90
pxor %xmm2, %xmm0
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
pcmpeqd %xmm3, %xmm3
movq %rdx, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
por %xmm1, %xmm4
pxor %xmm2, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm0, %xmm5
pcmpeqd %xmm0, %xmm4
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm4     # xmm4 = xmm5[1,1,3,3]
por %xmm6, %xmm4
movd %xmm4, %edi
notl %edi
testb $0x1, %dil
je 0x13050
movq %rsi, (%rax,%rdx,8)
pxor %xmm3, %xmm4
pextrw $0x4, %xmm4, %edi
testb $0x1, %dil
je 0x13064
movq %rsi, 0x8(%rax,%rdx,8)
addq $0x2, %rdx
cmpq %rdx, %rcx
jne 0x13010
jmp 0x130f7
movl $0x8, %esi
movl $0x1, %edi
xorl %ebp, %ebp
movapd 0x37b2a(%rip), %xmm0    # 0x4abb0
movsd (%rcx,%rsi), %xmm1
subsd (%rdx,%rsi), %xmm1
andpd %xmm0, %xmm1
ucomisd %xmm3, %xmm1
ja 0x12fab
movsd 0x8(%rcx,%rsi), %xmm1
subsd 0x8(%rdx,%rsi), %xmm1
andpd %xmm0, %xmm1
ucomisd %xmm3, %xmm1
ja 0x12fab
cmpq %rdi, %rax
je 0x130e3
setbe %bpl
movsd 0x28(%rcx,%rsi), %xmm1
subsd 0x28(%rdx,%rsi), %xmm1
andpd %xmm0, %xmm1
addq $0x30, %rsi
incq %rdi
ucomisd %xmm3, %xmm1
jbe 0x13086
jmp 0x12fab
addq $0x20, %rbx
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x13c1c
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1310e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x7390
andb $0x1, %bpl
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x13121
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1313b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x7390
movq %rbx, %rdi
callq 0x76d0
nop