// File: /workspace/github_cpp_makefile_star2_O1/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
subq $0x48, %rsp
movl %ecx, %r14d
movl %edx, %r13d
movq %rsi, %r15
movq %rdi, %rbx
xorb $0x1, %r8b
leaq 0x26814(%rip), %rax     # 0x55490
movq (%rax), %rax
movq 0x1720(%rax), %r12
cmpb $0x0, 0x1459(%rax)
sete %al
orb %r8b, %al
jne 0x2ef48
leal -0x6(%r13,%r13,8), %esi
leal (,%r13,2), %edx
movq %rbx, %rdi
movl %edx, -0x2c(%rbp)
callq 0x2def2
movl 0x38(%rbx), %eax
movq %rax, -0x40(%rbp)
cmpl $0x3, %r13d
jl 0x2ece7
movq 0x48(%rbx), %rax
leal -0x2(%r13), %ecx
movq -0x40(%rbp), %rsi
leal 0x2(%rsi), %edx
movw %si, (%rax)
movw %dx, 0x2(%rax)
addl $0x2, %edx
movw %dx, 0x4(%rax)
addq $0x6, %rax
decl %ecx
jne 0x2eccd
movq %rax, 0x48(%rbx)
movq %r12, -0x58(%rbp)
movl %r14d, -0x30(%rbp)
movslq %r13d, %rax
movq %rsp, %rcx
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x50(%rbp)
movq %rcx, %rsp
movq %r13, %rax
decl %r13d
movq %rax, -0x48(%rbp)
testl %eax, %eax
jle 0x2eddf
movl -0x48(%rbp), %edx
xorl %r12d, %r12d
movss 0xe655(%rip), %xmm2     # 0x3d380
xorps %xmm3, %xmm3
movaps 0xe5eb(%rip), %xmm4     # 0x3d320
movl %r13d, %eax
movq %rdx, -0x60(%rbp)
movslq %eax, %r14
movss (%r15,%r12,8), %xmm5
movss 0x4(%r15,%r12,8), %xmm6
subss (%r15,%r14,8), %xmm5
subss 0x4(%r15,%r14,8), %xmm6
movaps %xmm6, %xmm1
mulss %xmm6, %xmm1
movaps %xmm5, %xmm0
mulss %xmm5, %xmm0
addss %xmm1, %xmm0
ucomiss %xmm3, %xmm0
movaps %xmm2, %xmm1
jbe 0x2edaf
jb 0x2ed7b
sqrtss %xmm0, %xmm0
jmp 0x2eda8
movaps %xmm5, -0x70(%rbp)
movss %xmm6, -0x34(%rbp)
callq 0x7740
movss -0x34(%rbp), %xmm6
movaps -0x70(%rbp), %xmm5
movaps 0xe587(%rip), %xmm4     # 0x3d320
xorps %xmm3, %xmm3
movss 0xe5dc(%rip), %xmm2     # 0x3d380
movq -0x60(%rbp), %rdx
movaps %xmm2, %xmm1
divss %xmm0, %xmm1
mulss %xmm1, %xmm6
movq -0x50(%rbp), %rax
movss %xmm6, (%rax,%r14,8)
xorps %xmm4, %xmm5
mulss %xmm1, %xmm5
movss %xmm5, 0x4(%rax,%r14,8)
movl %r12d, %eax
leaq 0x1(%r12), %rcx
movq %rcx, %r12
cmpq %rcx, %rdx
jne 0x2ed3c
movq -0x48(%rbp), %rdx
testl %edx, %edx
movl -0x30(%rbp), %r10d
movq -0x58(%rbp), %r11
movq -0x40(%rbp), %r14
jle 0x2ef3a
movl %r10d, %eax
andl $0xffffff, %eax         # imm = 0xFFFFFF
leal 0x1(%r14), %ecx
movl %edx, %edx
xorl %esi, %esi
movss 0xe5ad(%rip), %xmm0     # 0x3d3bc
movss 0x13a25(%rip), %xmm1    # 0x4283c
movss 0xe561(%rip), %xmm2     # 0x3d380
movss 0xe641(%rip), %xmm3     # 0x3d468
movl %r14d, %edi
movslq %r13d, %r8
movq -0x50(%rbp), %r9
movss (%r9,%r8,8), %xmm4
addss (%r9,%rsi,8), %xmm4
movss 0x4(%r9,%r8,8), %xmm5
addss 0x4(%r9,%rsi,8), %xmm5
mulss %xmm0, %xmm4
mulss %xmm0, %xmm5
movaps %xmm5, %xmm7
mulss %xmm5, %xmm7
movaps %xmm4, %xmm6
mulss %xmm4, %xmm6
addss %xmm7, %xmm6
ucomiss %xmm1, %xmm6
jbe 0x2ee80
movaps %xmm2, %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 %xmm0, %xmm5
shufps $0x55, %xmm4, %xmm4     # xmm4 = xmm4[1,1,1,1]
mulss %xmm0, %xmm4
movss (%r15,%rsi,8), %xmm6
movss 0x4(%r15,%rsi,8), %xmm7
subss %xmm5, %xmm6
subss %xmm4, %xmm7
unpcklps %xmm7, %xmm6            # xmm6 = xmm6[0],xmm7[0],xmm6[1],xmm7[1]
movq 0x40(%rbx), %r8
movlps %xmm6, (%r8)
movq 0x40(%rbx), %r8
movq %r11, 0x8(%r8)
movq 0x40(%rbx), %r8
movl %r10d, 0x10(%r8)
addss (%r15,%rsi,8), %xmm5
addss 0x4(%r15,%rsi,8), %xmm4
unpcklps %xmm4, %xmm5            # xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1]
movlps %xmm5, 0x14(%r8)
movq 0x40(%rbx), %r8
movq %r11, 0x1c(%r8)
movq 0x40(%rbx), %r8
movl %eax, 0x24(%r8)
addq $0x28, %r8
movq %r8, 0x40(%rbx)
movq 0x48(%rbx), %r8
movw %di, (%r8)
leal (%r14,%r13,2), %r9d
movw %r9w, 0x2(%r8)
leal (%rcx,%r13,2), %r9d
movw %r9w, 0x4(%r8)
movw %r9w, 0x6(%r8)
leal 0x1(%rdi), %r9d
movw %r9w, 0x8(%r8)
movw %di, 0xa(%r8)
addq $0xc, %r8
movq %r8, 0x48(%rbx)
movl %esi, %r13d
leaq 0x1(%rsi), %r8
addl $0x2, %edi
movq %r8, %rsi
cmpq %r8, %rdx
jne 0x2ee2a
addq $0x38, %rbx
movl -0x2c(%rbp), %eax
andl $0xfffe, %eax           # imm = 0xFFFE
jmp 0x2efc7
leal -0x6(%r13,%r13,2), %esi
movq %rbx, %rdi
movl %r13d, %edx
callq 0x2def2
testl %r13d, %r13d
jle 0x2ef8d
movl %r13d, %eax
xorl %ecx, %ecx
movq 0x40(%rbx), %rdx
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 0x2ef62
cmpl $0x3, %r13d
jl 0x2efbf
movl 0x38(%rbx), %eax
movq 0x48(%rbx), %rcx
leal -0x2(%r13), %edx
movl %eax, %esi
addl $0x2, %esi
movw %ax, (%rcx)
leal -0x1(%rsi), %edi
movw %di, 0x2(%rcx)
movw %si, 0x4(%rcx)
addq $0x6, %rcx
incl %esi
decl %edx
jne 0x2efa3
movq %rcx, 0x48(%rbx)
movzwl %r13w, %eax
addq $0x38, %rbx
addl %eax, (%rbx)
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq