// File: /workspace/github_cpp_makefile_star2_O2/donfreiday[P]gb/./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);

    IndexXAdvance.clear();
    IndexXAdvance.resize(max_codepoint + 1);
    IndexLookup.clear();
    IndexLookup.resize(max_codepoint + 1);
    for (int i = 0; i < max_codepoint + 1; i++)
    {
        IndexXAdvance[i] = -1.0f;
        IndexLookup[i] = -1;
    }
    for (int i = 0; i < Glyphs.Size; i++)
    {
        int codepoint = (int)Glyphs[i].Codepoint;
        IndexXAdvance[codepoint] = Glyphs[i].XAdvance;
        IndexLookup[codepoint] = i;
    }

    // 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((unsigned short)' '))
    {
        if (Glyphs.back().Codepoint != '\t')   // So we can call this function multiple times
            Glyphs.resize(Glyphs.Size + 1);
        ImFont::Glyph& tab_glyph = Glyphs.back();
        tab_glyph = *FindGlyph((unsigned short)' ');
        tab_glyph.Codepoint = '\t';
        tab_glyph.XAdvance *= 4;
        IndexXAdvance[(int)tab_glyph.Codepoint] = (float)tab_glyph.XAdvance;
        IndexLookup[(int)tab_glyph.Codepoint] = (int)(Glyphs.Size-1);
    }

    FallbackGlyph = NULL;
    FallbackGlyph = FindGlyph(FallbackChar);
    FallbackXAdvance = FallbackGlyph ? FallbackGlyph->XAdvance : 0.0f;
    for (int i = 0; i < max_codepoint + 1; i++)
        if (IndexXAdvance[i] < 0.0f)
            IndexXAdvance[i] = FallbackXAdvance;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, -0x40(%rbp)
leaq 0x38(%rdi), %r12
xorl %ebx, %ebx
xorl %r14d, %r14d
cmpl (%r12), %ebx
je 0x2e284
movq %r12, %rdi
movl %ebx, %esi
callq 0x305e2
movzwl (%rax), %eax
cmpl %eax, %r14d
cmovlel %eax, %r14d
incl %ebx
jmp 0x2e266
movq -0x40(%rbp), %rbx
leaq 0x58(%rbx), %r15
movq %r15, %rdi
callq 0x305ba
incl %r14d
movq %r15, %rdi
movl %r14d, %esi
callq 0x1eefe
addq $0x68, %rbx
movq %rbx, %rdi
callq 0x27a2a
movq %rbx, -0x38(%rbp)
movq %rbx, %rdi
movl %r14d, %esi
callq 0x30616
xorl %ebx, %ebx
cmpl %ebx, %r14d
je 0x2e2e6
movq %r15, %rdi
movl %ebx, %esi
callq 0x1f61c
movl $0xbf800000, (%rax)     # imm = 0xBF800000
movq -0x38(%rbp), %rdi
movl %ebx, %esi
callq 0x279f6
orl $-0x1, (%rax)
incl %ebx
jmp 0x2e2bf
xorl %ebx, %ebx
cmpl (%r12), %ebx
jge 0x2e336
movq %r12, %rdi
movl %ebx, %esi
callq 0x305e2
movzwl (%rax), %r13d
movq %r12, %rdi
movl %ebx, %esi
callq 0x305e2
movss 0x4(%rax), %xmm0
movss %xmm0, -0x2c(%rbp)
movq %r15, %rdi
movl %r13d, %esi
callq 0x1f61c
movss -0x2c(%rbp), %xmm0
movss %xmm0, (%rax)
movq -0x38(%rbp), %rdi
movl %r13d, %esi
callq 0x279f6
movl %ebx, (%rax)
incl %ebx
jmp 0x2e2e8
pushq $0x20
popq %rsi
movq -0x40(%rbp), %r13
movq %r13, %rdi
callq 0x2e20c
testq %rax, %rax
je 0x2e3e0
movq %r12, %rdi
callq 0x304c6
cmpw $0x9, (%rax)
je 0x2e36a
movl (%r12), %esi
incl %esi
movq %r12, %rdi
callq 0x30488
movq %r12, %rdi
callq 0x304c6
movq %rax, %rbx
pushq $0x20
popq %rsi
movq -0x40(%rbp), %r13
movq %r13, %rdi
callq 0x2e20c
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm0, (%rbx)
movups %xmm1, 0x10(%rbx)
movq 0x20(%rax), %rax
movq %rax, 0x20(%rbx)
movw $0x9, (%rbx)
movss 0x4(%rbx), %xmm0
mulss 0x8008(%rip), %xmm0     # 0x363b4
movss %xmm0, -0x2c(%rbp)
movss %xmm0, 0x4(%rbx)
pushq $0x9
popq %rsi
movq %r15, %rdi
callq 0x1f61c
movss -0x2c(%rbp), %xmm0
movss %xmm0, (%rax)
movl 0x38(%r13), %r12d
decl %r12d
movzwl (%rbx), %esi
movq -0x38(%rbp), %rdi
callq 0x279f6
movl %r12d, (%rax)
andq $0x0, 0x48(%r13)
movzwl 0x10(%r13), %esi
movq %r13, %rdi
callq 0x2e20c
movq %rax, 0x48(%r13)
xorps %xmm0, %xmm0
testq %rax, %rax
je 0x2e403
movss 0x4(%rax), %xmm0
movss %xmm0, 0x50(%r13)
xorl %ebx, %ebx
cmpl %ebx, %r14d
je 0x2e444
movq %r15, %rdi
movl %ebx, %esi
callq 0x1f61c
xorps %xmm0, %xmm0
ucomiss (%rax), %xmm0
jbe 0x2e440
movss 0x50(%r13), %xmm0
movss %xmm0, -0x38(%rbp)
movq %r15, %rdi
movl %ebx, %esi
callq 0x1f61c
movss -0x38(%rbp), %xmm0
movss %xmm0, (%rax)
incl %ebx
jmp 0x2e40b
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop