// File: /workspace/github_cpp_makefile_star2_O1/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 0xb99a6(%rip), %rax     # 0xfdcd0
movq 0x1ae0(%rax), %r15
movq 0x20a8(%rax), %r14
testq %r14, %r14
je 0x4434f
cmpb $0x1, 0x249(%r14)
jne 0x4434f
movq %r14, %rdi
callq 0x8b7ea
movl 0x8(%rbx), %eax
testl %eax, %eax
je 0x444a5
movq 0xb996f(%rip), %rdx     # 0xfdcd0
movq 0x20a8(%rdx), %rcx
testq %rcx, %rcx
je 0x44376
addq $0x256, %rcx            # imm = 0x256
jmp 0x44382
movl $0x93, %ecx
addq 0x1ae0(%rdx), %rcx
cmpb $0x1, (%rcx)
je 0x444a5
cmpl $0x0, 0xc(%rbx)
je 0x443cf
cmpl $0x1, 0xc(%rbx)
jne 0x44436
xorps %xmm0, %xmm0
ucomiss 0x14(%rbx), %xmm0
jb 0x4450b
testq %r14, %r14
je 0x4440b
movss 0x80(%r14), %xmm0
movaps %xmm0, %xmm1
subss 0x7c(%r14), %xmm1
movss %xmm1, 0x14(%rbx)
movss %xmm0, 0xdc(%r15)
jmp 0x4441e
testq %r14, %r14
je 0x443e2
cmpb $0x0, 0x253(%r14)
je 0x444fa
movss 0xdc(%r15), %xmm0
movss %xmm0, 0x18(%rbx)
xorps %xmm0, %xmm0
ucomiss 0x14(%rbx), %xmm0
jae 0x444e7
movl 0x4(%rbx), %ecx
movl %ecx, (%rbx)
movl $0x2, 0xc(%rbx)
jmp 0x44391
movss 0xdc(%r15), %xmm0
subss 0x18(%rbx), %xmm0
movss %xmm0, 0x14(%rbx)
movss 0x14(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x4452a
movl $0x2, 0xc(%rbx)
movl 0x4(%rbx), %r14d
movl %eax, %edi
subl %r14d, %edi
jle 0x444a5
movl 0xc(%rbx), %ecx
cmpl $0x3, %ecx
je 0x444ba
cmpl $0x2, %ecx
jne 0x44549
movss 0x14(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x44568
leaq 0x4(%rbx), %rdx
movq %rbx, %rsi
callq 0x43ff1
movl (%rbx), %ecx
leal (%rcx,%r14), %eax
movl %eax, (%rbx)
addl %r14d, 0x4(%rbx)
testl %ecx, %ecx
jle 0x4449c
subl 0x10(%rbx), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss 0x14(%rbx), %xmm1
mulss %xmm1, %xmm0
addss 0x18(%rbx), %xmm0
callq 0x44231
movl $0x3, 0xc(%rbx)
jmp 0x44507
movq %rbx, %rdi
callq 0x441e6
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
je 0x444de
subl 0x10(%rbx), %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss 0x14(%rbx), %xmm1
mulss %xmm1, %xmm0
addss 0x18(%rbx), %xmm0
callq 0x44231
movl $0xffffffff, 0x8(%rbx)  # imm = 0xFFFFFFFF
jmp 0x444ad
movl 0x10(%rbx), %eax
movl %eax, (%rbx)
incl %eax
movl %eax, 0x4(%rbx)
movl $0x1, 0xc(%rbx)
jmp 0x44507
movl 0x10(%rbx), %eax
movl %eax, (%rbx)
incl %eax
movl %eax, 0x4(%rbx)
movl %eax, 0x10(%rbx)
movb $0x1, %al
jmp 0x444af
leaq 0x73e33(%rip), %rdi     # 0xb8345
leaq 0x73c4c(%rip), %rsi     # 0xb8165
leaq 0x73e39(%rip), %rcx     # 0xb8359
movl $0x90b, %edx            # imm = 0x90B
callq 0xc140
leaq 0x73e46(%rip), %rdi     # 0xb8377
leaq 0x73c2d(%rip), %rsi     # 0xb8165
leaq 0x73e1a(%rip), %rcx     # 0xb8359
movl $0x917, %edx            # imm = 0x917
callq 0xc140
leaq 0x75b9c(%rip), %rdi     # 0xba0ec
leaq 0x73c0e(%rip), %rsi     # 0xb8165
leaq 0x73dfb(%rip), %rcx     # 0xb8359
movl $0x93f, %edx            # imm = 0x93F
callq 0xc140
leaq 0x73e70(%rip), %rdi     # 0xb83df
leaq 0x73bef(%rip), %rsi     # 0xb8165
leaq 0x73ddc(%rip), %rcx     # 0xb8359
movl $0x925, %edx            # imm = 0x925
callq 0xc140