// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImBezierCubicClosestPoint(ImVec2 const&, ImVec2 const&, ImVec2 const&, ImVec2 const&, ImVec2 const&, int)
ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments)
{
    IM_ASSERT(num_segments > 0); // Use ImBezierCubicClosestPointCasteljau()
    ImVec2 p_last = p1;
    ImVec2 p_closest;
    float p_closest_dist2 = FLT_MAX;
    float t_step = 1.0f / (float)num_segments;
    for (int i_step = 1; i_step <= num_segments; i_step++)
    {
        ImVec2 p_current = ImBezierCubicCalc(p1, p2, p3, p4, t_step * i_step);
        ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p);
        float dist2 = ImLengthSqr(p - p_line);
        if (dist2 < p_closest_dist2)
        {
            p_closest = p_line;
            p_closest_dist2 = dist2;
        }
        p_last = p_current;
    }
    return p_closest;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, -0x40(%rbp)
movq %rdx, -0x38(%rbp)
testl %r9d, %r9d
jle 0x41bfa
movl %r9d, %ebx
movq %r8, %r14
movq %rsi, %r13
movq %rdi, %r15
cvtsi2ss %r9d, %xmm0
movsd (%rdi), %xmm4
movss 0x7551e(%rip), %xmm1    # 0xb6fe4
divss %xmm0, %xmm1
movss %xmm1, -0x2c(%rbp)
negl %ebx
xorps %xmm3, %xmm3
movl $0x1, %r12d
movss 0x75d5e(%rip), %xmm2    # 0xb7840
movaps %xmm4, -0x60(%rbp)
movaps %xmm3, -0x50(%rbp)
movss %xmm2, -0x30(%rbp)
xorps %xmm0, %xmm0
cvtsi2ss %r12d, %xmm0
mulss -0x2c(%rbp), %xmm0
movq %r15, %rdi
movq %r13, %rsi
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
callq 0x78c6e
movaps -0x60(%rbp), %xmm9
movss (%r14), %xmm2
movss 0x4(%r14), %xmm3
movaps %xmm2, %xmm7
subss %xmm9, %xmm7
movaps %xmm9, %xmm4
shufps $0x55, %xmm9, %xmm4     # xmm4 = xmm4[1,1],xmm9[1,1]
movaps %xmm3, %xmm1
subss %xmm4, %xmm1
movaps %xmm0, %xmm5
subps %xmm9, %xmm5
movaps %xmm5, %xmm6
shufps $0x55, %xmm5, %xmm6     # xmm6 = xmm6[1,1],xmm5[1,1]
mulss %xmm6, %xmm1
mulss %xmm5, %xmm7
addss %xmm1, %xmm7
xorps %xmm1, %xmm1
ucomiss %xmm7, %xmm1
jbe 0x41b5f
movaps %xmm9, %xmm1
jmp 0x41b9e
movaps %xmm6, %xmm1
mulss %xmm6, %xmm1
movaps %xmm5, %xmm8
mulss %xmm5, %xmm8
addss %xmm1, %xmm8
ucomiss %xmm8, %xmm7
movaps %xmm0, %xmm1
ja 0x41b9e
mulss %xmm7, %xmm5
mulss %xmm7, %xmm6
divss %xmm8, %xmm5
divss %xmm8, %xmm6
addss %xmm9, %xmm5
addss %xmm4, %xmm6
unpcklps %xmm6, %xmm5            # xmm5 = xmm5[0],xmm6[0],xmm5[1],xmm6[1]
movaps %xmm5, %xmm1
subss %xmm1, %xmm2
movaps %xmm1, %xmm4
shufps $0x55, %xmm1, %xmm4     # xmm4 = xmm4[1,1],xmm1[1,1]
subss %xmm4, %xmm3
mulss %xmm3, %xmm3
mulss %xmm2, %xmm2
addss %xmm3, %xmm2
movss -0x30(%rbp), %xmm3
ucomiss %xmm2, %xmm3
ja 0x41bc7
movaps -0x50(%rbp), %xmm1
minss %xmm3, %xmm2
leal (%rbx,%r12), %eax
incl %eax
movl %r12d, %ecx
incl %ecx
movl %ecx, %r12d
movaps %xmm1, %xmm3
movaps %xmm0, %xmm4
cmpl $0x1, %eax
jne 0x41ae2
movaps %xmm1, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x76553(%rip), %rdi     # 0xb8154
leaq 0x7655d(%rip), %rsi     # 0xb8165
leaq 0x7656e(%rip), %rcx     # 0xb817d
movl $0x46d, %edx            # imm = 0x46D
callq 0xc140