// File: 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
subq $0x70, %rsp
movl %edi, -0x4(%rbp)
movss %xmm0, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq 0x14c1b1(%rip), %rax    # 0x212f40
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x1ae0(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x3138(%rax)
je 0xc6dc7
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
movl -0x4(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xc6f56
callq 0xc6f60
testb $0x1, %al
jne 0xc6dd2
jmp 0xc6deb
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movl $0x0, (%rax)
jmp 0xc6f56
movq -0x28(%rbp), %rax
movq 0x258(%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x260(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x1d00(%rax)
je 0xc6e26
movq -0x20(%rbp), %rsi
addq $0x1cc8, %rsi           # imm = 0x1CC8
leaq -0x38(%rbp), %rdi
callq 0xe85b0
movq -0x20(%rbp), %rax
cmpl $0x0, 0x1cb4(%rax)
je 0xc6e9f
movq -0x28(%rbp), %rax
movl 0x3b0(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x1cb4(%rcx), %eax
jne 0xc6e9f
movq -0x28(%rbp), %rsi
movq %rsi, %rdi
addq $0x10, %rdi
addq $0x3b8, %rsi            # imm = 0x3B8
callq 0xc41b0
movlpd %xmm0, -0x50(%rbp)
movq -0x28(%rbp), %rsi
movq %rsi, %rdi
addq $0x10, %rdi
addq $0x3c0, %rsi            # imm = 0x3C0
callq 0xc41b0
movlpd %xmm0, -0x58(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0xe8660
leaq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xe85b0
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rax
movq %rax, -0x60(%rbp)
movss -0x34(%rbp), %xmm0
subss -0x5c(%rbp), %xmm0
divss -0x8(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x64(%rbp)
movss -0x2c(%rbp), %xmm0
subss -0x5c(%rbp), %xmm0
divss -0x8(%rbp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x68(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x1d00(%rax)
je 0xc6efd
movq -0x20(%rbp), %rax
cmpl $0x2, 0x1d18(%rax)
jne 0xc6efd
movl -0x64(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x64(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, 0x1d00(%rax)
je 0xc6f20
movq -0x20(%rbp), %rax
cmpl $0x3, 0x1d18(%rax)
jne 0xc6f20
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %edi
movl -0x4(%rbp), %edx
xorl %esi, %esi
callq 0xc6fb0
movl %eax, -0x64(%rbp)
movl -0x68(%rbp), %edi
addl $0x1, %edi
movl -0x64(%rbp), %esi
movl -0x4(%rbp), %edx
callq 0xc6fb0
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x68(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)