// File: /workspace/github_cpp_makefile_star2_O3/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 0x4131d
movl %r9d, %ebx
movq %r8, %r14
movq %rsi, %r13
movq %rdi, %r15
cvtsi2ss %r9d, %xmm0
movsd (%rdi), %xmm4
movss 0x73e13(%rip), %xmm1    # 0xb4fe4
divss %xmm0, %xmm1
movss %xmm1, -0x2c(%rbp)
negl %ebx
xorps %xmm3, %xmm3
movl $0x1, %r12d
movss 0x74653(%rip), %xmm2    # 0xb5840
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 0x774bc
movaps -0x60(%rbp), %xmm10
movaps %xmm0, %xmm5
shufps $0x55, %xmm0, %xmm5     # xmm5 = xmm5[1,1],xmm0[1,1]
movss (%r14), %xmm2
movss 0x4(%r14), %xmm1
movaps %xmm10, %xmm3
shufps $0x55, %xmm10, %xmm3    # xmm3 = xmm3[1,1],xmm10[1,1]
movaps %xmm2, %xmm7
subss %xmm10, %xmm7
movaps %xmm1, %xmm8
subss %xmm3, %xmm8
movaps %xmm0, %xmm4
subss %xmm10, %xmm4
movaps %xmm5, %xmm6
subss %xmm3, %xmm6
mulss %xmm6, %xmm8
mulss %xmm4, %xmm7
addss %xmm8, %xmm7
xorps %xmm8, %xmm8
ucomiss %xmm7, %xmm8
jbe 0x41278
movaps %xmm10, %xmm4
jmp 0x412c4
movaps %xmm6, %xmm9
mulss %xmm6, %xmm9
movaps %xmm4, %xmm8
mulss %xmm4, %xmm8
addss %xmm9, %xmm8
ucomiss %xmm8, %xmm7
jbe 0x412a1
movaps %xmm5, %xmm3
movaps %xmm0, %xmm4
movaps %xmm0, %xmm10
jmp 0x412c4
mulss %xmm7, %xmm4
mulss %xmm7, %xmm6
divss %xmm8, %xmm4
divss %xmm8, %xmm6
addss %xmm10, %xmm4
addss %xmm6, %xmm3
movaps %xmm4, %xmm10
unpcklps %xmm3, %xmm10           # xmm10 = xmm10[0],xmm3[0],xmm10[1],xmm3[1]
subss %xmm4, %xmm2
subss %xmm3, %xmm1
mulss %xmm1, %xmm1
mulss %xmm2, %xmm2
addss %xmm1, %xmm2
movss -0x30(%rbp), %xmm3
ucomiss %xmm2, %xmm3
movaps %xmm10, %xmm1
ja 0x412ea
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 0x411ed
movaps %xmm1, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x74e30(%rip), %rdi     # 0xb6154
leaq 0x74e3a(%rip), %rsi     # 0xb6165
leaq 0x74e4b(%rip), %rcx     # 0xb617d
movl $0x46d, %edx            # imm = 0x46D
callq 0xc140