// File: /workspace/github_cpp_makefile_star2_O2/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 0xae226(%rip), %rax     # 0xe3ce0
movq 0x1ae0(%rax), %r15
movq 0x20a8(%rax), %r14
testq %r14, %r14
je 0x35adf
cmpb $0x1, 0x249(%r14)
jne 0x35adf
movq %r14, %rdi
callq 0x733b7
movl 0x8(%rbx), %eax
testl %eax, %eax
je 0x35c21
movq 0xae1ef(%rip), %rdx     # 0xe3ce0
movq 0x20a8(%rdx), %rcx
testq %rcx, %rcx
je 0x35b06
addq $0x256, %rcx            # imm = 0x256
jmp 0x35b12
movl $0x93, %ecx
addq 0x1ae0(%rdx), %rcx
cmpb $0x1, (%rcx)
je 0x35c21
movl 0xc(%rbx), %ecx
cmpl $0x1, %ecx
je 0x35b60
testl %ecx, %ecx
jne 0x35bb8
testq %r14, %r14
je 0x35b3e
cmpb $0x0, 0x253(%r14)
je 0x35c70
movss 0xdc(%r15), %xmm0
movss %xmm0, 0x18(%rbx)
xorps %xmm0, %xmm0
ucomiss 0x14(%rbx), %xmm0
jae 0x35c5d
movl 0x4(%rbx), %ecx
movl %ecx, (%rbx)
jmp 0x35bae
xorps %xmm0, %xmm0
ucomiss 0x14(%rbx), %xmm0
jb 0x35c81
testq %r14, %r14
je 0x35b8f
movss 0x80(%r14), %xmm1
movaps %xmm1, %xmm0
subss 0x7c(%r14), %xmm0
movss %xmm1, 0xdc(%r15)
jmp 0x35b9d
movss 0xdc(%r15), %xmm0
subss 0x18(%rbx), %xmm0
movss %xmm0, 0x14(%rbx)
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x35ca0
movl $0x2, 0xc(%rbx)
pushq $0x2
popq %rcx
movl 0x4(%rbx), %r14d
movl %eax, %edi
subl %r14d, %edi
jle 0x35c21
cmpl $0x3, %ecx
je 0x35c36
cmpl $0x2, %ecx
jne 0x35cbf
movss 0x14(%rbx), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x35cde
leaq 0x4(%rbx), %rdx
movq %rbx, %rsi
callq 0x35756
movl (%rbx), %ecx
leal (%rcx,%r14), %eax
movl %eax, (%rbx)
addl %r14d, 0x4(%rbx)
testl %ecx, %ecx
jle 0x35c18
subl 0x10(%rbx), %eax
cvtsi2ss %eax, %xmm0
movss 0x14(%rbx), %xmm1
mulss %xmm1, %xmm0
addss 0x18(%rbx), %xmm0
callq 0x359c1
movl $0x3, 0xc(%rbx)
jmp 0x35c7d
movq %rbx, %rdi
callq 0x35976
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
je 0x35c57
subl 0x10(%rbx), %eax
cvtsi2ss %eax, %xmm0
movss 0x14(%rbx), %xmm1
mulss %xmm1, %xmm0
addss 0x18(%rbx), %xmm0
callq 0x359c1
orl $-0x1, 0x8(%rbx)
jmp 0x35c29
movl 0x10(%rbx), %eax
movl %eax, (%rbx)
incl %eax
movl %eax, 0x4(%rbx)
movl $0x1, 0xc(%rbx)
jmp 0x35c7d
movl 0x10(%rbx), %eax
movl %eax, (%rbx)
incl %eax
movl %eax, 0x4(%rbx)
movl %eax, 0x10(%rbx)
movb $0x1, %al
jmp 0x35c2b
leaq 0x676ed(%rip), %rdi     # 0x9d375
leaq 0x67506(%rip), %rsi     # 0x9d195
leaq 0x676f3(%rip), %rcx     # 0x9d389
movl $0x90b, %edx            # imm = 0x90B
callq 0xc140
leaq 0x67700(%rip), %rdi     # 0x9d3a7
leaq 0x674e7(%rip), %rsi     # 0x9d195
leaq 0x676d4(%rip), %rcx     # 0x9d389
movl $0x917, %edx            # imm = 0x917
callq 0xc140
leaq 0x69456(%rip), %rdi     # 0x9f11c
leaq 0x674c8(%rip), %rsi     # 0x9d195
leaq 0x676b5(%rip), %rcx     # 0x9d389
movl $0x93f, %edx            # imm = 0x93F
callq 0xc140
leaq 0x6772a(%rip), %rdi     # 0x9d40f
leaq 0x674a9(%rip), %rsi     # 0x9d195
leaq 0x67696(%rip), %rcx     # 0x9d389
movl $0x925, %edx            # imm = 0x925
callq 0xc140