// File: /workspace/github_cpp_makefile_star2_O3/Ciaxur[P]yagb-emu/include/imgui/imgui_draw.cpp
// Function: ImDrawList::AddConvexPolyFilled(ImVec2 const*, int, unsigned int)
void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col)
{
    if (points_count < 3)
        return;

    const ImVec2 uv = _Data->TexUvWhitePixel;

    if (Flags & ImDrawListFlags_AntiAliasedFill)
    {
        // Anti-aliased Fill
        const float AA_SIZE = _FringeScale;
        const ImU32 col_trans = col & ~IM_COL32_A_MASK;
        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)); //-V630
        for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
        {
            const ImVec2& p0 = points[i0];
            const ImVec2& p1 = points[i1];
            float dx = p1.x - p0.x;
            float dy = p1.y - p0.y;
            IM_NORMALIZE2F_OVER_ZERO(dx, dy);
            temp_normals[i0].x = dy;
            temp_normals[i0].y = -dx;
        }

        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];
            float dm_x = (n0.x + n1.x) * 0.5f;
            float dm_y = (n0.y + n1.y) * 0.5f;
            IM_FIXNORMAL2F(dm_x, dm_y);
            dm_x *= AA_SIZE * 0.5f;
            dm_y *= AA_SIZE * 0.5f;

            // Add vertices
            _VtxWritePtr[0].pos.x = (points[i1].x - dm_x); _VtxWritePtr[0].pos.y = (points[i1].y - dm_y); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;        // Inner
            _VtxWritePtr[1].pos.x = (points[i1].x + dm_x); _VtxWritePtr[1].pos.y = (points[i1].y + dm_y); _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:
cmpl $0x3, %edx
jl 0x7700d
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r14d
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq (%rax), %r13
testb $0x4, 0x30(%rdi)
jne 0x76de2
leal (%r12,%r12,2), %esi
addl $-0x6, %esi
movq %rbx, %rdi
movl %r12d, %edx
callq 0x75e52
movl %r12d, %eax
movq 0x48(%rbx), %rdx
xorl %ecx, %ecx
movq (%r15,%rcx,8), %rsi
movq %rsi, (%rdx)
movq 0x48(%rbx), %rdx
movq %r13, 0x8(%rdx)
movq 0x48(%rbx), %rdx
movl %r14d, 0x10(%rdx)
addq $0x14, %rdx
movq %rdx, 0x48(%rbx)
incq %rcx
cmpq %rcx, %rax
jne 0x76d82
movl 0x34(%rbx), %eax
movq 0x50(%rbx), %rcx
leal -0x2(%r12), %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 0x76db8
movq %rcx, 0x50(%rbx)
movzwl %r12w, %ecx
addl %ecx, %eax
movl %eax, 0x34(%rbx)
jmp 0x76fff
movss 0xc0(%rbx), %xmm0
movss %xmm0, -0x2c(%rbp)
movl %r14d, %eax
andl $0xffffff, %eax         # imm = 0xFFFFFF
movl %eax, -0x34(%rbp)
leal (%r12,%r12,8), %esi
addl $-0x6, %esi
leal (%r12,%r12), %edx
movq %rbx, %rdi
movl %edx, -0x30(%rbp)
callq 0x75e52
movl 0x34(%rbx), %eax
leal 0x1(%rax), %ecx
movq 0x50(%rbx), %rdx
leal -0x2(%r12), %esi
leal 0x2(%rax), %edi
movw %ax, (%rdx)
movw %di, 0x2(%rdx)
addl $0x2, %edi
movw %di, 0x4(%rdx)
addq $0x6, %rdx
decl %esi
jne 0x76e22
movq %rdx, 0x50(%rbx)
movl %r12d, %edx
movq %rsp, %rsi
leaq 0xf(,%rdx,8), %rdi
andq $-0x10, %rdi
subq %rdi, %rsi
movq %rsi, %rsp
decl %r12d
xorl %edi, %edi
xorps %xmm1, %xmm1
movss 0x3e180(%rip), %xmm0    # 0xb4fe4
movaps 0x3e155(%rip), %xmm2    # 0xb4fc0
movl %r12d, %r8d
movslq %r8d, %r8
movss (%r15,%rdi,8), %xmm3
movss 0x4(%r15,%rdi,8), %xmm4
subss (%r15,%r8,8), %xmm3
subss 0x4(%r15,%r8,8), %xmm4
movaps %xmm4, %xmm6
mulss %xmm4, %xmm6
movaps %xmm3, %xmm5
mulss %xmm3, %xmm5
addss %xmm6, %xmm5
ucomiss %xmm1, %xmm5
jbe 0x76eb5
sqrtss %xmm5, %xmm5
movaps %xmm0, %xmm6
divss %xmm5, %xmm6
mulss %xmm6, %xmm3
mulss %xmm6, %xmm4
xorps %xmm2, %xmm3
movss %xmm4, (%rsi,%r8,8)
movss %xmm3, 0x4(%rsi,%r8,8)
movl %edi, %r8d
leaq 0x1(%rdi), %r9
movq %r9, %rdi
cmpq %r9, %rdx
jne 0x76e6e
movss -0x2c(%rbp), %xmm6
mulss 0x3e123(%rip), %xmm6    # 0xb5004
movq 0x48(%rbx), %r9
xorl %edi, %edi
movss 0x3e115(%rip), %xmm1    # 0xb5004
movl %eax, %r8d
movl %r14d, -0x2c(%rbp)
movq %rcx, %r14
movl -0x34(%rbp), %ecx
movslq %r12d, %r10
movss (%rsi,%r10,8), %xmm2
movss 0x4(%rsi,%r10,8), %xmm3
addss (%rsi,%rdi,8), %xmm2
mulss %xmm1, %xmm2
addss 0x4(%rsi,%rdi,8), %xmm3
mulss %xmm1, %xmm3
movaps %xmm3, %xmm4
mulss %xmm3, %xmm4
movaps %xmm2, %xmm5
mulss %xmm2, %xmm5
addss %xmm4, %xmm5
movaps %xmm1, %xmm4
maxss %xmm5, %xmm4
movaps %xmm0, %xmm5
divss %xmm4, %xmm5
mulss %xmm5, %xmm2
mulss %xmm3, %xmm5
mulss %xmm6, %xmm2
mulss %xmm6, %xmm5
movss (%r15,%rdi,8), %xmm3
subss %xmm2, %xmm3
movss %xmm3, (%r9)
movss 0x4(%r15,%rdi,8), %xmm3
subss %xmm5, %xmm3
movss %xmm3, 0x4(%r9)
movq %r13, 0x8(%r9)
movq 0x48(%rbx), %r9
movl -0x2c(%rbp), %r11d
movl %r11d, 0x10(%r9)
addss (%r15,%rdi,8), %xmm2
movss %xmm2, 0x14(%r9)
addss 0x4(%r15,%rdi,8), %xmm5
movss %xmm5, 0x18(%r9)
movq %r13, 0x1c(%r9)
movq 0x48(%rbx), %r9
movl %ecx, 0x24(%r9)
addq $0x28, %r9
movq %r9, 0x48(%rbx)
movq 0x50(%rbx), %r11
movw %r8w, (%r11)
leal (%rax,%r10,2), %r12d
movw %r12w, 0x2(%r11)
leal (%r14,%r10,2), %r10d
movw %r10w, 0x4(%r11)
movw %r10w, 0x6(%r11)
leal 0x1(%r8), %r10d
movw %r10w, 0x8(%r11)
movw %r8w, 0xa(%r11)
addq $0xc, %r11
movq %r11, 0x50(%rbx)
movl %edi, %r12d
incq %rdi
addl $0x2, %r8d
cmpq %rdi, %rdx
jne 0x76efc
movl -0x30(%rbp), %eax
andl $0xfffe, %eax           # imm = 0xFFFE
addl %eax, 0x34(%rbx)
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq