// File: /workspace/github_cpp_makefile_star2_O2/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, %r15d
movl %edx, %r14d
movq %rsi, %r12
movq %rdi, %rbx
xorb $0x1, %r8b
leaq 0x276b3(%rip), %rax     # 0x50480
movq (%rax), %rax
movq 0x1720(%rax), %r13
cmpb $0x0, 0x1459(%rax)
sete %al
orb %r8b, %al
jne 0x2901a
leal (%r14,%r14,8), %esi
addl $-0x6, %esi
leal (%r14,%r14), %edx
movq %rbx, %rdi
movl %edx, -0x2c(%rbp)
callq 0x2820c
movl 0x38(%rbx), %eax
movq 0x48(%rbx), %rcx
leal 0x2(%rax), %edx
pushq $0x2
popq %rsi
cmpl %r14d, %esi
jge 0x28e2c
movw %ax, (%rcx)
movw %dx, 0x2(%rcx)
addl $0x2, %edx
movw %dx, 0x4(%rcx)
addq $0x6, %rcx
movq %rcx, 0x48(%rbx)
incl %esi
jmp 0x28e0d
movl %r15d, %ecx
andl $0xffffff, %ecx         # imm = 0xFFFFFF
movslq %r14d, %rsi
movq %rsp, %rdx
leaq 0xf(,%rsi,8), %rsi
andq $-0x10, %rsi
subq %rsi, %rdx
movq %rdx, %rsp
leal -0x1(%r14), %esi
xorl %edi, %edi
testl %r14d, %r14d
cmovlel %edi, %r14d
movss 0xd52e(%rip), %xmm0     # 0x36390
movaps 0xd4c7(%rip), %xmm1     # 0x36330
movl %esi, %r8d
cmpq %rdi, %r14
je 0x28edc
movslq %r8d, %r8
movss (%r12,%rdi,8), %xmm2
subss (%r12,%r8,8), %xmm2
movss 0x4(%r12,%rdi,8), %xmm3
subss 0x4(%r12,%r8,8), %xmm3
movaps %xmm3, %xmm4
mulss %xmm3, %xmm4
movaps %xmm2, %xmm5
mulss %xmm2, %xmm5
addss %xmm4, %xmm5
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, (%rdx,%r8,8)
xorps %xmm1, %xmm2
mulss %xmm4, %xmm2
movss %xmm2, 0x4(%rdx,%r8,8)
movl %edi, %r8d
incq %rdi
jmp 0x28e6c
leal 0x1(%rax), %edi
xorl %r8d, %r8d
movss 0xd4e6(%rip), %xmm1     # 0x363d0
movss 0x12ade(%rip), %xmm2    # 0x3b9d0
movss 0xd576(%rip), %xmm3     # 0x36470
movl %eax, %r9d
cmpq %r8, %r14
je 0x2900a
movslq %esi, %r10
movss (%rdx,%r10,8), %xmm4
addss (%rdx,%r8,8), %xmm4
movss 0x4(%rdx,%r10,8), %xmm5
addss 0x4(%rdx,%r8,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 0x28f58
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 (%r12,%r8,8), %xmm6
movss 0x4(%r12,%r8,8), %xmm7
subss %xmm5, %xmm6
subss %xmm4, %xmm7
unpcklps %xmm7, %xmm6            # xmm6 = xmm6[0],xmm7[0],xmm6[1],xmm7[1]
movq 0x40(%rbx), %r10
movlps %xmm6, (%r10)
movq 0x40(%rbx), %r10
movq %r13, 0x8(%r10)
movq 0x40(%rbx), %r10
movl %r15d, 0x10(%r10)
addss (%r12,%r8,8), %xmm5
addss 0x4(%r12,%r8,8), %xmm4
unpcklps %xmm4, %xmm5            # xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1]
movlps %xmm5, 0x14(%r10)
movq 0x40(%rbx), %r10
movq %r13, 0x1c(%r10)
movq 0x40(%rbx), %r10
movl %ecx, 0x24(%r10)
addq $0x28, %r10
movq %r10, 0x40(%rbx)
movq 0x48(%rbx), %r10
movw %r9w, (%r10)
leal (%rax,%rsi,2), %r11d
movw %r11w, 0x2(%r10)
leal (%rdi,%rsi,2), %esi
movw %si, 0x4(%r10)
movw %si, 0x6(%r10)
leal 0x1(%r9), %esi
movw %si, 0x8(%r10)
movw %r9w, 0xa(%r10)
addq $0xc, %r10
movq %r10, 0x48(%rbx)
movl %r8d, %esi
incq %r8
addl $0x2, %r9d
jmp 0x28efd
movl -0x2c(%rbp), %eax
andl $0xfffe, %eax           # imm = 0xFFFE
addl %eax, 0x38(%rbx)
jmp 0x2909e
leal (%r14,%r14,2), %esi
addl $-0x6, %esi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x2820c
xorl %eax, %eax
testl %r14d, %r14d
movl $0x0, %ecx
cmovgl %r14d, %ecx
cmpq %rax, %rcx
je 0x29067
movq 0x40(%rbx), %rdx
movq (%r12,%rax,8), %rsi
movq %rsi, (%rdx)
movq 0x40(%rbx), %rdx
movq %r13, 0x8(%rdx)
movq 0x40(%rbx), %rdx
movl %r15d, 0x10(%rdx)
addq $0x14, %rdx
movq %rdx, 0x40(%rbx)
incq %rax
jmp 0x2903a
movl 0x38(%rbx), %eax
movq 0x48(%rbx), %rcx
leal 0x2(%rax), %edx
pushq $0x2
popq %rsi
cmpl %r14d, %esi
jge 0x29095
movw %ax, (%rcx)
leal -0x1(%rdx), %edi
movw %di, 0x2(%rcx)
movw %dx, 0x4(%rcx)
addq $0x6, %rcx
movq %rcx, 0x48(%rbx)
incl %esi
incl %edx
jmp 0x29074
movzwl %r14w, %ecx
addl %ecx, %eax
movl %eax, 0x38(%rbx)
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop