// File: /workspace/github_cpp_makefile_star2_O3/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 0x80d16
xorl %r14d, %r14d
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
leal -0x1(%rax), %edx
cmpl %edx, %ecx
jbe 0x8104f
movq 0x30(%rbx), %rcx
leaq (,%rax,8), %rdx
leaq (%rdx,%rdx,4), %rdx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
xorl %edi, %edi
movl %r14d, %r8d
movl (%rcx,%rdi), %r14d
andl %esi, %r14d
cmpl %r14d, %r8d
cmovgl %r8d, %r14d
addq $0x28, %rdi
cmpq %rdi, %rdx
jne 0x80cec
cmpl $0xffff, %eax           # imm = 0xFFFF
jge 0x81066
incl %r14d
jmp 0x80d1c
movl $0x1, %r14d
movq 0x8(%rbx), %rdi
testq %rdi, %rdi
je 0x80d34
xorl %r15d, %r15d
movq %r15, (%rbx)
callq 0x41d3c
movq %r15, 0x8(%rbx)
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x80d4d
xorl %r15d, %r15d
movq %r15, 0x18(%rbx)
callq 0x41d3c
movq %r15, 0x20(%rbx)
movb $0x0, 0x56(%rbx)
movw $0x0, 0x68(%rbx)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x81590
movl 0x28(%rbx), %r12d
testl %r12d, %r12d
jle 0x80dd5
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 0x81019
movss (%rdx), %xmm0
movss %xmm0, (%rsi,%r9,4)
movl 0x18(%rbx), %eax
cmpl %r9d, %eax
jle 0x81030
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, %r12
jne 0x80d7e
jmp 0x80dd8
movl 0x18(%rbx), %eax
cmpl $0x20, %eax
jbe 0x80dee
movq 0x20(%rbx), %rcx
movzwl 0x40(%rcx), %ecx
cmpq $0xffff, %rcx           # imm = 0xFFFF
jne 0x80df4
movq 0x38(%rbx), %rcx
jmp 0x80dff
leaq (%rcx,%rcx,4), %rcx
shll $0x3, %ecx
addq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0x80f36
testl %r12d, %r12d
jle 0x81085
movq 0x30(%rbx), %r15
leaq (%r12,%r12,4), %rcx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl -0x28(%r15,%rcx,8), %edx
cmpl $0x9, %edx
je 0x80ea1
movl %r12d, %edx
incq %r12
movl 0x2c(%rbx), %ecx
cmpl %edx, %ecx
jg 0x80e9d
testl %ecx, %ecx
je 0x80e4b
movl %ecx, %r13d
shrl $0x1f, %r13d
addl %ecx, %r13d
sarl %r13d
addl %ecx, %r13d
jmp 0x80e51
movl $0x8, %r13d
cmpl %r12d, %r13d
cmovlel %r12d, %r13d
leaq (,%r13,8), %rax
leaq (%rax,%rax,4), %rdi
callq 0x41c63
movq %rax, %r15
movq 0x30(%rbx), %rsi
testq %rsi, %rsi
je 0x80e92
movslq 0x28(%rbx), %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdx
movq %r15, %rdi
callq 0xc080
movq 0x30(%rbx), %rdi
callq 0x41d3c
movq %r15, 0x30(%rbx)
movl %r13d, 0x2c(%rbx)
movl 0x18(%rbx), %eax
movl %r12d, 0x28(%rbx)
leaq (%r12,%r12,4), %rcx
leaq (%r15,%rcx,8), %rcx
cmpl $0x20, %eax
jbe 0x80ebe
movq 0x20(%rbx), %rax
movzwl 0x40(%rax), %eax
cmpq $0xffff, %rax           # imm = 0xFFFF
jne 0x80ec4
movq 0x38(%rbx), %rax
jmp 0x80ecc
leaq (%rax,%rax,4), %rax
leaq (%r15,%rax,8), %rax
movq 0x20(%rax), %rdx
movq %rdx, -0x8(%rcx)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, -0x18(%rcx)
movups %xmm0, -0x28(%rcx)
movl $0x80000000, %eax       # imm = 0x80000000
andl -0x28(%rcx), %eax
orl $0x9, %eax
movl %eax, -0x28(%rcx)
movss -0x24(%rcx), %xmm0
mulss 0x34966(%rip), %xmm0    # 0xb5864
movss %xmm0, -0x24(%rcx)
cmpl $0x9, (%rbx)
jle 0x81019
movq 0x8(%rbx), %rax
movss %xmm0, 0x24(%rax)
movl -0x28(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl 0x18(%rbx), %eax
cmpl %ecx, %eax
jle 0x81030
movl 0x28(%rbx), %edx
decl %edx
movq 0x20(%rbx), %rsi
movw %dx, (%rsi,%rcx,2)
cmpl $0x20, %eax
jbe 0x80f4c
movq 0x20(%rbx), %rcx
movzwl 0x40(%rcx), %ecx
cmpq $0xffff, %rcx           # imm = 0xFFFF
jne 0x80f52
movq 0x38(%rbx), %rcx
jmp 0x80f5d
leaq (%rcx,%rcx,4), %rcx
shll $0x3, %ecx
addq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0x80f69
andb $0x7f, 0x3(%rcx)
movl 0x18(%rbx), %eax
cmpl $0x9, %eax
jbe 0x80f7f
movq 0x20(%rbx), %rcx
movzwl 0x12(%rcx), %ecx
cmpq $0xffff, %rcx           # imm = 0xFFFF
jne 0x80f85
movq 0x38(%rbx), %rcx
jmp 0x80f90
leaq (%rcx,%rcx,4), %rcx
shll $0x3, %ecx
addq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0x80f9c
andb $0x7f, 0x3(%rcx)
movl 0x18(%rbx), %eax
movzwl 0x52(%rbx), %ecx
cltq
cmpq %rax, %rcx
jae 0x80fd3
movq 0x20(%rbx), %rax
movzwl (%rax,%rcx,2), %eax
cmpq $0xffff, %rax           # imm = 0xFFFF
je 0x80fd3
movq 0x30(%rbx), %rcx
leaq (%rax,%rax,4), %rax
leaq (%rcx,%rax,8), %rax
movq %rax, 0x38(%rbx)
testq %rcx, %rcx
je 0x80fdb
movss 0x4(%rax), %xmm0
jmp 0x80fde
movq $0x0, 0x38(%rbx)
xorps %xmm0, %xmm0
movss %xmm0, 0x10(%rbx)
movq 0x8(%rbx), %rax
movl %r14d, %ecx
xorl %edx, %edx
xorps %xmm1, %xmm1
movslq (%rbx), %rsi
cmpq %rsi, %rdx
jge 0x81019
ucomiss (%rax,%rdx,4), %xmm1
jbe 0x81002
movss %xmm0, (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rcx
jne 0x80fef
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x38658(%rip), %rdi     # 0xb9678
leaq 0x38664(%rip), %rsi     # 0xb968b
leaq 0x4dd8f(%rip), %rcx     # 0xcedbd
jmp 0x81045
leaq 0x38641(%rip), %rdi     # 0xb9678
leaq 0x3864d(%rip), %rsi     # 0xb968b
leaq 0x4d94f(%rip), %rcx     # 0xce994
movl $0x65c, %edx            # imm = 0x65C
callq 0xc140
leaq 0x38622(%rip), %rdi     # 0xb9678
leaq 0x3862e(%rip), %rsi     # 0xb968b
leaq 0x4dd1d(%rip), %rcx     # 0xced81
jmp 0x81045
leaq 0x4cc55(%rip), %rdi     # 0xcdcc2
leaq 0x4c132(%rip), %rsi     # 0xcd1a6
leaq 0x4cc5c(%rip), %rcx     # 0xcdcd7
movl $0xb57, %edx            # imm = 0xB57
callq 0xc140
leaq 0x4c91e(%rip), %rdi     # 0xcd9aa
leaq 0x385f8(%rip), %rsi     # 0xb968b
leaq 0x4dd53(%rip), %rcx     # 0xceded
movl $0x666, %edx            # imm = 0x666
callq 0xc140