// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGuiListClipper::Step()
bool ImGuiListClipper::Step()
{
    ImGuiContext& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;

    ImGuiTable* table = g.CurrentTable;
    if (table && table->IsInsideRow)
        ImGui::TableEndRow(table);

    // No items
    if (ItemsCount == 0 || GetSkipItemForListClipping())
    {
        End();
        return false;
    }

    // Step 0: Let you process the first element (regardless of it being visible or not, so we can measure the element height)
    if (StepNo == 0)
    {
        // While we are in frozen row state, keep displaying items one by one, unclipped
        // FIXME: Could be stored as a table-agnostic state.
        if (table != NULL && !table->IsUnfrozenRows)
        {
            DisplayStart = ItemsFrozen;
            DisplayEnd = ItemsFrozen + 1;
            ItemsFrozen++;
            return true;
        }

        StartPosY = window->DC.CursorPos.y;
        if (ItemsHeight <= 0.0f)
        {
            // Submit the first item so we can measure its height (generally it is 0..1)
            DisplayStart = ItemsFrozen;
            DisplayEnd = ItemsFrozen + 1;
            StepNo = 1;
            return true;
        }

        // Already has item height (given by user in Begin): skip to calculating step
        DisplayStart = DisplayEnd;
        StepNo = 2;
    }

    // Step 1: the clipper infer height from first element
    if (StepNo == 1)
    {
        IM_ASSERT(ItemsHeight <= 0.0f);
        if (table)
        {
            const float pos_y1 = table->RowPosY1;   // Using this instead of StartPosY to handle clipper straddling the frozen row
            const float pos_y2 = table->RowPosY2;   // Using this instead of CursorPos.y to take account of tallest cell.
            ItemsHeight = pos_y2 - pos_y1;
            window->DC.CursorPos.y = pos_y2;
        }
        else
        {
            ItemsHeight = window->DC.CursorPos.y - StartPosY;
        }
        IM_ASSERT(ItemsHeight > 0.0f && "Unable to calculate item height! First item hasn't moved the cursor vertically!");
        StepNo = 2;
    }

    // Reached end of list
    if (DisplayEnd >= ItemsCount)
    {
        End();
        return false;
    }

    // Step 2: calculate the actual range of elements to display, and position the cursor before the first element
    if (StepNo == 2)
    {
        IM_ASSERT(ItemsHeight > 0.0f);

        int already_submitted = DisplayEnd;
        ImGui::CalcListClipping(ItemsCount - already_submitted, ItemsHeight, &DisplayStart, &DisplayEnd);
        DisplayStart += already_submitted;
        DisplayEnd += already_submitted;

        // Seek cursor
        if (DisplayStart > already_submitted)
            SetCursorPosYAndSetupForPrevLine(StartPosY + (DisplayStart - ItemsFrozen) * ItemsHeight, ItemsHeight);

        StepNo = 3;
        return true;
    }

    // Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd),
    // Advance the cursor to the end of the list and then returns 'false' to end the loop.
    if (StepNo == 3)
    {
        // Seek cursor
        if (ItemsCount < INT_MAX)
            SetCursorPosYAndSetupForPrevLine(StartPosY + (ItemsCount - ItemsFrozen) * ItemsHeight, ItemsHeight); // advance cursor
        ItemsCount = -1;
        return false;
    }

    IM_ASSERT(0);
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0xb838a(%rip), %rax     # 0xfbcd0
movq 0x1ae0(%rax), %r15
movq 0x20a8(%rax), %r14
testq %r14, %r14
je 0x4396b
cmpb $0x1, 0x249(%r14)
jne 0x4396b
movq %r14, %rdi
callq 0x89b8c
movl 0x8(%rbx), %eax
testl %eax, %eax
je 0x43ab2
movq 0xb8353(%rip), %rdx     # 0xfbcd0
movq 0x20a8(%rdx), %rcx
testq %rcx, %rcx
je 0x43992
addq $0x256, %rcx            # imm = 0x256
jmp 0x4399e
movl $0x93, %ecx
addq 0x1ae0(%rdx), %rcx
cmpb $0x1, (%rcx)
je 0x43ab2
movl 0xc(%rbx), %ecx
cmpl $0x1, %ecx
je 0x439ec
testl %ecx, %ecx
jne 0x43a46
testq %r14, %r14
je 0x439ca
cmpb $0x0, 0x253(%r14)
je 0x43b07
movss 0xdc(%r15), %xmm0
movss %xmm0, 0x18(%rbx)
xorps %xmm0, %xmm0
ucomiss 0x14(%rbx), %xmm0
jae 0x43af4
movl 0x4(%rbx), %ecx
movl %ecx, (%rbx)
jmp 0x43a3a
xorps %xmm0, %xmm0
ucomiss 0x14(%rbx), %xmm0
jb 0x43b18
testq %r14, %r14
je 0x43a1b
movss 0x80(%r14), %xmm1
movaps %xmm1, %xmm0
subss 0x7c(%r14), %xmm0
movss %xmm1, 0xdc(%r15)
jmp 0x43a29
movss 0xdc(%r15), %xmm0
subss 0x18(%rbx), %xmm0
movss %xmm0, 0x14(%rbx)
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x43b37
movl $0x2, 0xc(%rbx)
movl $0x2, %ecx
movl 0x4(%rbx), %r14d
movl %eax, %edi
subl %r14d, %edi
jle 0x43ab2
cmpl $0x3, %ecx
je 0x43ac7
cmpl $0x2, %ecx
jne 0x43b56
movss 0x14(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x43b75
leaq 0x4(%rbx), %rdx
movq %rbx, %rsi
callq 0x4360d
movl (%rbx), %ecx
leal (%rcx,%r14), %eax
movl %eax, (%rbx)
addl %r14d, 0x4(%rbx)
testl %ecx, %ecx
jle 0x43aa9
subl 0x10(%rbx), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss 0x14(%rbx), %xmm1
mulss %xmm1, %xmm0
addss 0x18(%rbx), %xmm0
callq 0x4384d
movl $0x3, 0xc(%rbx)
jmp 0x43b14
movq %rbx, %rdi
callq 0x43802
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
je 0x43aeb
subl 0x10(%rbx), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss 0x14(%rbx), %xmm1
mulss %xmm1, %xmm0
addss 0x18(%rbx), %xmm0
callq 0x4384d
movl $0xffffffff, 0x8(%rbx)  # imm = 0xFFFFFFFF
jmp 0x43aba
movl 0x10(%rbx), %eax
movl %eax, (%rbx)
incl %eax
movl %eax, 0x4(%rbx)
movl $0x1, 0xc(%rbx)
jmp 0x43b14
movl 0x10(%rbx), %eax
movl %eax, (%rbx)
incl %eax
movl %eax, 0x4(%rbx)
movl %eax, 0x10(%rbx)
movb $0x1, %al
jmp 0x43abc
leaq 0x72826(%rip), %rdi     # 0xb6345
leaq 0x7263f(%rip), %rsi     # 0xb6165
leaq 0x7282c(%rip), %rcx     # 0xb6359
movl $0x90b, %edx            # imm = 0x90B
callq 0xc140
leaq 0x72839(%rip), %rdi     # 0xb6377
leaq 0x72620(%rip), %rsi     # 0xb6165
leaq 0x7280d(%rip), %rcx     # 0xb6359
movl $0x917, %edx            # imm = 0x917
callq 0xc140
leaq 0x7458f(%rip), %rdi     # 0xb80ec
leaq 0x72601(%rip), %rsi     # 0xb6165
leaq 0x727ee(%rip), %rcx     # 0xb6359
movl $0x93f, %edx            # imm = 0x93F
callq 0xc140
leaq 0x72863(%rip), %rdi     # 0xb63df
leaq 0x725e2(%rip), %rsi     # 0xb6165
leaq 0x727cf(%rip), %rcx     # 0xb6359
movl $0x925, %edx            # imm = 0x925
callq 0xc140