// File: /workspace/github_cpp_makefile_star2_O2/graphitemaster[P]smbf/smbf.cpp
// Function: vertexCacheOptimizer::init(std::vector<unsigned long, std::allocator<unsigned long>>&, unsigned long)
vertexCacheOptimizer::result vertexCacheOptimizer::init(u::vector<size_t> &indices, size_t maxVertex) {
    const size_t triangleCount = indices.size() / 3;

    // Reset draw list
    m_drawList.clear();
    m_drawList.reserve(maxVertex);

    // Reset and initialize vertices and triangles
    m_vertices.clear();
    m_vertices.reserve(maxVertex);
    for (size_t i = 0; i < maxVertex; i++)
        m_vertices.push_back(vertexCacheData());

    m_triangles.clear();
    m_triangles.reserve(triangleCount);
    for (size_t i = 0; i < triangleCount; i++) {
        triangleCacheData data;
        for (size_t j = 0; j < 3; j++)
            data.vertices[j] = indices[i * 3 + j];
        m_triangles.push_back(data);
    }

    // Copy the indices
    m_indices.clear();
    m_indices.reserve(indices.size());
    for (auto &it : indices)
        m_indices.push_back(it);

    // Run the initial pass
    m_vertexCache.clear();
    m_bestTriangle = (size_t)-1;

    return initialPass();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r12
movq %rdi, %rbx
movq 0x8(%rsi), %rax
movq %rsi, (%rsp)
subq (%rsi), %rax
sarq $0x3, %rax
pushq $0x3
popq %rcx
xorl %edx, %edx
divq %rcx
movq %rax, 0x8(%rsp)
addq $0x48, %rdi
movq 0x48(%rbx), %rax
cmpq %rax, 0x50(%rbx)
je 0x279e
movq %rax, 0x50(%rbx)
movq %r12, %rsi
callq 0x43f0
movq %rbx, %rdi
callq 0x4486
movq %rbx, %rdi
movq %r12, %rsi
callq 0x448e
leaq 0x38(%rsp), %r14
leaq 0x10(%rsp), %r13
subq $0x1, %r12
jb 0x2803
andq $0x0, 0x20(%rsp)
pxor %xmm0, %xmm0
movdqa %xmm0, 0x10(%rsp)
orq $-0x1, 0x28(%rsp)
andl $0x0, 0x30(%rsp)
movdqu %xmm0, (%r14)
movb $0x0, 0x10(%r14)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x57e4
movq %r13, %rdi
callq 0x5554
jmp 0x27c3
leaq 0x18(%rbx), %r12
movq 0x18(%rbx), %rax
cmpq %rax, 0x20(%rbx)
je 0x2815
movq %rax, 0x20(%rbx)
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x4522
leaq 0x18(%rsp), %rbp
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r15d, %r15d
cmpq 0x8(%rsp), %r15
je 0x288c
movb %r14b, 0x10(%rsp)
andl $0x0, 0x14(%rsp)
movb %r14b, 0x30(%rsp)
orq $-0x1, 0x10(%rbp)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, (%rbp)
movq (%rsp), %rax
movq (%rax), %rax
addq %r13, %rax
pushq $0x1
popq %rcx
cmpq $0x4, %rcx
je 0x2876
movq -0x8(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rsp,%rcx,8)
incq %rcx
jmp 0x2861
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x45f0
incq %r15
addq $0x18, %r13
jmp 0x2830
leaq 0x30(%rbx), %r15
movq 0x30(%rbx), %rax
cmpq %rax, 0x38(%rbx)
je 0x289e
movq %rax, 0x38(%rbx)
movq (%rsp), %r14
movq 0x8(%r14), %rsi
subq (%r14), %rsi
sarq $0x3, %rsi
movq %r15, %rdi
callq 0x43f0
movq (%r14), %r12
movq 0x8(%r14), %r14
cmpq %r14, %r12
je 0x28d2
movq %r15, %rdi
movq %r12, %rsi
callq 0x4348
addq $0x8, %r12
jmp 0x28bc
leaq 0x60(%rbx), %rdi
callq 0x2602
orq $-0x1, 0x1a8(%rbx)
movq %rbx, %rdi
callq 0x2ab0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5554
movq %rbx, %rdi
callq 0x2240
nop