// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImGui::CalcListClipping(int, float, int*, int*)
void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end)
{
    ImGuiContext& g = *GImGui;
    ImGuiWindow* window = g.CurrentWindow;
    if (g.LogEnabled)
    {
        // If logging is active, do not perform any clipping
        *out_items_display_start = 0;
        *out_items_display_end = items_count;
        return;
    }
    if (GetSkipItemForListClipping())
    {
        *out_items_display_start = *out_items_display_end = 0;
        return;
    }

    // We create the union of the ClipRect and the NavScoringRect which at worst should be 1 page away from ClipRect
    ImRect unclipped_rect = window->ClipRect;
    if (g.NavMoveRequest)
        unclipped_rect.Add(g.NavScoringRect);
    if (g.NavJustMovedToId && window->NavLastIds[0] == g.NavJustMovedToId)
        unclipped_rect.Add(ImRect(window->Pos + window->NavRectRel[0].Min, window->Pos + window->NavRectRel[0].Max));

    const ImVec2 pos = window->DC.CursorPos;
    int start = (int)((unclipped_rect.Min.y - pos.y) / items_height);
    int end = (int)((unclipped_rect.Max.y - pos.y) / items_height);

    // When performing a navigation request, ensure we have one item extra in the direction we are moving to
    if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Up)
        start--;
    if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Down)
        end++;

    start = ImClamp(start, 0, items_count);
    end = ImClamp(end + 1, start, items_count);
    *out_items_display_start = start;
    *out_items_display_end = end;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movl %edi, %r15d
movq 0xae569(%rip), %r12     # 0xe3ce0
cmpb $0x1, 0x3138(%r12)
jne 0x3578b
andl $0x0, (%r14)
jmp 0x358b4
movq 0x1ae0(%r12), %r13
movq 0x20a8(%r12), %rax
leaq 0x256(%rax), %rcx
leaq 0x93(%r13), %rdx
testq %rax, %rax
cmoveq %rdx, %rcx
cmpb $0x1, (%rcx)
jne 0x357c1
andl $0x0, (%rbx)
andl $0x0, (%r14)
jmp 0x358b7
movups 0x258(%r13), %xmm1
movaps %xmm1, -0x40(%rbp)
cmpb $0x1, 0x1d00(%r12)
jne 0x357f3
leaq 0x1cc8(%r12), %rsi
leaq -0x40(%rbp), %rdi
movss %xmm0, -0x44(%rbp)
callq 0x49d26
movss -0x44(%rbp), %xmm0
movl 0x1cb4(%r12), %eax
testl %eax, %eax
je 0x3583e
cmpl %eax, 0x3b0(%r13)
jne 0x3583e
movss 0x14(%r13), %xmm3
movss 0x3bc(%r13), %xmm1
addss %xmm3, %xmm1
addss 0x3c4(%r13), %xmm3
movss -0x3c(%rbp), %xmm2
ucomiss %xmm1, %xmm2
jbe 0x35833
movss %xmm1, -0x3c(%rbp)
ucomiss -0x34(%rbp), %xmm3
jbe 0x3583e
movss %xmm3, -0x34(%rbp)
movss 0xdc(%r13), %xmm3
movss -0x3c(%rbp), %xmm1
movss -0x34(%rbp), %xmm2
subss %xmm3, %xmm1
divss %xmm0, %xmm1
cvttss2si %xmm1, %ecx
subss %xmm3, %xmm2
divss %xmm0, %xmm2
cvttss2si %xmm2, %eax
cmpb $0x1, 0x1d00(%r12)
jne 0x35892
movl 0x1d18(%r12), %edx
xorl %esi, %esi
cmpl $0x2, %edx
sete %sil
subl %esi, %ecx
xorl %esi, %esi
cmpl $0x3, %edx
sete %sil
addl %esi, %eax
cmpl %r15d, %ecx
movl %r15d, %edx
cmovll %ecx, %edx
xorl %esi, %esi
testl %ecx, %ecx
cmovnsl %edx, %esi
incl %eax
cmpl %r15d, %eax
cmovll %eax, %r15d
cmpl %esi, %eax
cmovll %esi, %r15d
movl %esi, (%r14)
movl %r15d, (%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq