// File: /workspace/github_cpp_makefile_star2_O1/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 $0x48, %rsp
movl %r8d, %r12d
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, %r13
movss 0x10(%rbp), %xmm14
movaps %xmm7, -0x60(%rbp)
movaps %xmm6, -0x50(%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 0x751ea(%rip), %xmm15   # 0xb6fc0
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 0x41f3b
cmpl $0x9, %r12d
jg 0x41fff
movaps %xmm0, %xmm2
addss %xmm13, %xmm2
movss 0x751c5(%rip), %xmm6    # 0xb7004
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, -0x3c(%rbp)
addss %xmm8, %xmm10
mulss %xmm6, %xmm10
movss %xmm10, -0x40(%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, -0x34(%rbp)
addss %xmm10, %xmm12
mulss %xmm6, %xmm12
movss %xmm12, -0x38(%rbp)
movaps %xmm4, %xmm7
addss %xmm13, %xmm7
mulss %xmm6, %xmm7
movss %xmm7, -0x30(%rbp)
movaps %xmm5, %xmm10
addss %xmm12, %xmm10
mulss %xmm6, %xmm10
movss %xmm10, -0x2c(%rbp)
incl %r12d
movss %xmm14, (%rsp)
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, %rcx
movaps %xmm7, %xmm6
movaps %xmm10, %xmm7
movl %r12d, %r8d
callq 0x41d39
movss 0x10(%rbp), %xmm14
movss -0x34(%rbp), %xmm13
movss -0x38(%rbp), %xmm12
movss -0x3c(%rbp), %xmm11
movss -0x40(%rbp), %xmm10
movaps -0x50(%rbp), %xmm9
movaps -0x60(%rbp), %xmm8
movss -0x30(%rbp), %xmm0
movss -0x2c(%rbp), %xmm1
jmp 0x41d7f
movaps %xmm9, %xmm0
unpcklps %xmm8, %xmm0            # xmm0 = xmm0[0],xmm8[0],xmm0[1],xmm8[1]
movss (%r13), %xmm1
movss 0x4(%r13), %xmm2
movss (%rbx), %xmm3
movss 0x4(%rbx), %xmm4
movaps %xmm1, %xmm5
subss %xmm3, %xmm5
movaps %xmm2, %xmm6
subss %xmm4, %xmm6
subss %xmm3, %xmm9
subss %xmm4, %xmm8
mulss %xmm8, %xmm6
mulss %xmm9, %xmm5
addss %xmm6, %xmm5
xorps %xmm6, %xmm6
ucomiss %xmm5, %xmm6
jbe 0x41f8c
movsd (%rbx), %xmm6
jmp 0x41fce
movaps %xmm8, %xmm6
mulss %xmm8, %xmm6
movaps %xmm9, %xmm7
mulss %xmm9, %xmm7
addss %xmm6, %xmm7
ucomiss %xmm7, %xmm5
movaps %xmm0, %xmm6
ja 0x41fce
mulss %xmm5, %xmm9
mulss %xmm5, %xmm8
divss %xmm7, %xmm9
divss %xmm7, %xmm8
addss %xmm9, %xmm3
addss %xmm8, %xmm4
unpcklps %xmm4, %xmm3            # xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1]
movaps %xmm3, %xmm6
subss %xmm6, %xmm1
movaps %xmm6, %xmm3
shufps $0x55, %xmm6, %xmm3     # xmm3 = xmm3[1,1],xmm6[1,1]
subss %xmm3, %xmm2
mulss %xmm2, %xmm2
mulss %xmm1, %xmm1
addss %xmm2, %xmm1
movss (%r14), %xmm2
ucomiss %xmm1, %xmm2
jbe 0x41ffc
movlps %xmm6, (%r15)
movss %xmm1, (%r14)
movlps %xmm0, (%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq