// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/include/imgui/imgui_draw.cpp
// Function: ImFont::BuildLookupTable()
void ImFont::BuildLookupTable()
{
    int max_codepoint = 0;
    for (int i = 0; i != Glyphs.Size; i++)
        max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint);

    // Build lookup table
    IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved
    IndexAdvanceX.clear();
    IndexLookup.clear();
    DirtyLookupTables = false;
    memset(Used4kPagesMap, 0, sizeof(Used4kPagesMap));
    GrowIndex(max_codepoint + 1);
    for (int i = 0; i < Glyphs.Size; i++)
    {
        int codepoint = (int)Glyphs[i].Codepoint;
        IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX;
        IndexLookup[codepoint] = (ImWchar)i;

        // Mark 4K page as used
        const int page_n = codepoint / 4096;
        Used4kPagesMap[page_n >> 3] |= 1 << (page_n & 7);
    }

    // Create a glyph to handle TAB
    // FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?)
    if (FindGlyph((ImWchar)' '))
    {
        if (Glyphs.back().Codepoint != '\t')   // So we can call this function multiple times (FIXME: Flaky)
            Glyphs.resize(Glyphs.Size + 1);
        ImFontGlyph& tab_glyph = Glyphs.back();
        tab_glyph = *FindGlyph((ImWchar)' ');
        tab_glyph.Codepoint = '\t';
        tab_glyph.AdvanceX *= IM_TABSIZE;
        IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX;
        IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size - 1);
    }

    // Mark special glyphs as not visible (note that AddGlyph already mark as non-visible glyphs with zero-size polygons)
    SetGlyphVisible((ImWchar)' ', false);
    SetGlyphVisible((ImWchar)'\t', false);

    // Setup fall-backs
    FallbackGlyph = FindGlyphNoFallback(FallbackChar);
    FallbackAdvanceX = FallbackGlyph ? FallbackGlyph->AdvanceX : 0.0f;
    for (int i = 0; i < max_codepoint + 1; i++)
        if (IndexAdvanceX[i] < 0.0f)
            IndexAdvanceX[i] = FallbackAdvanceX;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x28(%rdi), %eax
testq %rax, %rax
je 0x827eb
movq 0x30(%rbx), %rcx
xorl %edx, %edx
testl %eax, %eax
movl $0x0, %esi
cmovgl %eax, %esi
leal -0x1(%rax), %edi
leaq (,%rax,8), %r8
leaq (%r8,%r8,4), %r8
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
xorl %r10d, %r10d
cmpl %edi, %esi
jbe 0x82b2f
movl (%rcx,%rdx), %r14d
andl %r9d, %r14d
cmpl %r14d, %r10d
cmovgl %r10d, %r14d
addq $0x28, %rdx
movl %r14d, %r10d
cmpq %rdx, %r8
jne 0x827c7
jmp 0x827ee
xorl %r14d, %r14d
cmpl $0xffff, %eax           # imm = 0xFFFF
jge 0x82b6d
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x82811
xorl %r15d, %r15d
movq %r15, (%rbx)
callq 0x425d4
movq %r15, 0x8(%rbx)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x8282a
xorl %r15d, %r15d
movq %r15, 0x18(%rbx)
callq 0x425d4
movq %r15, 0x20(%rbx)
movb $0x0, 0x56(%rbx)
movw $0x0, 0x68(%rbx)
incl %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x830ca
movslq 0x28(%rbx), %rax
testq %rax, %rax
jle 0x828b1
movq 0x30(%rbx), %rdx
movq 0x8(%rbx), %rsi
movq 0x20(%rbx), %rdi
addq $0x4, %rdx
xorl %r8d, %r8d
movl -0x4(%rdx), %ecx
movl %ecx, %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
cmpl %r9d, (%rbx)
jle 0x82b01
movss (%rdx), %xmm0
movss %xmm0, (%rsi,%r9,4)
cmpl %r9d, 0x18(%rbx)
jle 0x82b18
movw %r8w, (%rdi,%r9,2)
shrl $0xc, %ecx
andb $0x7, %cl
movl $0x1, %r10d
shll %cl, %r10d
shrl $0xf, %r9d
orb %r10b, 0x68(%rbx,%r9)
incq %r8
addq $0x28, %rdx
cmpq %r8, %rax
jne 0x8285e
cmpl $0x20, 0x18(%rbx)
jbe 0x828c8
movq 0x20(%rbx), %rcx
movzwl 0x40(%rcx), %ecx
cmpq $0xffff, %rcx           # imm = 0xFFFF
jne 0x828ce
movq 0x38(%rbx), %rcx
jmp 0x828d9
leaq (%rcx,%rcx,4), %rcx
shll $0x3, %ecx
addq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0x82a22
testl %eax, %eax
jle 0x82b4e
movq 0x30(%rbx), %rcx
leaq (%rax,%rax,4), %rdx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl -0x28(%rcx,%rdx,8), %esi
cmpl $0x9, %esi
je 0x8297a
movl %eax, %r12d
incl %r12d
movl 0x2c(%rbx), %ecx
cmpl %eax, %ecx
jg 0x82976
testl %ecx, %ecx
je 0x82923
movl %ecx, %r13d
shrl $0x1f, %r13d
addl %ecx, %r13d
sarl %r13d
addl %ecx, %r13d
jmp 0x82929
movl $0x8, %r13d
cmpl %r12d, %r13d
cmovlel %r12d, %r13d
cmpl %r13d, %ecx
jge 0x82976
movl %r13d, %eax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdi
callq 0x424fb
movq %rax, %r15
movq 0x30(%rbx), %rsi
testq %rsi, %rsi
je 0x8296e
movslq 0x28(%rbx), %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdx
movq %r15, %rdi
callq 0xc080
movq 0x30(%rbx), %rdi
callq 0x425d4
movq %r15, 0x30(%rbx)
movl %r13d, 0x2c(%rbx)
movl %r12d, 0x28(%rbx)
movslq 0x28(%rbx), %rax
testq %rax, %rax
jle 0x82b4e
movq 0x30(%rbx), %rcx
leaq (%rax,%rax,4), %rax
leaq (%rcx,%rax,8), %rax
cmpl $0x20, 0x18(%rbx)
jbe 0x829aa
movq 0x20(%rbx), %rcx
movzwl 0x40(%rcx), %ecx
cmpq $0xffff, %rcx           # imm = 0xFFFF
jne 0x829b0
movq 0x38(%rbx), %rcx
jmp 0x829bb
leaq (%rcx,%rcx,4), %rcx
shll $0x3, %ecx
addq 0x30(%rbx), %rcx
movq 0x20(%rcx), %rdx
movq %rdx, -0x8(%rax)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups %xmm1, -0x18(%rax)
movups %xmm0, -0x28(%rax)
movl $0x80000000, %ecx       # imm = 0x80000000
andl -0x28(%rax), %ecx
orl $0x9, %ecx
movl %ecx, -0x28(%rax)
movss -0x24(%rax), %xmm0
mulss 0x34e77(%rip), %xmm0    # 0xb7864
movss %xmm0, -0x24(%rax)
cmpl $0x9, (%rbx)
jle 0x82b01
movq 0x8(%rbx), %rcx
movss %xmm0, 0x24(%rcx)
movl -0x28(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl %eax, 0x18(%rbx)
jle 0x82b18
movl 0x28(%rbx), %ecx
decl %ecx
movq 0x20(%rbx), %rdx
movw %cx, (%rdx,%rax,2)
cmpl $0x20, 0x18(%rbx)
jbe 0x82a38
movq 0x20(%rbx), %rax
movzwl 0x40(%rax), %eax
cmpq $0xffff, %rax           # imm = 0xFFFF
jne 0x82a3e
movq 0x38(%rbx), %rax
jmp 0x82a49
leaq (%rax,%rax,4), %rax
shll $0x3, %eax
addq 0x30(%rbx), %rax
testq %rax, %rax
je 0x82a52
andb $0x7f, 0x3(%rax)
cmpl $0x9, 0x18(%rbx)
jbe 0x82a68
movq 0x20(%rbx), %rax
movzwl 0x12(%rax), %eax
cmpq $0xffff, %rax           # imm = 0xFFFF
jne 0x82a6e
movq 0x38(%rbx), %rax
jmp 0x82a79
leaq (%rax,%rax,4), %rax
shll $0x3, %eax
addq 0x30(%rbx), %rax
testq %rax, %rax
je 0x82a82
andb $0x7f, 0x3(%rax)
movzwl 0x52(%rbx), %eax
movslq 0x18(%rbx), %rcx
cmpq %rcx, %rax
jae 0x82ab1
movq 0x20(%rbx), %rcx
movzwl (%rcx,%rax,2), %ecx
leaq (%rcx,%rcx,4), %rdx
shll $0x3, %edx
addq 0x30(%rbx), %rdx
xorl %eax, %eax
cmpq $0xffff, %rcx           # imm = 0xFFFF
cmovneq %rdx, %rax
jmp 0x82ab3
xorl %eax, %eax
movq %rax, 0x38(%rbx)
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
testq %rax, %rax
je 0x82ac7
movss 0x4(%rax), %xmm1
movss %xmm1, 0x10(%rbx)
movq 0x8(%rbx), %rax
xorl %ecx, %ecx
movslq (%rbx), %rdx
cmpq %rdx, %rcx
jge 0x82b01
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x82aea
movss 0x10(%rbx), %xmm1
movss %xmm1, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %r14
jne 0x82ad2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x38b70(%rip), %rdi     # 0xbb678
leaq 0x38b7c(%rip), %rsi     # 0xbb68b
leaq 0x4e2de(%rip), %rcx     # 0xd0df4
jmp 0x82b44
leaq 0x38b59(%rip), %rdi     # 0xbb678
leaq 0x38b65(%rip), %rsi     # 0xbb68b
leaq 0x4decb(%rip), %rcx     # 0xd09f8
jmp 0x82b44
leaq 0x38b42(%rip), %rdi     # 0xbb678
leaq 0x38b4e(%rip), %rsi     # 0xbb68b
leaq 0x4e274(%rip), %rcx     # 0xd0db8
movl $0x65c, %edx            # imm = 0x65C
callq 0xc140
leaq 0x4ce85(%rip), %rdi     # 0xcf9da
leaq 0x38b2f(%rip), %rsi     # 0xbb68b
leaq 0x4e2c1(%rip), %rcx     # 0xd0e24
movl $0x666, %edx            # imm = 0x666
callq 0xc140
leaq 0x4d17e(%rip), %rdi     # 0xcfcf2
leaq 0x4c65b(%rip), %rsi     # 0xcf1d6
leaq 0x4d185(%rip), %rcx     # 0xcfd07
movl $0xb57, %edx            # imm = 0xB57
callq 0xc140