// File: /workspace/github_cpp_makefile_star2_O3/donfreiday[P]gb/./imgui/imgui_draw.cpp
// Function: ImDrawList::AddConvexPolyFilled(ImVec2 const*, int, unsigned int, bool)
void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col, bool anti_aliased)
{
    const ImVec2 uv = GImGui->FontTexUvWhitePixel;
    anti_aliased &= GImGui->Style.AntiAliasedShapes;
    //if (ImGui::GetIO().KeyCtrl) anti_aliased = false; // Debug

    if (anti_aliased)
    {
        // Anti-aliased Fill
        const float AA_SIZE = 1.0f;
        const ImU32 col_trans = col & 0x00ffffff;
        const int idx_count = (points_count-2)*3 + points_count*6;
        const int vtx_count = (points_count*2);
        PrimReserve(idx_count, vtx_count);

        // Add indexes for fill
        unsigned int vtx_inner_idx = _VtxCurrentIdx;
        unsigned int vtx_outer_idx = _VtxCurrentIdx+1;
        for (int i = 2; i < points_count; i++)
        {
            _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+((i-1)<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx+(i<<1));
            _IdxWritePtr += 3;
        }

        // Compute normals
        ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2));
        for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
        {
            const ImVec2& p0 = points[i0];
            const ImVec2& p1 = points[i1];
            ImVec2 diff = p1 - p0;
            diff *= ImInvLength(diff, 1.0f);
            temp_normals[i0].x = diff.y;
            temp_normals[i0].y = -diff.x;
        }

        for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
        {
            // Average normals
            const ImVec2& n0 = temp_normals[i0];
            const ImVec2& n1 = temp_normals[i1];
            ImVec2 dm = (n0 + n1) * 0.5f;
            float dmr2 = dm.x*dm.x + dm.y*dm.y;
            if (dmr2 > 0.000001f)
            {
                float scale = 1.0f / dmr2;
                if (scale > 100.0f) scale = 100.0f;
                dm *= scale;
            }
            dm *= AA_SIZE * 0.5f;

            // Add vertices
            _VtxWritePtr[0].pos = (points[i1] - dm); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;        // Inner
            _VtxWritePtr[1].pos = (points[i1] + dm); _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans;  // Outer
            _VtxWritePtr += 2;

            // Add indexes for fringes
            _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx+(i1<<1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx+(i0<<1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx+(i0<<1));
            _IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx+(i0<<1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx+(i1<<1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx+(i1<<1));
            _IdxWritePtr += 6;
        }
        _VtxCurrentIdx += (ImDrawIdx)vtx_count;
    }
    else
    {
        // Non Anti-aliased Fill
        const int idx_count = (points_count-2)*3;
        const int vtx_count = points_count;
        PrimReserve(idx_count, vtx_count);
        for (int i = 0; i < vtx_count; i++)
        {
            _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
            _VtxWritePtr++;
        }
        for (int i = 2; i < points_count; i++)
        {
            _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx+i-1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx+i);
            _IdxWritePtr += 3;
        }
        _VtxCurrentIdx += (ImDrawIdx)vtx_count;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r14d
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %rbx
xorb $0x1, %r8b
leaq 0x26e7f(%rip), %rax     # 0x55480
movq (%rax), %rax
movq 0x1720(%rax), %r12
cmpb $0x0, 0x1459(%rax)
sete %al
orb %r8b, %al
jne 0x2e864
leal -0x6(%r13,%r13,8), %esi
leal (,%r13,2), %edx
movq %rbx, %rdi
movl %edx, -0x2c(%rbp)
callq 0x2d97a
movl 0x38(%rbx), %eax
cmpl $0x3, %r13d
jl 0x2e664
movq 0x48(%rbx), %rcx
leal -0x2(%r13), %edx
leal 0x2(%rax), %esi
movw %ax, (%rcx)
movw %si, 0x2(%rcx)
addl $0x2, %esi
movw %si, 0x4(%rcx)
addq $0x6, %rcx
decl %edx
jne 0x2e64a
movq %rcx, 0x48(%rbx)
movslq %r13d, %rdx
movq %rsp, %rcx
leaq 0xf(,%rdx,8), %rdx
andq $-0x10, %rdx
subq %rdx, %rcx
movq %rcx, %rsp
testl %r13d, %r13d
jle 0x2e859
movl %r14d, %edx
andl $0xffffff, %edx         # imm = 0xFFFFFF
leal 0x1(%rax), %esi
leal -0x1(%r13), %r8d
movl %r13d, %edi
xorl %r9d, %r9d
movss 0xeced(%rip), %xmm0     # 0x3d390
movaps 0xec86(%rip), %xmm1     # 0x3d330
movl %r8d, %r10d
movslq %r10d, %r10
movss (%r15,%r9,8), %xmm2
movss 0x4(%r15,%r9,8), %xmm3
subss (%r15,%r10,8), %xmm2
subss 0x4(%r15,%r10,8), %xmm3
movaps %xmm3, %xmm4
mulss %xmm3, %xmm4
movaps %xmm2, %xmm5
mulss %xmm2, %xmm5
addss %xmm4, %xmm5
xorps %xmm4, %xmm4
sqrtss %xmm5, %xmm4
movaps %xmm0, %xmm6
divss %xmm4, %xmm6
xorps %xmm4, %xmm4
cmpltss %xmm5, %xmm4
andps %xmm4, %xmm6
andnps %xmm0, %xmm4
orps %xmm6, %xmm4
mulss %xmm4, %xmm3
movss %xmm3, (%rcx,%r10,8)
xorps %xmm1, %xmm2
mulss %xmm4, %xmm2
movss %xmm2, 0x4(%rcx,%r10,8)
movl %r9d, %r10d
leaq 0x1(%r9), %r11
movq %r11, %r9
cmpq %r11, %rdi
jne 0x2e6ad
testl %r13d, %r13d
jle 0x2e859
xorl %r9d, %r9d
movss 0xec96(%rip), %xmm1     # 0x3d3cc
movss 0x14082(%rip), %xmm2    # 0x427c0
movss 0xed32(%rip), %xmm3     # 0x3d478
movl %eax, %r10d
movslq %r8d, %r11
movss (%rcx,%r11,8), %xmm4
addss (%rcx,%r9,8), %xmm4
movss 0x4(%rcx,%r11,8), %xmm5
addss 0x4(%rcx,%r9,8), %xmm5
mulss %xmm1, %xmm4
mulss %xmm1, %xmm5
movaps %xmm5, %xmm7
mulss %xmm5, %xmm7
movaps %xmm4, %xmm6
mulss %xmm4, %xmm6
addss %xmm7, %xmm6
ucomiss %xmm2, %xmm6
jbe 0x2e79b
movaps %xmm0, %xmm7
divss %xmm6, %xmm7
movaps %xmm3, %xmm6
minss %xmm7, %xmm6
mulss %xmm6, %xmm4
mulss %xmm6, %xmm5
unpcklps %xmm5, %xmm4            # xmm4 = xmm4[0],xmm5[0],xmm4[1],xmm5[1]
movaps %xmm4, %xmm5
mulss %xmm1, %xmm5
shufps $0x55, %xmm4, %xmm4     # xmm4 = xmm4[1,1,1,1]
mulss %xmm1, %xmm4
movss (%r15,%r9,8), %xmm6
movss 0x4(%r15,%r9,8), %xmm7
subss %xmm5, %xmm6
subss %xmm4, %xmm7
unpcklps %xmm7, %xmm6            # xmm6 = xmm6[0],xmm7[0],xmm6[1],xmm7[1]
movq 0x40(%rbx), %r11
movlps %xmm6, (%r11)
movq 0x40(%rbx), %r11
movq %r12, 0x8(%r11)
movq 0x40(%rbx), %r11
movl %r14d, 0x10(%r11)
addss (%r15,%r9,8), %xmm5
addss 0x4(%r15,%r9,8), %xmm4
unpcklps %xmm4, %xmm5            # xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1]
movlps %xmm5, 0x14(%r11)
movq 0x40(%rbx), %r11
movq %r12, 0x1c(%r11)
movq 0x40(%rbx), %r11
movl %edx, 0x24(%r11)
addq $0x28, %r11
movq %r11, 0x40(%rbx)
movq 0x48(%rbx), %r11
movw %r10w, (%r11)
leal (%rax,%r8,2), %r13d
movw %r13w, 0x2(%r11)
leal (%rsi,%r8,2), %r8d
movw %r8w, 0x4(%r11)
movw %r8w, 0x6(%r11)
leal 0x1(%r10), %r8d
movw %r8w, 0x8(%r11)
movw %r10w, 0xa(%r11)
addq $0xc, %r11
movq %r11, 0x48(%rbx)
movl %r9d, %r8d
leaq 0x1(%r9), %r11
addl $0x2, %r10d
movq %r11, %r9
cmpq %r11, %rdi
jne 0x2e749
movl 0x38(%rbx), %eax
movl -0x2c(%rbp), %ecx
andl $0xfffe, %ecx           # imm = 0xFFFE
jmp 0x2e8e2
leal -0x6(%r13,%r13,2), %esi
movq %rbx, %rdi
movl %r13d, %edx
callq 0x2d97a
testl %r13d, %r13d
jle 0x2e8db
movl %r13d, %eax
movq 0x40(%rbx), %rdx
xorl %ecx, %ecx
movq (%r15,%rcx,8), %rsi
movq %rsi, (%rdx)
movq 0x40(%rbx), %rdx
movq %r12, 0x8(%rdx)
movq 0x40(%rbx), %rdx
movl %r14d, 0x10(%rdx)
addq $0x14, %rdx
movq %rdx, 0x40(%rbx)
incq %rcx
cmpq %rcx, %rax
jne 0x2e882
cmpl $0x2, %r13d
jle 0x2e8db
movl 0x38(%rbx), %eax
movq 0x48(%rbx), %rcx
leal -0x2(%r13), %edx
leal 0x2(%rax), %esi
movw %ax, (%rcx)
leal -0x1(%rsi), %edi
movw %di, 0x2(%rcx)
movw %si, 0x4(%rcx)
addq $0x6, %rcx
incl %esi
decl %edx
jne 0x2e8bd
movq %rcx, 0x48(%rbx)
jmp 0x2e8de
movl 0x38(%rbx), %eax
movzwl %r13w, %ecx
addl %eax, %ecx
movl %ecx, 0x38(%rbx)
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq