// File: /workspace/github_cpp_makefile_star2_O2/Ciaxur[P]yagb-emu/include/imgui/imgui.cpp
// Function: ImBezierCubicClosestPointCasteljauStep(ImVec2 const&, ImVec2&, ImVec2&, float&, float, float, float, float, float, float, float, float, float, int)
static void ImBezierCubicClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_closest, ImVec2& p_last, float& p_closest_dist2, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
{
    float dx = x4 - x1;
    float dy = y4 - y1;
    float d2 = ((x2 - x4) * dy - (y2 - y4) * dx);
    float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
    d2 = (d2 >= 0) ? d2 : -d2;
    d3 = (d3 >= 0) ? d3 : -d3;
    if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy))
    {
        ImVec2 p_current(x4, y4);
        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;
    }
    else if (level < 10)
    {
        float x12 = (x1 + x2)*0.5f,       y12 = (y1 + y2)*0.5f;
        float x23 = (x2 + x3)*0.5f,       y23 = (y2 + y3)*0.5f;
        float x34 = (x3 + x4)*0.5f,       y34 = (y3 + y4)*0.5f;
        float x123 = (x12 + x23)*0.5f,    y123 = (y12 + y23)*0.5f;
        float x234 = (x23 + x34)*0.5f,    y234 = (y23 + y34)*0.5f;
        float x1234 = (x123 + x234)*0.5f, y1234 = (y123 + y234)*0.5f;
        ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1);
        ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r8d, %r13d
movaps %xmm7, %xmm8
movaps %xmm6, %xmm9
movaps %xmm5, %xmm10
movaps %xmm4, %xmm11
movaps %xmm3, %xmm12
movaps %xmm2, %xmm13
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r12
movss 0x10(%rbp), %xmm14
movss %xmm7, -0x30(%rbp)
movss %xmm6, -0x2c(%rbp)
movaps %xmm9, %xmm2
subss %xmm0, %xmm2
movaps %xmm8, %xmm3
subss %xmm1, %xmm3
movaps %xmm13, %xmm4
subss %xmm9, %xmm4
movaps %xmm12, %xmm5
subss %xmm8, %xmm5
mulss %xmm2, %xmm5
mulss %xmm3, %xmm4
subss %xmm5, %xmm4
movaps %xmm11, %xmm5
subss %xmm9, %xmm5
movaps %xmm10, %xmm6
subss %xmm8, %xmm6
mulss %xmm2, %xmm6
mulss %xmm3, %xmm5
subss %xmm6, %xmm5
movaps %xmm4, %xmm6
movaps 0x680fb(%rip), %xmm15   # 0x9bfe0
xorps %xmm15, %xmm6
movaps %xmm6, %xmm7
cmpless %xmm4, %xmm7
andps %xmm7, %xmm4
andnps %xmm6, %xmm7
orps %xmm4, %xmm7
movaps %xmm5, %xmm4
xorps %xmm15, %xmm4
movaps %xmm4, %xmm6
cmpless %xmm5, %xmm6
andps %xmm6, %xmm5
andnps %xmm4, %xmm6
orps %xmm5, %xmm6
addss %xmm7, %xmm6
mulss %xmm6, %xmm6
mulss %xmm3, %xmm3
mulss %xmm2, %xmm2
addss %xmm3, %xmm2
mulss %xmm14, %xmm2
ucomiss %xmm6, %xmm2
ja 0x3404c
cmpl $0x9, %r13d
jg 0x340a8
movaps %xmm0, %xmm2
addss %xmm13, %xmm2
movss 0x680ca(%rip), %xmm6    # 0x9c018
mulss %xmm6, %xmm2
movaps %xmm1, %xmm3
addss %xmm12, %xmm3
mulss %xmm6, %xmm3
addss %xmm11, %xmm13
mulss %xmm6, %xmm13
addss %xmm10, %xmm12
mulss %xmm6, %xmm12
addss %xmm9, %xmm11
mulss %xmm6, %xmm11
movss %xmm11, -0x44(%rbp)
addss %xmm8, %xmm10
mulss %xmm6, %xmm10
movss %xmm10, -0x48(%rbp)
movaps %xmm2, %xmm4
addss %xmm13, %xmm4
mulss %xmm6, %xmm4
movaps %xmm3, %xmm5
addss %xmm12, %xmm5
mulss %xmm6, %xmm5
addss %xmm11, %xmm13
mulss %xmm6, %xmm13
movss %xmm13, -0x3c(%rbp)
addss %xmm10, %xmm12
mulss %xmm6, %xmm12
movss %xmm12, -0x40(%rbp)
movaps %xmm4, %xmm7
addss %xmm13, %xmm7
mulss %xmm6, %xmm7
movss %xmm7, -0x38(%rbp)
movaps %xmm5, %xmm10
addss %xmm12, %xmm10
mulss %xmm6, %xmm10
movss %xmm10, -0x34(%rbp)
incl %r13d
movss %xmm14, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
movaps %xmm7, %xmm6
movaps %xmm10, %xmm7
movl %r13d, %r8d
callq 0x33e46
movss 0x10(%rbp), %xmm14
movss -0x3c(%rbp), %xmm13
movss -0x40(%rbp), %xmm12
movss -0x44(%rbp), %xmm11
movss -0x48(%rbp), %xmm10
movss -0x2c(%rbp), %xmm9
movss -0x30(%rbp), %xmm8
movss -0x38(%rbp), %xmm0
movss -0x34(%rbp), %xmm1
jmp 0x33e8e
leaq -0x50(%rbp), %rsi
movss %xmm9, (%rsi)
movss %xmm8, 0x4(%rsi)
movq %rbx, %rdi
movq %r12, %rdx
callq 0x33d25
movaps %xmm0, %xmm2
shufps $0x55, %xmm0, %xmm2     # xmm2 = xmm2[1,1],xmm0[1,1]
movss (%r12), %xmm1
movss 0x4(%r12), %xmm3
subss %xmm0, %xmm1
subss %xmm2, %xmm3
mulss %xmm3, %xmm3
mulss %xmm1, %xmm1
addss %xmm3, %xmm1
movss (%r14), %xmm2
ucomiss %xmm1, %xmm2
jbe 0x340a1
movlps %xmm0, (%r15)
movss %xmm1, (%r14)
movq -0x50(%rbp), %rax
movq %rax, (%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq